Skip to content

feat(session-inspector): Session-scoped Terminal surface; drop Actions - #147

Merged
bubbleptr merged 1 commit into
mainfrom
feat/session-terminal-surface
Sep 2, 2026
Merged

bubbleptr merged 1 commit into
mainfrom
feat/session-terminal-surface

Conversation

@bubbleptr

@bubbleptr bubbleptr commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

What

右栏 SessionInspector 新增 Terminal surface——ADR-0028 预留的首个多实例 surface 实装:

  • 多实例:面板头部实例条(新建/关闭/切换),rail 单图标 + 实例数徽标;每个 Session 可开多个 shell
  • Session-scoped(ADR-0007):cwd 由 backend 解析为 Session 的 execution checkout(回退 runtime snapshot cwd),renderer 不传路径
  • 真 PTY:backend(utilityProcess)用 @lydell/node-pty——N-API 模块,Electron 免 rebuild;I/O 走既有 RPC 事件通道,attach 重放有界 scrollback 并按流偏移去重(修掉了启动横幅重复打印的竞态)
  • xterm.js 渲染:自建 TerminalView 原语(Astryx 无终端组件)——chrome 色经探针从 token 桥解析(@scope + 链式 var() + light-dark() 全链解析),ANSI 16 色按背景亮度在深/浅两套惯例色间切换,跟随 OS 明暗切换;滚动条按 app 语言瘦身为 8px token 半透明滑块(xterm 6 自绘滚动条,宽度由 overviewRuler.width 控制)
  • flushContent:registry 新增标志,flush surface 的表头与内容容器去掉内边距——Changes 与 Terminal 均满血贴缘;Terminal 实例条与 40px 表头带精确等高(py-1.5 凑 28+12=40)

同时移除 Actions surface(checkout 元数据 / model & cost / Archive 区块);归档入口保留在侧栏会话行菜单。

Packaging

node-pty 是首个原生依赖:scripts/stage-node-pty.mjs 把 bun store 里的实体包物化进 apps/desktop/node_modules(幂等,五个 package/dist 脚本已串上),electron-builder.yml 回包含并 asarUnpack 整个 @lydell scope(pty.node 要 dlopen、spawn-helper 要 exec)。已在打包产物(未签名)里实测终端可用。

Notes

  • AGENTS.md 新增 runtime gotcha:不要用 bun 运行时直接跑 pty driver(N-API 兼容问题);生产路径(Electron/Node)和 vitest 均不受影响。
  • 签名版 package:mac 已验证:pty.node/spawn-helper 带 hardened-runtime 签名,codesign --verify --deep --strict 通过,签名包终端 e2e 通过。dist:mac(dmg)会触发公证(notarize),需要 Apple 凭据,本次未跑。

Test plan

  • bun run typecheck 干净
  • bun run test:758 通过(新增 backend driver 9 个、service 4 个、client 3 个、TerminalView 5 个、面板 7 个单测;actions 相关测试移除或改道)
  • bun run test:e2e:17/17,含新增 terminal-surface.spec.ts(真实 Electron + zsh:spawn、echo 往返、多实例、tab 切换 scrollback 重放、关闭实例)
  • bun run test:e2e:packaged:mac -- terminal-surface:打包态通过

Add a Terminal surface to the inspector rail (ADR-0028's first
multi-instance surface): an instance strip in the panel header, a count
badge on the rail, and one xterm.js viewport per instance. The
utilityProcess backend owns real PTYs via @lydell/node-pty (N-API — no
Electron rebuild) and streams I/O over the existing RPC event channel;
attach replays a bounded scrollback with offset-based de-dupe. Shells
open in the Session's execution checkout (ADR-0007), falling back to
the runtime snapshot cwd.

- backend: drivers/terminal.ts + list/open/attach/input/resize/close RPC
- renderer: TerminalView primitive (token-resolved chrome colors,
  conventional ANSI palettes picked by background luminance, slim
  token-tinted scrollbar via overviewRuler.width), terminal-client,
  SessionTerminalPanel
- inspector: flushContent surface flag drops header and content padding;
  Changes and Terminal both render edge-to-edge; the terminal strip is a
  second 40px band matching the header
- Actions surface removed; archive stays on the sidebar row menu
- packaging: scripts/stage-node-pty.mjs materializes node-pty from bun's
  store so electron-builder can ship it (asarUnpacked)
- AGENTS.md: never exercise the pty driver under the Bun runtime

Verified: tsc clean, vitest 758 green, playwright 17/17 including a
packaged-app terminal smoke.
@bubbleptr
bubbleptr merged commit f415cba into main Sep 2, 2026
@bubbleptr
bubbleptr deleted the feat/session-terminal-surface branch September 2, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant