Skip to content

feat: queue sessions while workspace is provisioning#440

Open
matt2e wants to merge 10 commits intomainfrom
queue-while-provisioning
Open

feat: queue sessions while workspace is provisioning#440
matt2e wants to merge 10 commits intomainfrom
queue-while-provisioning

Conversation

@matt2e
Copy link
Contributor

@matt2e matt2e commented Mar 23, 2026

Summary

  • Adds a Queued session status variant so sessions can be created before a workspace is ready
  • Implements queue_branch_session and drain_queued_sessions backend commands to enqueue sessions and start them once the workspace is provisioned
  • Updates the UI (NewSessionModal, BranchCard, BranchCardSessionManager) to detect when a workspace isn't ready and queue sessions instead of starting them immediately
  • Adds drain triggers on session completion, workspace provisioning, and startup to automatically process queued sessions

Test plan

  • Create a session on a branch whose workspace is still provisioning — verify it shows as queued
  • Confirm queued sessions automatically start once the workspace finishes provisioning
  • Verify that completing or cancelling a running session drains the next queued session
  • Ensure sessions start normally when the workspace is already available

🤖 Generated with Claude Code

@matt2e matt2e requested review from baxen and wesbillman as code owners March 23, 2026 02:37
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7e6fc77271

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +971 to +973
branch_id: Some(branch_id.clone()),
project_id: None,
session_type: None,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Populate project metadata when draining a queued session

When a queued branch session is started here, the emitted running event still has project_id: None. listenForSessionStatus only registers running sessions when eventProjectId is present (/workspace/builderbot/apps/staged/src/lib/listeners/sessionStatusListener.ts:40-47), and terminal events from emit_status do not include branch context (/workspace/builderbot/apps/staged/src-tauri/src/session_runner.rs:1012-1020). In a branch with 2+ queued items, the first drained session therefore completes as an unknown session, so handleSessionEnd never calls drainQueuedSessions for the next item and the queue stalls after one run.

Useful? React with 👍 / 👎.

Comment on lines +731 to +737
pub fn queue_branch_session(
store: tauri::State<'_, Mutex<Option<Arc<Store>>>>,
branch_id: String,
prompt: String,
session_type: BranchSessionType,
provider: Option<String>,
) -> Result<BranchSessionResponse, String> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve image attachments when queueing a branch session

The modal submits imageIds for queued sessions (/workspace/builderbot/apps/staged/src/lib/features/sessions/NewSessionModal.svelte:107-109 and /workspace/builderbot/apps/staged/src/lib/features/branches/BranchCardSessionManager.svelte.ts:259-265), but this command has no image_ids parameter and never persists them. Later drainQueuedSessions is always invoked with imageIds: null (/workspace/builderbot/apps/staged/src/lib/commands.ts:572-577), so session_runner::start_session creates the eventual user message without any attachments (/workspace/builderbot/apps/staged/src-tauri/src/session_runner.rs:207-218). Queued commit/review sessions that rely on screenshots will silently lose that context.

Useful? React with 👍 / 👎.

Comment on lines +767 to +768
let review = store::Review::new(&branch_id, "", store::ReviewScope::Branch)
.with_session(&session.id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Capture the review tip SHA before queueing review sessions

The normal review path stores the current tip SHA on the Review row (/workspace/builderbot/apps/staged/src-tauri/src/session_commands.rs:648-660), but the queued path hard-codes an empty commit_sha and drain_queued_sessions never patches it later. Opening that saved review reuses review.commitSha (/workspace/builderbot/apps/staged/src/lib/features/branches/BranchCard.svelte:392-399), and the local diff builder treats Some("") as the target rev instead of falling back to HEAD (/workspace/builderbot/apps/staged/src-tauri/src/diff_commands.rs:97-104). For queued reviews on local branches, the review can finish, but reopening its diff later points Git at an invalid ref.

Useful? React with 👍 / 👎.

matt2e and others added 10 commits March 23, 2026 16:39
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ands

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ing, and startup

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… timeline

Queued sessions were previously misclassified as failed. Now they
display "Queued" as their subtitle and sort after active rows in the
branch card timeline (Completed < Active < Queued).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…egisters drained sessions

When drain_queued_sessions started a queued session, it emitted the
session-status-changed event with project_id: None and session_type: None.
The frontend sessionStatusListener requires project_id to register a
running session, so drained sessions were never tracked. When they later
completed, the listener couldn't look up their branch_id, preventing
drainQueuedSessions from being called for the next item in the queue.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add queued-commit, queued-note, and queued-review TimelineItemType
variants so queued sessions display a Clock icon rather than a
loading spinner, making it clear they are waiting rather than active.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
When a commit session completes and there are queued sessions waiting
for the same branch, skip triggering the auto-review. The queued
session takes priority and will be drained next instead.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…one spinners

Replace the "Creating worktree…" loading div and the RemoteWorkspaceStatusView
for 'starting' status with provisioning timeline rows that appear at the very
start of the timeline with gray styling and a spinner icon, consistent with
active session rows.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@matt2e matt2e force-pushed the queue-while-provisioning branch from 6d46fb7 to 9ed0b8d Compare March 24, 2026 03:07
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