DSH 0.1.6-alpha.2 ships a right-Sidebar terminal and a right-Sidebar browser of its own. Both were things this plugin had built from scratch, so keeping them meant two implementations of one surface plus a plugin that shadows a host type the product is actively developing. Terminal: the plugin's whole PTY stack goes — the UI-tab manager, the agent-owned registry, the lazy node-pty loader, the eight model-facing terminal_* tools, the xterm view and its font/link/scrollback helpers, and the cross-session 'pinned terminal' rail that existed only to keep a terminal alive across a session switch. The host's terminal kind becomes the only provider, which also retires the node-pty dependency, its pnpm allowBuilds entry, and the installer's -Repair mode (issue #140's whole class of 'node-pty failed to load' support). Model-facing capability note: the plugin used to inject terminal_* tools (off by default). Those are the model's only cross-call persistent terminal, and DSH's own equivalent (@deepseek-ai/dsh-tool-terminal) is not mounted by any shipped bundle, so removing them leaves the model with the one-shot bash/pwsh tools only. That is the accepted cost of not maintaining a second PTY surface; the README documents how to enable the upstream toolset. Browser: the plugin's browser tab type is dropped, so the host's own browser kind owns embedded pages. The DOM-level link takeover STAYS (it is the only thing that can route an https link to the system browser by protocol, which the host does not do) but now delegates to the host's browser tab via ctx.sidebarRight.openTab('browser', …) with a window.open fallback, and the two settings that only ever configured the plugin's own iframe (sandbox escape hatch, loopback allowlist) go with it — along with the host-side browser.probe route they fed. Cards: the empty-pane welcome cards adopt the host's guide-capsule recipe (0.5px l4 hairline, 24px radius, layer-1 fill, 56px floor, 14px/20px padding) so the plugin's 'pick what opens here' surface reads as the same design as DSH's own. A theme.spec guard pins the geometry and the token-only paint — including that the upstream-only --dsw-alias-bg-l1/-l2 spellings (defined nowhere, so their declarations are silently dropped upstream) never appear here. Also drops the dead state the removed features left behind (SidebarTab.pin, nextTerminal, agentWaits, bottomOpenedOnce, the agent-tab helpers, the pinned-tab memo key), re-points every test fixture that used them at surviving equivalents, and prunes the specs of the deleted features.
84 lines
2.9 KiB
TypeScript
84 lines
2.9 KiB
TypeScript
/**
|
|
* Orphaned-tab tests: a persisted tab whose type is not registered must
|
|
* survive sanitize (title/path kept for recovery) and render the graceful
|
|
* placeholder instead of crashing — the degradation path of the open
|
|
* tab-type set (a contributing plugin not installed / not yet loaded).
|
|
*/
|
|
import { describe, expect, it } from 'vitest'
|
|
import { renderToString } from 'react-dom/server'
|
|
import { OrphanedTab } from '../src/client/OrphanedTab.tsx'
|
|
import { sanitizeState } from '../src/client/state.ts'
|
|
|
|
/** Collect every tab type in a sanitized tree (leaf/split recursive). */
|
|
function typesOf(node: unknown): string[] {
|
|
if (node === null || typeof node !== 'object') return []
|
|
const record = node as { kind?: unknown; tabs?: unknown; children?: unknown }
|
|
if (record.kind === 'leaf' && Array.isArray(record.tabs)) {
|
|
return (record.tabs as Array<{ type: string }>).map(tab => tab.type)
|
|
}
|
|
if (Array.isArray(record.children)) return record.children.flatMap(typesOf)
|
|
return []
|
|
}
|
|
|
|
describe('sanitize keeps unregistered tab types', () => {
|
|
it('preserves a persisted tab of an unknown type with its title/path', () => {
|
|
const raw = {
|
|
nextBrowser: 1,
|
|
activePane: null,
|
|
expanded: [],
|
|
bottomSplits: {
|
|
kind: 'leaf',
|
|
id: 'pane:1',
|
|
tabs: [
|
|
{ id: 'tab:1', type: 'my-plugin:db', title: 'Database', path: '/data.sqlite' },
|
|
{ id: 'tab:2', type: 'explorer', title: 'Explorer' },
|
|
],
|
|
active: 'tab:1',
|
|
},
|
|
}
|
|
const clean = sanitizeState(raw)
|
|
expect(clean).toBeDefined()
|
|
expect(typesOf(clean!.bottomSplits)).toContain('my-plugin:db')
|
|
// The kept tab keeps its payload so a later registration can reuse it.
|
|
const leaf = clean!.bottomSplits as unknown as { kind: 'leaf'; tabs: Array<Record<string, unknown>> }
|
|
const kept = leaf.tabs.find(tab => tab.type === 'my-plugin:db')
|
|
expect(kept).toMatchObject({ title: 'Database', path: '/data.sqlite' })
|
|
})
|
|
|
|
it('an unknown type alone in a pane still sanitizes cleanly', () => {
|
|
const raw = {
|
|
nextBrowser: 1,
|
|
activePane: null,
|
|
expanded: [],
|
|
bottomSplits: {
|
|
kind: 'leaf',
|
|
id: 'pane:1',
|
|
tabs: [{ id: 'tab:1', type: 'some-plugin:page', title: 'Page' }],
|
|
active: 'tab:1',
|
|
},
|
|
}
|
|
const clean = sanitizeState(raw)
|
|
expect(clean).toBeDefined()
|
|
expect(typesOf(clean!.bottomSplits)).toEqual(['some-plugin:page'])
|
|
})
|
|
})
|
|
|
|
describe('OrphanedTab placeholder', () => {
|
|
const tab = { id: 'tab:1', type: 'my-plugin:db', title: 'Database' }
|
|
|
|
it('renders the unregistered type and keeps the title', () => {
|
|
const html = renderToString((
|
|
<OrphanedTab
|
|
ctx={undefined as never}
|
|
store={undefined as never}
|
|
scope={{ sessionId: 's1', cwd: '/p' }}
|
|
tab={tab}
|
|
visible={false}
|
|
/>
|
|
))
|
|
expect(html).toContain('my-plugin:db')
|
|
expect(html).toContain('Database')
|
|
expect(html).not.toContain('undefined')
|
|
})
|
|
})
|