Skip to content

fix(agents): open a shell in empty workspaces when no default set - #36734

Closed
anmol0b wants to merge 1 commit into
stablyai:mainfrom
anmol0b:fix/auto-default-no-empty-workspace-chat
Closed

anmol0b wants to merge 1 commit into
stablyai:mainfrom
anmol0b:fix/auto-default-no-empty-workspace-chat

Conversation

@anmol0b

@anmol0b anmol0b commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

ELI5

If you never picked a default agent (the Default Agent setting is still on "Auto"), opening an empty workspace started a chat with whichever agent comes first in Orca's list, which is Claude. Someone who meant to use Codex got a Claude tab they never asked for. Now an empty workspace opens a plain shell until you save a default agent. A saved agent or Blank Terminal default works exactly as before.

What Changed

When you open a workspace with no tabs, ensureWorktreeHasInitialTerminal calls openDefaultAgentChatInEmptyWorkspace. That function passes settings.defaultTuiAgent to pickTuiAgent, and with null it falls back to the first agent detected, in TUI_AGENT_AUTO_PICK_ORDER order. Claude is first in that list, so a Claude chat started without any click.

defaultChatDetectionTarget now returns undefined unless a real agent is saved as the default. Before, it only did this for 'blank'. All three exports in the file go through it, so with Auto:

  • openDefaultAgentChatInEmptyWorkspace returns null and the seeding step creates its usual shell.
  • emptyWorkspaceDefaultChatAwaitsDetection and loadEmptyWorkspaceDefaultChatDetection no longer hold the workspace for up to 5 s waiting on agent detection that could no longer open anything.

What stays the same:

  • A saved agent still opens as a chat. If it isn't installed on that host, the next detected agent still opens instead, as fix(native-chat): an empty workspace opens the default agent as a chat when chat is the default view #23693 intended ("the same fallback the new-agent-tab shortcut uses").
  • Blank Terminal still opens a shell.
  • Workspaces that already have tabs and folder workspaces behave as before.
  • Every place where you click to launch an agent (the tab bar, shortcuts, quick workspace, source control, the dashboard) still lets Auto pick one, because there you asked for an agent.

Why

This empty-workspace path is the only one that starts an agent without a click. #23693 made it opt-in so it "can never start an unrequested agent". A default you never picked isn't a choice to act on. The onboarding folder path (onboardingFolderDefaultAgent) already treats an unset default as no agent; this makes the empty-workspace path agree.

Rejected alternatives:

Linked Issue

Fixes #36594

Visual Proof

Default agent left on Auto, Claude and Codex detected, empty workspace opened from the sidebar. Captured on macOS from a hidden Electron run.

Before (main): a Claude Chat tab opens without being asked for.
image

After: the workspace opens a plain shell (Terminal 1).
image

Testing

I reproduced the bug on upstream/main first. With getDefaultSettings() (defaultTuiAgent: null) and claude and codex both detected, openDefaultAgentChatInEmptyWorkspace launched claude.

I added two checks in empty-workspace-default-agent-chat.test.ts:

  • No saved default: launchAgentInNewTab is never called. The test asserts no launch at all, not just "not Claude", so a fix that only reorders the list still fails it.
  • No saved default, agent list not loaded: the workspace doesn't wait for detection on an SSH host.

Both fail with the fix reverted and pass with it.

Commands run:

  • pnpm test on empty-workspace-default-agent-chat.test.ts and worktree-activation-default-agent-chat.test.ts (21/21)
  • pnpm tc:web
  • oxlint and oxfmt --check on the changed files
  • check:code-quality:changed (0 new findings)

Hidden-Electron e2e run on macOS, same steps on main and on this branch: Claude Chat before, Terminal 1 after.

Ran on macOS only. I didn't run it by hand on Linux, Windows or a real SSH host; the SSH wait is covered by the unit test.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

AI Disclosure

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Mobile isn't changed. Its create-workspace picker shows the preselected agent and you confirm it before anything starts, so nothing launches silently. No setting is migrated and nothing between client and host changes, so mixed versions are unaffected.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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)

@coderabbitai

coderabbitai Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b5ea853c-d995-4dd8-bcf4-d68fcd1a5a5b
Commits

Reviewing files that changed from the base of the PR and between 24d1d10 and 7f6a96e.

Files selected for processing: 2
  • src/renderer/src/lib/empty-workspace-default-agent-chat.test.ts
  • src/renderer/src/lib/empty-workspace-default-agent-chat.ts

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

