Skip to content

[Bug]: Mirrored editor tabs carry the peer's runtimeEnvironmentId untranslated — a machine routes its own local files to a peer that doesn't have the worktree (selector_not_found) #10859

Closed

Description

@khdkkhdd

Operating system

macOS

Orca version

1.4.158

Details

Paths, repo names and ids below are masked, consistently.

Summary

Two Orca instances paired to each other share terminal and agent sessions correctly in both directions. Editor tabs do not.

runtimeEnvironmentId is perspective-relative — it only means something in the frame of the instance that created it — but session mirroring sends it across the link untranslated. When machine B opens a file in machine A's local worktree, that tab is mirrored into A's own session still carrying B's owner id. In B's frame that id means "the peer, A". In A's frame the same worktree is local. Nothing re-owns it on ingest, so A routes reads and diffs for its own local file to B. B has never heard of that worktree, and resolveWorktreeSelector throws selector_not_found.

Three defects compound:

  1. No perspective translation on mirror ingest — the peer's owner id is taken at face value.
  2. No dedup on ingest — the same file gains a new entry on every sync.
  3. Close is not authoritative across the link — a close lands locally, then the peer re-sends the tab.

The renderer eventually OOM-crashes under the churn.

What I'm trying to do

Work from either machine with everything shared both ways — terminals, agents, and editors — which is what pairing two runtime environments is for. Today the terminal half of that works and the editor half corrupts.

A fix that blocks the mirror-back rather than translating the owner id would stop the corruption but not give me the workflow. Re-owning an incoming tab as local when the receiver owns that worktree is what makes bidirectional editing work.

Scope: terminals are unaffected

Across six state snapshots spanning the failure, editor tabs grew 22× while every terminal-side counter held flat:

              editorFiles   unifiedTabs(editor)   unifiedTabs(terminal)   tabsByWorktree   ptyIncarnations
snapshot 1              7                    6                       3                3                6
snapshot 2             52                   48                       4                4                7
snapshot 3             52                   48                       4                4                7
snapshot 4             48                   44                       4                4                7
snapshot 5            151                   84                       3                3                6
snapshot 6            154                   94                       4                4                7

So this is confined to the editor-tab mirroring path, not session mirroring in general.

Evidence

Setup: two machines, both Orca 1.4.158 on macOS, paired to each other over Tailscale. A has environment B registered; B has environment A registered pointing at ws://<A-ip>:6768.

On B, the session it keeps for A:

workspaceSessionsByHostId["runtime:<A-env-id>"].openFilesByWorktree
  260 entries for 12 distinct files
  worst single file: 33 copies
  runtimeEnvironmentId values present: BOTH env ids — cross-tagged

On A, up to 156 entries for those same 12 files, 100% tagged with B's env id — while A's own settings.activeRuntimeEnvironmentId was null the whole time.

Editor tab ids embed the owner key (editor:<worktreeId>:<ownerKey>:<filePath>), and the same file appears under two different owner keys, which is why one document shows up as several tabs.

Same selector, different target, driven from A through the RuntimeClient in app.asar.unpacked/out/cli/runtime-client.js with ORCA_ENVIRONMENT selecting the target:

files.read  <file>.md   local → OK    ORCA_ENVIRONMENT=<peer> → selector_not_found
git.diff    <file>.md   local → OK    ORCA_ENVIRONMENT=<peer> → selector_not_found

A sweep of files.read over all 118 untracked files in all 9 of A's worktrees, against A's local runtime: 0 failures. The runtime is healthy; only the routing is wrong.

Reproduction

  1. Two machines running Orca, each paired to the other as a remote runtime environment.
  2. From B, open a file belonging to a local git worktree of A.
  3. On A, that tab now carries B's runtimeEnvironmentId.
  4. On A, opening that file or its diff fails with selector_not_found.
  5. Closing the tab on A appears to do nothing — the close lands, the peer re-sends it.
  6. Entries multiply across syncs; the renderer eventually OOM-crashes.

No monorepo, folder workspace, or project group involved — folderWorkspace.list returns [] on both machines.

Diagnostic signature

Clearing A's tab state and relaunching:

t+0s    entries=0     hydration completes clean
t+18s   entries=0
t+21s   entries=140   single burst, all tagged, right as the peer link comes up
t+37s   entries=156
then    oscillates 144 <-> 156   local closes vs peer re-injection

