Skip to content

A CLI or phone file on a layout-owner server opens in the tab group a paired desktop shows (switch-on builds only) - #31264

Merged
Jinwoo-H merged 9 commits into
mainfrom
fd/h5c-v-view-facts
Oct 20, 2026
Merged

Jinwoo-H merged 9 commits into
mainfrom
fd/h5c-v-view-facts

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​796 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​794
Prod 9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​265 $\color{#cf222e}{\Huge{\mathbf{−}}}$​13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​252

ELI5

When you open a file from the command line or a phone on an Orca server, the server opens it in "the tab group you're looking at". A paired desktop never told the server which group it was looking at, so the file landed in whatever group was saved last. Now the desktop tells the server, and the file lands where you're looking. This only happens in the internal test build with the new layout model turned on, against a server that supports it. Nothing changes in any build we ship.

What Changed

  • Before (switch-on builds): on a server with no window, a CLI or phone file open used the saved view's group, even while a paired desktop was showing a different group of that workspace.
  • After: the desktop reports the group it shows for each server workspace it draws, and the file opens there.

Mechanism:

  • Server (src/main/runtime/view-facts/active-group-view-facts.ts): the group each workspace shows is now kept per source, meaning the server's own window plus each paired client connection. The newest report wins, else the saved view. When a client connection closes, its reports are dropped. The window's reports behave as before.
  • Wire: a new method, layout.reportView { activeGroupByWorkspace, refresh?: true }.
    • It is served to paired desktops only; phones are refused.
    • It is registered only where the other layout-owner methods are, so a server that does not advertise layout.intents.v1 never has it.
    • A desktop sends it only to servers that advertise that capability.
  • Desktop (src/renderer/src/runtime/server-layout-view-report.ts, wired into server-layout-frames.ts): for each workspace a server's layout frames draw, the desktop reports the active group when it changes. After each stream snapshot it sends everything again with refresh: true, because a reopened stream can mean a new connection.
  • refresh: a re-sent report ranks below every live report. A desktop that just reconnected never takes "the group you're looking at" away from another desktop the user is actively using, but it still replaces its own earlier report and beats the saved view.

Why

  • One server, several desktops: facts are kept per connection and the newest live one wins. Sharing them across connections would let a closed or idle desktop decide where files open.
  • Why refresh is separate: without it, a reconnect would count as the user's latest action and override a desktop that is actually in use.
  • Mixed versions: the method is new, so it is gated by the capability in both directions. An old desktop never sends it; a new desktop never sends it to an old server.

Frame-applied changes: a group change that comes from applying the server's own frames (a snapshot, or the server closing the shown group) is sent as refresh, never as a live report, so a desktop never echoes the server's state back as a user choice.

Unsupported servers: after a server's first "method not found" for layout.reportView (a switch-on build from before this PR), the desktop stops reporting to it for that stream's lifetime and logs once.

Reconnects: the desktop sends its reports again, with refresh, after every layout-stream snapshot and whenever the shared-control connection to that server becomes ready on a new socket. That uses the existing shared-control diagnostics event, not a timer.

By design: a desktop that only looks at a workspace, without switching groups, does not outrank an older report from the server's own window. It takes over on the user's next real switch.

Linked Issue

Part of the terminal-layout final design (H5c-v, paired desktop to a server). No separate issue.

Visual Proof

N/A: no change in any shipped build. The path exists only in a build with the layout-owner switch on, against a server that advertises the capability.

Testing

  • Server unit:

    • The newest report wins across two connections and the window.
    • A closed connection falls back to the other desktop, else the saved view.
    • The window's report survives a closed connection.
    • refresh: desktop A changes its group, then desktop B re-sends with refresh, and A still wins; without the flag B wins. These tests fail with the flag ignored.
    • A refresh replaces its own connection's earlier entry.
  • Wire: a phone is refused and a desktop is admitted. Bad params are rejected, including refresh: false. A call with no connection is refused. A switch-off build does not register the method.

  • Desktop: it reports frame-drawn workspaces only, and sends again only on a change. A failed send is not retried. A new snapshot re-sends with refresh, and so does a control-connection reconnect while the stream stays up. Nothing goes to an old server.

  • E2E (switch-on desktop and switch-on orca serve): tests/e2e/paired-desktop-server-file-open-group.spec.ts. The desktop switches between groups B, A and B, and a server-side file open lands in each. It is on the switch-on leg. With desktop reporting disabled, the spec fails at its first step.

  • Gates:

    • Static gate: all steps passed.
    • pnpm tc: clean.
    • e2e typecheck ratchet: OK.
    • Switch-on comparison of main runtime and persistence: no file passes at base and fails at head.
  • I manually tested these changes locally

  • Automated tests added/updated, or explained why not below

AI Disclosure

Written with AI coding agents; reviewed by an independent AI review pass.

Review

An independent review, then delta reviews after each fix round. The findings fixed were: a desktop's own resend lowering its own rank; frame-applied group changes counting as live; an explicit live/refresh rank; and the stop after a method-not-found.

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

  • SSH and folder workspaces: routing only changes for workspaces a capable paired server draws; folder workspaces on that server are covered the same way.
  • Mobile: unchanged; phones cannot call the method.
  • Ledger: L242 (the control-reconnect gap) is opened and closed by this PR.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…s in the group a paired desktop shows

Each paired desktop reports, through a new layout.reportView (served only by layout.intents.v1
servers, never to phones), the group it shows in each workspace the server's frames draw. The
server keeps reports per connection beside the window's, opens files in the latest one's group,
and drops a connection's reports when it closes, falling back to the saved view.
…outranks another desktop's live report

layout.reportView takes an optional refresh flag. The desktop's first report of each workspace
after a stream snapshot carries it; the server ranks such entries below every live report, while
they still replace the connection's own earlier entries and beat the saved view.
… when its control connection to the server comes up on a new socket

The server drops a connection's view reports when it closes, and the layout stream can stay up
across that, so the desktop watches the shared control diagnostics for a new socket.
…reporting to a server without layout.reportView

A same-connection resubscribe re-sends its view as a refresh, which demoted the connection's
own live report below an older desktop's. Ranks are now an explicit live/refresh tier. A pre-PR
switch-on server answers method_not_found; the desktop then stops sending for that stream.
… a refresh, never a live report

The snapshot resend read the store before the sync applied the snapshot, so the flush's group
change reached the store subscription as the user's. Writes made by the frame sync now report as
refreshes, and the snapshot resend runs after the flush.
…; the frame-write mark survives nested writes
@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

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: 6b493feb-dcaa-4dd0-8b2c-e2b3215b33a6
📥 Commits

Reviewing files that changed from the base of the PR and between ef95040 and 0f95f48.

⛔ Files ignored due to path filters: 1
  • src/shared/rpc-contract/rpc-params-catalog.generated.ts is excluded by !**/*.generated.*
📒 Files selected for processing: 13
  • .github/workflows/layout-owner-e2e.yml
  • src/main/runtime/editor-open-active-group.test.ts
  • src/main/runtime/rpc/methods/index.ts
  • src/main/runtime/rpc/methods/workspace-layout-paired-desktop.test.ts
  • src/main/runtime/rpc/methods/workspace-layout.ts
  • src/main/runtime/session-graph/session-graph-promotion.ts
  • src/main/runtime/view-facts/active-group-view-facts.test.ts
  • src/main/runtime/view-facts/active-group-view-facts.ts
  • src/renderer/src/runtime/server-layout-frames.ts
  • src/renderer/src/runtime/server-layout-view-report.test.ts
  • src/renderer/src/runtime/server-layout-view-report.ts
  • src/shared/rpc-contract/workspace-layout-params.ts
  • tests/e2e/paired-desktop-server-file-open-group.spec.ts

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

📝 Walkthrough

The runtime now accepts active-group reports from paired desktop connections and ranks them alongside window reports. The renderer reports active groups shown in server layout frames, including refresh reports after snapshots or control reconnections. Added tests cover report validation, report precedence, connection cleanup, renderer reporting, and end-to-end file placement in the selected server group.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 0f95f

This change adds paired-desktop active-group reporting behind a layout-owner gate, with no shipped build changes reported. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Description check Warning The description is detailed and covers the user impact, mechanism, rationale, testing, compatibility, and checklist items. However, the required Linked Issue section does not contain an actual issue r… Add a valid linked issue reference in the Linked Issue section, such as “Fixes #31264” or the applicable existing issue. Keep the current explanation only if repository policy permits linking a parent or design issue instead of a dedicated …
Docstring Coverage Warning Docstring coverage is 29.41% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 12 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly describes the primary change: routing CLI or phone file opens to the tab group shown by a paired desktop on layout-owner servers. It is somewhat long but specific and relevant.
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 user impact, mechanism, rationale, testing, compatibility, and checklist items. However, the required Linked Issue section does not contain an actual issue reference; it states that no separate issue exists and leaves “Fixes #” blank.

Resolution

Add a valid linked issue reference in the Linked Issue section, such as “Fixes #31264” or the applicable existing issue. Keep the current explanation only if repository policy permits linking a parent or design issue instead of a dedicated issue for this change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 29.41% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 17 functions across 12 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

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

@Jinwoo-H
Jinwoo-H merged commit a931098 into main Oct 20, 2026
52 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.

1 participant