diff options
| author | salmonik <salmonik@tuta.io> | 2026-11-15 15:37:56 +0100 |
|---|---|---|
| committer | salmonik <salmonik@tuta.io> | 2026-11-15 15:37:56 +0100 |
| commit | 714534475818e6e5dced91ecad100ca9e286ccce (patch) | |
| tree | dd36ffe02376e06bd92d9e3650bcd4ddb21d0768 /src/ui.rs | |
| parent | 0.4.0: grep takes a regular expression, fixed=true for literals (diff) | |
| download | agent686-714534475818e6e5dced91ecad100ca9e286ccce.tar.gz agent686-714534475818e6e5dced91ecad100ca9e286ccce.zip | |
0.4.1 + 0.4.2: abort integrity, stream completeness, tool-call indexing
- an aborted multi-call step now answers every announced tool call
- sessions with unanswered calls are repaired by appending results
- a stream without [DONE]/finish_reason is an error, not an answer
- tool call deltas keyed by index can no longer vanish or invent empty calls
- one-shot exit codes: 130 aborted, 3 denied
Diffstat (limited to '')
| -rw-r--r-- | src/ui.rs | 26 |
1 files changed, 14 insertions, 12 deletions
| @@ -104,14 +104,13 @@ pub fn tool_line(name: &str, args: &serde_json::Value) { | |||
| 104 | let _ = std::io::stdout().flush(); | 104 | let _ = std::io::stdout().flush(); |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | pub fn tool_result(result: &Result<String, String>) { | 107 | pub fn tool_result(summary: &str, aborted: bool) { |
| 108 | let text = match result { | 108 | let text = if aborted { |
| 109 | Ok(output) => output, | 109 | "aborted".to_string() |
| 110 | Err(error) => error, | 110 | } else { |
| 111 | crate::provider::truncate(summary.trim(), 100) | ||
| 111 | }; | 112 | }; |
| 112 | let first = text.lines().find(|l| !l.trim().is_empty()).unwrap_or(""); | 113 | println!(" {} {}", paint("2", "└"), paint("2", &text)); |
| 113 | let summary = crate::provider::truncate(first.trim(), 100); | ||
| 114 | println!(" {} {}", paint("2", "└"), paint("2", &summary)); | ||
| 115 | let _ = std::io::stdout().flush(); | 114 | let _ = std::io::stdout().flush(); |
| 116 | } | 115 | } |
| 117 | 116 | ||
| @@ -163,7 +162,7 @@ impl Approver { | |||
| 163 | self.yolo | 162 | self.yolo |
| 164 | } | 163 | } |
| 165 | 164 | ||
| 166 | fn ask(&self, question: &str) -> Answer { | 165 | fn ask(&self, question: &str, allow_always: bool) -> Answer { |
| 167 | if self.yolo { | 166 | if self.yolo { |
| 168 | return Answer::Yes; | 167 | return Answer::Yes; |
| 169 | } | 168 | } |
| @@ -174,7 +173,8 @@ impl Approver { | |||
| 174 | ); | 173 | ); |
| 175 | return Answer::No; | 174 | return Answer::No; |
| 176 | } | 175 | } |
| 177 | print!("\n{} {} ", question, paint("2", "[y/N/a]")); | 176 | let hint = if allow_always { "[y/N/a]" } else { "[y/N]" }; |
| 177 | print!("\n{} {} ", question, paint("2", hint)); | ||
| 178 | let _ = std::io::stdout().flush(); | 178 | let _ = std::io::stdout().flush(); |
| 179 | 179 | ||
| 180 | let mut line = String::new(); | 180 | let mut line = String::new(); |
| @@ -183,7 +183,7 @@ impl Approver { | |||
| 183 | } | 183 | } |
| 184 | match line.trim().to_ascii_lowercase().as_str() { | 184 | match line.trim().to_ascii_lowercase().as_str() { |
| 185 | "y" | "yes" => Answer::Yes, | 185 | "y" | "yes" => Answer::Yes, |
| 186 | "a" | "always" => Answer::Always, | 186 | "a" | "always" if allow_always => Answer::Always, |
| 187 | _ => Answer::No, | 187 | _ => Answer::No, |
| 188 | } | 188 | } |
| 189 | } | 189 | } |
| @@ -194,7 +194,7 @@ impl Approver { | |||
| 194 | return true; | 194 | return true; |
| 195 | } | 195 | } |
| 196 | println!("{preview}"); | 196 | println!("{preview}"); |
| 197 | match self.ask(&format!("apply this change to {path}?")) { | 197 | match self.ask(&format!("apply this change to {path}?"), true) { |
| 198 | Answer::Yes => true, | 198 | Answer::Yes => true, |
| 199 | Answer::Always => { | 199 | Answer::Always => { |
| 200 | self.edits_allowed = true; | 200 | self.edits_allowed = true; |
| @@ -209,6 +209,8 @@ impl Approver { | |||
| 209 | if self.yolo { | 209 | if self.yolo { |
| 210 | return true; | 210 | return true; |
| 211 | } | 211 | } |
| 212 | self.ask(&format!("run: {}", crate::provider::truncate(cmd, 200))) == Answer::Yes | 212 | // Bash prompts every call by design, so "always" is not offered here. |
| 213 | self.ask(&format!("run: {}", crate::provider::truncate(cmd, 200)), false) | ||
| 214 | == Answer::Yes | ||
| 213 | } | 215 | } |
| 214 | } | 216 | } |
