Skip to content

fix(terminal): close async capability review gaps - #11887

Merged
nwparker merged 1 commit into
mainfrom
fix-pr-11881-review-gaps
Aug 1, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix-pr-11881-review-gaps

Conversation

@nwparker

@nwparker nwparker commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • fixes the stale timeout clock so capability retries do not wait an extra second
  • makes the renderer-stall E2E fail when the capability API is missing
  • narrows reliability metadata and evidence to directly verified coverage
  • shortens new comments to match repository guidance

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-gates
  • pnpm exec electron-vite build --mode e2e
  • SKIP_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.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The 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)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: fixing asynchronous terminal capability review gaps.
Description check ✅ Passed The description covers the summary, visual changes, testing, AI review, security audit, and notes with relevant implementation details.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes a stale-clock bug in synchronizeTerminalProviderSnapshotCapabilities: when a capability batch resolution timed out, the retry delay was computed against nowMs (captured at function entry) rather than the current time, causing an extra ~1 s of unnecessary wait after the timeout already consumed the retry window. It also makes the renderer-stall E2E test fail loudly when the capability API is absent rather than silently passing.

  • Stale clock fix (terminal-provider-snapshot-capability.ts line 178): when observedAtMs is not provided (production path), a fresh Date.now() is used at return time so a 1 s timeout that consumes the full retry delay returns 0 instead of 1000, letting the loop retry in 1 ms rather than after an extra second.
  • E2E hardening (pty-snapshot-capability-main-stall.spec.ts): replaces silent optional-chain no-op with an early guard that throws 'PTY snapshot capability API is unavailable', and adds .catch(() => {}) to prevent unhandled rejections from IPC calls fired during the stall window.
  • Reliability gates (reliability-gates.jsonc): narrows coveredScenarios, coveredPlatforms, and coveredProviders to only what the current test run directly verified, removing claims backed by Docker SSH journeys that were not re-run.

Confidence Score: 5/5

Safe 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.

Important Files Changed

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
Loading

Reviews (1): Last reviewed commit: "fix(terminal): tighten async capability ..." | Re-trigger Greptile

@nwparker
nwparker merged commit 278a4b2 into main Aug 1, 2026
46 checks passed
@nwparker
nwparker deleted the fix-pr-11881-review-gaps branch August 1, 2026 07:00
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
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