Skip to content

perf: avoid building launch routes for preference reads - #41803

Merged
AmethystLiang merged 1 commit into
mainfrom
nwparker/perf-agent-preferences-owner
Nov 13, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
nwparker/perf-agent-preferences-owner

Conversation

@nwparker

@nwparker nwparker commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

ELI5

Reading agent launch preferences now resolves only which host owns those preferences, instead of building and discarding a complete launch route.

Files Added Deleted Net
Test 0 0 0 0
Prod 2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​11 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​5

What Changed

Extract the existing owner/execution-host resolution into resolveAgentLaunchOwner. Both the full launch host resolver and launch preference reader reuse it. Actual launch routes retain their capability and routing construction.

Why

The terminal keyboard owner reaches this reader through handleTerminalWorkspaceKeyDown → resolveTerminalAgentTabShortcut → readAgentTabShortcutActions, including nonrepeat keys that do not match a shortcut. UI and async preference readers also reach it. Previously each read constructed project/transcript/capability/catalog fields solely to use executionHostId.

Introduced by f4a1b05 (#31971). Exact-source controls at installed e58bf50 and base ddf4aa8 show 100/1,000 reads build 100/1,000 full routes and read a staged four-agent catalog 400/4,000 times. Afterward those discarded operations are zero; required owner resolutions are unchanged. These are staged seam counts, not the live catalog population or a latency measurement. This does not establish the cause of observed input stalls.

Linked Issue

Performance investigation; no separate issue.

Visual Proof

N/A — no visual or interaction behavior changes.

Testing

  • Existing route-input and host-preference source tests: 2 files, 11 tests pass.
  • External exact-source controls at installed/base/after: 100 and 1,000 reads over local, paired runtime, SSH and ambiguous ownership.
  • External hardcoded correctness controls: 12 cases / 96 assertions on both base and after, including local/WSL/folder/floating, paired/SSH, prospective hosts and execution contexts.
  • Final pnpm check:changed: 28/29 checks pass (including typecheck, lint, formatting and ratchets). Broad related-unit selection was stopped after 365 seconds to bound host load; its captured output includes localhost:3000 ECONNREFUSED errors. The broad suite did not complete; no full-suite pass is claimed.
  • macOS validation only. Staged host cases do not establish native Windows/Linux or live SSH performance. No app restart, input injection, transport change or new repository tests.

Risk

Level: Low. Host ownership is the sensitive boundary: an incorrect extraction could read another host’s preferences. The owner and fallback expression are unchanged and shared with actual launch routing; the parity controls cover their precedence. No persistence or protocol changes. Plain revert restores previous behavior.

Agent skill upstream boundary

  • Not applicable; no upstream skill source copied.

Checklist

  • Small and focused; self-reviewed for correctness and performance.
  • Cross-platform, folder, SSH/remote and mobile ownership considered.
  • No presentation changes; visual proof N/A.
  • Full build and native platform checks left to CI/review.

@AmethystLiang
AmethystLiang marked this pull request as ready for review November 13, 2026 05:40
@coderabbitai

coderabbitai Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

A new resolveAgentLaunchOwner helper resolves the structured-session owner for worktree launches and returns it with the selected execution host ID. resolveAgentLaunchHost now uses the helper and retains its existing return behavior. Workspace preference selection also uses the helper to determine the execution host.

Merge Risk: Minimal · up to 791c4

This change avoids building launch routes when only the owning host is needed for preference reads. No behavioral regression was identified, so it looks safe to merge after normal checks.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "perf: avoid building launch routes for preference reads" matches the main change: owner/execution-host resolution is extracted into resolveAgentLaunchOwner, and the preference reader no lon…
Description check Passed The description follows the template. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing, Risk (Low, with rollback stated), AI Disclosure section, and checklist.…
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 "perf: avoid building launch routes for preference reads" matches the main change: owner/execution-host resolution is extracted into resolveAgentLaunchOwner, and the preference reader no longer builds a full launch route it discards. It uses a conventional prefix and stays concise.

Full details: Description check

Explanation

The description follows the template. It has the ELI5, What Changed, Why, Linked Issue, Visual Proof (N/A with reason), Testing, Risk (Low, with rollback stated), AI Disclosure section, and checklist. The Linked Issue section says 'Performance investigation; no separate issue' and does not contain an issue reference such as 'Fixes #'. The template requires an actual linked issue for outside contributors, so that section is incomplete. The Testing checkboxes for manual testing and automated tests are unchecked, and the Review and Agent skill sections are only partly addressed. Most sections are complete, so the check passes, but the missing issue link should be resolved.

Resolution

Consider adding an actual linked issue (or confirming the maintainer exemption) in the Linked Issue section. Also clarify the unchecked Testing items, since the author states no new repository tests were added.

  • 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

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: 5d83e416-1d9b-4262-b478-a70bf55b6f4f
Commits

Reviewing files that changed from the base of the PR and between cc29ae4 and 791c483.

Files selected for processing: 2

  • src/renderer/src/lib/agent-session/launch/routing/agent-launch-route-input.ts
  • src/renderer/src/runtime/agent-launch-settings/use-host-agent-launch-preferences.ts

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

@AmethystLiang
AmethystLiang merged commit 7582371 into main Nov 13, 2026
98 of 100 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.

2 participants