Fix /orchestrate slash command not detected due to race condition with shell startup#12658
Draft
seemeroland wants to merge 1 commit into
Draft
Fix /orchestrate slash command not detected due to race condition with shell startup#12658seemeroland wants to merge 1 commit into
seemeroland wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fix a race condition where
/orchestrate(and otherLOCAL-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_contextdetermines whether to set theAvailability::LOCALflag by callingActiveSession::session_type(), which returnsOption<SessionType>. Before the shell finishes bootstrapping, this returnsNone. The previous check usedis_some_and(|st| st == SessionType::Local), which evaluatesNoneasfalse— soLOCALwas 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 inActiveSession::location_for_path(Some(SessionType::Local) | None => ...). Once the session finishes bootstrapping, the existingActiveSessionEvent::Bootstrappedsubscription onSlashCommandDataSourcecallsrecompute_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-specorready-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/runAgent 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.