test(terminal): #774 收尾——补 bottomOnly 原生承载面的单元判别性守护

独立验证节点实测:把 src/client/native/index.ts 的 sync() 里
`if (descriptor.bottomOnly === true) continue` 删掉后,14 个相关 spec、158 条
断言全绿,只有挂载 lane 能抓住「原生 guide 条目从 0 变 1」——这半边当时只有
部署级守护。

- tests/native-registration.spec.ts 新增「a bottomOnly descriptor never
  reaches the native surface」:断言注册表的**事件日志**里没有该 id、没有它的
  slot,guide 条目只有 files 与 git;正控(其余描述符确实注册了)在前,所以
  这条不会因为「什么都没注册」而空过。实测删掉那行 skip 后:本次相关的 8 个
  spec / 171 条用例中只有这条红(170 绿)。
- tests/terminal-tab.spec.tsx:「已退出只说一次」那条断言原先**不判别**——
  只翻 info.state 时 statusOf 本来就返回 undefined,门在不在都一样。现在把
  phase 也置为 disconnected(statusOf 有自己的一行),断言状态行恰好 1 个、
  唯一按钮是「新建终端」、且不含 disconnected 文案。实测去掉
  TerminalView.tsx 的 `missing || ended` 门即红。
- tests/terminal-tab.spec.tsx 新增「新建终端」的**真实路由**用例:此前被假
  betterSidebar.updateTab 掩盖,现在接真 service,覆盖 surface.update 认领
  与 store.reduce(patchTab) 两半(bottomOnly 类型永远没有原生记录,落 store
  是它唯一的真实路径)。
- src/client/builtins/tabs.tsx:onClose 不再以 `scope?.sessionId ?? ''` 调宿主
  close(),缺 scope 直接 return——空 sessionId 会让宿主 no-op 并让 shell 一直
  挂着一个 per-session 槽位。
This commit is contained in:
Menghuan1918 committed 2026-10-06 00:06:37 +08:00
1 parent 2f66c921df
commit 6c60693e7d
3 files changed
+145 -8

No files matched your search

+11 -1
View File
@@ -269,7 +269,17 @@ export function builtinTabs(ctx: Context): readonly TabDescriptor[] {
// reattach), so closing the TAB is the only thing that ends the process
// — without it every closed bottom terminal would hold one of the host's
// per-session terminal slots forever.
onClose: (tab, scope) => { closeBottomTerminal(ctx, tab, scope?.sessionId ?? '') },
onClose: (tab, scope) => {
// Every close path resolves a scope (the type makes it required), so
// this guard should be unreachable. It returns instead of substituting
// `''` for a missing one because an empty session id is the ONE option
// that is worse than doing nothing: the host would look the terminal up
// in a session that does not exist, no-op, and leave the shell running
// — invisibly holding a per-session terminal slot for the page's life.
const sessionId: string | undefined = scope?.sessionId
if (sessionId === undefined || sessionId === '') return
closeBottomTerminal(ctx, tab, sessionId)
},
},
{
id: 'diff',