Repository navigation
Restore editor file watching when remote host contact returns - #26606
Conversation
0c3a32b to
1ce04b2
Compare
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe editor runtime file watcher now retries subscriptions after host contact returns, emits an overflow event, and stops on runtime retirement or disposal. The editor hook uses this watcher directly. New unit and Docker-gated E2E tests cover watch recovery, including managed-server restart. CI routes relevant source changes to the dedicated E2E spec and runs it in the Docker conversion job. Priority: ➖ Normal Merge Risk: 🔵 Low · up to A failed remote-watch replacement can leave an affected editor without live updates until host contact changes again. This is a bounded reliability risk rather than a broader outage. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)✅ Passed checks (3 passed)Full details: Description checkExplanation The description is detailed and covers the change, rationale, testing, visual proof, scope, and checklist. However, the required Linked Issue section does not provide an issue link and explicitly states that no existing issue exists. Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 8 files. (1 skipped: 1 unsupported.) ✨ Finishing Touches 💡 1📝 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 |
31a0101 to
75c93a0
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
232d37ac-cbf9-43df-8869-abbe5b7ac163
📒 Files selected for processing (9)
.github/workflows/e2e.ymlconfig/scripts/ci-e2e-job-selection.mjsconfig/scripts/ci-e2e-job-selection.test.mjsconfig/scripts/pr-e2e-source-routing.mjssrc/renderer/src/hooks/editor-runtime-file-watch.test.tssrc/renderer/src/hooks/editor-runtime-file-watch.tssrc/renderer/src/hooks/useEditorExternalWatch-subscriptions.test.tsxsrc/renderer/src/hooks/useEditorExternalWatch.tstests/e2e/ssh-orcad-editor-watch-recovery.spec.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 2 remain after this review.
| const currentAttempt = ++attempt | ||
| unsubscribe?.() | ||
| unsubscribe = null |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '10,105p' src/renderer/src/hooks/editor-runtime-file-watch.ts
sed -n '45,110p' src/renderer/src/runtime/runtime-file-watch-client.ts
sed -n '105,170p' src/renderer/src/hooks/editor-runtime-file-watch.test.tsRepository: stablyai/orca
Length of output: 6307
🏁 Script executed:
sed -n '1,130p' src/renderer/src/hooks/editor-runtime-file-watch.ts
sed -n '1,190p' src/renderer/src/hooks/editor-runtime-file-watch.test.ts
sed -n '45,145p' src/renderer/src/runtime/runtime-file-watch-client.ts
sed -n '190,245p' src/renderer/src/runtime/runtime-file-watch-client.tsRepository: stablyai/orca
Length of output: 13483
Keep the old attempt active until replacement succeeds.
Retaining the old unsubscribe handle is not sufficient. The replacement still increments attempt, so the old callback's isCurrent() test rejects every payload. If replacement setup fails, the old stream remains registered but does not update the editor.
Keep the active attempt current while replacement setup is pending. Switch to the new attempt and stop the old handle only after the replacement resolves. If setup fails, leave the old handle and its callback active.
75c93a0 to
c11d9ce
Compare
ELI5
After an SSH host moves to Remote or reconnects, open editors keep receiving changes made on that host.
What Changed
Before, the editor's first managed file-watch request could fail during conversion and never restart. The host could return the updated README while the editor still displayed its old contents. The watch now retains its recovery subscription, uses Orca's existing host-contact signal to replace the stream, and requests a reread for changes missed during the gap.
Why
Workspace paths and tab ownership often stay unchanged during reconnect, so waiting for an editor rerender cannot restore a lost subscription. Reusing the existing contact epoch and connection generation avoids another polling loop. Each watch owns its cancellation; replaced attempts cannot deliver late data, and retiring a host disposes the watch before a same-ID replacement can revive old work.
Linked Issue
Found during SSH → Remote consolidation testing; no existing issue.
Visual Proof
Before: positive host read contains UPDATED_REMOTE_MARKDOWN, but the open editor keeps the old heading. After: the same conversion journey renders the externally updated contents. Runtime logs also verify a new file event after a real managed-server restart.
editor-watch-recovery-runtime-red-final.log
editor-watch-recovery-runtime-post-restart-red.log
editor-watch-recovery-runtime-green-final.log
Testing
Untouched Phase 3.5 fails the conversion case in 24.2 s. A separate baseline restart check receives the new file from the host but times out waiting for its watcher event. The corrected build passes both final cases: conversion 9.5 s; restart plus a new post-restart file event 15.9 s. The restart fixture first proves a live watcher, terminates the owned server, changes README during the gap, verifies a replacement PID and positive host reads, then requires the new file's actual host-qualified event.
The original restart text control already passes baseline through session mirroring; displayed text alone is not used as proof of a recovered watcher.
Two new hook regressions fail before the fix. 144 tests across 15 files pass afterward, including existing watch sharing, WSL/SSH ownership and status-counter coverage, plus new late-handle cancellation, stale callback rejection, host retirement and non-Git folder recovery. Full
pnpm tc,pnpm lint, changed-code quality, standalone CI React Doctor, fresh E2E build and commit hooks pass.Review
Independent Phase 3.5 fix. Only the managed editor watcher uses the new recovery lifetime; local/direct SSH watcher behavior continues through its existing path. Existing editor reload policy handles the overflow reread.
Agent skill upstream boundary
Notes
No server or remote wire change. Host contact remains the shared store's evidence; this change does not infer process death from an outage. All destructive test actions target disposable owned Docker hosts. Windows was not runtime-tested.
Wrong-host Markdown metadata, duplicate editor records and rich-link metadata rendering are independent fixes; related errors may appear in baseline logs. This PR restores the editor watcher and its existing event broker; other independently owned subscriptions may need separate recovery checks.
Checklist