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.
57 lines
2.6 KiB
TypeScript
57 lines
2.6 KiB
TypeScript
/**
|
|
* Built chunk artifact contract: each lib/client-<name>.js must, when
|
|
* executed as a classic script, assign its factory to the plugin-owned
|
|
* global registry (globalThis.__dshChunks__[<name>]), and the factory must
|
|
* be callable with a require that resolves the platform externals — the
|
|
* exact shape the loader (src/client/chunk-loader.ts) depends on. Reads the
|
|
* built lib/ output, so run `pnpm build` first (like manifest-consistency).
|
|
* A missing lib/ (fresh clone before the first build) skips the whole suite
|
|
* instead of crashing on ENOENT.
|
|
*/
|
|
import { existsSync, readFileSync } from 'node:fs'
|
|
import { describe, expect, it } from 'vitest'
|
|
// Browser globals first: chunk bodies probe `self`/`document` at evaluation
|
|
// (CodeMirror's UA probe).
|
|
import './browser-globals.ts'
|
|
import { CHUNK_EXTERNALS } from '../src/client/chunk-loader.ts'
|
|
|
|
const g = globalThis as Record<string, unknown>
|
|
|
|
const CHUNKS = ['editor', 'mermaid']
|
|
|
|
/** All chunk artifacts present (tsdown emits the whole lib/ in one run). */
|
|
const chunksBuilt = CHUNKS.every(name => existsSync(`lib/client-${name}.js`))
|
|
|
|
if (!chunksBuilt) {
|
|
console.warn('[chunk-artifact] lib/ chunk artifacts missing — run `pnpm build` first; skipping this suite')
|
|
}
|
|
|
|
describe.skipIf(!chunksBuilt)('built chunk artifacts', () => {
|
|
it('each chunk assigns its global registry slot when executed as a script', () => {
|
|
g.window = g // classic-script globals
|
|
// mermaid's core hooks window.addEventListener('load') at module scope
|
|
// (its startOnLoad wiring); the Node global lacks the API, so stub it
|
|
// exactly like browser-globals.ts does for its window stub.
|
|
if (typeof g.addEventListener !== 'function') g.addEventListener = () => {}
|
|
if (typeof g.removeEventListener !== 'function') g.removeEventListener = () => {}
|
|
for (const name of CHUNKS) {
|
|
const code = readFileSync(`lib/client-${name}.js`, 'utf8')
|
|
expect(() => new Function(code)(), name).not.toThrow()
|
|
const registry = g.__dshChunks__ as Record<string, unknown>
|
|
expect(typeof registry[name], name).toBe('function')
|
|
}
|
|
})
|
|
|
|
it('each chunk factory materializes through a require over the platform externals', () => {
|
|
const registry = g.__dshChunks__ as Record<string, unknown>
|
|
const table = new Map<string, unknown>(CHUNK_EXTERNALS.map(spec => [spec, { spec }]))
|
|
for (const name of CHUNKS) {
|
|
const factory = registry[name] as (require: (spec: string) => unknown) => Record<string, unknown>
|
|
expect(() => factory((spec) => {
|
|
if (!table.has(spec)) throw new Error(`require("${spec}") missed the module table`)
|
|
return table.get(spec)
|
|
}), name).not.toThrow()
|
|
}
|
|
})
|
|
})
|