Walkthrough

When defaultTuiAgent is unset, default-chat detection now skips agent selection. Tests verify that opening an empty-workspace chat does not launch an agent and that detection does not wait for remote detected-agent data.

Severity of issue fixed: Medium

Merge Risk: Minimal · up to 7f6a9

The change preserves saved-agent behavior while preventing unintended automatic agent launches for untouched Auto settings.

Pre-merge checks: Passed 4 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #36594 is the only active directly linked issue, so its coding requirements apply. Desktop requirements are met at head 7f6a96e. In src/renderer/src/lib/empty-workspace-default-agent-chat.ts, de… Establish whether the mobile workspace-creation picker preselects an agent from catalog order when defaultTuiAgent is null, and whether that preselection can start an agent without an explicit user confirmation. Read mobile/src/tasks/worksp…
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: opening a shell in empty workspaces when no default agent is set.
Description check Passed The description follows the required template and explains the user-visible behavior, implementation, rationale, linked issue, visual proof, testing, scope, and checklist status. It also documents tha…
Out of Scope Changes check Passed The PR changes two files: src/renderer/src/lib/empty-workspace-default-agent-chat.ts (about +3/-5 lines) and src/renderer/src/lib/empty-workspace-default-agent-chat.test.ts (+11 lines). Both files dir…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Description check

Explanation

The description follows the required template and explains the user-visible behavior, implementation, rationale, linked issue, visual proof, testing, scope, and checklist status. It also documents that full lint, typecheck, test, and build commands were not run locally but are expected to be covered by CI.

Full details: Out of Scope Changes check

Explanation

The PR changes two files: src/renderer/src/lib/empty-workspace-default-agent-chat.ts (about +3/-5 lines) and src/renderer/src/lib/empty-workspace-default-agent-chat.test.ts (+11 lines). Both files directly serve #36594. The source change adds the unset-default condition to defaultChatDetectionTarget, which gates the empty-workspace launch and the detection wait. The added tests cover the no-launch and no-wait cases for Auto. The saved-agent fallback, blank-terminal, and SSH detection tests cover behavior the issue requires preserved. No unrelated file or hunk appears in the PR summary. The file list comes from the PR summary and the head file contents, because the diff tool could not read the changed blobs; this limits confidence in completeness but shows no unrelated change.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. 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 1 functions across 2 files.

Full details: Linked Issues check

Explanation

Issue #36594 is the only active directly linked issue, so its coding requirements apply. Desktop requirements are met at head 7f6a96e. In src/renderer/src/lib/empty-workspace-default-agent-chat.ts, defaultChatDetectionTarget returns undefined when defaultTuiAgent is null, so openDefaultAgentChatInEmptyWorkspace returns null and the workspace seeds a shell. A saved agent still opens a chat through pickTuiAgent, and 'blank' still opens a shell. The three exports all use this helper, so the wait for detection is also skipped for Auto. The test file adds 'starts no agent when no default agent was saved', which asserts that launchAgentInNewTab is never called, and a waiting test that covers defaultTuiAgent null. Mobile is not established. The issue acceptance criteria name mobile: the mobile workspace-agent selection falls back to catalog order when the default is unset, including while detection is unresolved, and the issue asks for an explicit, stable choice there. The PR states that mobile is unchanged and that its picker requires confirmation before launch. That claim was not verified: mobile/src/tasks/workspace-agent-selection.ts was not read, and the inspection budget was spent. The diff tool also could not read the changed blobs, so the base-to-head change set rests on the PR summary and the head file contents.

Resolution

Establish whether the mobile workspace-creation picker preselects an agent from catalog order when defaultTuiAgent is null, and whether that preselection can start an agent without an explicit user confirmation. Read mobile/src/tasks/workspace-agent-selection.ts at head, together with its caller, for that question. If mobile preselects an agent without a choice, the mobile acceptance criterion in #36594 is unmet and the change needs a matching mobile fix or a documented scope decision by the issue owner. If the picker requires a user confirmation before any launch, record that evidence and this check can pass.

  • 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

@AmoabaKelvin

Copy link
Copy Markdown
Collaborator

Thanks @anmol0b, this was the right diagnosis. We landed the fix in #36927, which also reads the paired host's own default, so I'm closing this one.

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.

[Bug]: Auto default can open an unrequested Claude chat in an empty workspace

2 participants