Repository navigation
fix(terminal): close async capability review gaps - #11887
Conversation
📝 WalkthroughWalkthroughThe changes clarify PTY snapshot capability resolution semantics and update comments for unresolved providers. Renderer synchronization now uses the current clock when no observation timestamp is provided and includes coverage for immediate retry after timeout. The end-to-end probe validates the PTY capability API before use. The reliability gate narrows its supported surfaces and removes unsupported restoration results from its evidence summary. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a stale-clock bug in
Confidence Score: 5/5Safe to merge; the change is surgical and all affected paths are covered by the new unit test and the updated E2E. The stale-clock fix is a one-line change with a dedicated new unit test that exactly demonstrates the before/after behaviour. The E2E change removes a silent correctness gap. Comment and metadata trims carry no runtime risk. No existing test expectations were loosened. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/renderer/src/components/terminal/terminal-provider-snapshot-capability.ts | Core fix: returns a fresh Date.now() (instead of stale nowMs) when computing the retry delay after a batch timeout, so a timeout that consumes the full retry window doesn't add an unnecessary extra second of wait. |
| src/renderer/src/components/terminal/terminal-provider-snapshot-capability.test.ts | Adds a dedicated unit test for the stale-clock fix and trims a multi-line comment to a one-liner; vi.useFakeTimers() is properly cleaned up by the existing afterEach. |
| tests/e2e/pty-snapshot-capability-main-stall.spec.ts | E2E probe now throws immediately if the capability API is absent (replacing silent optional-chain no-op), and adds .catch(() => {}) to swallow expected IPC rejections during the stall window. |
| config/reliability-gates.jsonc | Narrows coveredScenarios, coveredPlatforms, and coveredProviders to only what the current test run directly verified; removes Docker SSH journey reference from the E2E summary. |
| src/main/ipc/pty.ts | Comment-only change: multi-line explanation of null-vs-false semantics condensed to a single line; no logic change. |
| src/main/ipc/pty.test.ts | Comment-only change: condensed a multi-line Why comment into a single sentence; no logic change. |
Sequence Diagram
sequenceDiagram
participant Caller as startSynchronization loop
participant Sync as synchronize()
participant Batch as resolveSnapshotCapabilityBatch
participant Clock as Date.now()
note over Caller,Clock: Before fix — stale clock causes 1s extra wait
Caller->>Sync: synchronizeTerminalProviderSnapshotCapabilities(ids)
activate Sync
Sync->>Clock: "nowMs = Date.now() captured at T=0"
Sync->>Batch: race(resolve(batch), timeout 1000ms)
note over Batch: timeout fires at T≈1000ms
Batch-->>Sync: null
Sync->>Sync: "backOffUnknownCapability(id, nowMs=0) → retryAt=1000"
Sync-->>Caller: "retryDelay = max(0, 1000-0) = 1000ms STALE"
deactivate Sync
note over Caller,Clock: After fix — fresh clock returns 0 delay
Caller->>Sync: synchronizeTerminalProviderSnapshotCapabilities(ids)
activate Sync
Sync->>Clock: "nowMs = Date.now() captured at T=0"
Sync->>Batch: race(resolve(batch), timeout 1000ms)
note over Batch: timeout fires at T≈1000ms
Batch-->>Sync: null
Sync->>Sync: "backOffUnknownCapability(id, nowMs=0) → retryAt=1000"
Sync->>Clock: fresh Date.now() at return T≈1000ms
Sync-->>Caller: "retryDelay = max(0, 1000-1000) = 0ms CORRECT"
deactivate Sync
note over Caller: Math.max(1,0)=1ms → effectively immediate retry
Reviews (1): Last reviewed commit: "fix(terminal): tighten async capability ..." | Re-trigger Greptile
Summary
Follow-up to #11881, which merged while its review loop was still running.
Screenshots
No visual change.
Testing
pnpm exec vitest run --config config/vitest.config.ts src/preload/pty-snapshot-capability-ipc.test.ts src/main/ipc/pty.test.ts src/main/providers/ssh-pty-provider.test.ts src/renderer/src/components/terminal/terminal-provider-snapshot-capability.test.ts src/renderer/src/components/terminal/use-terminal-provider-snapshot-capability.test.tsx src/renderer/src/components/terminal/background-terminal-worktree-mount.test.ts src/renderer/src/components/terminal-pane/terminal-hidden-view-parking.test.ts src/renderer/src/app-startup-routing.test.ts --reporter=dot(574 passed)pnpm run check:reliability-gatespnpm exec electron-vite build --mode e2eSKIP_BUILD=1 pnpm exec playwright test tests/e2e/pty-snapshot-capability-main-stall.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1 --repeat-each=3(3 passed)AI Review Report
Reviewed retry timing, timeout recovery, stale-generation handling, IPC validation, E2E false-pass behavior, and reliability evidence traceability. CodeRabbit reported no actionable code findings on this follow-up.
Security Audit
No new permissions, command execution, filesystem access, network surface, or secret handling. The change only adjusts renderer retry scheduling, tests, comments, and reliability metadata.
Notes
The local full typecheck was contaminated by unrelated untracked freeze-lab tests in the active worktree; clean-tree PR CI typecheck passed.