Commit Graph
9 Commits
Author SHA1 Message Date
Menghuan1918 4ebd3e9bdd chore: adapt sidebar to DSH 0.2.1-alpha.5 2026-10-17 02:12:44 +08:00
Menghuan1918 1ff8fa3514 feat(terminal): 底部工作台终端 tab terminal-bottom(#774)
底部 + 菜单里开得出 shell,刷新后认回同一个 shell,且**不**变成宿主
右列终端的第二个入口。

实现分三层:

1. 宿主能力层(src/client/terminal-client.ts,核心 bundle 安全):结构化
   探测 `ctx.webTerminals`(view/close/recover 三个函数都在才算数)+
   身份助手。**不写进 dsh.client.inject**:注入一个不存在的服务会把整行
   拖成 pending,插件在无终端控制器的部署上会整体不加载;也**不**
   value-import 任何 @deepseek-ai/*(纯度门),类型面手工声明。
2. chunk 层(src/client/TerminalView.tsx + terminal.module.css +
   chunks/terminal.tsx + terminal-lazy.tsx):xterm 与它的样式表整份打进
   lib/client-terminal.js(750 KB),核心包一处都没有;chunk 名在 9 处
   镜像(tsdown / bundle-route / chunk-loader / package.json.files /
   package-registry / bundle-route.spec),另两处 spec 从 CHUNK_NAMES 派生。
3. 描述符层(builtins/tabs.tsx):第 6 个内置类型,`bottomOnly: true`
   (见上一个 commit)、`single`、`available` 读同一份探测、`onClose`
   结束进程。

三条恢复语义的由来:

- **contentId 恒定,terminalId 不写进 tab.meta**:宿主 view() 显式传
  terminalId 会关掉「缺了就建」分支,一个过期 id 会把页签永久卡在
  missingTerminal;宿主自己的 (sessionId, contentId) → 终端 id 持久绑定
  本来就能在刷新后认回同一个 shell。
- **「新建终端」换代号**:DSH 重启后 PTY 没了而 localStorage 绑定还在,
  恒定 contentId 会永远认领死绑定。tab.meta.terminalRun(默认 0)+1 换
  一代 contentId 让宿主另铸进程;key 与 contentId 一起换(views 按
  (sessionId, key) 记忆化)。
- **关页签才结束进程**:宿主的契约是「视图跨 DOM 卸载存活」,这正是刷新
  能认回同一个 shell 的原因,所以卸载不 close;但不 close 会让每个关掉
  的终端永久占一个 per-session 终端槽位(terminalLimit),因此 descriptor
  的 onClose → webTerminals.close() 是唯一且必须存在的回收路径。

测试(判别性证据见交付报告):
- tests/terminal-tab.spec.tsx 14 条:view() 调用形状与 contentId 恒定性、
  mount/detach、write/resize 转发与上限夹紧、snapshot 重放 + acknowledge、
  无服务降级、missingTerminal → 换代号、onClose → close()。
- tests/builtins.spec.ts 内置清单 5 → 6,并新增「terminal-bottom 是
  bottomOnly、其余内置都不是」。
- tests/chunk-artifact.spec.ts 新增产物包含性断言:chunk 里必须有
  xterm(xterm-char-measure-element / @xterm/xterm/lib/xterm.js),
  lib/client.js 与 lib/client-registry.js 里一处都不许有。
- tests/e2e/mount.e2e.ts 第三条真实浏览器用例:先开原生右列(guide 基线
  = 宿主 terminal 恰好 1 条)→ 展开底部工作台(data-active + 布局推挤
  > 0)→ 点空面板的 Terminal 卡片 → 断言 tab 挂载、.xterm 在、chunk 有
  响应、状态不停在 unavailable/loading、宿主 terminal 条目仍为 1 且
  terminal-bottom 条目为 0、无 pageerror / 插件 console 错误。

依赖:@xterm/xterm@^6.0.0 + @xterm/addon-fit@^0.11.0(与宿主自用版本一致,
安装期零脚本,不触市场拒绝名单)。lockfile 只手工拼接这 2 个包的 4 个块:
pnpm add 会顺手重解析无关 caret 范围,产出 99+/69- 的噪声 diff。
2026-10-05 23:42:45 +08:00
Menghuan1918 2a39a0c8b2 chore: adapt the tasks/workflow/teams work to DSH 0.1.7-rc.1 (rebase onto v0.21.1)
Rebases the whole branch onto main's new 0.1.7-rc.1 baseline and lands the
adaptation the new host contract requires: the ui-primitives icon family rename
(Icon<Name><14|16> -> Icon<Name>Regular/Medium, with the 14px defaults pinned
back explicitly) and the StateDot redraw, the rewritten dsh-settings surface
(entry-id namespace, DSH schemastery with collected volatile returns,
configure auto:false), session format v4 (producer-owned source kind plus the
rewritten tool-result shape, parsers accepting both), the client snapshot move
to projectionsBySession.subagentCatalog with the jobs.list route behind it, the
^0.1.7-rc.1 peer floor with vendor and bare-import devDeps, the reduced chunk
set mirrored in all eight places, and the capability hand-backs (read-only
previews, terminal, browser).

Verified: typecheck and lint clean; 119 files / 1200 tests; build with no old
contract residue in the bundles; mount e2e 7/7; the tasks page still passes its
70-assertion real-browser contract.
2026-09-27 22:18:19 +08:00
Menghuan1918 de99fd4cfb docs: record the 0.1.6-alpha.2 adaptation and resync the user docs
Adds the per-version adaptation record (docs/plans/2026-09-21-…-adaptation.md),
rewrites AGENTS.md §3 for the new baseline (the two silent contract breaks, the
terminal/browser handoff, the new official plugin-manager surface, the three
ui-primitives breaks, the widened primitives bare-import set), and updates both
READMEs and the integration guide for the v0.20.0 feature set.

Also retires the support text the terminal deletion made false: the install
flow is one step again (no build-script approval), the FAQ's two node-pty rows
collapse into one pointing at DSH's own terminal, the platform note no longer
promises prebuilt native binaries (there are no native deps left), and the
installers drop the -Repair mode and their allowBuilds writes along with
pnpm-workspace.yaml's now-empty allowBuilds block. Removes the dead
browserNoSandboxWarning locale key (its setting went with the plugin's browser)
and tightens theme.spec's capsule guard so a literal colour fails it.

The e2e resolver now refuses a PATH  that is not on the baseline line:
this machine's PATH  is 0.1.6-alpha.1, and running the mount lane against
it fails at 'the bundle was not registered' with a zero exit from the CLI —
a misleading dead end worth one explicit error instead.
2026-09-21 21:00:09 +08:00
Menghuan1918 5912274e41 feat: yield the terminal and browser to DSH 0.1.6's own sidebar types
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.
2026-09-21 20:35:11 +08:00
Menghuan1918 61c9c550d9 fix(registry): registry 打包补上 mermaid 懒加载 chunk
package.json files 白名单与 tsdown 产物都含 lib/client-mermaid.js(+
.map),registry 通道的复制清单却缺它——经 dsh registry 安装后 Markdown
预览首次加载 mermaid 会拿到 /sidebar/bundle 404。与 terminal/editor
两 chunk 同款补齐。
2026-09-03 12:03:05 +08:00
Menghuan1918 cbc28473a0 feat: 设置页「添加插件」推荐目录 + 复制安装命令;移除内置 Office 预览
- 设置页侧边栏内容/文件预览两个网格末尾各增虚线卡片,弹出对应 kind 的插件弹窗
- 弹窗:GitHub topic 按钮(新标签页)+ 推荐插件目录(plugins-tabs.ts / plugins-viewers.ts)
- 每条目「跳转」(window.open 新标签页直达仓库)与「复制」(writeClipboard + 已复制反馈)
- 不做终端预填流:不关闭弹窗、不打开终端、无失败路径(install/installNotice/installError* 文案删除)
- 内置 Office 预览(docx/xlsx/pptx)整体移除,chunk 白名单 5→2(terminal/editor)
- 文案「内置插件」→「推荐插件」;AGENTS.md/README/设计文档同步
2026-08-14 22:30:34 +08:00
Menghuan1918 bab659f8bd feat: 客户端懒加载分块 — 重依赖(Univer/xterm/CodeMirror/Office)拆独立 bundle 按需下发(/sidebar/bundle 路由 + __dshChunks__ 注册表),核心启动仅 ~325KB 2026-08-12 18:19:44 +08:00
Menghuan1918 a1286191d6 feat: plugin-registry 标准发布面(dsh.plugin.json + 双 client bundle + registry 打包),v0.1.2
- dsh.plugin.json 原生清单:id dsh-external/dsh-better-sidebar,version 0.1.2,
  main = lib/index.js,client.main = lib/client-registry.js,contributes 空声明
- tsdown client 构建参数化:lib/client.js(官方通道,id = 包名)+ lib/client-registry.js
  (registry 通道,id = 清单 id),同源不漂移
- scripts/package-registry.mjs 组装 registry/ 安装根(gitignore,不入库)
- tests/manifest-consistency.spec.ts:id 两段校验 / version 同步 / 入口存在 /
  双 bundle id 不互换 / contributes 空
- README:新增「通过 plugin-registry 安装(标准)」章节 + 保留官方 profile 安装
  方案 + 通道互斥说明;架构表补 manifest 与双 client 行
2026-08-09 23:49:58 +08:00