From 1359fca0266b85f48c29f7527e4055ada5f655e3 Mon Sep 17 00:00:00 2001 From: Matthew Ball <13823657+matthewrball@users.noreply.github.com> Date: Thu, 12 Nov 2026 01:18:50 -0800 Subject: [PATCH 1/5] Agent: Show on a step that it waits for permission, and what you said A call that needed permission looked like any running step, and once answered nothing in the transcript said whether it had been allowed. The step the request is about now reads "waiting" in coral, then "allowed" or "denied" for as long as the view shows the task. The card gains the tool's icon beside the call, a note field that says what it is for, and a line naming the mode that asked. --- apps/maple-agent/app/locales/de/app.ftl | 3 + apps/maple-agent/app/locales/en/app.ftl | 3 + apps/maple-agent/app/locales/es/app.ftl | 3 + apps/maple-agent/app/src/ui/chat/mod.rs | 17 +++- apps/maple-agent/app/src/ui/chat/paging.rs | 2 + apps/maple-agent/app/src/ui/chat/step.rs | 43 +++++++--- apps/maple-agent/app/src/ui/chat/tests.rs | 37 +++++++++ .../maple-agent/app/src/ui/chat/transcript.rs | 81 +++++++++++++++++-- apps/maple-agent/app/src/ui/chat/turn.rs | 48 +++++++++++ .../app/translation-revisions/de.txt | 2 + .../app/translation-revisions/es.txt | 2 + 11 files changed, 224 insertions(+), 17 deletions(-) diff --git a/apps/maple-agent/app/locales/de/app.ftl b/apps/maple-agent/app/locales/de/app.ftl index 23fc3cd53..6f0198904 100644 --- a/apps/maple-agent/app/locales/de/app.ftl +++ b/apps/maple-agent/app/locales/de/app.ftl @@ -1543,6 +1543,9 @@ chat-question-label = Frage von Maple chat-permission-label = Diese Aktion erlauben? chat-permission-allow = Einmal erlauben chat-permission-deny = Ablehnen +chat-permission-note-placeholder = Oder sag Maple, was es stattdessen tun soll… +# $mode is the name of the task's permission mode, for example Auto. +chat-permission-mode-hint = Im Modus „{ $mode }“ fragt Maple vor Aktionen wie dieser chat-permission-reason-secrets = Dies liest Geheimnisse oder Zugangsdaten. chat-permission-reason-secrets-leaving = Dies könnte Geheimnisse von diesem Computer nach außen senden. chat-permission-reason-sends-out = Dies sendet oder veröffentlicht etwas außerhalb dieses Computers. diff --git a/apps/maple-agent/app/locales/en/app.ftl b/apps/maple-agent/app/locales/en/app.ftl index ab94dad33..c091ecc1b 100644 --- a/apps/maple-agent/app/locales/en/app.ftl +++ b/apps/maple-agent/app/locales/en/app.ftl @@ -1543,6 +1543,9 @@ chat-question-label = Question from Maple chat-permission-label = Allow this action? chat-permission-allow = Allow once chat-permission-deny = Deny +chat-permission-note-placeholder = Or tell Maple what to do instead… +# $mode is the name of the task's permission mode, for example Auto. +chat-permission-mode-hint = { $mode } asks before actions like this chat-permission-reason-secrets = This reads secrets or credentials. chat-permission-reason-secrets-leaving = This could send secrets off this computer. chat-permission-reason-sends-out = This sends or publishes something outside this computer. diff --git a/apps/maple-agent/app/locales/es/app.ftl b/apps/maple-agent/app/locales/es/app.ftl index 87e39665e..94e111ff7 100644 --- a/apps/maple-agent/app/locales/es/app.ftl +++ b/apps/maple-agent/app/locales/es/app.ftl @@ -1430,6 +1430,9 @@ chat-question-label = Pregunta de Maple chat-permission-label = ¿Permitir esta acción? chat-permission-allow = Permitir una vez chat-permission-deny = Rechazar +chat-permission-note-placeholder = O dile a Maple qué hacer en su lugar… +# $mode is the name of the task's permission mode, for example Auto. +chat-permission-mode-hint = El modo { $mode } pregunta antes de acciones como esta chat-permission-reason-secrets = Esto lee secretos o credenciales. chat-permission-reason-secrets-leaving = Esto podría enviar secretos fuera de esta computadora. chat-permission-reason-sends-out = Esto envía o publica algo fuera de esta computadora. diff --git a/apps/maple-agent/app/src/ui/chat/mod.rs b/apps/maple-agent/app/src/ui/chat/mod.rs index 1ef7e7dc4..158f48498 100644 --- a/apps/maple-agent/app/src/ui/chat/mod.rs +++ b/apps/maple-agent/app/src/ui/chat/mod.rs @@ -230,6 +230,8 @@ struct TranscriptCtx<'a> { /// For a step: whether the thread's rail runs on to the steps drawn /// right above and below it. rail: step::Rail, + /// For a tool call the user was asked to allow: where that stands. + asked: Option, } /// Text-to-speech progress for one message. @@ -851,6 +853,9 @@ pub struct ChatScreen { /// How long finished turns worked, by lead item id. Only turns this /// window timed have one. turn_worked: HashMap, + /// What the user said to the permission requests answered in this + /// view, by the id of the tool call each was about: allowed, or not. + step_permissions: HashMap, /// Clocks of the runs this window saw start, by session id. run_clocks: HashMap, /// A repaint for a running turn's time is on its way. @@ -1688,6 +1693,7 @@ impl ChatScreen { turns: turn::Turns::default(), toggled_turns: HashSet::new(), turn_worked: HashMap::new(), + step_permissions: HashMap::new(), run_clocks: HashMap::new(), run_tick_pending: std::cell::Cell::new(false), question_selected: HashMap::new(), @@ -3765,6 +3771,7 @@ impl ChatScreen { self.toggled_tools.clear(); self.toggled_turns.clear(); self.turn_worked.clear(); + self.step_permissions.clear(); if let Some(composer) = self.composer.clone() { composer.update(cx, |input, cx| input.reset_vim_context(cx)); } @@ -5755,8 +5762,14 @@ impl ChatScreen { let chat = cx.entity().downgrade(); let question_chat = chat.clone(); let application_vim_enabled = self.application_vim_enabled; + // On a permission request the field is the other way to answer. + let placeholder = if self.current_permission().is_some() { + "chat-permission-note-placeholder" + } else { + "chat-answer-placeholder" + }; let input = cx.new(move |cx| { - TextInput::localized("chat-answer-placeholder", cx) + TextInput::localized(placeholder, cx) .application_vim(application_vim_enabled) .on_application_escape(move |window, cx| { if let Some(chat) = question_chat.upgrade() { @@ -5851,6 +5864,7 @@ impl ChatScreen { if answer.trim().is_empty() { return; } + self.settle_permission(&question); let request_id = question.request_id.clone(); let callback_request_id = request_id.clone(); let backend = self.backend.clone(); @@ -7508,6 +7522,7 @@ impl Render for ChatScreen { input, &self.question_selected, &key_labels, + self.permission_mode, &self.messages, cx, ), diff --git a/apps/maple-agent/app/src/ui/chat/paging.rs b/apps/maple-agent/app/src/ui/chat/paging.rs index adb34c18e..b07a4bb18 100644 --- a/apps/maple-agent/app/src/ui/chat/paging.rs +++ b/apps/maple-agent/app/src/ui/chat/paging.rs @@ -264,6 +264,8 @@ impl ChatScreen { .retain(|id| self.timeline_index.contains_key(id)); self.turn_worked .retain(|id, _| self.timeline_index.contains_key(id)); + self.step_permissions + .retain(|id, _| self.timeline_index.contains_key(id)); self.markdown_cache.clear(); self.derived.clear(); self.messages = Default::default(); diff --git a/apps/maple-agent/app/src/ui/chat/step.rs b/apps/maple-agent/app/src/ui/chat/step.rs index 81fece6af..da5ebfb6a 100644 --- a/apps/maple-agent/app/src/ui/chat/step.rs +++ b/apps/maple-agent/app/src/ui/chat/step.rs @@ -20,9 +20,13 @@ const NODE_CENTRE: Pixels = px(16.); #[derive(Clone, Copy, Debug, PartialEq, Eq)] pub(super) enum StepState { Running, + /// The call waits for the user to allow it. + Waiting, Done, Failed, Stopped, + /// The user said no to the call. + Denied, } impl StepState { @@ -38,23 +42,38 @@ impl StepState { /// Colour of the step's title. pub(super) fn ink(self) -> u32 { match self { - Self::Done | Self::Failed => theme::text_primary(), - Self::Running | Self::Stopped => theme::text_muted(), + Self::Done | Self::Failed | Self::Waiting => theme::text_primary(), + Self::Running | Self::Stopped | Self::Denied => theme::text_muted(), } } } +/// What the user was asked about a tool call, and said. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub(super) enum Asked { + /// The request is on screen. + Waiting, + Allowed, + Denied, +} + /// Whether the rail runs on from a step's node to the step drawn right /// above it, and to the one right below. pub(super) type Rail = (bool, bool); /// The icon on a tool call's node, by what the tool does. pub(super) fn tool_icon(item: &AgentTimelineItem) -> &'static str { - let name = item - .label - .as_ref() - .filter(|label| label.kind == "tool") - .and_then(|label| label.name.as_deref()); + icon_for_tool( + item.label + .as_ref() + .filter(|label| label.kind == "tool") + .and_then(|label| label.name.as_deref()), + ) +} + +/// The icon for a tool by its name; a tool the app does not know gets the +/// plain one. +pub(super) fn icon_for_tool(name: Option<&str>) -> &'static str { match name { Some("bash" | "powershell" | "shell") => "terminal", Some("read" | "read_file") => "file-text", @@ -90,7 +109,9 @@ pub(super) fn step( let glyph = match state { StepState::Done => theme::text_secondary(), StepState::Failed => theme::status_error(), - StepState::Running | StepState::Stopped => theme::text_muted(), + // Coral means the step waits on the user. + StepState::Waiting => theme::accent_ink(), + StepState::Running | StepState::Stopped | StepState::Denied => theme::text_muted(), }; let segment = || div().absolute().left(px(10.)).w(px(1.)).bg(line); div() @@ -120,7 +141,11 @@ pub(super) fn step( .rounded_full() .bg(gpui::rgb(theme::bg_app())) .border_1() - .border_color(line) + .border_color(if state == StepState::Waiting { + gpui::rgb(glyph) + } else { + line + }) .flex() .items_center() .justify_center() diff --git a/apps/maple-agent/app/src/ui/chat/tests.rs b/apps/maple-agent/app/src/ui/chat/tests.rs index 00db95c6d..d7c4a076c 100644 --- a/apps/maple-agent/app/src/ui/chat/tests.rs +++ b/apps/maple-agent/app/src/ui/chat/tests.rs @@ -2154,6 +2154,43 @@ mod state_tests { }); } + /// A permission request is about the call still running, and that + /// call keeps what the user answered. + #[gpui::test] + fn test_a_call_keeps_what_the_user_said_to_its_permission_request(cx: &mut TestAppContext) { + cx.executor().allow_parking(); + let screen = screen(cx); + screen.update(cx, |this, cx| { + this.selected_session = Some("s1".to_string()); + let call = |id: &str, status: &str| AgentTimelineItem { + status: Some(status.to_string()), + ..item(id, "tool", None) + }; + this.replace_timeline(vec![ + user_item("u1", "Push it"), + call("read", "completed"), + call("push", "running"), + ]); + assert_eq!(this.waiting_step(), None, "nothing waits before a request"); + + this.handle_service_event(permission_event("p1"), cx); + assert_eq!( + this.waiting_step(), + Some(2), + "the request is about the call that has not finished" + ); + this.toggle_question_option(0, 0, cx); + assert_eq!(this.step_permissions.get("push"), Some(&true)); + + // The next call is refused; the earlier answer stays. + this.apply_incoming_item("s1", call("force", "running"), cx); + this.handle_service_event(permission_event("p2"), cx); + this.toggle_question_option(0, 1, cx); + assert_eq!(this.step_permissions.get("force"), Some(&false)); + assert_eq!(this.step_permissions.get("push"), Some(&true)); + }); + } + /// A permission card and its notification are worded in the interface's /// language, and the answer stays the runtime's label in any language. #[gpui::test] diff --git a/apps/maple-agent/app/src/ui/chat/transcript.rs b/apps/maple-agent/app/src/ui/chat/transcript.rs index b8ac78e94..ecc33337b 100644 --- a/apps/maple-agent/app/src/ui/chat/transcript.rs +++ b/apps/maple-agent/app/src/ui/chat/transcript.rs @@ -58,6 +58,8 @@ impl ChatScreen { let switch_reveal = self.row_motion.switch_progress(now, reduced); let show_jump = count > 0 && !self.list_state.is_following_tail(); let tool_details = self.tool_details; + // The call a permission request on screen is about. + let waiting_step = self.waiting_step(); let entity = cx.entity().downgrade(); let selection = self.selection.clone(); let transcript_focus = self.transcript_focus.clone(); @@ -122,6 +124,17 @@ impl ChatScreen { turn != TurnRow::Plain && matches!(chat.turns.row(ix + 1), TurnRow::Step(_)), ), + asked: if waiting_step == Some(ix) { + Some(step::Asked::Waiting) + } else { + chat.step_permissions.get(&item.id).map(|allowed| { + if *allowed { + step::Asked::Allowed + } else { + step::Asked::Denied + } + }) + }, }; let expanded = tool_details != chat.toggled_tools.contains(&item.id); let revision = chat @@ -1345,17 +1358,23 @@ fn revealed(details: E, reveal: f32) -> E { } } -/// What a step says after its title when it did not simply finish. A -/// running step says nothing: it is dim, and the turn's line is the one -/// thing that moves. -fn step_outcome(state: StepState) -> Option
{ +/// What a step says after its title when it did not simply run and +/// finish. A running step says nothing: it is dim, and the turn's line is +/// the one thing that moves. `allowed`: the user let the call run. +fn step_outcome(state: StepState, allowed: bool) -> Option
{ let (label, color) = match state { + StepState::Waiting => (tr("chat-status-waiting"), theme::accent_ink()), + StepState::Denied => (tr("chat-status-denied"), theme::text_muted()), StepState::Failed => (tr("chat-status-failed"), theme::status_error()), StepState::Stopped => (tr("chat-status-stopped"), theme::text_muted()), + StepState::Running | StepState::Done if allowed => { + (tr("chat-status-allowed"), theme::text_muted()) + } StepState::Running | StepState::Done => return None, }; Some( div() + .debug_selector(|| "step-outcome".to_string()) .flex_none() .font_weight(gpui::FontWeight::NORMAL) .text_xs() @@ -1786,7 +1805,14 @@ fn render_tool( diff: bool, transcript: &TranscriptCtx, ) -> Div { - let state = StepState::of(item.status.as_deref()); + // What the user was asked about the call says more than its status: a + // call that waits is not running, and one the user refused did not + // fail on its own. + let state = match transcript.asked { + Some(step::Asked::Waiting) => StepState::Waiting, + Some(step::Asked::Denied) => StepState::Denied, + Some(step::Asked::Allowed) | None => StepState::of(item.status.as_deref()), + }; let item_id = item.id.clone(); let chat = transcript.chat.clone(); let derived = transcript.derived.get(item, revision); @@ -1836,7 +1862,10 @@ fn render_tool( .filter(|_| state == StepState::Done) .map(step::changed), ) - .children(step_outcome(state)) + .children(step_outcome( + state, + transcript.asked == Some(step::Asked::Allowed), + )) .child(motion::chevron( SharedString::from(format!("tool-chevron-{}", item.id)), details, @@ -2288,6 +2317,7 @@ pub(super) fn render_question_card( input: Option>, selected: &HashMap, key_labels: &[SharedString], + mode: maple_agent::agent::AgentPermissionMode, messages: &MessageCache, cx: &mut Context, ) -> Div { @@ -2311,6 +2341,19 @@ pub(super) fn render_question_card( let step = step.min(question.questions.len().saturating_sub(1)); let entry = question.questions.get(step); let permission = entry.and_then(|entry| entry.permission.as_ref()); + // A request comes from the task's mode: the footer says which one + // asked. Full access never asks, so it has nothing to say. + let mode_hint = match mode { + maple_agent::agent::AgentPermissionMode::ReadOnly => Some(tr("chat-mode-read-only")), + maple_agent::agent::AgentPermissionMode::Auto => Some(tr("chat-mode-auto")), + maple_agent::agent::AgentPermissionMode::FullAccess => None, + } + .map(|mode| { + messages.get( + "chat-permission-mode-hint", + [("mode", mode.to_string().into())], + ) + }); let card_label = if permission.is_some() { tr("chat-permission-label") } else { @@ -2436,10 +2479,31 @@ pub(super) fn render_question_card( .py_1p5() .rounded(theme::RADIUS_SM) .bg(gpui::rgb(theme::bg_sidebar_pill())) + .flex() + .items_start() + .gap_2() .font_family(crate::assets::FONT_MONO) .text_xs() .text_color(gpui::rgb(theme::text_primary())) - .child(gpui::text!(prompt.action.clone())), + // The icon of the tool that would run, as on its + // step in the transcript. + .child( + div() + .debug_selector(|| "permission-tool".to_string()) + .flex_none() + .mt(px(2.)) + .child(icon( + step::icon_for_tool(Some(&prompt.tool)), + px(13.), + theme::text_muted(), + )), + ) + .child( + div() + .flex_1() + .min_w_0() + .child(gpui::text!(prompt.action.clone())), + ), ), ); } else { @@ -2603,6 +2667,9 @@ pub(super) fn render_question_card( } else { tr("chat-question-answer-hint") }) + }) + .when_some(permission.and(mode_hint), |hint, text| { + hint.child(gpui::text!(text)) }), ) .child( diff --git a/apps/maple-agent/app/src/ui/chat/turn.rs b/apps/maple-agent/app/src/ui/chat/turn.rs index f5672b5af..3db37b867 100644 --- a/apps/maple-agent/app/src/ui/chat/turn.rs +++ b/apps/maple-agent/app/src/ui/chat/turn.rs @@ -562,6 +562,54 @@ impl ChatScreen { if let Some(worked) = self.turn_worked.remove(old) { self.turn_worked.insert(new.to_owned(), worked); } + if let Some(allowed) = self.step_permissions.remove(old) { + self.step_permissions.insert(new.to_owned(), allowed); + } + } + + /// The permission request on screen, if the question card shows one. + pub(super) fn current_permission(&self) -> Option<&maple_agent::agent::AgentPermissionPrompt> { + self.current_question()? + .questions + .iter() + .find_map(|entry| entry.permission.as_ref()) + } + + /// The tool call the permission request on screen is about: the + /// newest call of the turn that has not finished. + pub(super) fn waiting_step(&self) -> Option { + self.current_permission()?; + self.timeline + .iter() + .enumerate() + .rev() + .take_while(|(_, item)| !starts_turn(item)) + .find(|(_, item)| { + is_tool(item) + && step::StepState::of(item.status.as_deref()) == step::StepState::Running + }) + .map(|(index, _)| index) + } + + /// The user answered a permission request: the call it was about keeps + /// what they said for as long as this view shows the task. + pub(super) fn settle_permission(&mut self, question: &crate::backend::PendingQuestion) { + let Some(asked) = question + .questions + .iter() + .position(|entry| entry.permission.is_some()) + else { + return; + }; + let Some(call) = self.waiting_step().and_then(|step| self.timeline.get(step)) else { + return; + }; + // Only the first option, "Allow once", lets the call run. + let allowed = self + .question_selected + .get(&asked) + .is_some_and(|selection| selection.picked.contains(&0)); + self.step_permissions.insert(call.id.clone(), allowed); } /// Paint once a second while a run is timed, so the time on its line diff --git a/apps/maple-agent/app/translation-revisions/de.txt b/apps/maple-agent/app/translation-revisions/de.txt index 0cd01e19a..6ca13e166 100644 --- a/apps/maple-agent/app/translation-revisions/de.txt +++ b/apps/maple-agent/app/translation-revisions/de.txt @@ -230,6 +230,8 @@ chat-page-settled-retry 7819952f23b4deca chat-permission-allow 48955332314aface chat-permission-deny 247877b375d74e51 chat-permission-label 003c13cd34c8664b +chat-permission-mode-hint 3d0a17c847edd1fc +chat-permission-note-placeholder c0d5f880b0115262 chat-permission-reason-changes-outside-project 419d3ad8e0d467ef chat-permission-reason-changes-project be40ea472bf88e4c chat-permission-reason-destructive 7abdcab1435c106b diff --git a/apps/maple-agent/app/translation-revisions/es.txt b/apps/maple-agent/app/translation-revisions/es.txt index 0cd01e19a..6ca13e166 100644 --- a/apps/maple-agent/app/translation-revisions/es.txt +++ b/apps/maple-agent/app/translation-revisions/es.txt @@ -230,6 +230,8 @@ chat-page-settled-retry 7819952f23b4deca chat-permission-allow 48955332314aface chat-permission-deny 247877b375d74e51 chat-permission-label 003c13cd34c8664b +chat-permission-mode-hint 3d0a17c847edd1fc +chat-permission-note-placeholder c0d5f880b0115262 chat-permission-reason-changes-outside-project 419d3ad8e0d467ef chat-permission-reason-changes-project be40ea472bf88e4c chat-permission-reason-destructive 7abdcab1435c106b From bbf9038417587b99ddaf75bd5a2bc1cbe915b013 Mon Sep 17 00:00:00 2001 From: Matthew Ball <13823657+matthewrball@users.noreply.github.com> Date: Thu, 12 Nov 2026 01:52:15 -0800 Subject: [PATCH 2/5] Agent: Mark the call a permission request is about, not the newest Every call of a reply is on screen as running before the first is asked about, so the newest unfinished call was often the wrong one, and it kept the answer meant for another. The request names its tool and what the call would do. The step that waits is now the earliest unanswered call of the turn that matches both; with nothing to compare, no step is marked. What the user said is also text a screen reader can reach. --- apps/maple-agent/app/src/ui/chat/tests.rs | 27 ++++++--- .../maple-agent/app/src/ui/chat/transcript.rs | 2 +- apps/maple-agent/app/src/ui/chat/turn.rs | 59 +++++++++++++++---- 3 files changed, 69 insertions(+), 19 deletions(-) diff --git a/apps/maple-agent/app/src/ui/chat/tests.rs b/apps/maple-agent/app/src/ui/chat/tests.rs index 9ff99af9e..33ce43155 100644 --- a/apps/maple-agent/app/src/ui/chat/tests.rs +++ b/apps/maple-agent/app/src/ui/chat/tests.rs @@ -2162,14 +2162,24 @@ mod state_tests { let screen = screen(cx); screen.update(cx, |this, cx| { this.selected_session = Some("s1".to_string()); - let call = |id: &str, status: &str| AgentTimelineItem { + let call = |id: &str, status: &str, command: &str| AgentTimelineItem { status: Some(status.to_string()), + label: Some(maple_agent::agent::AgentTimelineLabel { + kind: "tool".to_string(), + name: Some("bash".to_string()), + detail: Some(command.to_string()), + }), + input: Some(serde_json::json!({ "command": command })), ..item(id, "tool", None) }; + // One reply made three calls. All are on screen as running + // before the first is asked about. this.replace_timeline(vec![ user_item("u1", "Push it"), - call("read", "completed"), - call("push", "running"), + call("read", "completed", "cat notes.txt"), + call("push", "running", "git push"), + call("list", "running", "ls"), + call("again", "running", "git push"), ]); assert_eq!(this.waiting_step(), None, "nothing waits before a request"); @@ -2177,17 +2187,20 @@ mod state_tests { assert_eq!( this.waiting_step(), Some(2), - "the request is about the call that has not finished" + "the request is about the earliest call that would do what it says, \ + not the newest call" ); this.toggle_question_option(0, 0, cx); assert_eq!(this.step_permissions.get("push"), Some(&true)); - // The next call is refused; the earlier answer stays. - this.apply_incoming_item("s1", call("force", "running"), cx); + // The same command again is the next call's; it is refused, + // and the earlier answer stays. this.handle_service_event(permission_event("p2"), cx); + assert_eq!(this.waiting_step(), Some(4)); this.toggle_question_option(0, 1, cx); - assert_eq!(this.step_permissions.get("force"), Some(&false)); + assert_eq!(this.step_permissions.get("again"), Some(&false)); assert_eq!(this.step_permissions.get("push"), Some(&true)); + assert_eq!(this.step_permissions.get("list"), None); }); } diff --git a/apps/maple-agent/app/src/ui/chat/transcript.rs b/apps/maple-agent/app/src/ui/chat/transcript.rs index 0b257830d..363169d41 100644 --- a/apps/maple-agent/app/src/ui/chat/transcript.rs +++ b/apps/maple-agent/app/src/ui/chat/transcript.rs @@ -1379,7 +1379,7 @@ fn step_outcome(state: StepState, allowed: bool) -> Option
{ .font_weight(gpui::FontWeight::NORMAL) .text_xs() .text_color(gpui::rgb(color)) - .child(label), + .child(gpui::text!(label)), ) } diff --git a/apps/maple-agent/app/src/ui/chat/turn.rs b/apps/maple-agent/app/src/ui/chat/turn.rs index 29a187b75..44292ec41 100644 --- a/apps/maple-agent/app/src/ui/chat/turn.rs +++ b/apps/maple-agent/app/src/ui/chat/turn.rs @@ -618,19 +618,38 @@ impl ChatScreen { .find_map(|entry| entry.permission.as_ref()) } - /// The tool call the permission request on screen is about: the - /// newest call of the turn that has not finished. + /// The tool call the permission request on screen is about. The + /// request names its tool and what the call would do, not the call, + /// and every call of a reply is on screen as running before the first + /// is asked about. So the call is the earliest unanswered one of the + /// turn with that tool and that action; requests come in call order. + /// A call whose input has no command, path, url or query to compare + /// is taken only when it is the one call of that tool left. pub(super) fn waiting_step(&self) -> Option { - self.current_permission()?; - self.timeline - .iter() - .enumerate() - .rev() - .take_while(|(_, item)| !starts_turn(item)) - .find(|(_, item)| { - is_tool(item) - && step::StepState::of(item.status.as_deref()) == step::StepState::Running + let prompt = self.current_permission()?; + let open = || { + self.timeline + .iter() + .enumerate() + .rev() + .take_while(|(_, item)| !starts_turn(item)) + .filter(|(_, item)| { + is_tool(item) + && step::StepState::of(item.status.as_deref()) == step::StepState::Running + && !self.step_permissions.contains_key(&item.id) + && item.label.as_ref().and_then(|label| label.name.as_deref()) + == Some(prompt.tool.as_str()) + }) + }; + // Newest first, so the last match is the earliest call. + let named = open() + .filter(|(_, item)| { + call_action(item).is_some_and(|action| same_action(&prompt.action, action)) }) + .last(); + let mut unnamed = open().filter(|(_, item)| call_action(item).is_none()); + named + .or_else(|| unnamed.next().filter(|_| unnamed.next().is_none())) .map(|(index, _)| index) } @@ -681,6 +700,24 @@ impl ChatScreen { } } +/// What a call would do, as a permission request words it: the first of +/// these fields its input has. +fn call_action(item: &AgentTimelineItem) -> Option<&str> { + let input = item.input.as_ref()?; + ["command", "path", "url", "query"] + .into_iter() + .find_map(|field| input.get(field)?.as_str()) +} + +/// Whether the action a request shows is the call's. The request cuts the +/// middle out of a long one and says so on a line of its own. +fn same_action(shown: &str, full: &str) -> bool { + shown == full + || shown.split_once("\n[").is_some_and(|(start, _)| { + !start.is_empty() && full.len() > shown.len() && full.starts_with(start) + }) +} + #[cfg(test)] mod tests { use super::*; From 4b93d77d637d1d97746c61b3def224c984bb67b3 Mon Sep 17 00:00:00 2001 From: Matthew Ball <13823657+matthewrball@users.noreply.github.com> Date: Thu, 12 Nov 2026 02:01:46 -0800 Subject: [PATCH 3/5] Agent: Mark no step when a permission request could mean two calls A call the mode lets through stays on screen as running beside an identical one that asks, so "the earliest match" could still be the wrong call. With more than one candidate the view now marks none and keeps no answer, rather than guess. --- apps/maple-agent/app/src/ui/chat/tests.rs | 19 ++++++--- apps/maple-agent/app/src/ui/chat/turn.rs | 49 ++++++++++------------- 2 files changed, 34 insertions(+), 34 deletions(-) diff --git a/apps/maple-agent/app/src/ui/chat/tests.rs b/apps/maple-agent/app/src/ui/chat/tests.rs index 33ce43155..90a93c981 100644 --- a/apps/maple-agent/app/src/ui/chat/tests.rs +++ b/apps/maple-agent/app/src/ui/chat/tests.rs @@ -2172,14 +2172,13 @@ mod state_tests { input: Some(serde_json::json!({ "command": command })), ..item(id, "tool", None) }; - // One reply made three calls. All are on screen as running - // before the first is asked about. + // One reply made these calls. All are on screen as running + // before any is asked about. this.replace_timeline(vec![ user_item("u1", "Push it"), call("read", "completed", "cat notes.txt"), call("push", "running", "git push"), call("list", "running", "ls"), - call("again", "running", "git push"), ]); assert_eq!(this.waiting_step(), None, "nothing waits before a request"); @@ -2187,20 +2186,28 @@ mod state_tests { assert_eq!( this.waiting_step(), Some(2), - "the request is about the earliest call that would do what it says, \ - not the newest call" + "the request is about the call that would do what it says, not the newest" ); this.toggle_question_option(0, 0, cx); assert_eq!(this.step_permissions.get("push"), Some(&true)); // The same command again is the next call's; it is refused, // and the earlier answer stays. + this.apply_incoming_item("s1", call("again", "running", "git push"), cx); this.handle_service_event(permission_event("p2"), cx); assert_eq!(this.waiting_step(), Some(4)); this.toggle_question_option(0, 1, cx); assert_eq!(this.step_permissions.get("again"), Some(&false)); assert_eq!(this.step_permissions.get("push"), Some(&true)); - assert_eq!(this.step_permissions.get("list"), None); + + // Two calls the request could mean: neither is marked, and + // neither keeps the answer. + this.apply_incoming_item("s1", call("third", "running", "git push"), cx); + this.apply_incoming_item("s1", call("fourth", "running", "git push"), cx); + this.handle_service_event(permission_event("p3"), cx); + assert_eq!(this.waiting_step(), None); + this.toggle_question_option(0, 0, cx); + assert_eq!(this.step_permissions.len(), 2); }); } diff --git a/apps/maple-agent/app/src/ui/chat/turn.rs b/apps/maple-agent/app/src/ui/chat/turn.rs index e3c09bc83..e14bae77f 100644 --- a/apps/maple-agent/app/src/ui/chat/turn.rs +++ b/apps/maple-agent/app/src/ui/chat/turn.rs @@ -622,37 +622,30 @@ impl ChatScreen { /// The tool call the permission request on screen is about. The /// request names its tool and what the call would do, not the call, - /// and every call of a reply is on screen as running before the first - /// is asked about. So the call is the earliest unanswered one of the - /// turn with that tool and that action; requests come in call order. - /// A call whose input has no command, path, url or query to compare - /// is taken only when it is the one call of that tool left. + /// and every call of a reply is on screen as running before any is + /// asked about. So the call is the turn's one unanswered call with + /// that tool and that action. Where two could be meant, none is + /// marked: a wrong step would keep an answer that was not its own. pub(super) fn waiting_step(&self) -> Option { let prompt = self.current_permission()?; - let open = || { - self.timeline - .iter() - .enumerate() - .rev() - .take_while(|(_, item)| !starts_turn(item)) - .filter(|(_, item)| { - is_tool(item) - && step::StepState::of(item.status.as_deref()) == step::StepState::Running - && !self.step_permissions.contains_key(&item.id) - && item.label.as_ref().and_then(|label| label.name.as_deref()) - == Some(prompt.tool.as_str()) - }) - }; - // Newest first, so the last match is the earliest call. - let named = open() + let mut meant = self + .timeline + .iter() + .enumerate() + .rev() + .take_while(|(_, item)| !starts_turn(item)) .filter(|(_, item)| { - call_action(item).is_some_and(|action| same_action(&prompt.action, action)) - }) - .last(); - let mut unnamed = open().filter(|(_, item)| call_action(item).is_none()); - named - .or_else(|| unnamed.next().filter(|_| unnamed.next().is_none())) - .map(|(index, _)| index) + is_tool(item) + && step::StepState::of(item.status.as_deref()) == step::StepState::Running + && !self.step_permissions.contains_key(&item.id) + && item.label.as_ref().and_then(|label| label.name.as_deref()) + == Some(prompt.tool.as_str()) + // An input with no command, path, url or query has + // nothing to compare; the tool alone decides. + && call_action(item).is_none_or(|action| same_action(&prompt.action, action)) + }); + let (index, _) = meant.next()?; + meant.next().is_none().then_some(index) } /// The user answered a permission request: the call it was about keeps From 5575d93de2de0823953e0ccfa31633ba213727ef Mon Sep 17 00:00:00 2001 From: Matthew Ball <13823657+matthewrball@users.noreply.github.com> Date: Tue, 17 Nov 2026 14:45:16 -0800 Subject: [PATCH 4/5] Agent: count a chunk's steps across every step state A chunk counted its steps in four slots, but a step can also wait for permission or be refused. Size the counts by the states. Record the Korean permission strings. --- apps/maple-agent/app/src/ui/chat/turn.rs | 4 +++- apps/maple-agent/app/translation-revisions/ko.txt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/maple-agent/app/src/ui/chat/turn.rs b/apps/maple-agent/app/src/ui/chat/turn.rs index 5164e7abb..442754549 100644 --- a/apps/maple-agent/app/src/ui/chat/turn.rs +++ b/apps/maple-agent/app/src/ui/chat/turn.rs @@ -55,7 +55,9 @@ impl TurnRow { pub(super) struct Chunk { end: usize, icons: Vec<(&'static str, usize)>, - states: [usize; 4], + /// How many of the chunk's steps are in each state. A step waiting on + /// the user, or refused, still counts by its call's own status. + states: [usize; step::StepState::Denied as usize + 1], } impl Chunk { diff --git a/apps/maple-agent/app/translation-revisions/ko.txt b/apps/maple-agent/app/translation-revisions/ko.txt index e0b1ef44a..7d2df1225 100644 --- a/apps/maple-agent/app/translation-revisions/ko.txt +++ b/apps/maple-agent/app/translation-revisions/ko.txt @@ -2,6 +2,7 @@ chat-absolute-path a2ba378ac24704c4 chat-active 196d1c9462f99ad3 chat-activity-outside dc914a2d8037659c +chat-activity-steps a12bb21490dd0f51 chat-agent-task-cancelled e26bb0917a4c240b chat-agents-running 15f7861d7b1f2dc3 chat-all-settings f521b783e34e05d0 @@ -232,6 +233,8 @@ chat-page-settled-retry 7819952f23b4deca chat-permission-allow 48955332314aface chat-permission-deny 247877b375d74e51 chat-permission-label 003c13cd34c8664b +chat-permission-mode-hint 3d0a17c847edd1fc +chat-permission-note-placeholder c0d5f880b0115262 chat-permission-reason-changes-outside-project 419d3ad8e0d467ef chat-permission-reason-changes-project be40ea472bf88e4c chat-permission-reason-destructive 7abdcab1435c106b @@ -354,7 +357,6 @@ chat-staging-unsafe-directory 13ed7aa88e08c0a8 chat-starting f00ec83fc396c4b0 chat-starting-agent 0e61b8da983ef787 chat-status-allowed 11310a7438dc9e0c -chat-status-completed f7f8f9dd4adb3a0c chat-status-denied deee947bb13482c4 chat-status-done 54904e435ce0c52e chat-status-failed 3aa7979f86ebefa0 From ee737aff4de2977d363e45002970a874d7171018 Mon Sep 17 00:00:00 2001 From: Matthew Ball <13823657+matthewrball@users.noreply.github.com> Date: Tue, 17 Nov 2026 15:19:14 -0800 Subject: [PATCH 5/5] Agent: say on a folded group that its call waits for permission Groups are folded by default, which hides the step that says it is waiting. The header read "running" under a line that said "Waiting for you". --- apps/maple-agent/app/src/ui/chat/transcript.rs | 2 ++ apps/maple-agent/app/src/ui/chat/turn.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/maple-agent/app/src/ui/chat/transcript.rs b/apps/maple-agent/app/src/ui/chat/transcript.rs index 996812e03..49d31bb03 100644 --- a/apps/maple-agent/app/src/ui/chat/transcript.rs +++ b/apps/maple-agent/app/src/ui/chat/transcript.rs @@ -173,6 +173,8 @@ impl ChatScreen { chunk, open, chat.turn_runs(ix), + waiting_step + .is_some_and(|step| (ix..chat.turns.end(ix)).contains(&step)), &entity, &chat.messages, )) diff --git a/apps/maple-agent/app/src/ui/chat/turn.rs b/apps/maple-agent/app/src/ui/chat/turn.rs index 442754549..9ecb6247c 100644 --- a/apps/maple-agent/app/src/ui/chat/turn.rs +++ b/apps/maple-agent/app/src/ui/chat/turn.rs @@ -548,14 +548,23 @@ pub(super) fn render_chunk( chunk: &Chunk, open: bool, live: bool, + // One of the chunk's calls waits for the user to allow it. Folded, the + // step that says so is hidden, so the header says it. + waiting: bool, chat: &gpui::WeakEntity, messages: &MessageCache, ) -> Div { let label = messages.get("chat-activity-steps", [("count", chunk.count().into())]); - let status = chunk.state(live).map(|state| { + let state = if waiting { + Some(step::StepState::Waiting) + } else { + chunk.state(live) + }; + let status = state.map(|state| { let (key, ink) = match state { step::StepState::Failed => ("chat-status-failed", theme::status_error()), step::StepState::Stopped => ("chat-status-stopped", theme::text_muted()), + step::StepState::Waiting => ("chat-status-waiting", theme::accent_ink()), _ => ("chat-status-running", theme::text_muted()), }; let id = SharedString::from(format!("activity-status-{lead}"));