Skip to content

Fix /orchestrate slash command not detected due to race condition with shell startup#12658

Draft
seemeroland wants to merge 1 commit into
masterfrom
oz-agent/APP-4748/fix-orchestrate-race-condition
Draft

Fix /orchestrate slash command not detected due to race condition with shell startup#12658
seemeroland wants to merge 1 commit into
masterfrom
oz-agent/APP-4748/fix-orchestrate-race-condition

Conversation

@seemeroland

Copy link
Copy Markdown
Contributor

Description

Fix a race condition where /orchestrate (and other LOCAL-gated slash commands like /open-file, /open-repo) wouldn't appear in the slash command menu when typed immediately after shell startup.

Root cause: SlashCommandDataSource::active_commands_context determines whether to set the Availability::LOCAL flag by calling ActiveSession::session_type(), which returns Option<SessionType>. Before the shell finishes bootstrapping, this returns None. The previous check used is_some_and(|st| st == SessionType::Local), which evaluates None as false — so LOCAL was never set during the window before bootstrap completes.

Fix: Use is_none_or(|st| st == SessionType::Local) to treat an absent session (not yet initialized) as local. This matches the permissive default already used in ActiveSession::location_for_path (Some(SessionType::Local) | None => ...). Once the session finishes bootstrapping, the existing ActiveSessionEvent::Bootstrapped subscription on SlashCommandDataSource calls recompute_active_commands, so any remote session that temporarily showed LOCAL-gated commands will correctly remove them at that point.

Linked Issue

Testing

  • The linked issue is labeled ready-to-spec or ready-to-implement.

  • Where appropriate, screenshots or a short video of the implementation are included below (especially for user-visible or UI changes).

  • I have manually tested my changes locally with ./script/run

Agent Mode

  • Warp Agent Mode - This PR was created via Warp's AI Agent Mode

Conversation: https://staging.warp.dev/conversation/c25a7fe3-d153-4859-bf22-03d7f68705e3
Run: https://oz.staging.warp.dev/runs/019eccab-4042-7ed0-ad64-5cbc075d460b
This PR was generated with Oz.

When the user types a slash command quickly after opening a new terminal
tab, the shell may not have finished bootstrapping yet. In this state,
`ActiveSession::session_type()` returns `None` (no active session ID
or session not yet registered). The `is_local` check was using
`is_some_and` which evaluates `None` as `false`, so `Availability::LOCAL`
was never set during early shell startup.

Commands that require `Availability::LOCAL` (e.g. `/orchestrate`,
`/open-file`, `/open-repo`) were therefore absent from the slash-command
menu until the first `ActiveSessionEvent::Bootstrapped` or
`UpdatedPwd` event fired.

Fix: use `is_none_or` to treat an absent session type as local — the
same permissive default already used in `ActiveSession::location_for_path`.
When the session finishes bootstrapping, `recompute_active_commands` is
called via the existing `ActiveSessionEvent::Bootstrapped` subscription,
so a remote session that started with an unknown type will correctly
remove the LOCAL flag at that point.

Fixes APP-4748

Co-Authored-By: Oz <oz-agent@warp.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant