Skip to content

Use the shared default agent selection for work-item launches - #35748

Merged
brennanb2025 merged 8 commits into
mainfrom
brennanb2025/sta-12494-workitem-agent
Oct 29, 2026
Merged

brennanb2025 merged 8 commits into
mainfrom
brennanb2025/sta-12494-workitem-agent

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 5 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​578 $\color{#cf222e}{\Huge{\mathbf{−}}}$​264 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​314
Prod 8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​355 $\color{#cf222e}{\Huge{\mathbf{−}}}$​67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​288

Launching a work item could open Claude even when Codex was preferred and its chat was usable. Preflight considered detected CLIs only, then passed its inferred fallback as an explicit choice. Paired-host launches could also use desktop preferences where a new agent tab used the workspace host's preferences.

Direct work-item launches now share the workspace default resolver and owner-preference reader used by new agent tabs. A usable preferred chat stays ahead of a detected fallback, and only an explicit user choice becomes an override. Final selection reads the actual created workspace's inventory. If the selected agent changes, its replacement plan and startup use the same current settings snapshot.

The launch path also skips workspace-root lookup when no custom working directory is requested. The real default-launch/acquisition contract at 100 and 1,000 worktrees checks zero unnecessary root calls/row visits, bounded offered-agent route evaluations, the selected plan and released subscriptions. This does not claim the whole launch is constant time.

Tracked in STA-12494; the original regression came from #30449. Routing/test overlap with #34657 preserves its separate detection-failure behavior. The narrow menu performance assertion is coordinated with #34728; picker UI is unchanged.

Review path: full, because this changes default-agent selection and host-derived inputs to a user action. No saved field, wire operation, server minimum, process lifecycle implementation or visual layout changes.

The common pattern derives selection from the destination's settings and available providers while preserving explicit intent. Intended adapters: Orca supports CLI or native chat across local, SSH and paired hosts, including independently updated clients and servers. The shared synchronous reader keeps the existing desktop fallback when current host preferences are absent or unsupported; supplied preference snapshots remain authoritative. Final inferred defaults are reread after acquisition, while matching-agent preflight adoption retains its existing contract. Blank workspace creation still opens no agent; an explicit new-agent-tab action may auto-pick.

Onboarding replays its configured enabled agent; dashboard offers a list including running agents; composer selection preserves touched/draft input; empty-workspace seeding may retain a shell. These distinct contracts are intentionally unchanged. No temporary reference deviation remains.

Validation: CI passed on 5e6f22e48a889bf3bb9cb7898744b43c11408cca (run 40866623677): all ten unit shards, Linux and Windows packaging, and required checks. The changed-code casting gate executed with zero new findings. Both compiler guards were true and all four normal compiler programs, including web/composite checking, actually executed and passed; no TS2883 or replacement error remained. Retained explicit results for all twelve required suites include defaults (13 cases), menu (8 cases), delayed availability, and the 100/1,000-workspace contract. The final supplemental commit changes only the fixture casting comment; its types and runtime expressions are unchanged. Changed flows are renderer selection/route construction and performance under the review skill's tests row. There is no appearance change requiring a screenshot and no lifecycle/process/login implementation requiring application or live-agent QA. No live-agent pass is claimed. Commits were made normally without bypass flags; this dependency-free worktree lacks the generated Husky launcher, so no pre-commit-hook pass is claimed. CI is the lint/compiler gate.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 29, 2026 06:56
@greptile-apps

greptile-apps Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The change since the previous review appears safe to merge.

Summary

Work-item launches now share workspace default-agent selection and host preferences with new agent tabs.

  • Work-item launches follow the destination host’s current agent choice.
  • Default launches skip workspace-root lookups when no custom directory is set.

Since the previous review, only a targeted lint suppression was added to the shared test fixture. No new actionable issue or mounted-rule violation was found.

Reviews (6) · Last reviewed commit: "test: document partial launch store asse..." · Reviewed by Greptile

@greptile-apps

greptile-apps Bot commented Oct 29, 2026

Copy link
Copy Markdown

Comments Outside Diff

These findings could not be posted inline.

  • P1 Preferred chat opens a terminal src/renderer/src/lib/launch-work-item-direct-route-preparation.ts:163 ▶

    If the default changes from Claude to a detected, host-registered agent such as pi during workspace creation, this branch builds the replacement plan without waiting for the host's agent list. Claude's preflight does not need that list, and resolveDirectWorkItemAgent skips discovery because the new agent's CLI is detected. If the list has not loaded yet, the plan chooses terminal-tui even though the host supports chat for pi. The background refresh does not repair this launch.

    Await awaitStructuredRouteHostAnswer for the replacement request before building its plan.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
Walkthrough

Direct launch and new-tab agent selection now share workspace-aware default resolution and host-preference reading. Launch preparation uses the selected agent’s store for launch state and accepts a preflight plan only when its agent matches the effective agent. Route-input construction skips the workspace-root check when no custom working directory is supplied. Tests cover preference updates, agent selection, launch behavior, and bounded route-input construction.

Priority: Normal

Merge Risk: Low · up to 57bae

The implementation is supported, but a focused regression test is needed to prevent the new-tab preference behavior from silently regressing.

Pre-merge checks: Passed 3 · Failed 2

Failed Failed checks: 2 warnings

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check Warning The description explains the problem, implementation, scope, compatibility considerations, and validation in detail. However, it does not follow the required template structure. It lacks an actual lin… Update the description to use the required template headings and checklist. Add the actual issue link in the Fixes #... field, or document the applicable maintainer exception. Add N/A with a brief reason for visual proof. Complete the T…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly identifies the main change: direct work-item launches now use the shared default agent selection.
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: Docstring Coverage

Explanation

Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 8 functions across 13 files.

Resolution

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

Full details: Description check

Explanation

The description explains the problem, implementation, scope, compatibility considerations, and validation in detail. However, it does not follow the required template structure. It lacks an actual linked issue in the required Fixes # format, explicit N/A visual proof, the Testing and Agent skill upstream boundary checkboxes, and the required checklist. The validation statements also conflict with the PR objectives, which state that CI and review validation were pending, while the description states that CI passed.

Resolution

Update the description to use the required template headings and checklist. Add the actual issue link in the Fixes #... field, or document the applicable maintainer exception. Add N/A with a brief reason for visual proof. Complete the Testing, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist sections. Reconcile the conflicting CI and validation status statements.

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.

@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: f899b944-660f-4c85-be67-3e53da01012a
Commits

Reviewing files that changed from the base of the PR and between 4049bc7 and 507d5b4.

Files selected for processing: 6
  • src/renderer/src/lib/agent-tab-shortcuts.ts
  • src/renderer/src/lib/launch-work-item-direct-agent-routing.ts
  • src/renderer/src/lib/launch-work-item-direct-preflight.ts
  • src/renderer/src/lib/launch-work-item-direct-route-preparation.ts
  • src/renderer/src/lib/launch-work-item-direct.test.ts
  • src/renderer/src/lib/launch-work-item-direct.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.

@brennanb2025

brennanb2025 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Direct work-item launches could choose a detected fallback instead of a usable preferred chat because preflight omitted chat eligibility and promoted its inference into an explicit override. On paired hosts, direct launch also used desktop preferences where a new tab used the workspace owner's preferences.

The change now shares the workspace preference source and default picker, preserves explicit choices, detects the actual created workspace's agents, and uses one current snapshot for changed-agent replacement planning and startup. It also skips unnecessary root traversal when no custom working directory is requested.

Full review completed through round 6. Repairs covered the owner source, actual destination inventory, settings freshness, the real acquisition performance contract, and contract-faithful tests with real availability publication, activation and cleanup. Final panels settled the resource fixture, public mock type boundary and cumulative growth; production remained unchanged after the accepted repair. No open P0/P1 or known worse user behavior. Deferred concerns only: a different cold-preference policy and universal same-agent preflight revalidation; no concrete failing input was established, and existing policies were retained.

Intended distinctions: blank creation versus an explicit new-agent-tab action; supplied preference snapshots; synchronous cold/unsupported-host fallback; existing matching-agent preflight adoption; CLI/chat and mixed-host adapters. Onboarding, dashboard, composer and shell-seeding contracts are intentionally unchanged. Whole-mechanism reference comparison is complete; no temporary deviation remains.

CI passed on 5e6f22e48a889bf3bb9cb7898744b43c11408cca (run 40866623677): all ten unit shards, Linux and Windows packaging, and required checks. The casting gate actually executed with zero new findings; both compiler guards were true and all four normal compiler programs, including web/composite, actually executed and passed. No TS2883 or replacement compiler error remains. Explicit passing evidence from the runtime-equivalent parent covers all twelve required suites, defaults (13 cases), menu (8 cases/full 60-row matrix), delayed availability, and the 100/1,000-workspace acquisition/performance contract. The final commit is the authorized one-line casting-comment change on 57bae606; no type or runtime expression changed. Production has been unchanged since the accepted repair and final main sync. The prior blocked status is superseded by this completed validation.

All changed flows are renderer selection/route/performance tests rows (qa=tests). No appearance, process ownership, session lifecycle or provider-login implementation changed; no screenshot or live-agent run was required or claimed. Normal commits used no bypass flags; the generated hook was absent in this checkout, so no hook pass is claimed.

For Brennan's review:

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

Nitpick comments: 1
src/renderer/src/lib/agent-tab-shortcuts.ts: 1

48-78: Trivial · Functional Correctness · Quick win

Add a regression case for a chat-capable preferred agent.

resolveTerminalAgentTabShortcut passes chatIn to resolveDefaultAgentForNewTab. Add a test where the configured preferred agent is chat-usable but absent from detectedAgentIds, and assert that the preferred agent is selected. Existing tests do not exercise this branch. A future loss of chatIn forwarding could therefore regress this shortcut without failing an existing assertion.


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: f407aa88-0d94-4305-ba1a-32a6d7629f42
Commits

Reviewing files that changed from the base of the PR and between 72c5697 and 57bae60.

Files selected for processing: 1
  • src/renderer/src/lib/launch-work-item-direct-test-fixture.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.

@brennanb2025
brennanb2025 merged commit ec4d46f into main Oct 29, 2026
41 checks passed
@brennanb2025
brennanb2025 deleted the brennanb2025/sta-12494-workitem-agent branch October 29, 2026 20:56
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