docs+test: 对齐等待 banner 的注释/设计口径并钉住 skip-wait 的 404 契约
v0.19.0 发版前 review 发现两处「文档与实现互相矛盾」(均不改运行时行为):
- use-host-feeds.ts 的 effect 注释仍写「terminal tab 类型禁用时 pushes are
ignored」,而 mirrorAgentWaits 恰恰改成了不忽略(只跳过 tab 增删 reconcile)。
注释改为如实描述;
- 设计文档 §1 写「轮询每圈优先检查 skipped」,实现是 aborted → exited →
skipped。维持实现现状(pty 已死是客观事实,两种顺序下用户可见结果——banner
消失 / skipWait 归零 / 等待结束——完全相同,只有 kind 文案不同),设计原文
同步为「退出优先」,并在实施偏差记录写清未采纳「用户意图优先」的理由与日后
改动点;
- src/index.ts 的 agent-pty.skip-wait 注释把「无活动等待 → 0」泛化成了
「幂等」,收窄为「无活动等待返回 {skipped:0};未知 uuid 走 expect → 404,
客户端 .catch 容忍并等下一次推送收敛」。
另把 skipWait 未知 uuid 的既有断言从「只校验 /not found/ 文案」升级为
「SidebarError + status 404 + code not-found」——HTTP 层 writeError 直接把
status 映射成响应码,此前这条契约没有测试守护(把 404 改成 410 时新断言即
失败,已验证)。
验证:pnpm test 126 files / 1312 passed / 0 failed,tsc --noEmit 与 eslint
均 exit 0;改动面仅 5 个文件,src/client/service.ts、builtins/ 与
external-plugin-guide.md 继续零改动。
This commit is contained in:
1 parent
22a0452a59
commit
7f2674ab70
5 files changed
+53
-6
No files matched your search
@@ -12,6 +12,7 @@ import {
|
||||
snapshotOf,
|
||||
tryResizePty,
|
||||
} from '../src/agent-pty.ts'
|
||||
import { SidebarError } from '../src/wire.ts'
|
||||
|
||||
/**
|
||||
* Resolve a shell binary for tests: on Windows use PowerShell (available on
|
||||
@@ -478,6 +479,17 @@ describe('AgentPtyRegistry', () => {
|
||||
const registry = new AgentPtyRegistry(testShell())
|
||||
try {
|
||||
expect(() => registry.skipWait('missing-uuid')).toThrow(/not found/)
|
||||
// The HTTP layer maps `status` straight onto the response, so the 404
|
||||
// contract rides this field — assert it, not just the message.
|
||||
let thrown: unknown
|
||||
try {
|
||||
registry.skipWait('missing-uuid')
|
||||
} catch (error) {
|
||||
thrown = error
|
||||
}
|
||||
expect(thrown).toBeInstanceOf(SidebarError)
|
||||
expect((thrown as SidebarError).status).toBe(404)
|
||||
expect((thrown as SidebarError).code).toBe('not-found')
|
||||
} finally {
|
||||
registry.disposeAll()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user