Skip to content

Commit 34e69d1

Browse files
feat(ui): stop spinner only for tools requiring stdout/stderr access (tailcallhq#2243)
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
1 parent b2168ef commit 34e69d1

3 files changed

Lines changed: 41 additions & 2 deletions

File tree

‎crates/forge_domain/src/tools/call/tool_call.rs‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ impl ToolCallFull {
9191
}
9292
}
9393

94+
/// Returns true if this tool requires direct stdout/stderr access
95+
pub fn requires_stdout(&self) -> bool {
96+
crate::ToolCatalog::requires_stdout(&self.name)
97+
}
98+
9499
pub fn try_from_parts(parts: &[ToolCallPart]) -> Result<Vec<Self>> {
95100
if parts.is_empty() {
96101
return Ok(vec![]);
@@ -272,6 +277,18 @@ mod tests {
272277

273278
use super::*;
274279

280+
#[test]
281+
fn test_requires_stdout_for_shell_tool() {
282+
let fixture = ToolCallFull::new("shell");
283+
assert!(fixture.requires_stdout());
284+
}
285+
286+
#[test]
287+
fn test_requires_stdout_for_non_shell_tool() {
288+
let fixture = ToolCallFull::new("read");
289+
assert!(!fixture.requires_stdout());
290+
}
291+
275292
#[test]
276293
fn test_multiple_calls() {
277294
let input = [

‎crates/forge_domain/src/tools/catalog.rs‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,6 +537,13 @@ impl ToolCatalog {
537537
.any(|v| v.to_string().to_case(Case::Snake).eq(tool_name.as_str()))
538538
}
539539

540+
pub fn requires_stdout(tool_name: &ToolName) -> bool {
541+
// Tools that require direct stdout/stderr access
542+
[ToolKind::Shell]
543+
.iter()
544+
.any(|v| v.to_string().to_case(Case::Snake).eq(tool_name.as_str()))
545+
}
546+
540547
/// Convert a tool input to its corresponding domain operation for policy
541548
/// checking. Returns None for tools that don't require permission
542549
/// checks.
@@ -833,6 +840,18 @@ mod tests {
833840
assert_eq!(actual, expected);
834841
}
835842

843+
#[test]
844+
fn test_requires_stdout_for_shell() {
845+
let fixture = ToolName::new("shell");
846+
assert!(ToolCatalog::requires_stdout(&fixture));
847+
}
848+
849+
#[test]
850+
fn test_requires_stdout_for_non_shell() {
851+
let fixture = ToolName::new("read");
852+
assert!(!ToolCatalog::requires_stdout(&fixture));
853+
}
854+
836855
#[test]
837856
fn test_tool_definition_json() {
838857
let tools = ToolCatalog::iter()

‎crates/forge_main/src/ui.rs‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2631,8 +2631,11 @@ impl<A: API + 'static, F: Fn() -> A + Send + Sync> UI<A, F> {
26312631
self.writeln(self.markdown.render(&text))?;
26322632
}
26332633
},
2634-
ChatResponse::ToolCallStart(_) => {
2635-
self.spinner.stop(None)?;
2634+
ChatResponse::ToolCallStart(tool_call) => {
2635+
// Stop spinner only for tools that require stdout/stderr access
2636+
if tool_call.requires_stdout() {
2637+
self.spinner.stop(None)?;
2638+
}
26362639
}
26372640
ChatResponse::ToolCallEnd(toolcall_result) => {
26382641
// Only track toolcall name in case of success else track the error.

0 commit comments

Comments
 (0)