Skip to content

fix(runtime): collapse mirrored Markdown aliases with shared backing identity - #31984

Merged
nwparker merged 5 commits into
stablyai:mainfrom
DaveDev42:fix/mirrored-editor-tab-inbound-dedup
Oct 24, 2026
Merged

nwparker merged 5 commits into
stablyai:mainfrom
DaveDev42:fix/mirrored-editor-tab-inbound-dedup

Conversation

@DaveDev42

@DaveDev42 DaveDev42 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

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 sourceFileId collapse. 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

  • Reproduced on main baseline 92dfb4fda69e using the actual desktop buildMobileSessionTabSnapshots publisher and the actual mirror: five aliases of one backing file produced five tabs instead of one.
  • Reproduced and corrected original-fix hazards involving unsolicited focus replacement, retained dirty-file identity, distinct source owners, and path-only identities from the actual headless producer.
  • 348 tests pass across 45 suites on committed head 51730f5a9ad9, covering reconciliation, editor ownership, actual desktop/headless publication, navigation, groups, terminals, browser authority, and window visibility.
  • The exact four changed files pass formatting and the changed-code quality gate with zero new findings. git diff --check passes.
  • Independent adversarial review pinned to that head found no remaining blockers; low merge risk.
  • The follow-up moves the actual headless-producer regression to the existing cross-process tests/e2e/*.unit.test.ts area 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

  • Not applicable: no upstream skill-installer code or resources copied.

…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.
@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent 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: f4bc8c9a-ebe8-40d9-b4ad-bb09d28e73df
📥 Commits

Reviewing files that changed from the base of the PR and between 347f916 and 51730f5.

📒 Files selected for processing: 4
  • src/renderer/src/runtime/web-session-tabs-sync-editor-tabs.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/apply-preparation-browser.ts
  • src/renderer/src/runtime/web-session-tabs-sync/tab-builders.ts
  • tests/e2e/headless-editor-mirror-identities.unit.test.ts

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

The tab builder now deduplicates valid environment-minted editor tabs by worktree, mode, file path, and source identity before mirroring them. It prefers the specified host tab, then an active tab, then the first encountered tab. Browser preparation supplies the navigation-intent tab ID when available, or the visible tab ID otherwise. Added tests cover selection, identity preservation, path aliases, and IDs or views that remain distinct.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 51730

The reviewed tab-selection and draft-preservation paths retain the intended tab and file identity. No actionable merge blocker remains after normal checks.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 14.29% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description explains the user impact, implementation, rationale, testing, visual proof, AI use, and merge risk. It does not follow the required template completely: the Why, Linked Issue, Testing,… Add the required template sections and headings. Include an explicit linked issue using Fixes #, complete the Why section with alternatives considered, restore the Testing and Checklist items, and add Review and Notes content …
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title accurately names the main change: mirrored Markdown editor-tab aliases that share a backing identity are collapsed. The raw summary confirms the change in buildMirroredEditorTabs, apply-prep…
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: Title check

Explanation

The title accurately names the main change: mirrored Markdown editor-tab aliases that share a backing identity are collapsed. The raw summary confirms the change in buildMirroredEditorTabs, apply-preparation-browser, and the related tests. The title is concise, specific, and follows the conventional-commit style. The PR objectives describe the same change.

Full details: Description check

Explanation

The description explains the user impact, implementation, rationale, testing, visual proof, AI use, and merge risk. It does not follow the required template completely: the Why, Linked Issue, Testing, Review, Notes, and Checklist sections are missing or renamed. It also uses related issue references instead of an explicit issue link in the required Fixes # format.

Resolution

Add the required template sections and headings. Include an explicit linked issue using Fixes #<issue-number>, complete the Why section with alternatives considered, restore the Testing and Checklist items, and add Review and Notes content or state that each item is not applicable.

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

@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: 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
📥 Commits

Reviewing files that changed from the base of the PR and between 48660ae and 421cca6.

📒 Files selected for processing: 2
  • src/renderer/src/runtime/web-session-tabs-sync-editor-tabs.test.ts
  • src/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.

@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
  • 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
📥 Commits

Reviewing files that changed from the base of the PR and between 421cca6 and 347f916.

📒 Files selected for processing: 3
  • src/renderer/src/runtime/web-session-tabs-sync-editor-tabs.test.ts
  • src/renderer/src/runtime/web-session-tabs-sync/apply-preparation-browser.ts
  • src/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.

Comment on lines +152 to +153
if (!current || tabRank > current.rank) {
winnerByBucket.set(bucket, { segment, rank: tabRank })

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.

🗄️ 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.

@nwparker nwparker changed the title fix(runtime): collapse mirrored editor tab variants that differ only by environment fix(runtime): collapse mirrored Markdown aliases with shared backing identity Oct 23, 2026
@nwparker
nwparker merged commit 60c58ea into stablyai:main Oct 24, 2026
45 checks passed
nwparker added a commit to BearMett/orca that referenced this pull request Oct 24, 2026
…epublishes mirrors

Main's stablyai#31984 fixture published a mirrored row, which this branch no longer republishes.
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