Skip to content

Restore editor file watching when remote host contact returns - #26606

Merged
OrcaWin merged 2 commits into
mainfrom
nwparker/remote-editor-watch-recovery
Oct 9, 2026
Merged

OrcaWin merged 2 commits into
mainfrom
nwparker/remote-editor-watch-recovery

Conversation

@nwparker

@nwparker nwparker commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​424 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​422
Prod 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114 $\color{#cf222e}{\Huge{\mathbf{−}}}$​37 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​77

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-before-final.png

editor-watch-recovery-after-final.png
editor-watch-recovery-runtime-red-final.log
editor-watch-recovery-runtime-post-restart-red.log
editor-watch-recovery-runtime-green-final.log

Testing

  • Manually tested with a hidden macOS Electron client and owned Linux Docker SSH hosts using the installed production server template.
  • Automated recovery/lifetime tests and dedicated template-building Docker CI routing added.

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

  • Not applicable; this change copies no upstream skill-installer source or resources.

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

  • Focused product change
  • ELI5, before/after, mechanism and approach explained
  • Before/after screenshots and real runtime logs attached
  • Self-reviewed for correctness, security and performance
  • SSH ownership, folder workspaces, paths and compatibility considered
  • Local lint, typechecks, affected tests and build pass

@OrcaWin
OrcaWin force-pushed the nwparker/remote-editor-watch-recovery branch from 0c3a32b to 1ce04b2 Compare October 9, 2026 02:27
@OrcaWin
OrcaWin changed the base branch from OrcaWin/phase35 to main October 9, 2026 02:27
@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 581baef1-056e-424a-a963-8f778df65b9e

📥 Commits

Reviewing files that changed from the base of the PR and between c11d9ce and 59037bf.


You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 46e78f0e-4794-47fe-9a96-3314fdbeaf00

📥 Commits

Reviewing files that changed from the base of the PR and between 75c93a0 and c11d9ce.


📒 Files selected for processing (4)
  • .github/workflows/e2e.yml
  • config/scripts/ci-e2e-job-selection.mjs
  • config/scripts/ci-e2e-job-selection.test.mjs
  • config/scripts/pr-e2e-source-routing.mjs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.



📝 Walkthrough

Walkthrough

The 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 c11d9

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)

Check name Status Explanation Resolution
Description check Warning 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 stat… Add a link to the actual issue addressed by this pull request in the Linked Issue section, using the required Fixes # format. If the contributor is an internal maintainer, document the applicable maintainer exception instead.
Docstring Coverage Warning 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 … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check Passed The title clearly and concisely describes the primary change: restoring editor file watching after remote host contact returns.
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.

Full details: Description check

Explanation

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 Coverage

Explanation

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 💡
  • Commit to this branch
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@OrcaWin
OrcaWin force-pushed the nwparker/remote-editor-watch-recovery branch 2 times, most recently from 31a0101 to 75c93a0 Compare October 9, 2026 06:10

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 232d37ac-cbf9-43df-8869-abbe5b7ac163
📥 Commits

Reviewing files that changed from the base of the PR and between d2d2d39 and 75c93a0.

📒 Files selected for processing (9)
  • .github/workflows/e2e.yml
  • config/scripts/ci-e2e-job-selection.mjs
  • config/scripts/ci-e2e-job-selection.test.mjs
  • config/scripts/pr-e2e-source-routing.mjs
  • src/renderer/src/hooks/editor-runtime-file-watch.test.ts
  • src/renderer/src/hooks/editor-runtime-file-watch.ts
  • src/renderer/src/hooks/useEditorExternalWatch-subscriptions.test.tsx
  • src/renderer/src/hooks/useEditorExternalWatch.ts
  • tests/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.

Comment on lines +20 to +22
const currentAttempt = ++attempt
unsubscribe?.()
unsubscribe = null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 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.ts

Repository: 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.ts

Repository: 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.

@OrcaWin
OrcaWin force-pushed the nwparker/remote-editor-watch-recovery branch from 75c93a0 to c11d9ce Compare October 9, 2026 09:18
@OrcaWin
OrcaWin merged commit 4845ae8 into main Oct 9, 2026
39 checks passed
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.

2 participants