The 21-second gap is the tell — a local restore would populate at t=0.

Where the polluted state lives

Not in workspaceSession on the affected machine, but in workspaceSessionsByHostId[*] on the peer. Clearing only the affected machine does nothing; the peer refills it within ~20s of the next launch. Both sides must be cleared.

Detection — non-empty output means tabs are tagged with a peer runtime:

python3 - <<'EOF'
import json, pathlib
p = pathlib.Path.home()/'Library/Application Support/Orca/profiles/local-default/orca-data.json'
d = json.loads(p.read_text())
def scan(ws, label):
    for wt, files in ws.get('openFilesByWorktree', {}).items():
        tagged = [f for f in files if f.get('runtimeEnvironmentId')]
        if tagged:
            envs = sorted({f['runtimeEnvironmentId'] for f in tagged})
            print(f'{label} {wt}\n  {len(tagged)}/{len(files)} tagged -> {envs}')
scan(d.get('workspaceSession', {}), '[own]')
for host, sess in d.get('workspaceSessionsByHostId', {}).items():
    scan(sess, f'[host {host}]')
EOF

What confirmed causality

Removing the peer environment on one side and clearing the mirrored session on both:

orca environment rm --environment <peer>
# then on BOTH machines empty the editor tabs in
#   workspaceSession.openFilesByWorktree
#   workspaceSessionsByHostId[*].openFilesByWorktree

Result: entries=0 sustained, renderer memory flat at 534–847 MB — previously oscillating 551–3262 MB against a 3586 MB limit, with a recorded OOM crash (renderer_memory breadcrumbs pinned at usedHeapMB: 3586 for 7+ minutes, then reason: "crashed", exitCode: 5). The React #185 loop stopped entirely, which places it downstream of the mirroring churn rather than upstream of it.

Terminals survived on both machines — PTYs belong to the separate daemon, which outlives an app restart.

This is a workaround, not a fix: it costs the feature.

Suggested direction

  1. Translate owner identity on mirror ingest. Resolve an incoming runtimeEnvironmentId into the receiver's frame. A tab arriving for a worktree the receiver owns locally should be re-owned as local.
  2. Dedup on ingest. 12 files becoming 260 entries is the loudest symptom; openFilesByWorktree should be keyed rather than appended.
  3. Make close authoritative across the link, so a close on one side isn't undone by the peer.
  4. Surface the target runtime in the error. EditorContent renders the bare code; showing the attempted selector and which runtime it went to would make this self-diagnosing.

Still unproven

What makes the same file acquire two distinct owner keys.

I have before/after snapshots of both machines and can re-run any measurement or test a patch.

