Repository navigation
fix(runtime): collapse mirrored Markdown aliases with shared backing identity - #31984
Conversation
…by environment A snapshot that already lists one file under several per-environment host tab ids (editor:<worktree>:<env>:<path> or the bare path) fanned out into one mirrored tab per variant. Keep one minted variant per (worktree, mode, path) when building mirrored editor tabs; tabs with opaque ids (deliberate splits) are untouched. Protects receivers from older peers that still republish mirrored files and from snapshots that are already polluted.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
17699c53-b360-41e7-a8b3-87cacd348dfb
📒 Files selected for processing: 2
src/renderer/src/runtime/web-session-tabs-sync-editor-tabs.test.tssrc/renderer/src/runtime/web-session-tabs-sync/tab-builders.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
…rget when collapsing variants Host tab ids come from buildOwnedEditorFileId, which URL-encodes the worktree, environment and path, so the raw-path predicate never matched a real variant. Each candidate is now checked by rebuilding it with buildOwnedEditorFileId, and the tab a pending focus/follow intent targets wins its bucket ahead of an active one. Tests build their ids the same way.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Source mode: Auto
- Repository: Unavailable
- Branch: Unavailable
- File: No configuration file from this repository applied
- Commit: Unavailable
- Layers: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
57e07497-cd4c-4564-b0ac-28652afed05b
📒 Files selected for processing: 3
src/renderer/src/runtime/web-session-tabs-sync-editor-tabs.test.tssrc/renderer/src/runtime/web-session-tabs-sync/apply-preparation-browser.tssrc/renderer/src/runtime/web-session-tabs-sync/tab-builders.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
| if (!current || tabRank > current.rank) { | ||
| winnerByBucket.set(bucket, { segment, rank: tabRank }) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
-
🏁 Script executed:
set -u rg -n -F -e 'buildMirroredEditorTabs' -e 'dedupeReadyEditorTabsByFile' -e 'createMirroredEditorFileResolver' -e 'buildOwnedEditorFileId' -e 'preferredHostTabId' -- src/renderer/src/runtime || test "$?" -eq 1 echo '--- tab-builders.ts outline' ast-grep outline src/renderer/src/runtime/web-session-tabs-sync/tab-builders.ts --view expanded || true echo '--- tab-builders.ts lines 1-260' sed -n '1,260p' src/renderer/src/runtime/web-session-tabs-sync/tab-builders.ts echo '--- mirrored-editor-file-identity.ts' ls -l src/renderer/src/runtime/web-session-tabs-sync/mirrored-editor-file-identity.ts || true sed -n '1,220p' src/renderer/src/runtime/web-session-tabs-sync/mirrored-editor-file-identity.ts || true
Repository: stablyai/orca
Length of output: 18781
🏁 Script executed:
set -u rg -n -F -e 'runtimeOwnerKey' -e 'buildOwnedEditorFileId' -- src/renderer/src/store/slices/editor/file-ids/ || test "$?" -eq 1 echo '--- editor-file-ids.ts' sed -n '1,120p' src/renderer/src/store/slices/editor/file-ids/editor-file-ids.ts
Repository: stablyai/orca
Length of output: 7254
Keep the retained file identity when an owned-ID variant wins deduplication.
When a retained bare-path tab and an active owned-ID variant share a file, deduplication keeps the owned-ID tab and drops the bare-path tab before the file resolver runs. The resolver then cannot match the retained null-owner file. It assigns the owned-ID file identity to the mirror, so the retained file and its draft remain as a separate tab for the same file.
This applies only when a snapshot contains both variants, the owned-ID variant ranks higher, and the retained file has no environment owner. The fix must carry the retained file identity to the winning host tab ID. Deduplication should not discard the retained bare-path identity before the resolver sees it.
…epublishes mirrors Main's stablyai#31984 fixture published a mirrored row, which this branch no longer republishes.
ELI5
A paired desktop can receive several environment-specific tabs for the same Markdown file. The receiving desktop now collapses aliases that prove they share one backing file, so an ordinary session update does not keep recreating duplicate tabs.
Related to #31544, #23967, #21121, and #25877. This addresses inbound alias duplication; it does not claim to resolve every restore or untitled-editor case in #31544.
What changed
Only canonical host-minted Markdown aliases with the same worktree, path, mode, and non-path
sourceFileIdcollapse. Opaque split IDs, distinct backing owners, legacy non-Markdown tabs, malformed IDs, and path-only headless source identities remain visible.Explicit navigation wins, followed by the client's visible tab, then the host-active alias. The existing file resolver sees every alias before filtering, preserving retained file and dirty-draft ownership even when a different alias wins.
The original contribution and commit by Dave Choi (@DaveDev42) are preserved. Follow-up work strengthens the identity boundary, focus and draft handling, and production-path regressions. There is no snapshot-schema or RPC change; the operation remains linear in the number of editor tabs.
Verification
92dfb4fda69eusing the actual desktopbuildMobileSessionTabSnapshotspublisher and the actual mirror: five aliases of one backing file produced five tabs instead of one.51730f5a9ad9, covering reconciliation, editor ownership, actual desktop/headless publication, navigation, groups, terminals, browser authority, and window visibility.git diff --checkpasses.tests/e2e/*.unit.test.tsarea after CI identified a renderer/main TypeScript project boundary. Production and assertions are unchanged; the full 348-test reconciliation run and committed 23-test producer regressions pass again, including a repeat after independent follow-up review. Fresh CI passes the complete static-analysis/typecheck job, including formatting, changed-code quality, and standalone React Doctor; all final-head workflows are now green, including all five Node unit shards, Linux and Windows packaging, changed E2E specs, managed SSH Docker coverage, and both selected layout-oracle jobs. Headless and Test LoC workflows also pass. Full renderer typechecking, the complete repository suite, native desktop UI, and physical mobile hardware were not run locally.Merge risk
Low, with a conservative identity boundary. The filter runs only on inbound mirrored editor tabs and requires both a canonical alias ID and a shared non-path backing ID. Path-only or unknown identities retain their existing behavior. Source paths remain opaque strings, with POSIX, Windows, UNC, and folder-workspace cases covered by the actual ID builder and reconciler. Mixed-version peers require no protocol update.
Visual proof
N/A: no layout change. The actual publisher-to-mirror regression demonstrates the visible duplicate-tab behavior. No native UI validation is claimed.
AI disclosure
The original author used Claude Code. AI coding agents helped reproduce, review, and strengthen the final fix and verification.
Agent skill upstream boundary