feat(terminal): 等待 banner + 跳过等待(terminal_wait_for 增 skipped) - #606
feat(terminal): 等待 banner + 跳过等待(terminal_wait_for 增 skipped)#606HuanLinOTO wants to merge 12 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
There are a couple of small but concrete test robustness issues (hard-coded uuid in tools test and insufficient localStorage guard) that should be fixed to avoid brittleness/flakiness.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a user-visible “waiting” affordance for terminal_wait_for across host → push feed → client state → UI, including a skip mechanism that returns a new { kind: 'skipped' } tool result, plus an hourglass badge on agent terminal tabs.
Changes:
- Extend
AgentPtyRegistry.waitFor()with wait registration/snapshot exposure (waiting) and a newskipWait()path returning{ kind: 'skipped' }. - Mirror pushed
waitingstate into clientstate.agentWaits(transient) and render a Terminal wait banner + ⏳ tab badge for agent terminals. - Update tool schema/rendering and add tests covering registry skip, tool output validity, reconcile behavior, banner component, and badge end-to-end.
File summaries
| File | Description |
|---|---|
| tests/tools.spec.ts | Adds tool-layer coverage for terminal_wait_for returning skipped and render messaging. |
| tests/terminal-wait-banner.spec.tsx | New jsdom unit tests for the wait banner text, skip button wiring, and needle truncation behavior. |
| tests/agent-wait-badge.spec.tsx | New jsdom end-to-end test for ⏳ badge driven by /sidebar/ws/agent-terminals pushes. |
| tests/agent-terminal-reconcile.spec.ts | Adds reconcile tests for mirroring/clearing agentWaits and idempotency on waits-only updates. |
| tests/agent-pty.spec.ts | Adds registry tests for skip behavior, snapshot waiting, notifications, and unknown-uuid handling. |
| src/tools.ts | Extends terminal_wait_for description, output schema, and render to include skipped. |
| src/index.ts | Adds host API route agent-pty.skip-wait returning { ok, skipped }. |
| src/client/TerminalWaitBanner.tsx | New banner component for displaying the current wait needle and skip button. |
| src/client/TerminalView.tsx | Wires banner into agent terminal view by subscribing to state.agentWaits and calling api.agentSkipWait. |
| src/client/state.ts | Adds transient agentWaits to sidebar state and reconciles it from agent-terminals push snapshots. |
| src/client/sidebar/use-host-feeds.ts | Extends agent-terminals push parsing type to include optional waiting. |
| src/client/Sidebar.tsx | Adds a shell-level tabBadgeOf special-case to show ⏳ on waiting agent terminal tabs. |
| src/client/sidebar.module.css | Adds styles for the wait banner layout and needle display. |
| src/client/locales.ts | Adds terminalWaitBanner / terminalSkipWait keys to zh/en. |
| src/client/locales-zh-TW.ts | Adds the two new terminal wait keys for zh-TW. |
| src/client/locales-zh-MO.ts | Adds the two new terminal wait keys for zh-MO. |
| src/client/locales-zh-HK.ts | Adds the two new terminal wait keys for zh-HK. |
| src/client/locales-vi.ts | Adds the two new terminal wait keys for vi. |
| src/client/locales-tr.ts | Adds the two new terminal wait keys for tr. |
| src/client/locales-th.ts | Adds the two new terminal wait keys for th. |
| src/client/locales-sv.ts | Adds the two new terminal wait keys for sv. |
| src/client/locales-ru.ts | Adds the two new terminal wait keys for ru. |
| src/client/locales-pt.ts | Adds the two new terminal wait keys for pt. |
| src/client/locales-pl.ts | Adds the two new terminal wait keys for pl. |
| src/client/locales-nl.ts | Adds the two new terminal wait keys for nl. |
| src/client/locales-ko.ts | Adds the two new terminal wait keys for ko. |
| src/client/locales-ja.ts | Adds the two new terminal wait keys for ja. |
| src/client/locales-it.ts | Adds the two new terminal wait keys for it. |
| src/client/locales-id.ts | Adds the two new terminal wait keys for id. |
| src/client/locales-hi.ts | Adds the two new terminal wait keys for hi. |
| src/client/locales-fr.ts | Adds the two new terminal wait keys for fr. |
| src/client/locales-de.ts | Adds the two new terminal wait keys for de. |
| src/client/locales-ar.ts | Adds the two new terminal wait keys for ar. |
| docs/plans/2026-09-09-terminal-wait-banner-plan.md | Adds an implementation plan document for the wait banner + skip feature. |
| docs/plans/2026-09-09-terminal-wait-banner-design.md | Adds the design doc (incl. implementation deviations) for the wait banner + skip feature. |
Review details
- Files reviewed: 37/37 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| // a pending 200ms debounce write left behind between tests. Guarded — some | ||
| // node/jsdom combos (node >=22 without --localstorage-file) expose no | ||
| // working localStorage and a bare access would throw in the hook. | ||
| if (typeof localStorage !== 'undefined') localStorage.clear() |
| registry.create('s1', 'skipper', '') | ||
| registry.nextWaitResult = { kind: 'skipped' } | ||
| const value = await tool.execute({ uuid: 'uuid-1', needle: 'BUILD_OK', timeout_ms: 1000 }, exec('s1')) | ||
| expect(value).toEqual({ kind: 'skipped', needle: 'BUILD_OK' }) |
There was a problem hiding this comment.
🟡 Changes recommended
Cross-session pinned agent terminals cannot receive the new live banner or wait badge.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review details
- Files reviewed: 37/37 changed files
- Comments generated: 2
- Review effort level: Balanced
| if (isAgentTabId(tab.id)) { | ||
| const wait = state.agentWaits?.[agentUuidOf(tab.id)] | ||
| if (wait !== undefined) return <span className={css.tabBadge}>{'⏳'}</span> |
| const read = (): void => { | ||
| const next = store.getSnapshot().state?.agentWaits?.[agentUuid] |
|
Copilot review 处置(9a2c56e):
|
…openTabInBottomPane
设计:docs/plans/2026-09-09-terminal-wait-banner-design.md(含实施偏差记录,随本 PR)。
功能
agent 阻塞在 \ erminal_wait_for\ 时:
实现要点
验证