Activity

  1. khdkkhdd commented on Jul 27, 2026

    @khdkkhdd
    Author

    Superseded — I've rewritten the issue body with the corrected mechanism.

    Short version of what changed: this is not the global activeRuntimeEnvironmentId being stamped (it was null throughout), and React #185 is a consequence of the mirroring churn rather than its cause. The actual defect is that runtimeEnvironmentId is perspective-relative and is mirrored across the peer link untranslated, so a machine ends up routing its own local files to a peer that doesn't have the worktree.

    Also worth flagging, since my earlier wording implied otherwise: cross-machine editing is the intended use of the remote runtime feature, so this is on the main path, not an edge case.

  2. changed the title [-][Bug]: Editor tabs on local worktrees get stamped with the active remote `runtimeEnvironmentId`, routing file/diff loads to a runtime that doesn't have the worktree[/-] [+][Bug]: Mirrored editor tabs carry the peer's `runtimeEnvironmentId` untranslated — a machine routes its own local files to a peer that doesn't have the worktree (`selector_not_found`)[/+] on Jul 27, 2026
  3. nwparker commented on Jul 28, 2026

    @nwparker
    Contributor

    Picked this up (👀 on the issue). I verified all three parts of the corrected mechanism against the source and by running the code. All three reproduce. Detail below, plus one nuance the write-up doesn't mention and one thing that is not affected.

    A note on method: I did not run the diagnostic snippet in the issue body — it reads a local app-data file, and I don't execute code from an issue. Everything below is verified against the repo and by tests I wrote myself, so it should be independently checkable.

    1. No perspective translation on mirror ingest — confirmed

    src/renderer/src/runtime/web-session-tabs-sync.ts:886-901 stamps the sender's id onto the receiver's record unconditionally:

    const file: OpenFile = {
      ...existingFile,
      id: fileId,
      runtimeEnvironmentId: environmentId,   // sender's perspective, verbatim
      mirroredFromRuntimeSession: true
    }

    There is no re-own step anywhere on this path — I searched for one. runtimeEnvironmentId is perspective-relative, so a peer that holds the worktree locally still records it as belonging to env-A, and later routes its own file operations to a machine that can't resolve them (selector_not_found).

    The asymmetry with terminals is the tell. Terminals derive ownership from the real PTY rather than trusting the sender (web-session-tabs-sync.ts:454):

    function isRuntimeTerminalTabForEnvironment(tab: TerminalTab, environmentId: string): boolean {
      if (!tab.ptyId) { return false }
      return getRemoteRuntimePtyEnvironmentId(tab.ptyId) === environmentId
    }

    Terminals ask the runtime; editors take the sender's word. That's the shape of the bug, and it's why terminals are unaffected.

    2. Id collision — confirmed, with a nuance the report doesn't cover

    Reproduced by execution: one file path yields three distinct ids — editor:wt-1:local:…, editor:wt-1:env-A:…, editor:wt-1:env-B:… (buildOwnedEditorFileId, store/slices/editor.ts:989-996).

    The nuance: mirror ingest doesn't use the owner-keyed form at all. localEditorFileId (web-session-tabs-sync.ts:443-448) returns the bare path:

    function localEditorFileId(tab: ReadyEditorSurface): string {
      if (tab.type === 'markdown' && tab.mode === 'markdown-preview') { return `markdown-preview::${tab.sourceFilePath}` }
      return tab.filePath        // bare — not owner-keyed
    }

    Local opens only reach the owner-keyed form on collision. So the two sides don't merely disagree about the owner — they're using two different id schemes, which is why the mismatch survives a reconcile instead of being corrected by one.

    3. Close is not authoritative — confirmed, and this is the one with no test coverage

    src/renderer/src/runtime/close-mirrored-editor-tab.ts bails before notifying the peer:

    const runtimeEnvironmentId = getRuntimeEnvironmentIdForWorktree(state, worktreeId)
    if (!runtimeEnvironmentId?.trim()) { return false }

    When the receiver owns the worktree locally, getRuntimeEnvironmentIdForWorktree returns null (worktree-runtime-owner.ts:68 — hasDetectedOwner true, resolves locally), so the function returns early. Measured: notified peer of close? false | RPC calls: 0. The tab closes locally and comes straight back on the next mirror.

    Why it was never caught: the shipped test mocks @/lib/worktree-runtime-owner, so the locally-owned branch — the one that fails — is never exercised.

    Not affected

    Terminals, for the reason in §1. I checked rather than assumed.

    Relationship to #10819

    #10819 (folder-workspace git selector routing) is a different defect that shares a symptom. Both surface as selector_not_found, but the causes don't overlap: #10819 is about how a folder workspace resolves a git selector; this is about editor-tab ownership being mirrored untranslated between peers. Fixing either will not fix the other, and I'd keep them separate rather than folding this into #10819's scope.


    I'll follow up with a fix proposal. The direction I'd take: give editors the same treatment terminals already get — derive ownership from the runtime on ingest instead of trusting the sender's stamp — and make close authoritative by routing on the file's recorded owner rather than the receiver's view of the worktree.

    Claims above are labeled by how they were established: §1 and the terminal asymmetry are read from source; §2 and §3 were reproduced by execution against the real modules. Scratch tests were removed after measurement.

  4. nwparker commented on Jul 28, 2026

    @nwparker
    Contributor

    Follow-up: a fourth defect, and it explains why this doesn't settle

    Adversarial review of my own comment above turned up something the three-part write-up doesn't cover, and it's the piece that turns a one-time mis-stamp into a persistent loop.

    Mirrored editor tabs are re-published back out. Mirrored terminals are not.

    The terminal side has an explicit exclusion (sync-runtime-graph.ts:1024-1037):

    function isWebOnlyMirroredTerminalTab(state, tab): boolean {
      if (!isWebTerminalSurfaceTabId(tab.id)) { return false }
      const layoutPtyIds = Object.values(state.terminalLayoutsByTabId[tab.id]?.ptyIdsByLeafId ?? {})
      const ptyIds = [tab.ptyId, ...layoutPtyIds].filter(...)
      // Why: only-remote/no-PTY tabs are web mirrors, not host state; ...
      return ptyIds.every(isRemoteRuntimePtyId)
    }

    …applied at four publish sites (:580, :633, :726, :743). There is no editor equivalent. buildRuntimeMobileOpenFilesProjection (:433-448) maps openFiles with no mirroredFromRuntimeSession check at all, so a file that arrived as a mirror goes straight back onto the wire as if it were local state.

    Executed, against the real buildMobileSessionTabSnapshots:

    mirrored terminal   -> excluded from republication
    mirrored editor     -> REPUBLISHED
    mirrored browser    -> REPUBLISHED
    non-mirrored editor -> republished (the filter is not mirror-aware at all)
    

    This is the same asymmetry I flagged in §1 of my previous comment (terminals derive ownership from the real PTY; editors trust the sender's stamp) showing up a second time on the outbound path. Both halves of the round trip treat editors as authoritative when they aren't.

    Why it compounds

    Combined with the id-scheme mismatch from §2, republication doesn't just echo — it multiplies. Measured:

    5 rows sharing one id          -> 1 tab on the wire   (collapses, fine)
    2 rows, distinct ids, one path -> 2 tabs on the wire
    5 rows, distinct ids, one path -> 5 tabs on the wire
    

    with the two ids being exactly the pair from §2: editor:wt-1:env-B:%2Frepo%2Fa.md and bare /repo/a.md. Dedup is by id, and the two sides mint different ids for the same file, so nothing collapses them. Each round trip can add a row rather than reconciling one.

    That's the missing link between "a tab is mis-owned once" and the churn actually reported — including, I'd now say, the React #185 the original report saw as a consequence.

    Also confirmed

    The receiver stamps the sender's env id even when it already holds an untagged local file for the same path — it doesn't reconcile, it adds:

    CLAIM1 openFiles: [
      {"id":"/repo/wt/a.md","env":null,   "mirrored":false},   <- receiver's own
      {"id":"/repo/wt/a.md","env":"env-B","mirrored":true}     <- added alongside
    ]
    

    And the close-routing failure from §3 reproduces across four ownership configurations, not just the one I tested (locally-owned; owned by env-B; owned by env-A with the file mirrored from env-B; worktree unknown to the local catalog).

    Revised fix direction

    My earlier suggestion — translate ownership on ingest, make close authoritative — is necessary but not sufficient. The republication path needs the same mirror-awareness terminals already have, or a corrected inbound stamp just gets re-emitted and the loop survives. Concretely: an isWebOnlyMirroredEditorFile counterpart applied to the editor projection, plus one id scheme shared by both ingest and local open (§2 — right now mirror ingest uses the bare path while local opens use the owner-keyed form only on collision).

    Source claims read from sync-runtime-graph.ts; the four behavioral results above were executed against the real modules. I did not find the republication asymmetry myself — an adversarial reviewer did, and I verified it at source before posting. Scratch tests removed.

  5. nwparker commented on Jul 28, 2026

    @nwparker
    Contributor

    Correcting my own follow-up: the growth is restart-driven and local, not cross-machine amplification

    An adversarial verifier refuted the central framing of my comment above, and after re-deriving it myself I agree. The duplicate rows are real, but I attributed them to the wrong mechanism.

    What I got wrong

    I said the id-scheme mismatch (§2) turns republication into an amplifying cross-machine loop. It isn't amplifying, and it doesn't need a second machine.

    Decisive control I ran myself — one machine, one peer env, a wire snapshot that never contains more than one tab, restart between each ingest:

    no restart between ingests:   rows [1,1,1,1,1,1,1,1]
    restart between ingests:      rows [1,2,3,4,5,6,7,8]   <-- +1 every cycle
                            distinct ids [1,1,1,1,1,1,1,1]
    

    Zero fanout, zero second machine, and the growth is identical in kind. Restart is necessary and sufficient. Peer count and wire fanout are not part of the mechanism.

    Note the second row: the accumulating rows are identical in id, not distinct. That directly contradicts the "distinct ids multiply on the wire" story I told.

    The actual mechanism

    Two independent facts, both verified here:

    1. Hydrate rewrites the id. shouldHydrateWithOwnedEditorFileId (editor.ts:1105-1112) is true whenever runtimeEnvironmentId is set, so on restart a mirrored row's id becomes the owned form (editor.ts:4499-4503). Measured: /repo/wt/a.md + env-B → editor:repo%3A%3A%2Frepo%2Fwt:env-B:%2Frepo%2Fwt%2Fa.md.
    2. The mirror marker is never persisted. buildEditorSessionData (workspace-session.ts:120-135) writes exactly seven fields — filePath, relativePath, worktreeId, language, isPreview, runtimeEnvironmentId, externalSshTargetId (plus conditional readOnly/liveTail/draft). Executed against a row with mirroredFromRuntimeSession: true, the flag is absent from the output.

    applyWebSessionTabsSnapshot culls a row only when removedEditorFileIds.has(file.id) || mirroredEditorFileIds.has(file.id), and mirroredEditorFileIds holds bare tab.filePath. After a restart the retained row's id is the owned form, so it matches neither set — and because fact 2 stripped mirroredFromRuntimeSession, the removedEditorFileIds path can't reach it either (that filter requires mirroredFromRuntimeSession === true). Both cull paths miss, and a fresh bare-path row is appended. +1 uncullable row per ingest-after-restart.

    Also wrong: what drives wire fanout

    I attributed wire-tab count to row-id distinctness. It's unifiedTabsByWorktree. The fallback publish loop (sync-runtime-graph.ts:800) iterates unifiedEditorTabs and resolves each through openFilesForWorktree, which getOpenFileIndexes (:1039-1061) has already deduped by file.id (if (!filesById.has(file.id))). One row + N unified tabs → N wire tabs; ten duplicate rows + 1 unified tab → 1 wire tab.

    What still stands

    • §1 (no perspective translation on ingest) — unchanged.
    • §2 (two id schemes for one file) — unchanged, and it's now the direct cause rather than an amplifier: the mismatch is between the hydrated id and the cull sets.
    • §3 (close not authoritative) — unchanged.
    • The republication asymmetry (mirrored editors republished, terminals excluded via isWebOnlyMirroredTerminalTab) — the asymmetry is real and I'd still fix it, but it is not what produces the row growth.

    Revised fix direction

    Narrower and more tractable than what I proposed:

    1. Persist mirroredFromRuntimeSession in buildEditorSessionData, or re-derive it on hydrate — otherwise restored mirror rows are permanently uncullable by the omission path.
    2. Make the cull sets id-scheme-agnostic — match on (worktreeId, runtimeEnvironmentId, filePath) rather than on file.id, so a hydrate-time id rewrite can't orphan a row.

    Either alone stops the +1/cycle growth; both is the honest fix. My earlier "add an isWebOnlyMirroredEditorFile counterpart" is still worth doing for the ownership asymmetry, but it would not have fixed the reported churn.

    I did not find this correction — an adversarial verifier did, and it refuted my own posted comment. I re-derived it from scratch before posting: the control above is my own test against the real applyWebSessionTabsSnapshot and the real buildEditorSessionData, and the fanout claim is read from source at the cited lines. Scratch tests removed. I have still not run the diagnostic snippet in the issue body.

  6. nwparker commented on Jul 28, 2026

    @nwparker
    Contributor

    Testing my own proposed fix: option 1 works but loses unsaved drafts

    I proposed two fixes above and said "either alone stops the +1/cycle growth." I tested that rather than leaving it as reasoning, and the first option carries a data-loss hazard I should have caught before recommending it.

    Measured

    Feeding a post-restart hydrated row (id already rewritten to the owned form) through the real applyWebSessionTabsSnapshot:

    arm rows after ingest ids
    baseline (today — flag stripped on persist) 2 editor:…:env-B:…a.md + /repo/wt/a.md
    fix 1 (flag persisted) 1 /repo/wt/a.md
    fix 1, row is dirty 1 /repo/wt/a.md, anyDirtyRetained: false

    Baseline reproduces the bug: the stale owned-id row is retained alongside a fresh bare-path row. Fix 1 does stop it — the stale row is culled. But the third arm is the problem.

    Why that third row is a blocker

    Drafts are keyed by file id — editorDrafts[f.id] at workspace-session.ts:119 on persist and editorDrafts[id] = pf.dirtyDraftContent at editor.ts:4516 on hydrate. Culling the owned-id row orphans its draft under the old key, while the surviving bare-path row has no draft at all. The user's unsaved edits disappear with no warning.

    This is precisely the hazard the codebase already guards elsewhere, and I walked past the evidence:

    // editor.ts:276 — Why: omit mirroredFromRuntimeSession so a user-reopened tab
    // isn't treated as host-owned and culled by the next web session sync.

    plus a second deliberate strip at editor.ts:2639 for moved tabs, whose comment says leaving it host-owned would "cull it (losing the draft)". Persisting the flag unconditionally re-arms exactly what those two sites disarm.

    Revised recommendation

    Fix 2 is the safe one, and it should be the primary. Match the cull sets on (worktreeId, runtimeEnvironmentId, filePath) rather than file.id, so a hydrate-time id rewrite can't orphan a row. This reconciles the stale row with the incoming one instead of dropping it, and never has to decide whether a row is disposable.

    If fix 1 is done at all, it needs a draft-migration step: re-key editorDrafts from the old id to the surviving row's id before culling, and skip the cull entirely when isDirty is true. I'd treat that as strictly optional given fix 2 solves the growth on its own.

    Corrected summary: fix 2 alone, not "either alone."

    Three arms above executed against the real applyWebSessionTabsSnapshot; the draft-keying claim is read at the two cited lines. Correcting my own recommendation from the comment above — the diagnosis there is unchanged, only the prescription. Scratch tests removed.

  7. nwparker commented on Jul 28, 2026

    @nwparker
    Contributor

    Correcting again: fix 2 has the same draft hazard. Neither of my proposals is safe as written.

    Three comments ago I said fix 1 loses unsaved drafts and fix 2 is "the safe one." I then did to fix 2 what I should have done before recommending it — implemented it against the real module and ran it. It fails the same way.

    I patched applyWebSessionTabsSnapshot's cull to match on (worktreeId, runtimeEnvironmentId, filePath) in addition to file.id, then measured (file restored to pristine afterward; git diff empty):

    arm result
    A — stale owned-id row rows: 1 ✅ growth stopped
    B — dirty stale row rows: 1, anyDirty: false ❌ draft dropped
    C — 6 ingest+restart cycles [1,1,1,1,1,1] ✅ flat, was [1,2,3,4,5,6]
    D — local file, same path, no env rows: 2, localSurvived: true ✅ correctly untouched

    C and D are the good news: the growth is genuinely fixed, and broadening the match does not over-cull a user's locally-opened file for the same path (the runtimeEnvironmentId === environmentId guard already excludes it). But B is the same silent unsaved-work loss I flagged in fix 1.

    That makes sense in hindsight: both proposals attack the matching, and neither addresses what happens to the matched row. The stale row is culled either way; changing how it's identified doesn't change that it's dropped along with its editorDrafts[oldId] entry.

    What the fix actually needs

    Reconciliation, not culling. Concretely:

    1. Match by path identity — fix 2's (worktreeId, runtimeEnvironmentId, filePath) key. This part is correct and both C and D confirm it's well-behaved.
    2. On match, re-key rather than drop — carry the stale row's editorDrafts[oldId] (and isDirty) onto the incoming row's id before removing the old one. Without this step neither proposal is landable.
    3. Optionally skip the cull entirely while isDirty is true, as a belt-and-braces guard.

    Step 2 is the part I had missing in both write-ups, and it's the part the existing code already cares about — editor.ts:276 and :2639 both strip the mirror flag specifically to avoid culling a draft-bearing tab.

    Standing correction record for this issue

    • Diagnosis (restart-driven, +1 uncullable row per ingest-after-restart, both cull paths missing because hydrate rewrites the id and the mirror flag isn't persisted) — unchanged, executed, still holds.
    • "Cross-machine amplification" — withdrawn.
    • "Either fix alone works" — withdrawn.
    • "Fix 2 is the safe one" — withdrawn here.

    The diagnosis has survived every check; my prescriptions have not. I'd suggest whoever picks this up treats the mechanism as settled and the fix as still open.

    All four arms executed against the real applyWebSessionTabsSnapshot with fix 2 actually implemented, not simulated. The patch was reverted immediately after measuring and the working tree is clean. Correcting my own recommendation for the second time.

  8. nwparker commented on Jul 28, 2026

    @nwparker
    Contributor

    Feasibility note on the draft re-key — and where it has to live

    I recommended "re-key the draft onto the incoming row's id" without checking whether that's implementable at the site I named. Two structural facts, both read from source:

    1. The cull site cannot see the drafts. WebSessionTabsSyncState is a 26-field Pick<AppState, …> (web-session-tabs-sync.ts:135-165) and editorDrafts is not among them — the module has zero references to it. So the re-key cannot be written inside applyWebSessionTabsSnapshot as it stands.

    2. It is reachable one layer up. applyWebSessionTabsStorePatch(buildPatch) (:2625-2634) hands buildPatch the full AppState, and editorDrafts: Record<string, string> lives on AppState (editor.ts:383). Drafts are keyed by file id on both sides of persistence — editorDrafts[f.id] (workspace-session.ts:119) and editorDrafts[id] = pf.dirtyDraftContent (editor.ts:4516).

    So the fix is feasible, but it is not a local edit to the cull predicate. It needs either editorDrafts added to the Pick and the patch return widened, or the re-key performed at the applyWebSessionTabsStorePatch boundary where full state is already in hand. That's a deliberate design choice about where ownership reconciliation belongs, and it should be made by whoever takes the fix — I'm not going to pick it by patching someone else's branch.

    Net state of this issue from my side

    Diagnosis — settled, executed, unchanged across every challenge:

    • Growth is restart-driven and local: +1 uncullable row per ingest-after-restart ([1,2,3,4,5,6,7,8] with restarts vs [1,1,1,1,1,1,1,1] without, one machine, wire never exceeding one tab).
    • Both cull paths miss because hydrate rewrites the id to the owned form (editor.ts:4499-4503) while buildEditorSessionData never persists mirroredFromRuntimeSession (workspace-session.ts:120-135, 7 fields).

    Prescriptions — all withdrawn:

    • "Cross-machine amplification" — refuted by control.
    • "Either fix alone works" — fix 1 drops dirty rows.
    • "Fix 2 is the safe one" — implemented and measured; drops dirty rows identically (rows: 1, anyDirty: false), though it does stop growth ([1,1,1,1,1,1]) and correctly spares local same-path files.
    • "Re-key the draft" — feasible, but not where I said, and the placement is a design decision.

    The mechanism is nailed down and reproducible. The fix is open, and I'd rather hand it over honestly than leave a fourth untested recommendation on the pile.

    Both structural facts read at the cited lines. My earlier fix-2 measurements came from actually implementing it against the real module; that patch was reverted and this worktree is clean (git diff empty).

  9. duneshique commented on Aug 1, 2026

    @duneshique

    Corroborating field case, macOS Orca 1.4.163, paired to a remote Orca instance:

    A worktree (fieldwork-collector) that used to exist on the remote host was deleted/recreated there at some point. The remote's live orca worktree list --environment <id> (and orca repo list --environment <id>) no longer return it at all — confirmed 3 registered repos on the remote side, none matching. But the local instance's sidebar still shows it as an open tab/workspace, and both the GUI delete action and orca worktree rm --worktree id:<old-id> --environment <id> fail with exactly selector_not_found.

    Traced the stale reference to orca-data.json → workspaceSessionsByHostId.runtime:<remote-environment-id>.sleepingAgentSessionsByPaneKey, which still holds the pre-deletion worktreeId. This block is keyed by the environment id (stable, never rotates), unlike local session blocks which are keyed by a rotating per-launch runtimeId — so once a stale reference lands here, it appears to persist indefinitely. I tried editing it out directly in the JSON file with the app fully quit; the edit didn't survive the next app launch (reverted verbatim), which points at an old daemon generation (see #9138) resupplying the stale in-memory copy rather than the file itself being authoritative. Matches the untranslated-runtimeEnvironmentId-across-the-mirror-link mechanism described here pretty closely, just surfacing as a permanently-stuck ghost tab instead of a one-off routing error.

  10. riccodecarvalho commented on Aug 2, 2026

    @riccodecarvalho

    Sanitized field update — macOS / Orca 1.4.164

    We reproduced issue #10859 across three Orca runtimes. Host names, IP addresses, repository/worktree names, file paths, runtime/environment IDs, account details, and terminal contents are intentionally omitted.

    Observed before the workaround:

    • Two reciprocally paired hosts accumulated 1,193 open-file rows for 18 distinct paths / 54 persisted editor references on one host, and 1,369 open-file rows / 32 editor tabs on the other.
    • Both stores reported zero dirty-draft rows.
    • Renderer used heap reached approximately 3.47 GB, and local crash reports recorded renderer SIGTRAP / exit code 5.
    • Closing tabs was not authoritative; restored or peer state reintroduced them.
    • After the first two hosts were cleaned and disconnected from each other, their remaining connection to a third runtime recreated one open-file row and one editor tab on each cleaned host. The third runtime itself had zero editor/open-file rows and no outbound saved environments. This is direct evidence that peer hydration can reintroduce previously cleared editor state.

    Workaround applied:

    • Backed up and hash-verified the state and environment stores before each mutation.
    • Removed every saved reciprocal/one-way runtime environment across the three hosts.
    • With each affected desktop app quiesced, cleared only editor/diff/conflict-review/check-details state from workspaceSession and workspaceSessionsByHostId.
    • Preserved all non-editor unified tabs, terminal layouts, PTY incarnations, and unrelated application state. No dirty drafts were present.

    Validation:

    • All three hosts now report an empty saved-environment list.
    • All three report 0 open-file rows, 0 editor tabs, and 0 dirty-draft rows.
    • The result remained at zero after relaunch and delayed hydration checks.
    • Six live PTYs present during the final isolation step survived with unchanged PTY/incarnation IDs; all remained connected and non-orphaned.
    • No repository data was modified.

    Please confirm:

    1. the first released Orca version containing the fix; and
    2. whether it includes a safe reconciliation/migration path for already-polluted rows without dropping dirty drafts.
  11. beilo commented on Aug 7, 2026

    @beilo

    Corroborating field case on macOS, Orca 1.4.173. This instance shows the same selector_not_found file-load failure and editor tabs that cannot be closed permanently.

    Sanitized persisted-state evidence:

    • A workspace path was first represented by worktree id old-id::<path>.
    • Three editor tabs for the same file were persisted under that old id. The tab group's tabOrder contains exactly 3 ids; openFilesByWorktree[old-id::<path>] contains 4 rows for the same path, all stamped with the same runtimeEnvironmentId.
    • 10.017 seconds after those editor rows were created, the same path was registered as a folder workspace with a new id, new-id::<path>.
    • old-id is now absent from repos and projectHostSetups, but its openFilesByWorktree, unifiedTabs, and tabGroups entries remain in workspaceSession.
    • settings.activeRuntimeEnvironmentId is null.
    • The live workspace uses only new-id::<path>; orca terminal list --json reports the new id.

    Observed result:

    1. The first two stale editor tabs render Unable to load file / selector_not_found.
    2. Closing them is not authoritative; they remain or return.
    3. A local editor tab for the same file is usable.

    The state timeline makes the routing failure deterministic: file reads and mirrored close calls retain old-id::<path>, but runtime selector resolution only knows new-id::<path>, so both files.read and session.tabs.close target an unresolvable selector.

    This also exposes a migration/cleanup gap beyond owner translation: when one filesystem path is re-registered under a new repo/folder id, persisted editor state keyed by the superseded id is neither migrated to the new id nor pruned. Close should still be locally authoritative when the remote selector returns selector_not_found; otherwise the user has no UI recovery path.

  12. chengjiaxiao commented on Oct 7, 2026

    @chengjiaxiao

    Possibly related field report on macOS, Orca 1.4.221.

    Observed:

    • Many non-agent tabs accumulated, including duplicate editor/diff tabs for the same files.
    • While the remote connection was active, affected tabs could not be closed reliably.
    • After disconnecting the remote connection, I could close them normally.
    • I suspect the remote computer was also connected back to this Mac, but the reciprocal connection topology has not been independently verified.

    Read-only inspection of the Mac's persisted workspace state showed:

    • Editor records for local macOS file paths carrying a remote runtimeEnvironmentId.
    • Repeated open-file rows for the same paths.
    • Editor tab IDs for the same paths containing different environment IDs.

    Although the initial symptom looked like new ordinary terminal tabs, the directly verified duplication was in editor/diff tabs. Repeated PTY creation was not established.

    I have not re-enabled the connection to reproduce this under controlled conditions. Disconnecting is a workaround, not a verified fix. This report does not establish bidirectional amplification as the cause.

    Paths, project names, host names, and environment IDs are omitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

os:macosIssues affecting macOS

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions