Skip to content

fix(cmd-j): preserve browser tab host ownership - #17379

Closed
Jinwoo-H wants to merge 1 commit into
mainfrom
aug30-sta5290-cmdj-local-browser-host-routing
Closed

Jinwoo-H wants to merge 1 commit into
mainfrom
aug30-sta5290-cmdj-local-browser-host-routing

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​59 $\color{#cf222e}{\Huge{\mathbf{−}}}$​10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​49

Summary

Fixes STA-5290. Cmd+J browser-page activation now preserves the result's execution-host ownership when paired local and remote runtimes share worktree IDs.

The canonical browser activation boundary now:

  • resolves the host-owned unified browser tab using existing execution-host alias rules
  • validates the backing workspace/page/tab before switching active host state
  • scopes host-qualified tab activation by worktree
  • preserves legacy callers that do not provide host metadata

Root cause

PR #15686 host-qualified palette candidates, but browser activation still resolved unified tabs and browser records by bare IDs. With same-ID local/remote candidates, activation could leave the remote host selected or focus the wrong group.

Validation

  • pnpm test src/renderer/src/lib/browser-page-palette-activation.test.ts src/renderer/src/lib/browser-palette-page-entries.test.ts src/renderer/src/lib/cmd-j-host-qualified-candidate-ownership.test.ts
  • pnpm test src/renderer/src/lib/browser-page-palette-activation.test.ts src/renderer/src/lib/file-preview.test.ts
  • pnpm tc:web
  • pnpm run check:code-quality:changed
  • SKIP_BUILD=1 pnpm exec playwright test tests/e2e/paired-cmd-j-host-qualified-tabs.spec.ts --config tests/playwright.config.ts --project electron-headless --workers=1

The deterministic collision oracle fails when the host-aware resolver is disabled and passes with this change, including remote-to-local repeated activation and visible active-tab assertions.

Notes

No Linear status/comment changes were made in this PR creation step.

@greptile-apps

greptile-apps Bot commented Aug 30, 2026

Copy link
Copy Markdown

Greptile Summary

Cmd+J browser-page activation now resolves the unified browser tab through execution-host ownership before changing active host state.

  • Validates the target worktree, browser workspace, page, and host-owned unified tab before activation.
  • Passes execution-host and worktree scope through browser-tab activation while retaining legacy behavior for callers without host metadata.
  • Adds a regression test for repeated activation between local and paired-runtime tabs sharing a worktree and workspace identity.

Confidence Score: 5/5

The PR appears safe to merge, with the changed activation path preserving host ownership and failing before partial host switching when the backing tab is unavailable.

The resolver uses the repository’s existing execution-host alias and ambiguous-worktree ownership rules, validates the target before host activation, and the final scoped tab activation produces the expected visible group and browser state.

Important Files Changed

Filename Overview
src/renderer/src/lib/browser-page-palette-activation.ts Adds worktree-qualified record validation and resolves the host-owned unified tab before switching active host state.
src/renderer/src/lib/browser-workspace-tab-activation.ts Introduces execution-host-aware browser-tab resolution and scopes host-qualified tab activation to the target worktree.
src/renderer/src/lib/browser-page-palette-activation.test.ts Covers local-to-remote and remote-to-local activation when paired hosts share worktree and browser workspace identities.

Sequence Diagram

sequenceDiagram
    participant P as Cmd+J palette
    participant A as Browser page activation
    participant R as Host-aware tab resolver
    participant S as Renderer store
    P->>A: Activate page target with executionHostId
    A->>S: Validate worktree, workspace, and page
    A->>R: Resolve host-owned unified browser tab
    R->>S: Apply worktree host-alias ownership rules
    R-->>A: Matching tab or null
    alt Matching tab exists
        A->>S: Reveal owning worktree and host
        A->>S: Activate browser page and scoped tab
        A-->>P: activated
    else Missing or stale ownership
        A-->>P: failed without switching host
    end
Loading

Reviews (1): Last reviewed commit: "fix(cmd-j): preserve browser tab host ow..." | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2e0c3ff2-f173-4ea4-adf8-b54560ec3d66

📥 Commits

Reviewing files that changed from the base of the PR and between 58a52a8 and 4883701.

📒 Files selected for processing (3)
  • src/renderer/src/lib/browser-page-palette-activation.test.ts
  • src/renderer/src/lib/browser-page-palette-activation.ts
  • src/renderer/src/lib/browser-workspace-tab-activation.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

Browser page palette activation now validates the page and workspace against the requested worktree. It resolves unified browser tabs by execution host and returns missing-tab when no matching tab exists. Browser tab activation uses the resolved worktree when an execution host is provided. Tests cover activation between local and remote tabs that share a workspace.

Merge Risk: ⚪ Minimal · up to 48837

This localized change preserves execution-host ownership during browser-tab activation and prevents incorrect tab or host selection for paired runtimes. No actionable merge-blocking risk remains beyond normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the change, root cause, linked issue, validation, and scope. However, it omits most required template sections, including ELI5, What Changed, Why, Visual Proof or an explicit … Rewrite the description using the repository template. Add each required section, provide visual proof or state N/A with a reason, record manual and automated testing details, complete the required checkboxes, and retain the existing root c…
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 3 files. 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 identifies the main change: preserving browser tab host ownership for Cmd+J activation.
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 explains the change, root cause, linked issue, validation, and scope. However, it omits most required template sections, including ELI5, What Changed, Why, Visual Proof or an explicit N/A reason, Testing checklist details, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist.

Resolution

Rewrite the description using the repository template. Add each required section, provide visual proof or state N/A with a reason, record manual and automated testing details, complete the required checkboxes, and retain the existing root cause and validation information.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@pullfrog pullfrog 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.

ℹ️ Minor suggestion only — the fix is correct, well-scoped, and its regression test is a real oracle.

Reviewed changes

  • browser-workspace-tab-activation.ts — new host-aware resolveBrowserWorkspaceUnifiedTab and executionHostId threading through activateBrowserWorkspaceTab, including a load-bearing reorder of the activation sequence.
  • browser-page-palette-activation.ts — page/workspace lookups now also scope by worktreeId; unified-tab ownership is validated before worktree activation, and executionHostId is threaded through.
  • browser-page-palette-activation.test.ts — a host-collision regression test asserting the correct group and host win for local vs paired-runtime activation.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

if (params.pageId) {
state.setActiveBrowserPage(params.workspaceId, params.pageId)
}
state.focusGroup(params.worktreeId, unifiedTab.groupId)

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.

This reorder is load-bearing: setActiveBrowserTab internally calls activateTab on the first browser tab matching the workspace id (browser.ts setActiveBrowserTab), unscoped to any host. In a host collision that would focus the wrong group; running the host-scoped activateTab last is what corrects it. A short Why: comment would stop a future cleanup from reordering it back.

Suggested change
state.focusGroup(params.worktreeId, unifiedTab.groupId)
// Why: setActiveBrowserTab re-activates the first workspace-matching tab unscoped
// (browser.ts setActiveBrowserTab), so this host-scoped activation must run last.
state.focusGroup(params.worktreeId, unifiedTab.groupId)

@pullfrog

pullfrog Bot commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Run failed. View the logs →

Pullfrog  | Rerun failed job ➔ | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@nwparker

nwparker commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Superseded by #19005, which shipped host-scoped tab validation before Cmd+J browser activation. Closing.

@nwparker nwparker closed this Nov 1, 2026
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