Skip to content

feat(agents): launch profiles — run one agent under several credential homes or providers at once - #18674

Draft
ColorC wants to merge 12 commits into
stablyai:mainfrom
ColorC:feat/agent-launch-profiles
Draft

ColorC wants to merge 12 commits into
stablyai:mainfrom
ColorC:feat/agent-launch-profiles

Conversation

@ColorC

@ColorC ColorC commented Sep 4, 2026 •

Copy link
Copy Markdown

ELI5

Today Orca can hold several Codex or Claude accounts, but only one of them is "the" account at a time, and API-key or proxy providers have no seat at all. This PR adds launch profiles: when you start an agent you can say "run this one under my second Codex home" or "run this one against my work proxy", per launch. Two panes on the same host can then run the same CLI under different accounts or providers side by side. Launching without a profile is unchanged.

What Changed

  • Shared contract src/shared/agent-launch-profile/: two built-in secondary-home profiles (codex-secondary-home → CODEX_HOME=~/.codex-2, claude-secondary-home → CLAUDE_CONFIG_DIR=~/.claude-2, both overridable with ORCA_*_SECONDARY_HOME) plus user-defined settings.agentLaunchProfiles rows (args + env, tokenized for the launch shell exactly like agentDefaultArgs). Ids are slugs; built-ins cannot be shadowed.
  • Host: terminal.createAgentSession, session.tabs.createTerminal and worktree.create take an optional launchProfileId / startupLaunchProfileId. The host resolves it against its own catalog and raises agent_session_launch_profile_unknown or _agent_mismatch; _remote_unsupported is raised at SSH spawn only when the session never learned the remote home. New capability agent-session.launch-profile.v1.
  • Execution host: a secondary-home launch only carries a marker (ORCA_CODEX_HOME_PROFILE / ORCA_CLAUDE_CONFIG_DIR_PROFILE); the daemon spawn turns it into the real directory (WSL: the distro home) and consumes the marker. Such launches skip managed Codex home selection, the managed-auth wait and the hook preflight; skip managed Claude credential materialization and auth-env stripping; and are recorded in codex-pane-accounts.json as custom-home with launchProfileId, so stale-account prompts never name them.
  • SSH lane: the env reaches the relay as a literal map, so the secondary home is joined from the remote home and platform the session probed at connect time (in the remote's path flavor) and the marker is dropped before the spawn RPC. Without that probe the launch fails with the named error rather than starting on the remote default home.
  • Desktop: the tab-bar agent row becomes a submenu (Default launch + one item per profile) when profiles exist for that agent. The New Workspace composer gets a Launch profile select under the agent picker, shown only when the chosen agent has profiles; the profile is layered into the startup command/env the renderer already sends, so worktree.create needs no new field on that path.
  • Mobile: the new-tab sheet lists each agent's profiles beneath its default launch once the host advertises the capability (an older host never gets a profile id it would ignore), a Codex profile launch bypasses the structured chat path it cannot ride, and a terminal tab shows a small badge with the profile it runs under.
  • Paired web: launchProfileId rides the structured create; the legacy env-only create is refused on hosts that lack the capability instead of launching unvalidated.
  • CLI: orca worktree create --agent codex --launch-profile codex-secondary-home.
  • Status attribution: AgentStatusEntry.launchProfileId (optional) is stamped by main from a small per-pty registry (agent-launch-profile-panes.json, mirroring the Codex pane account registry) so desktop and paired clients can show which profile a pane runs under; it survives daemon reattach across restarts.
  • In-process local lane: fresh spawns routed to LocalPtyProvider resolve the home marker too (after the host env, so it wins over an injected managed home) and export a WSL-resolved home through WSLENV, matching the daemon lane.
  • Opt-in: the pickers are behind a new agentLaunchProfilesEnabled setting (Settings → Agents → Agent launch profiles, off by default, searchable). With it off nothing in the UI changes; the RPC fields and the CLI flag accept a profile id regardless. The strict client settings schema now also lists agentLaunchProfiles so paired clients can save profiles over RPC.
  • Docs: docs/reference/agent-launch-profiles.md.

Why

Relation to open work: this is the per-launch primitive underneath rp0927's pinned-account stack (#13270–#13275) and #10394 (import existing CODEX_HOME); a pinned managed account can later become one more home source of a profile.

Linked Issue

Addresses #8770 (CLI selection via --launch-profile) and the launch-scoped half of #2314. Refs #9129.

Visual Proof

Tab-bar quick-launch menu and the New Workspace composer (below), captured with the setting turned on; with the default (off) setting both surfaces look exactly like the base. Mobile picker/badge screenshots will be added before this leaves draft. Web, CLI and host changes have no visual change.

Before (base) After
Quick-launch menu before: Codex and Claude are flat items Quick-launch menu after: Codex opens a submenu with Default launch, the built-in secondary home and a custom profile

Composer: the Launch profile select appears under the agent picker only when the chosen agent has profiles (before: no such control).

New Workspace composer with the Launch profile select open under Codex

An agent with no profiles keeps its flat item and no composer select. Captured with tests/e2e/agent-launch-profile-quick-launch-screenshot.spec.ts (opt-in via ORCA_LAUNCH_PROFILE_SHOTS; the "before" frame is the same spec in baseline mode on the base commit).

Testing

  • Unit: src/shared/agent-launch-profile/*.test.ts, src/main/agent-launch-profile/*.test.ts, src/main/codex/codex-pane-account-registry-launch-profile.test.ts, src/main/providers/ssh-pty-spawn-env.test.ts, src/renderer/src/lib/launch-agent-profile.test.ts, src/renderer/src/hooks/composer-state/quick-startup-plan.test.ts, src/renderer/src/components/NewWorkspaceComposerCard.test.tsx (profile picker case), src/cli/handlers/worktree-startup-agent-flags.test.ts; mobile: mobile/src/session/mobile-new-tab-agent-options.test.ts, mobile-new-tab-agent-loader.test.ts, mobile-terminal-tab-agent.test.ts, mobile-launch-profile-labels.test.ts, use-mobile-session-terminal-create-actions.test.ts.

  • E2E: tests/e2e/agent-launch-profile-conformance.spec.ts — a headless paired host plus an env-echo fake agent; asserts over RPC only that both secondary homes resolve under the host's HOME, the marker is consumed, a plain launch stays profile-free, and the two error codes fire. Passes on Windows (electron-headless). tests/e2e/agent-launch-profile-quick-launch-screenshot.spec.ts is the opt-in @headful capture behind the screenshots above.

  • Static gates from the PR workflow run locally against the base commit and pass: check:code-quality:changed (incl. type-aware and React Doctor), the max-lines / ts-nocheck / runtime-Electron ratchets, Zustand fan-out, reliability-gate manifest, root-directory guard, and the four localization verifications. pnpm typecheck (node, cli, web) passes. Full pnpm test and pnpm build are left to CI.

  • Platforms exercised locally: Windows 10 (daemon spawn, PowerShell). WSL and SSH resolution are unit-tested; macOS/Linux and a live SSH host are not exercised.

  • I manually tested these changes locally

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

AI Disclosure

Implemented with Claude (Claude Code); reviewed and driven by a human.

Review

  • Cross-platform: marker resolution uses path.join and homedir(); WSL resolves inside the distro home and is exported through the existing WSLENV path; nothing platform-specific in the renderer.
  • SSH/remote: secondary homes resolve from the connect-time remote home probe in the remote path flavor and fail closed when the probe is absent; args-only profiles pass through the existing quoting path (planAgentCliArgsSuffix). Resolution sits in main because the session already holds the probe; the relay is version-locked to the app, so moving this into the relay's buildSpawnEnv (which would also honor an ORCA_*_SECONDARY_HOME override set on the remote box) is a possible follow-up rather than a compatibility concern.
  • Agents/integrations: only Codex and Claude have home profiles; every other agent can use args/env profiles. Managed-account paths are bypassed only when a home marker is present.
  • Backwards compatibility: every new wire field is optional; hosts advertise a capability; clients refuse the env-only fallback on old hosts.
  • Performance: no new I/O on the plain launch path; profile resolution is an in-memory lookup.
  • UI: submenu and composer select use the existing dropdown/select primitives and tokens; en/zh catalogs updated. Mobile has no i18n layer; its strings follow the existing inline-English pattern.
  • Security: profile env values are stored like agentDefaultEnv (settings) and never logged; markers are consumed on the execution host so a nested launch cannot re-resolve them.

Checklist

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

…credential homes at once

A launch profile pins one launch of a CLI agent to a credential home and/or process-local
overrides, selected per launch instead of through the global managed-account slot. Two panes
on the same host can now run Codex (or Claude Code) under different accounts, or against
different model providers, side by side.

- shared: `agent-launch-profile` contract with two built-ins (`codex-secondary-home`,
  `claude-secondary-home`) and user-defined `settings.agentLaunchProfiles` (args/env, same
  shell tokenization as `agentDefaultArgs`); ids are slugs, built-ins cannot be shadowed.
- host: `terminal.createAgentSession`, `session.tabs.createTerminal` and
  `worktree.create` accept an optional `launchProfileId` / `startupLaunchProfileId`; the host
  resolves it against its own catalog and raises `agent_session_launch_profile_unknown`,
  `_agent_mismatch` or `_remote_unsupported`. Capability `agent-session.launch-profile.v1`.
- execution host: a secondary-home launch carries only a marker
  (`ORCA_CODEX_HOME_PROFILE` / `ORCA_CLAUDE_CONFIG_DIR_PROFILE`); the daemon spawn turns it
  into `~/.codex-2` / `~/.claude-2` (WSL: the distro home), overridable with
  `ORCA_CODEX_SECONDARY_HOME` / `ORCA_CLAUDE_SECONDARY_HOME`. Such launches skip managed
  Codex home selection, the managed-auth wait and the hook preflight, skip managed Claude
  credential materialization and auth-env stripping, and are recorded in
  `codex-pane-accounts.json` as `custom-home` with `launchProfileId` so stale-account prompts
  never name them.
- desktop: the tab-bar agent row becomes a submenu when profiles exist.
- paired web: `launchProfileId` rides the structured create; the legacy env-only create is
  refused on hosts without the capability instead of launching unvalidated.
- cli: `orca worktree create --agent <id> --launch-profile <id>`.
- e2e: `agent-launch-profile-conformance.spec.ts` asserts the contract over RPC only, so the
  same expectations hold for any client; the headless host helper gains a `settings` seed.

Refs stablyai#2314, stablyai#8770. Related: stablyai#13270-stablyai#13275, stablyai#10394.
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Test User and others added 11 commits September 4, 2026 23:44
…e-read

parseRegistry whitelists fields when codex-pane-accounts.json is read back, so the
launchProfileId written for a secondary-home launch was dropped on the next restart and the
pane could be misattributed again. Validate and carry it; the record validators move to
codex-pane-account-record-validation.ts to stay within the file budget.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Stamp `launchProfileId` onto agent status rows so desktop and paired clients can tell which
profile (secondary home, custom provider) a pane is running under. The profile is baked into the
PTY env at spawn and the daemon keeps shells alive across restarts, so a small per-pty registry
(`agent-launch-profile-panes.json`, mirroring the Codex pane account registry) records it at
spawn commit, drops it on real teardown, and both the hook-status listener and the mobile
projections read it back by pty id. New optional field only; no wire opcode changes.

Also adds an opt-in @headful e2e that captures the quick-launch submenu screenshots.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
… lane too

Only the daemon spawn turned a secondary-home marker into a real directory; a fresh spawn
routed to the in-process LocalPtyProvider kept the marker and launched on the default home.
Resolve it after the host env is built (so it wins over an injected managed home) and export
a WSL-resolved home as a Linux path through WSLENV, mirroring the daemon lane.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Re-detect agents after the golden stub is configured (detection is cached per
context before the override exists), force the English catalog, close the root
menu fully between captures, and crop to the menu. A baseline mode captures the
same menu on the base branch, which has no launch-profile settings.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…rrows

isAgentLaunchProfileId is a `value is string` guard, so the rejected branch
sees `never` and trips restrict-template-expressions in the type-aware gate.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
The tab strip badges a terminal tab with the launch profile the host stamps on
its agent status (built-ins shortened to their distinguishing half, custom ids
as-is). The new-tab picker lists each agent's profiles beneath its default
launch, but only when the host advertises agent-session.launch-profile.v1, so
an older host never silently starts the default launch under a profile's
name. A Codex launch with a profile skips the structured chat path, which
cannot carry one, and goes through session.tabs.createTerminal.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
The SSH lane ships its env to the relay as a literal map, so nothing there can
expand a home. The session already probes the remote home and platform when it
connects; the spawn env builder now joins the secondary home from that probe in
the remote's path flavor and drops the marker. When the probe is missing the
launch fails with agent_session_launch_profile_remote_unsupported instead of
silently starting on the remote default home, and the request resolver no
longer refuses SSH targets up front.

Also tracks docs/reference/agent-launch-profiles.md: docs/** is ignored unless
allow-listed, so the reference never made it into the earlier commits.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…poser

A Launch profile select sits under the agent picker and only renders when the
chosen agent has profiles. The selection is validated during render against
the current catalog and reset when the agent changes. The composer already
builds the startup command and env itself, so the profile is layered in
through the shared launch helper and rides to the host in startupEnv; a stale
id that races a settings change falls back to the default launch.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…roof spec

Also dismisses the recoverable-error dialog before every interaction and
retries opening the composer around it, since the dialog can land between
steps on the e2e profile.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
Reviewers flagged the extra submenu and select as UI weight most users never
need. A new agentLaunchProfilesEnabled setting (Settings > Agents, off by
default, searchable) now decides whether the tab bar, the New Workspace
composer and the Orca Mobile picker offer profiles at all; the RPC fields and
the CLI flag keep accepting a profile id regardless. The client settings
schema is strict and never listed agentLaunchProfiles, so paired clients could
not save profiles over RPC; both keys are registered now.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
…roof spec

The sidebar entry point differs between Orca and downstream builds; the
new-workspace-composer modal action is the contract both share.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_0195oeVTHwh8oYesB2Ln6bao
@dlgochan

dlgochan commented Oct 2, 2026 •

Copy link
Copy Markdown

Update: the official contribution is now stablyai/orca#25066, covering named Claude/Codex profiles with managed-account and existing-home bindings. The earlier ColorC/orca-lite#1 draft is closed and superseded. The official PR documents synthetic integration evidence, current-app screenshots and native-auth limits. The original branch-specific reproduction below remains historical context.


I tested an existing-home case while investigating #2284. At head f8fc5df98daf98ac3a42627bc3d724daa8da59e9, a custom Claude profile can still take the managed-auth preparation path and lose its explicit home.

Reproduction added to the existing src/main/ipc/pty-spawn-env-terminal-basics.test.ts harness:

  1. Apply a custom profile { id: 'claude-work', agent: 'claude', source: 'custom', label: 'Work', env: { CLAUDE_CONFIG_DIR: '/tmp/external-claude-work' } } with applyAgentLaunchProfile.
  2. Register prepareClaudeAuth returning { configDir: '/tmp/selected-managed-account', envPatch: { CLAUDE_CONFIG_DIR: '/tmp/selected-managed-account' }, stripAuthEnv: true, provenance: 'managed:account-1' }.
  3. Send pty:spawn with command: 'claude' and the resulting profile env.
  4. Assert the env passed to the PTY retains /tmp/external-claude-work, and that managed-auth preparation was not invoked.

The first assertion fails: the PTY receives /tmp/selected-managed-account. The preflight bypass checks only hasAgentLaunchProfileHomeMarker; custom env profiles have no secondary-home marker. spawn-env.ts then overlays claudeAuth.envPatch onto the explicit profile env. Even when that patch is empty, this route still invokes managed-auth preparation for a launch intended to use an external home.

Validation: unchanged file 27 passed; with this regression 27 passed, 1 failed, in an isolated Linux container with mocked PTY/auth preparation and synthetic paths. No real credentials or native OAuth were exercised. This is AI-assisted testing, not a claim of live-account validation.

Would it fit this PR to treat a validated custom Claude home as an explicit external-home launch, alongside built-in home profiles, and share that decision across desktop/runtime preparation? I can contribute the focused regression and fix if this remains the intended landing branch; I'm coordinating against the overlapping profile/auth work in #2284 rather than introducing another catalog.

Update: the runtime-controller path reproduces the same failure. I opened a focused draft follow-up against this feature branch: ColorC/orca-lite#1. It records explicit profile-home provenance during composition, so a home inherited from agentDefaultEnv does not change args-only profile behavior. Both preflights use that provenance; child environments consume it while the original launch environment remains reusable. 55 tests / 3 files, Node/web/CLI TypeScript checks and changed-code quality pass. Full application/native/SSH integration limits are documented in the draft. This is offered as a complementary fix, without assuming a decision on the broader landing branch.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants