Skip to content

Commit 4542e8d

Browse files
authored
Hide handoff entrypoint hint when already viewing a cloud conversation (warpdotdev#10946)
## Description <!-- Please remember to add your design buddy onto the PR for review, if it contains any UI changes! --> WISOTT. This hint doesn't make sense to show if we're already in a cloud mode conversation.; ## Testing <!-- How did you test this change? What automated tests did you add? If you didn't add any new tests, what's your justification for not adding any? Manual testing is required for changes that can be manually tested, and almost all changes can be manually tested. If your change can be manually tested, please include screenshots or a screen recording that show it working end to end. You can run the app locally using `./script/run` - see WARP.md for more details on how to get set up. --> - [x] I have manually tested my changes locally with `./script/run` ### Screenshots / Videos <!-- Attach screenshots or a short video demonstrating the change, where appropriate. Remove this section if it is not relevant to your PR. --> https://www.loom.com/share/774534f7db79460fb99f6683d2193526 ## Agent Mode - [x] Warp Agent Mode - This PR was created via Warp's AI Agent Mode
1 parent 036b5d6 commit 4542e8d

4 files changed

Lines changed: 45 additions & 14 deletions

File tree

app/src/ai/blocklist/agent_view/agent_input_footer/mod.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1982,6 +1982,7 @@ impl AgentInputFooter {
19821982
&self,
19831983
item: &AgentToolbarItemKind,
19841984
shared_status: &SharedSessionStatus,
1985+
is_cloud_context: bool,
19851986
app: &AppContext,
19861987
) -> Option<Box<dyn Element>> {
19871988
let is_cloud_mode = FeatureFlag::CloudModeImageContext.is_enabled()
@@ -2061,11 +2062,7 @@ impl AgentInputFooter {
20612062
.is_enabled()
20622063
.then(|| ChildView::new(&self.fast_forward_button).finish()),
20632064
AgentToolbarItemKind::HandoffToCloud => {
2064-
if !AISettings::as_ref(app).is_cloud_handoff_enabled(app) {
2065-
return None;
2066-
}
2067-
2068-
if is_cloud_mode {
2065+
if !AISettings::as_ref(app).is_cloud_handoff_enabled(app) || is_cloud_context {
20692066
return None;
20702067
}
20712068

@@ -2155,9 +2152,15 @@ impl View for AgentInputFooter {
21552152

21562153
let terminal_model = self.terminal_model.lock();
21572154
let shared_status = terminal_model.shared_session_status();
2155+
let is_cloud_context = super::is_in_cloud_context(
2156+
terminal_model.block_list().agent_view_state(),
2157+
&terminal_model,
2158+
);
21582159

21592160
for item in &left_items {
2160-
if let Some(element) = self.render_toolbar_item(item, shared_status, app) {
2161+
if let Some(element) =
2162+
self.render_toolbar_item(item, shared_status, is_cloud_context, app)
2163+
{
21612164
left_buttons.add_child(element);
21622165
}
21632166
}
@@ -2178,7 +2181,9 @@ impl View for AgentInputFooter {
21782181
);
21792182
} else {
21802183
for item in &right_items {
2181-
if let Some(element) = self.render_toolbar_item(item, shared_status, app) {
2184+
if let Some(element) =
2185+
self.render_toolbar_item(item, shared_status, is_cloud_context, app)
2186+
{
21822187
right_buttons.add_child(element);
21832188
}
21842189
}

app/src/ai/blocklist/agent_view/agent_message_bar.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::ai::agent::{
1818
use crate::ai::blocklist::agent_view::shortcuts::AgentShortcutViewModel;
1919
use crate::ai::blocklist::agent_view::zero_state_block::render_ambient_credits_banner;
2020
use crate::ai::blocklist::agent_view::{
21-
agent_view_bg_fill, AgentViewController, AgentViewControllerEvent,
21+
agent_view_bg_fill, is_in_cloud_context, AgentViewController, AgentViewControllerEvent,
2222
};
2323
use crate::ai::blocklist::{
2424
ai_brand_color, BlocklistAIContextEvent, BlocklistAIContextModel, BlocklistAIHistoryEvent,
@@ -578,10 +578,8 @@ impl MessageProvider<AgentMessageArgs<'_>> for ZeroStateMessageProducer {
578578
.with_is_disabled(!is_buffer_empty),
579579
);
580580

581-
let is_cloud_agent = matches!(
582-
agent_view_controller.agent_view_state(),
583-
AgentViewState::Active { origin, .. } if origin.is_cloud_agent()
584-
);
581+
let is_cloud_agent =
582+
is_in_cloud_context(agent_view_controller.agent_view_state(), terminal_model);
585583

586584
// Handoff to cloud only available for local agents.
587585
if !is_cloud_agent && AISettings::as_ref(app).is_ampersand_handoff_enabled(app) {

app/src/ai/blocklist/agent_view/mod.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use warp_core::ui::{appearance::Appearance, color::blend::Blend};
3131
use warpui::keymap::Keystroke;
3232
use warpui::{AppContext, SingletonEntity};
3333

34+
use crate::terminal::model::TerminalModel;
3435
use crate::view_components::action_button::ActionButtonTheme;
3536

3637
pub static ENTER_AGENT_VIEW_NEW_CONVERSATION_KEYSTROKE: LazyLock<Keystroke> = LazyLock::new(|| {
@@ -73,6 +74,26 @@ pub static ENTER_CLOUD_AGENT_VIEW_NEW_CONVERSATION_KEYSTROKE: LazyLock<Keystroke
7374
}
7475
});
7576

77+
/// Returns `true` when the current pane is in a cloud or remote context where
78+
/// local-to-cloud handoff is not applicable. Use this to gate the `&` hint,
79+
/// handoff chip, `/handoff` command activation, and `&` prefix activation.
80+
pub fn is_in_cloud_context(
81+
agent_view_state: &AgentViewState,
82+
terminal_model: &TerminalModel,
83+
) -> bool {
84+
let origin_is_cloud = matches!(
85+
agent_view_state,
86+
AgentViewState::Active { origin, .. }
87+
if matches!(
88+
origin,
89+
AgentViewEntryOrigin::CloudAgent | AgentViewEntryOrigin::ThirdPartyCloudAgent
90+
)
91+
);
92+
origin_is_cloud
93+
|| terminal_model.is_conversation_transcript_viewer()
94+
|| terminal_model.is_dummy_cloud_mode_session()
95+
}
96+
7697
pub fn agent_view_bg_fill(app: &AppContext) -> Fill {
7798
let appearance = Appearance::as_ref(app);
7899
appearance.theme().surface_overlay_1()

app/src/terminal/input.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ use crate::ai::block_context::BlockContext;
112112
#[cfg(all(feature = "local_fs", not(target_family = "wasm")))]
113113
use crate::ai::blocklist::agent_view::agent_input_footer::sort_environments_by_recency;
114114
use crate::ai::blocklist::agent_view::{
115-
AgentInputFooter, AgentInputFooterEvent, AgentViewController,
115+
is_in_cloud_context, AgentInputFooter, AgentInputFooterEvent, AgentViewController,
116116
};
117117
#[cfg(all(feature = "local_fs", not(target_family = "wasm")))]
118118
use crate::ai::blocklist::handoff::touched_repos::{
@@ -3850,12 +3850,19 @@ impl Input {
38503850
let is_powershell_with_nld_enabled = self.editor.as_ref(ctx).shell_family()
38513851
== Some(ShellFamily::PowerShell)
38523852
&& AISettings::as_ref(ctx).is_ai_autodetection_enabled(ctx);
3853+
let is_cloud = {
3854+
let terminal_model = self.model.lock();
3855+
is_in_cloud_context(
3856+
terminal_model.block_list().agent_view_state(),
3857+
&terminal_model,
3858+
)
3859+
};
38533860
*edit_origin == EditOrigin::UserTyped
38543861
&& AISettings::as_ref(ctx).is_ampersand_handoff_enabled(ctx)
38553862
&& !is_powershell_with_nld_enabled
38563863
&& FeatureFlag::AgentView.is_enabled()
38573864
&& self.agent_view_controller.as_ref(ctx).is_fullscreen()
3858-
&& self.ambient_agent_view_model().is_none()
3865+
&& !is_cloud
38593866
&& !CLIAgentSessionsModel::as_ref(ctx).is_input_open(self.terminal_view_id)
38603867
&& self.prefix_mode(ctx) == InputPrefixMode::None
38613868
}

0 commit comments

Comments
 (0)