Skip to content

fix(desktop): process pending terminal setups for already-initialized workspaces#1322

Merged
saddlepaddle merged 2 commits into
mainfrom
fix-spawn-claude-session-logic
Feb 8, 2026
Merged

fix(desktop): process pending terminal setups for already-initialized workspaces#1322
saddlepaddle merged 2 commits into
mainfrom
fix-spawn-claude-session-logic

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Feb 8, 2026

Summary

Two bugs fixed in the spawn Claude session flow:

  1. Pending terminal setups never processed for already-initialized workspacesWorkspaceInitEffects only processed setups when initProgress[workspaceId].step === "ready". For workspaces that were already initialized, initProgress had been cleared, so the pending terminal setup was never processed.

  2. Default preset silently lost when appending commands during initialization — When start_claude_session appended a command to an existing pending setup (created by useCreateWorkspace), pending?.defaultPreset ?? null coerced undefined to null. Since WorkspaceInitEffects only fetches the preset from the backend when defaultPreset === undefined, this prevented preset application.

Changes

  • WorkspaceInitEffects.tsx: Process pending terminal setups immediately when no initProgress entry exists (workspace already initialized)
  • start-claude-session.ts: Use ternary to preserve undefined vs null distinction for defaultPreset

Test plan

  • Call start_claude_session via MCP for an already-initialized workspace and verify Claude session starts
  • Call create_workspace then start_claude_session in quick succession and verify both workspace init commands AND Claude session run, with default preset applied
  • Call start_claude_subagent for the active workspace and verify it still works
  • Normal workspace creation flow (without MCP) and verify terminals still create correctly with presets

Summary by CodeRabbit

  • Bug Fixes
    • Already-initialized workspaces now trigger immediate processing and complete their pending terminal setup reliably.
    • Starting a session now preserves an explicitly unspecified preset versus no pending setup, preventing unintended default selection.

… workspaces

WorkspaceInitEffects only processed pending terminal setups when a
matching initProgress entry existed with step "ready". When
start_claude_session was called via MCP for a workspace that was
already initialized, no initProgress entry existed (it had been
cleared after initial setup), so the pending terminal setup was
never processed and the Claude session never started.

Handle the case where a pending setup has no corresponding
initProgress entry by treating the workspace as already ready and
processing the setup immediately.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Adds an immediate processing path in WorkspaceInitEffects to run terminal setup when no initProgress entry exists, and adjusts how defaultPreset is preserved when adding pending terminal setups in start-claude-session.ts to distinguish an existing pending object with an undefined preset from no pending object.

Changes

Cohort / File(s) Summary
Workspace init effect
apps/desktop/src/renderer/screens/main/components/WorkspaceInitEffects.tsx
Adds a branch that treats absent initProgress as already-initialized: marks workspace processing, calls handleTerminalSetup, then removes pending setup and clears processing before falling back to the existing progress-based logic.
Start Claude session / pending preset handling
apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/start-claude-session.ts
Changes defaultPreset passed to addPendingTerminalSetup from pending?.defaultPreset ?? null to pending ? pending.defaultPreset : null, preserving undefined when a pending object exists but has no defaultPreset, while using null when there is no pending object.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰
I hopped where initProgress was none,
Marked it busy, set the terminal spun.
Cleared the wait and tidied the mess—
A tiny rabbit, making setups bless. 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(desktop): process pending terminal setups for already-initialized workspaces' directly summarizes the main change, which is processing pending terminal setups for workspaces without initProgress entries.
Description check ✅ Passed The pull request description includes all required template sections with comprehensive content: clear summary explaining both bugs, detailed changes, test plan with specific scenarios, and related issue context. All major sections are complete and well-documented.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-spawn-claude-session-logic

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

…ing setup

When start_claude_session appends a command to an existing pending
terminal setup, `pending?.defaultPreset ?? null` coerces `undefined`
to `null`. This prevents WorkspaceInitEffects from fetching the
default preset from the backend (it only fetches when
`defaultPreset === undefined`).

Use a ternary to preserve the original value: when an existing
pending setup has `undefined`, keep it so the preset fetch still
triggers.
@saddlepaddle saddlepaddle merged commit 68b7a28 into main Feb 8, 2026
6 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 8, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

@Kitenite Kitenite deleted the fix-spawn-claude-session-logic branch February 9, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant