Skip to content

feat: support configurable custom agents - #8573

Open
Cloeille wants to merge 9 commits into
stablyai:mainfrom
Cloeille:feat/custom-agents
Open

Cloeille wants to merge 9 commits into
stablyai:mainfrom
Cloeille:feat/custom-agents

Conversation

@Cloeille

@Cloeille Cloeille commented Jul 13, 2026 •

Copy link
Copy Markdown

Summary

Custom terminal agents can now be configured with a name, command, prompt-delivery mode, optional template, and icon. They appear in Settings and the workspace agent picker, can be enabled or disabled, and can be selected as the default agent. Custom-agent launch state is propagated through local, SSH, remote-runtime, and automation paths.

Screenshots

The change includes Settings and workspace agent-picker UI updates. No screenshots or recording were captured in this environment.

Testing

  • pnpm lint (run with [email protected]; passed with warnings)
  • pnpm typecheck (run with [email protected]; passed)
  • pnpm test (run with [email protected]; existing failures remain in PTY shell, relay, startup, review UI, daemon, and sidebar suites)
  • pnpm build (run with [email protected]; completed through desktop, native, Electron, relay, CLI, and web build steps; the CLI symlink step reported the expected permission warning for /usr/local/bin/orca-dev)
  • Focused custom-agent regression tests: 31 tests passed
  • Added or updated high-quality tests covering custom-agent validation, startup behavior, and default-agent selection.

AI Review Report

The AI coding-agent review checked custom-agent validation and normalization, enable/disable and default persistence, prompt delivery through PTY/argv/template modes, command/environment/argument handling, stale IDs, IPC/runtime propagation, SSH and remote startup, shell-aware command construction, UI behavior, cleanup, and supported native-agent compatibility.

The review explicitly checked macOS, Linux, and Windows compatibility, including shortcuts, labels, paths, shell behavior, and Electron-specific platform differences touched by this PR. It also checked local, SSH, and remote-runtime execution and provider-neutral behavior. The main risk found was an incomplete AgentId/TuiAgent migration; the affected launch contracts and native-only consumers were corrected and pnpm typecheck now passes.

Security Audit

The review covered custom command and prompt-template validation, icon data URLs and size/type checks, command execution boundaries, shell quoting, SSH/remote paths, IPC/runtime settings normalization, filesystem paths, auth, secrets, dependencies, and cleanup. Custom commands remain intentionally user-controlled executable input and continue through the existing shell-aware startup and trust/preflight paths. No secrets, auth, or dependency changes were introduced.

Notes

  • Contributor X/Twitter: @Zoeillle
  • Full-suite test failures are pre-existing/current branch-wide failures outside the focused custom-agent suites; CI should be checked with Node 24, the repository-supported version.
  • The local environment uses Node 26 and invokes the repository scripts through [email protected] because pnpm is not installed globally.
  • The normal fork-to-upstream flow is used: Zoeille:feat/custom-agents → stablyai/orca:main.

ELI5

You can define your own terminal agents with a name, command, how prompts are sent, optional template, and icon. They show up in Settings and the agent picker, can be enabled or set as default, and work over local, SSH, remote, and automation paths.

@Cloeille
Cloeille marked this pull request as draft July 13, 2026 15:01
@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor

Review 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

Walkthrough

The change introduces custom agent IDs and definitions, including normalization, validation, command resolution, prompt delivery, icons, and enablement state. Agent identifiers are widened across shared types, persistence, daemon, IPC, preload, runtime, terminal, worktree, automation, and renderer contracts. Workspace and terminal startup flows now forward custom-agent settings, persist custom-agent metadata, and distinguish TUI-specific behavior. The settings UI adds custom-agent creation, editing, enablement, removal, icon selection, and localization. Tests cover normalization, persistence, startup planning, workspace creation, activation, selection, and rendering.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and accurately summarizes the main change: configurable custom agents.
Description check ✅ Passed The description covers all required template sections and includes testing, review, security, and notes details.

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: 7

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (9)
src/renderer/src/lib/worktree-activation.ts (1)

76-87: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Align queueTabStartupCommand with AgentId

WorktreeStartupPayload.launchAgent and createTab already use AgentId, but queueTabStartupCommand still narrows it to TuiAgent. That breaks the buildCreatedAgentReopenStartup() path for custom agents and makes the payload contract inconsistent.

src/renderer/src/lib/github-work-item-background-request.ts (1)

125-140: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Align the background snapshot and return type with custom agents.

Line 140 reads store.settings?.customAgents, but GitHubWorkItemBackgroundStoreSnapshot.settings omits customAgents from its Pick<GlobalSettings, ...>, producing a TypeScript error. The function also still returns Promise<TuiAgent | null> even though custom selection can return a custom AgentId.

Add customAgents to the snapshot and change the return type/import to AgentId.

Proposed contract fix
 type GitHubWorkItemBackgroundStoreSnapshot = {
   settings: Partial<Pick<GlobalSettings,
     | 'activeRuntimeEnvironmentId'
     | 'defaultTuiAgent'
     | 'disabledTuiAgents'
+    | 'customAgents'
     | 'agentCmdOverrides'
     | 'agentDefaultArgs'
     | 'agentDefaultEnv'
     | 'terminalWindowsShell'
   >>
 }

-export async function resolvePreferredQuickAgentForGitHubWorkItem(...): Promise<TuiAgent | null> {
+export async function resolvePreferredQuickAgentForGitHubWorkItem(...): Promise<AgentId | null> {
src/renderer/src/components/automations/AutomationsPage.tsx (1)

402-412: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Enforce custom-agent enablement when selecting the default.

enabledAgents correctly excludes custom definitions with enabled: false, but defaultAgent bypasses that list and checks only isTuiAgentEnabled, which does not account for the custom definition’s enabled flag. A disabled custom agent can therefore become the default for new automations and pass through the picker/save flow.

Use enabledAgents.includes(settings.defaultTuiAgent) here, and reuse the same predicate during save validation.

Proposed fix
   const defaultAgent =
     settings?.defaultTuiAgent &&
     settings.defaultTuiAgent !== 'blank' &&
-    isTuiAgentEnabled(settings.defaultTuiAgent, settings.disabledTuiAgents)
+    enabledAgents.includes(settings.defaultTuiAgent)
       ? settings.defaultTuiAgent
       : (enabledAgents[0] ?? AGENTS[0])
src/main/runtime/orca-runtime.ts (1)

14220-14260: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Widen the trust helpers to AgentId WorktreeStartupDraftPaste.agent and effectiveCreatedWithAgent are AgentId, so the createManagedWorktree → remote path still feeds a wider type into markLocalWorkspaceTrustedForAgent / markRemoteWorkspaceTrustedForAgent. Widen markRemoteWorkspaceTrustedForAgent and createManagedRemoteWorktree.createdWithAgent to AgentId, and keep the isTuiAgent guard before touching TUI_AGENT_CONFIG.

src/renderer/src/lib/agent-launch-prompt-delivery.ts (1)

5-18: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Widen the draft helpers to accept AgentId

isNativeChatSupportedAgent already accepts broader agent values, but agentDeliversDraftViaNativePrefill and pasteDraftWhenAgentReady still narrow to TuiAgent. deliverLaunchPromptToAgentTab now passes AgentId through both, so custom-agent launches through this path will fail type-checking unless those signatures are widened or custom ids are handled separately.

src/renderer/src/lib/launch-agent-web-host-tab.ts (1)

45-55: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Pass launchAgent in the no-prompt branch
agent is AgentId, but createWebRuntimeSessionTerminal still types agent?: TuiAgent. Use the separate launchAgent field here (or narrow to a TuiAgent) so custom-agent ids don’t go through the wrong contract.

src/main/persistence.ts (1)

3054-3070: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Normalize persisted agent settings on load — load() still runs disabledTuiAgents through normalizeDisabledTuiAgents(...), while updateSettings() writes them with normalizeAgentIds(...). That strips persisted custom:* ids on restart. customAgents is also carried through from disk without normalizeCustomAgents(...), so malformed entries can reach store.settings at startup. Normalize both fields in load() to match the update path.

src/renderer/src/hooks/useComposerState.ts (1)

3395-3417: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

settings?.customAgents read but not in useCallback deps for submitFolderTarget, submit, and submitQuick.

All three callbacks read settings?.customAgents in their bodies (lines 3351, 3613, 4037, 4071) to build the launch plan/args for custom agents, but none of their dependency arrays list settings?.customAgents. If customAgents changes without any other listed setting changing (e.g. the user edits a custom agent's command, or toggles its enabled flag, then immediately launches), these memoized callbacks stay stale and will build the startup plan from the outdated custom-agent definitions.

♻️ Proposed fix
       settings?.agentCmdOverrides,
       settings?.agentDefaultArgs,
       settings?.agentDefaultEnv,
       settings?.autoRenameBranchFromWork,
+      settings?.customAgents,
       settings?.terminalWindowsShell,

(apply the equivalent addition to the deps arrays of submit, submitFolderTarget, and submitQuick)

Also applies to: 3754-3810, 4217-4275

src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts (1)

190-202: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

customAgents not forwarded to buildFolderWorkspaceLinkedStartupPlan.

The sibling branch two lines below (line 214, no linked work item) correctly passes customAgents into buildAgentStartupPlan, but this branch — used whenever there's both a quickAgent and a linkedWorkItem — omits it entirely from the call to buildFolderWorkspaceLinkedStartupPlan. Since that function's own signature (line 71-81) accepts and forwards customAgents to its internal buildAgentDraftLaunchPlan/buildAgentStartupPlan calls, launching a custom agent for a folder workspace that also has a linked work item will build the startup command with customAgents === undefined, breaking resolution of the custom agent's launch command for this common combined flow.

🐛 Proposed fix
   const startupPlan =
     quickAgent && linkedWorkItem
       ? buildFolderWorkspaceLinkedStartupPlan({
           agent: quickAgent,
           linkedWorkItem,
           note,
           agentCmdOverrides,
           agentArgs,
           agentEnv,
           platform: launchPlatform,
           shell: launchShell,
-          isRemote: launchIsRemote
+          isRemote: launchIsRemote,
+          customAgents
         })
🧹 Nitpick comments (4)
src/shared/tui-agent-startup.ts (1)

83-90: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated synthetic TuiAgentConfig construction for custom agents.

buildAgentStartupPlan and buildAgentDraftLaunchPlan each inline a near-identical synthetic TuiAgentConfig for custom agents. Extracting a shared helper (e.g. buildCustomAgentTuiConfig(agent, customAgent)) would remove the duplication and reduce the chance the two copies drift (as already happened with the expectedProcess issue above).

♻️ Suggested extraction
function buildCustomAgentTuiConfig(
  agent: AgentId,
  customAgent: CustomAgentDefinition | undefined,
  promptInjectionMode: AgentPromptInjectionMode = 'stdin-after-start'
): TuiAgentConfig {
  return {
    detectCmd: '',
    launchCmd: '',
    expectedProcess: agent,
    promptInjectionMode: customAgent?.promptMode === 'argv' ? 'argv' : promptInjectionMode
  }
}

Also applies to: 296-298

src/renderer/src/components/settings/AgentsPane.tsx (1)

849-855: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Consider extracting the custom-agent row/pill rendering.

The default-agent-pill loop for custom agents (849-855) and the custom-agent list row (996-1013) duplicate patterns already used for native agents elsewhere in this file. Extracting a small CustomAgentPill/CustomAgentRow helper would keep AgentsPane (already ~1040 lines) more manageable as more agent-related UI gets added here.

Also applies to: 988-1029

src/main/ipc/worktree-remote.ts (1)

297-306: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value

launchAgent forwarded without isAgentId validation, unlike the sibling createdWithAgent metadata writes.

const terminal = await runtime.createTerminal(id:${worktree.id}, { command: sequencedStartup.command, ...(setup ? { claudeAgentTeamsSourceCommand: startup.command } : {}), env: sequencedStartup.env, ...(sequencedStartup.launchConfig ? { launchConfig: sequencedStartup.launchConfig } : {}), ...(createdWithAgent ? { launchAgent: createdWithAgent } : {}), only checks truthiness, whereas the same file's metadata persistence paths guard with isAgentId(args.createdWithAgent) before use (lines ~1896, ~2526). Since createdWithAgent ultimately originates from an IPC-supplied CreateWorktreeArgs, this is an inconsistent trust boundary — a malformed value would still reach runtime.createTerminal's launchAgent option even though it would be rejected everywhere else in the same function/file.

Consider guarding this spot with isAgentId(createdWithAgent) too, for consistency and defense-in-depth.

src/shared/tui-agent-selection.ts (1)

76-79: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

isTuiAgentEnabled silently no-ops for custom agents.

For any AgentId that isn't a TuiAgent (i.e. every custom agent), this returns true unconditionally — it never checks the custom agent's own enabled flag. Every current caller compensates by separately checking isCustomAgentId(...) && customAgentForId(...)?.enabled === true, but the function name/signature (agent: AgentId) invites future callers to treat it as the complete "is this agent usable" gate, which would let disabled custom agents slip through (e.g. useComposerState.ts's submitFolderTarget/submitQuick rely on it as the only guard before accepting requestedAgent, and only stay safe because upstream selection already filtered custom agents).

Consider either keeping this TuiAgent-only (reverting the AgentId widening and pushing the union handling to call sites that already do the compound check) or folding the custom-agent enabled check into this function so it's a complete guard for AgentId.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ea019f73-52c0-41d4-a447-c1be8392052f

📥 Commits

Reviewing files that changed from the base of the PR and between 7b3103f and 89f4372.

📒 Files selected for processing (50)
  • src/main/daemon/daemon-server.ts
  • src/main/daemon/session.ts
  • src/main/daemon/terminal-host-create-contract.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty.ts
  • src/main/ipc/repos.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/persistence.ts
  • src/main/providers/types.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/automations.ts
  • src/main/runtime/rpc/methods/client-ui-schemas.ts
  • src/main/runtime/rpc/methods/folder-workspace.ts
  • src/main/runtime/rpc/methods/terminal.ts
  • src/renderer/src/components/NewWorkspaceComposerCard.tsx
  • src/renderer/src/components/NewWorkspaceComposerModal.tsx
  • src/renderer/src/components/agent/AgentCombobox.tsx
  • src/renderer/src/components/automations/AutomationDetail.tsx
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-templates.ts
  • src/renderer/src/components/settings/AgentsPane.tsx
  • src/renderer/src/components/settings/CustomAgentDialog.tsx
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/components/terminal-pane/pty-connection-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport-types.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/ui/textarea.tsx
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/lib/agent-catalog.tsx
  • src/renderer/src/lib/agent-launch-prompt-delivery.ts
  • src/renderer/src/lib/github-work-item-background-request.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/launch-agent-web-host-tab.ts
  • src/renderer/src/lib/quick-workspace-agent-selection.test.ts
  • src/renderer/src/lib/quick-workspace-agent-selection.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/shared/automations-types.ts
  • src/shared/commit-message-agent-spec.ts
  • src/shared/constants.ts
  • src/shared/custom-agent-startup.test.ts
  • src/shared/custom-agent.test.ts
  • src/shared/custom-agent.ts
  • src/shared/folder-workspaces.ts
  • src/shared/runtime-types.ts
  • src/shared/tui-agent-selection.ts
  • src/shared/tui-agent-startup.ts
  • src/shared/types.ts

Comment thread src/shared/tui-agent-startup.ts Resolved
@Cloeille
Cloeille marked this pull request as ready for review July 13, 2026 15:58

@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

🧹 Nitpick comments (2)
src/renderer/src/lib/agent-native-draft-prefill.ts (1)

1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Merge duplicate named imports from the same module. Both files import TUI_AGENT_CONFIG and isTuiAgent via two separate statements from ../../../shared/tui-agent-config; combine each pair into a single import statement.

  • src/renderer/src/lib/agent-native-draft-prefill.ts#L1-L3: combine import { TUI_AGENT_CONFIG, isTuiAgent } from '../../../shared/tui-agent-config'.
  • src/renderer/src/lib/agent-paste-draft.ts#L1-L3: combine import { TUI_AGENT_CONFIG, isTuiAgent } from '../../../shared/tui-agent-config'.
src/main/runtime/orca-runtime.ts (1)

14750-14752: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Custom-agent createdWithAgent is silently dropped for worktree metadata.

These sites gate createdWithAgent on isTuiAgent(...), so worktrees created with a custom agent never persist createdWithAgent in WorktreeMeta/remote-create args. If this is intentional (metadata field stays native-only for now), consider a brief comment noting why, since it's easy to mistake for an oversight during future maintenance.

Also applies to: 14845-14847, 15331-15333, 15709-15711


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b6bea097-5d35-4f6a-9554-525c23352d0f

📥 Commits

Reviewing files that changed from the base of the PR and between 89f4372 and 06744eb.

📒 Files selected for processing (78)
  • src/main/codex-accounts/runtime-home-service.test.ts
  • src/main/codex-accounts/service.test.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees.ts
  • src/main/runtime/orca-runtime.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/NewWorkspaceComposerModal.tsx
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/agent/AgentCombobox.tsx
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/feature-wall/FeatureWallSetupChecklist.tsx
  • src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx
  • src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts
  • src/renderer/src/components/onboarding/onboarding-settings-hydration.ts
  • src/renderer/src/components/onboarding/use-onboarding-flow.ts
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.tsx
  • src/renderer/src/components/right-sidebar/source-control-agent-action-dialog-support.ts
  • src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts
  • src/renderer/src/components/settings/CustomAgentDialog.tsx
  • src/renderer/src/components/settings/RepositorySourceControlAiSection.tsx
  • src/renderer/src/components/settings/SourceControlActionRecipeRow.tsx
  • src/renderer/src/components/settings/shortcut-groups.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/tab-agent-launch-options.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-protocol-pane-agent.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/components/terminal-quick-commands/terminal-quick-command-agent-options.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/renderer/src/lib/agent-background-session-timeout-toast.ts
  • src/renderer/src/lib/agent-catalog.tsx
  • src/renderer/src/lib/agent-native-draft-prefill.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/agent-tab-shortcuts.ts
  • src/renderer/src/lib/github-work-item-background-request.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct.ts
  • src/renderer/src/lib/native-chat-initial-view-mode.ts
  • src/renderer/src/lib/native-chat-launch-prompt.ts
  • src/renderer/src/lib/native-chat-supported-agent.ts
  • src/renderer/src/lib/onboarding-folder-agent-startup.ts
  • src/renderer/src/lib/pending-worktree-creation.ts
  • src/renderer/src/lib/source-control-agent-action-plan.ts
  • src/renderer/src/lib/source-control-launch-agent-selection.ts
  • src/renderer/src/lib/use-tab-agent.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/lib/worktree-creation-flow.ts
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/tabs.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/shared/automations-types.ts
  • src/shared/custom-agent.ts
  • src/shared/folder-workspace-worktree.ts
  • src/shared/runtime-types.ts
  • src/shared/tui-agent-launch-defaults.ts
  • src/shared/tui-agent-resume-startup.ts
  • src/shared/tui-agent-selection.ts
  • src/shared/tui-agent-startup.ts
  • src/shared/types.ts
💤 Files with no reviewable changes (4)
  • src/main/daemon/types.ts
  • src/shared/runtime-types.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/renderer/src/components/NewWorkspaceComposerModal.tsx
  • src/shared/automations-types.ts
  • src/main/ipc/pty.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/components/agent/AgentCombobox.tsx
  • src/renderer/src/lib/agent-catalog.tsx
  • src/shared/types.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/shared/custom-agent.ts
  • src/renderer/src/components/settings/CustomAgentDialog.tsx
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts

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

Caution

Inline review comments failed to post. This is likely due to GitHub's internal server error or limits when posting large numbers of comments. If you are seeing this consistently it is likely a permissions issue. Please check "Moderation" -> "Code review limits" under your organization settings.

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/renderer/src/lib/agent-native-draft-prefill.ts (1)

1-3: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Merge duplicate named imports from the same module. Both files import TUI_AGENT_CONFIG and isTuiAgent via two separate statements from ../../../shared/tui-agent-config; combine each pair into a single import statement.

  • src/renderer/src/lib/agent-native-draft-prefill.ts#L1-L3: combine import { TUI_AGENT_CONFIG, isTuiAgent } from '../../../shared/tui-agent-config'.
  • src/renderer/src/lib/agent-paste-draft.ts#L1-L3: combine import { TUI_AGENT_CONFIG, isTuiAgent } from '../../../shared/tui-agent-config'.
src/main/runtime/orca-runtime.ts (1)

14750-14752: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Custom-agent createdWithAgent is silently dropped for worktree metadata.

These sites gate createdWithAgent on isTuiAgent(...), so worktrees created with a custom agent never persist createdWithAgent in WorktreeMeta/remote-create args. If this is intentional (metadata field stays native-only for now), consider a brief comment noting why, since it's easy to mistake for an oversight during future maintenance.

Also applies to: 14845-14847, 15331-15333, 15709-15711


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b6bea097-5d35-4f6a-9554-525c23352d0f

📥 Commits

Reviewing files that changed from the base of the PR and between 89f4372 and 06744eb.

📒 Files selected for processing (78)
  • src/main/codex-accounts/runtime-home-service.test.ts
  • src/main/codex-accounts/service.test.ts
  • src/main/daemon/types.ts
  • src/main/ipc/pty.ts
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees.ts
  • src/main/runtime/orca-runtime.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/renderer/src/components/NewWorkspaceComposerModal.tsx
  • src/renderer/src/components/Terminal.tsx
  • src/renderer/src/components/agent/AgentCombobox.tsx
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/feature-wall/FeatureWallSetupChecklist.tsx
  • src/renderer/src/components/floating-terminal/FloatingTerminalWindowControls.tsx
  • src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts
  • src/renderer/src/components/onboarding/onboarding-settings-hydration.ts
  • src/renderer/src/components/onboarding/use-onboarding-flow.ts
  • src/renderer/src/components/right-sidebar/SourceControl.tsx
  • src/renderer/src/components/right-sidebar/SourceControlAgentActionDialogForm.tsx
  • src/renderer/src/components/right-sidebar/source-control-agent-action-dialog-support.ts
  • src/renderer/src/components/right-sidebar/useSourceControlAgentActionDialog.ts
  • src/renderer/src/components/settings/CustomAgentDialog.tsx
  • src/renderer/src/components/settings/RepositorySourceControlAiSection.tsx
  • src/renderer/src/components/settings/SourceControlActionRecipeRow.tsx
  • src/renderer/src/components/settings/shortcut-groups.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/components/tab-bar/TabBar.tsx
  • src/renderer/src/components/tab-bar/tab-agent-launch-options.ts
  • src/renderer/src/components/terminal-pane/TerminalPane.tsx
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/terminal-keyboard-protocol-pane-agent.ts
  • src/renderer/src/components/terminal-pane/use-terminal-pane-lifecycle.ts
  • src/renderer/src/components/terminal-quick-commands/terminal-quick-command-agent-options.ts
  • src/renderer/src/hooks/useAutomationDispatchEvents.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/i18n/locales/en.json
  • src/renderer/src/i18n/locales/es.json
  • src/renderer/src/i18n/locales/ja.json
  • src/renderer/src/i18n/locales/ko.json
  • src/renderer/src/i18n/locales/zh.json
  • src/renderer/src/lib/agent-background-session-contract.ts
  • src/renderer/src/lib/agent-background-session-timeout-toast.ts
  • src/renderer/src/lib/agent-catalog.tsx
  • src/renderer/src/lib/agent-native-draft-prefill.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/agent-tab-shortcuts.ts
  • src/renderer/src/lib/github-work-item-background-request.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
  • src/renderer/src/lib/launch-work-item-direct-agent.ts
  • src/renderer/src/lib/launch-work-item-direct.ts
  • src/renderer/src/lib/native-chat-initial-view-mode.ts
  • src/renderer/src/lib/native-chat-launch-prompt.ts
  • src/renderer/src/lib/native-chat-supported-agent.ts
  • src/renderer/src/lib/onboarding-folder-agent-startup.ts
  • src/renderer/src/lib/pending-worktree-creation.ts
  • src/renderer/src/lib/source-control-agent-action-plan.ts
  • src/renderer/src/lib/source-control-launch-agent-selection.ts
  • src/renderer/src/lib/use-tab-agent.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/lib/worktree-creation-flow.ts
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/renderer/src/runtime/web-session-tabs-sync.ts
  • src/renderer/src/store/slices/tabs.ts
  • src/renderer/src/store/slices/terminals.ts
  • src/renderer/src/store/slices/worktree-helpers.ts
  • src/shared/automations-types.ts
  • src/shared/custom-agent.ts
  • src/shared/folder-workspace-worktree.ts
  • src/shared/runtime-types.ts
  • src/shared/tui-agent-launch-defaults.ts
  • src/shared/tui-agent-resume-startup.ts
  • src/shared/tui-agent-selection.ts
  • src/shared/tui-agent-startup.ts
  • src/shared/types.ts
💤 Files with no reviewable changes (4)
  • src/main/daemon/types.ts
  • src/shared/runtime-types.ts
  • src/renderer/src/components/automations/AutomationEditorDialog.tsx
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/renderer/src/runtime/web-runtime-session.ts
  • src/renderer/src/components/NewWorkspaceComposerModal.tsx
  • src/shared/automations-types.ts
  • src/main/ipc/pty.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/renderer/src/components/agent/AgentCombobox.tsx
  • src/renderer/src/lib/agent-catalog.tsx
  • src/shared/types.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/shared/custom-agent.ts
  • src/renderer/src/components/settings/CustomAgentDialog.tsx
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
🛑 Comments failed to post (2)
src/main/ipc/worktree-remote.ts (1)

1895-1898: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Preserve all custom AgentId values when persisting worktree metadata.

Both paths use the native-only isTuiAgent guard, so custom-agent launch identity and pending rename state are silently dropped.

  • src/main/ipc/worktree-remote.ts#L1895-L1898: preserve and validate custom AgentId values for remote worktrees.
  • src/main/ipc/worktree-remote.ts#L2525-L2528: apply the same full-AgentId handling to local worktrees.
📍 Affects 1 file
  • src/main/ipc/worktree-remote.ts#L1895-L1898 (this comment)
  • src/main/ipc/worktree-remote.ts#L2525-L2528
src/renderer/src/hooks/useComposerState.ts (1)

3850-3852: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve custom agent IDs in quick-create.

Both branches discard custom agents: the folder branch passes null, and the repository branch makes agent null whenever requestedAgent is not a TUI agent. Selecting a custom agent therefore creates a workspace without launching it.

Proposed fix
-        await submitFolderTarget(isTuiAgent(requestedAgent) ? requestedAgent : null)
+        await submitFolderTarget(requestedAgent)

-        const agent =
-          requestedAgent &&
-          isTuiAgent(requestedAgent) &&
-          isTuiAgentEnabled(requestedAgent, disabledTuiAgents)
+        const agent =
+          requestedAgent &&
+          isTuiAgentEnabled(requestedAgent, disabledTuiAgents)

Also applies to: 3882-3887

Several code paths still treated a custom agent id as "not a recognized
agent" instead of handling it explicitly, since the TuiAgent -> AgentId
migration was incomplete in a few spots:

- launch-agent-in-new-tab.ts: crash on an orphaned/disabled custom agent
  (and the same bug one level deeper in resolveBaseCommand)
- QuickLaunchButton.tsx: custom agents hidden while TUI detection is loading
- useComposerState.ts: quick-launch silently dropped custom agent selection,
  and missing customAgents in submit callbacks' useCallback deps
- session-tabs-schemas.ts: CreateTerminalTab RPC schema rejected custom
  agent ids from paired web/mobile sessions
- tui-agent-startup.ts: expectedProcess for custom agents was the literal
  custom:* id instead of the real binary name, breaking readiness detection
- types.ts / orca-runtime.ts / worktree-remote.ts / worktrees.ts /
  folder-workspace-worktree.ts: createdWithAgent gated by isTuiAgent instead
  of isAgentId in five separate places, so custom-agent worktrees/folder
  workspaces never persisted (or re-projected) their creation agent
- AutomationsPage.tsx: default agent bypassed the custom agent enabled check
- persistence.ts: load() stripped disabled custom agent ids and skipped
  normalizeCustomAgents, both restored by any settings write afterwards
- folder-workspace-composer-submit.ts: customAgents not forwarded when a
  quick agent also has a linked work item

Each fix has a regression test; test-full.log failures on this branch are
pre-existing and unrelated (confirmed via git stash).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XwsxezmtFxvKSc3yRGYf85
@Cloeille

Copy link
Copy Markdown
Author

@coderabbitai I went through both review passes and fixed everything that was actually a real issue (one nitpick on the literal i18n keys in AgentsPane.tsx was left as-is — no CI rule enforces the hashed-key convention and the file already mixes both styles).

Pushed in c1d6395:

  • Crash on an orphaned/disabled custom agent id (and the same bug one level deeper in resolveBaseCommand)
  • Custom agents hidden from the quick-launch menu while TUI detection is still loading
  • Composer quick-launch silently dropping the custom agent selection, plus missing customAgents in the relevant useCallback deps
  • CreateTerminalTab RPC schema rejecting custom agent ids from paired web/mobile sessions
  • expectedProcess for custom agents being the literal custom:* id instead of the real binary name (broke readiness detection), plus de-duped the synthetic TUI config building
  • createdWithAgent gated by isTuiAgent instead of isAgentId in five separate places (types.ts, orca-runtime.ts, worktree-remote.ts, worktrees.ts, folder-workspace-worktree.ts) — custom-agent worktrees/folder workspaces never persisted or re-projected their creation agent
  • Automations default agent bypassing the custom agent's own enabled flag
  • persistence.ts load() stripping disabled custom agent ids and skipping normalizeCustomAgents on restart
  • customAgents not forwarded when a quick agent also has a linked work item

Each fix has a regression test. Please take another pass.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026 •

Copy link
Copy Markdown
Contributor
🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail
git log --oneline -5
echo "---"
git show --stat c1d639558 | head -50

Length of output: 3524


🏁 Script executed:

#!/bin/bash
set -euo pipefail
echo "=== persistence.ts load section ==="
rg -n "normalizeAgentIds|normalizeCustomAgents|disabledTuiAgents|customAgents" src/main/persistence.ts

echo "=== worktrees.ts ==="
rg -n "isAgentId|isTuiAgent" src/main/ipc/worktrees.ts

echo "=== worktree-remote.ts ==="
rg -n "isAgentId|isTuiAgent" src/main/ipc/worktree-remote.ts

echo "=== folder-workspace-worktree.ts ==="
rg -n "isAgentId|isTuiAgent" src/shared/folder-workspace-worktree.ts

echo "=== orca-runtime.ts createdWithAgent ==="
rg -n "isAgentId|isTuiAgent" src/main/runtime/orca-runtime.ts

echo "=== tui-agent-startup.ts expectedProcess ==="
rg -n "expectedProcess" src/shared/tui-agent-startup.ts

echo "=== QuickLaunchButton.tsx loading state ==="
rg -n "detect|loading|customAgents" src/renderer/src/components/tab-bar/QuickLaunchButton.tsx | head -30

echo "=== useComposerState.ts customAgents deps ==="
rg -n "customAgents" src/renderer/src/hooks/useComposerState.ts

echo "=== launch-agent-in-new-tab.ts ==="
rg -n "customAgentForId|resolveBaseCommand|isCustomAgentId" src/renderer/src/lib/launch-agent-in-new-tab.ts src/shared/tui-agent-startup.ts

echo "=== session-tabs-schemas.ts ==="
rg -n "isAgentId|isTuiAgent" src/main/runtime/rpc/methods/session-tabs-schemas.ts

echo "=== AutomationsPage.tsx default agent ==="
rg -n "enabled|customAgentForId" src/renderer/src/components/automations/automation-default-agent.ts

echo "=== folder-workspace-composer-submit.ts work item ==="
rg -n "customAgents" src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts

Length of output: 10446


All the fixes check out — I verified each one directly in c1d6395:

  • persistence.ts: load() now uses normalizeAgentIds for disabledTuiAgents and normalizeCustomAgents for customAgents (Lines 3053, 3191), so a restart no longer strips disabled custom agent ids or drops normalization.
  • worktrees.ts, worktree-remote.ts (Lines 302, 1896, 2527), folder-workspace-worktree.ts, and orca-runtime.ts (Lines 14750, 14845, 15331, 15709) all gate createdWithAgent/launchAgent on isAgentId now instead of isTuiAgent.
  • tui-agent-startup.ts: expectedProcess is now derived from the custom agent's command binary basename rather than the raw custom:* id, and resolveBaseCommand correctly branches on isCustomAgentId.
  • QuickLaunchButton.tsx: custom agents are merged into agents regardless of detection-loading state, so they're no longer hidden while TUI detection is in flight.
  • useComposerState.ts: customAgents is threaded through isRequestedAgentEnabled and included in the relevant dependency arrays.
  • session-tabs-schemas.ts: the AgentId custom schema (isAgentId) replaces the old TUI-only check, so paired web/mobile custom agent ids validate correctly.
  • AutomationsPage.tsx/automation-default-agent.ts: default agent resolution now checks the custom agent's own enabled flag via customAgentForId.
  • folder-workspace-composer-submit.ts: customAgents is forwarded through the work-item-linked startup path too.

Everything lines up with the PR summary, and each area has an accompanying regression test file (orca-runtime.test.ts, persistence.test.ts, worktrees.test.ts, session-tabs-schemas.test.ts, automation-default-agent.test.ts, folder-workspace-composer-submit.test.ts, QuickLaunchButton.test.ts). This is a solid, thorough follow-up pass — nice work closing out the gaps.

On the i18n literal-key nitpick in AgentsPane.tsx: agreed that's fine to leave as-is given there's no enforced convention and the file already mixes styles.

I'm satisfied with these fixes. 🐰✨

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@Cloeille

Copy link
Copy Markdown
Author

Some pics of the PR:
image
image

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a5283887-82f6-4f5d-9e38-b84526152c4e

📥 Commits

Reviewing files that changed from the base of the PR and between 06744eb and c1d6395.

📒 Files selected for processing (29)
  • src/main/ipc/worktree-remote.ts
  • src/main/ipc/worktrees.test.ts
  • src/main/ipc/worktrees.ts
  • src/main/persistence.test.ts
  • src/main/persistence.ts
  • src/main/runtime/orca-runtime.test.ts
  • src/main/runtime/orca-runtime.ts
  • src/main/runtime/rpc/methods/session-tabs-schemas.test.ts
  • src/main/runtime/rpc/methods/session-tabs-schemas.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-default-agent.test.ts
  • src/renderer/src/components/automations/automation-default-agent.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.test.ts
  • src/renderer/src/components/sidebar/folder-workspace-composer-submit.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.test.ts
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/hooks/useComposerState-host-context-boundaries.test.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/renderer/src/lib/agent-native-draft-prefill.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.test.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/lib/worktree-activation-created-agent.test.ts
  • src/renderer/src/lib/worktree-activation.ts
  • src/shared/folder-workspace-worktree.test.ts
  • src/shared/folder-workspace-worktree.ts
  • src/shared/tui-agent-startup-custom-agent.test.ts
  • src/shared/tui-agent-startup.ts
  • src/shared/types.ts
🚧 Files skipped from review as they are similar to previous changes (11)
  • src/renderer/src/lib/agent-native-draft-prefill.ts
  • src/shared/folder-workspace-worktree.ts
  • src/shared/types.ts
  • src/renderer/src/lib/agent-paste-draft.ts
  • src/renderer/src/lib/launch-agent-in-new-tab.ts
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/tab-bar/QuickLaunchButton.tsx
  • src/renderer/src/lib/worktree-activation.ts
  • src/shared/tui-agent-startup.ts
  • src/renderer/src/hooks/useComposerState.ts
  • src/main/runtime/orca-runtime.ts

Comment on lines +185 to +234
it('does not reopen a worktree whose creation-time custom agent was since deleted or disabled', () => {
const worktree = { ...makeWorktree(), createdWithAgent: 'custom:ghost' as const }
const revealWorktreeInSidebar = vi.fn()

useAppStore.setState({
repos: [
{
id: 'repo-1',
path: '/workspace/repo',
displayName: 'repo',
badgeColor: '#000000',
addedAt: 0
}
],
worktreesByRepo: { 'repo-1': [worktree] },
activeRepoId: 'repo-1',
activeView: 'terminal',
tabsByWorktree: {},
unifiedTabsByWorktree: {},
groupsByWorktree: {},
layoutByWorktree: {},
activeGroupIdByWorktree: {},
openFiles: [],
browserTabsByWorktree: {},
activeFileIdByWorktree: {},
activeBrowserTabIdByWorktree: {},
activeTabTypeByWorktree: {},
activeTabIdByWorktree: {},
tabBarOrderByWorktree: {},
pendingStartupByTabId: {},
settings: {
agentCmdOverrides: {},
setupScriptLaunchMode: 'new-tab',
customAgents: []
} as unknown as ReturnType<typeof useAppStore.getState>['settings'],
markWorktreeVisited: vi.fn(),
recordWorktreeVisit: vi.fn(),
refreshGitHubForWorktreeIfStale: vi.fn(),
revealWorktreeInSidebar
})

const result = activateAndRevealWorktree(worktree.id)
const state = useAppStore.getState()
const reopenedTab = state.tabsByWorktree[worktree.id]?.[0]

expect(result).toEqual({ primaryTabId: reopenedTab?.id })
expect(reopenedTab).toBeDefined()
expect(state.pendingStartupByTabId[reopenedTab!.id]).toBeUndefined()
expect(revealWorktreeInSidebar).toHaveBeenCalledWith(worktree.id)
})

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add a test case for the "disabled" scenario mentioned in the test title.

The test title says "deleted or disabled" but only covers the deleted case (customAgents: []). A disabled agent (present in customAgents with enabled: false) should also prevent startup, but this path is untested. Adding a case with enabled: false would catch regressions if the enablement check changes.

🧪 Suggested additional test case
   it('does not enqueue startup for a worktree whose creation-time custom agent was disabled', () => {
     const worktree = { ...makeWorktree(), createdWithAgent: 'custom:ghost' as const }
     const revealWorktreeInSidebar = vi.fn()

     useAppStore.setState({
       // ... same setup as the deleted test ...
       settings: {
         agentCmdOverrides: {},
         setupScriptLaunchMode: 'new-tab',
         customAgents: [
           {
             id: 'custom:ghost',
             name: 'Ghost',
             command: '/usr/local/bin/ghost',
             promptMode: 'pty',
             icon: { kind: 'terminal' },
             enabled: false
           }
         ]
       } as unknown as ReturnType<typeof useAppStore.getState>['settings'],
       // ... same remaining setup ...
     })

     const result = activateAndRevealWorktree(worktree.id)
     const state = useAppStore.getState()
     const reopenedTab = state.tabsByWorktree[worktree.id]?.[0]

     expect(result).toEqual({ primaryTabId: reopenedTab?.id })
     expect(reopenedTab).toBeDefined()
     expect(state.pendingStartupByTabId[reopenedTab!.id]).toBeUndefined()
     expect(revealWorktreeInSidebar).toHaveBeenCalledWith(worktree.id)
   })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it('does not reopen a worktree whose creation-time custom agent was since deleted or disabled', () => {
const worktree = { ...makeWorktree(), createdWithAgent: 'custom:ghost' as const }
const revealWorktreeInSidebar = vi.fn()
useAppStore.setState({
repos: [
{
id: 'repo-1',
path: '/workspace/repo',
displayName: 'repo',
badgeColor: '#000000',
addedAt: 0
}
],
worktreesByRepo: { 'repo-1': [worktree] },
activeRepoId: 'repo-1',
activeView: 'terminal',
tabsByWorktree: {},
unifiedTabsByWorktree: {},
groupsByWorktree: {},
layoutByWorktree: {},
activeGroupIdByWorktree: {},
openFiles: [],
browserTabsByWorktree: {},
activeFileIdByWorktree: {},
activeBrowserTabIdByWorktree: {},
activeTabTypeByWorktree: {},
activeTabIdByWorktree: {},
tabBarOrderByWorktree: {},
pendingStartupByTabId: {},
settings: {
agentCmdOverrides: {},
setupScriptLaunchMode: 'new-tab',
customAgents: []
} as unknown as ReturnType<typeof useAppStore.getState>['settings'],
markWorktreeVisited: vi.fn(),
recordWorktreeVisit: vi.fn(),
refreshGitHubForWorktreeIfStale: vi.fn(),
revealWorktreeInSidebar
})
const result = activateAndRevealWorktree(worktree.id)
const state = useAppStore.getState()
const reopenedTab = state.tabsByWorktree[worktree.id]?.[0]
expect(result).toEqual({ primaryTabId: reopenedTab?.id })
expect(reopenedTab).toBeDefined()
expect(state.pendingStartupByTabId[reopenedTab!.id]).toBeUndefined()
expect(revealWorktreeInSidebar).toHaveBeenCalledWith(worktree.id)
})
it('does not reopen a worktree whose creation-time custom agent was since deleted or disabled', () => {
const worktree = { ...makeWorktree(), createdWithAgent: 'custom:ghost' as const }
const revealWorktreeInSidebar = vi.fn()
useAppStore.setState({
repos: [
{
id: 'repo-1',
path: '/workspace/repo',
displayName: 'repo',
badgeColor: '`#000000`',
addedAt: 0
}
],
worktreesByRepo: { 'repo-1': [worktree] },
activeRepoId: 'repo-1',
activeView: 'terminal',
tabsByWorktree: {},
unifiedTabsByWorktree: {},
groupsByWorktree: {},
layoutByWorktree: {},
activeGroupIdByWorktree: {},
openFiles: [],
browserTabsByWorktree: {},
activeFileIdByWorktree: {},
activeBrowserTabIdByWorktree: {},
activeTabTypeByWorktree: {},
activeTabIdByWorktree: {},
tabBarOrderByWorktree: {},
pendingStartupByTabId: {},
settings: {
agentCmdOverrides: {},
setupScriptLaunchMode: 'new-tab',
customAgents: []
} as unknown as ReturnType<typeof useAppStore.getState>['settings'],
markWorktreeVisited: vi.fn(),
recordWorktreeVisit: vi.fn(),
refreshGitHubForWorktreeIfStale: vi.fn(),
revealWorktreeInSidebar
})
const result = activateAndRevealWorktree(worktree.id)
const state = useAppStore.getState()
const reopenedTab = state.tabsByWorktree[worktree.id]?.[0]
expect(result).toEqual({ primaryTabId: reopenedTab?.id })
expect(reopenedTab).toBeDefined()
expect(state.pendingStartupByTabId[reopenedTab!.id]).toBeUndefined()
expect(revealWorktreeInSidebar).toHaveBeenCalledWith(worktree.id)
})
it('does not reopen a worktree whose creation-time custom agent was disabled', () => {
const worktree = { ...makeWorktree(), createdWithAgent: 'custom:ghost' as const }
const revealWorktreeInSidebar = vi.fn()
useAppStore.setState({
repos: [
{
id: 'repo-1',
path: '/workspace/repo',
displayName: 'repo',
badgeColor: '`#000000`',
addedAt: 0
}
],
worktreesByRepo: { 'repo-1': [worktree] },
activeRepoId: 'repo-1',
activeView: 'terminal',
tabsByWorktree: {},
unifiedTabsByWorktree: {},
groupsByWorktree: {},
layoutByWorktree: {},
activeGroupIdByWorktree: {},
openFiles: [],
browserTabsByWorktree: {},
activeFileIdByWorktree: {},
activeBrowserTabIdByWorktree: {},
activeTabTypeByWorktree: {},
activeTabIdByWorktree: {},
tabBarOrderByWorktree: {},
pendingStartupByTabId: {},
settings: {
agentCmdOverrides: {},
setupScriptLaunchMode: 'new-tab',
customAgents: [
{
id: 'custom:ghost',
name: 'Ghost',
command: '/usr/local/bin/ghost',
promptMode: 'pty',
icon: { kind: 'terminal' },
enabled: false
}
]
} as unknown as ReturnType<typeof useAppStore.getState>['settings'],
markWorktreeVisited: vi.fn(),
recordWorktreeVisit: vi.fn(),
refreshGitHubForWorktreeIfStale: vi.fn(),
revealWorktreeInSidebar
})
const result = activateAndRevealWorktree(worktree.id)
const state = useAppStore.getState()
const reopenedTab = state.tabsByWorktree[worktree.id]?.[0]
expect(result).toEqual({ primaryTabId: reopenedTab?.id })
expect(reopenedTab).toBeDefined()
expect(state.pendingStartupByTabId[reopenedTab!.id]).toBeUndefined()
expect(revealWorktreeInSidebar).toHaveBeenCalledWith(worktree.id)
})

@AmethystLiang
AmethystLiang requested review from AmethystLiang and removed request for brennanb2025 July 13, 2026 22:27
Cloeille added 2 commits July 16, 2026 20:57
# Conflicts:
#	src/main/daemon/session.ts
#	src/main/ipc/pty.ts
#	src/main/runtime/orca-runtime.ts
#	src/preload/api-types.ts
#	src/preload/index.ts
#	src/renderer/src/components/native-chat/use-native-chat-toggle-shortcut.ts
#	src/renderer/src/components/tab-bar/TabBar.tsx
#	src/renderer/src/components/terminal-pane/TerminalPane.tsx
#	src/renderer/src/components/terminal-pane/pty-transport-types.ts
#	src/renderer/src/components/terminal-pane/pty-transport.ts
#	src/renderer/src/i18n/locales/en.json
#	src/renderer/src/i18n/locales/es.json
#	src/renderer/src/i18n/locales/ja.json
#	src/renderer/src/i18n/locales/ko.json
#	src/renderer/src/i18n/locales/zh.json
#	src/renderer/src/lib/launch-agent-background-session.ts
#	src/renderer/src/lib/launch-agent-web-host-tab.ts
#	src/renderer/src/runtime/web-runtime-session.ts
#	src/shared/runtime-types.ts
Two call sites still typed launchAgent as TuiAgent after merging
origin/main into feat/custom-agents, which broke tsc: RuntimePtyController's
spawn options and scheduleAgentBackgroundDraft's agent param. Both only
gate on presence/dispatch and already flow through isTuiAgent-aware
consumers, so widening is safe.

@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

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 084785cc-1df7-43a1-a191-6a18d15b01fc

📥 Commits

Reviewing files that changed from the base of the PR and between c1d6395 and 21c2113.

📒 Files selected for processing (3)
  • 2026-07-13-195002-this-session-is-being-continued-from-a-previous-c.txt
  • src/main/daemon/daemon-server.ts
  • src/main/daemon/session.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/main/daemon/daemon-server.ts
  • src/main/daemon/session.ts

Cloeille added 2 commits July 16, 2026 21:55
Code review of the merge-conflict resolution surfaced spots where
launchAgent was still narrowed to TuiAgent (or guarded inconsistently)
after widening the type to AgentId, so custom agents silently lost
functionality:

- pty-transport.ts: the outbound PTY spawn path filtered launchAgent
  with isTuiAgent instead of isAgentId, so custom agents never reached
  the daemon's Session.launchAgent, weakening process-group kill.
- launch-agent-background-session.ts: buildAgentStartupPlan was never
  given customAgents, so a custom agent launched via background/
  automation flows always failed to resolve its command.
- pty-connection.ts: indexing TUI_AGENT_CONFIG with an AgentId-typed
  value silently returned undefined for custom agents, disabling the
  startup-draft-paste readiness fallback.
- orca-runtime.ts: effectiveCreatedWithAgent was isAgentId-guarded in
  some spreads but only truthiness-checked in others; made consistent.
- pty-subprocess.ts: PtySubprocessOptions.launchAgent was still typed
  TuiAgent though a real AgentId can reach it; widened for accuracy.
2026-07-13-195002-this-session-is-being-continued-from-a-previous-c.txt
was an untracked local Claude Code session transcript sitting in the repo
root; it got swept in by `git add -A` while staging the origin/main merge
resolution and should never have been committed.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/renderer/src/lib/launch-agent-background-session.ts (1)

84-86: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Base the follow-up prompt check on the resolved startup plan for custom agents. agentConfig is null for custom agents, but buildAgentStartupPlan() still maps some of them to stdin-after-start and returns a followupPrompt. Those prompts never reach scheduleAgentBackgroundDraft() here, so custom interactive agents can launch without their prompt.

🧹 Nitpick comments (1)
src/main/runtime/orca-runtime.ts (1)

16448-16448: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use isAgentId for consistency.

While args.createdWithAgent is safe here because it is strictly passed from the caller where it was already validated, using isAgentId would keep the remote payload construction perfectly aligned with its local counterpart createManagedWorktree (e.g., line 16145).

♻️ Proposed refactor
-          ...(args.createdWithAgent ? { launchAgent: args.createdWithAgent } : {}),
+          ...(isAgentId(args.createdWithAgent) ? { launchAgent: args.createdWithAgent } : {}),

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0752f830-3ef7-4f38-82b7-842fc1d5c4d8

📥 Commits

Reviewing files that changed from the base of the PR and between 21c2113 and a5df2df.

📒 Files selected for processing (5)
  • src/main/daemon/pty-subprocess.ts
  • src/main/runtime/orca-runtime.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/lib/launch-agent-background-session.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/renderer/src/components/terminal-pane/pty-transport.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts

Cloeille added 2 commits July 16, 2026 22:14
The new Custom agents section in AgentsPane.tsx used plain descriptive
translate() keys (customAgents, disabled, enable, ...) while every other
string in the file follows the 10-char sha1 hash convention. Regenerated
via localize-renderer-strings.mjs so the keys match the rest of the file,
then synced the non-English locale catalogs.

The other flagged item (QuickLaunchButton hiding custom agents while TUI
detection is still loading) was already fixed in c1d6395 - verified via
git history and current behavior, no change needed.
# Conflicts:
#	src/renderer/src/lib/native-chat-supported-agent.ts
@Cloeille

Copy link
Copy Markdown
Author

@brennanb2025 / @AmethystLiang hey is this going to be processed soon in a patch version or in a minor release (1.X.0) ?
Tell me if you need any changes, it's a very cool feature.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants