Skip to content

Commit da849a0

Browse files
committed
refactor(ai_chat): drop /suggest placeholder for minimum-diff feedback
The "Thinking..." placeholder + replace-in-place logic was UX nice-to-have but added ~14 lines of state tracking on top of an already-async command. cmd_suggest now just spawns; drain_suggest just push_info on the result. The double-fire guard is dropped too: a second /suggest overwrites the prior receiver, the abandoned worker's send becomes a no-op via let _.
1 parent 733d4cb commit da849a0

1 file changed

Lines changed: 3 additions & 25 deletions

File tree

kaku-gui/src/overlay/ai_chat/state.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ use super::prompt_context::{
2121
use super::types::*;
2222
use super::{strings, syntax, waza};
2323

24-
/// Placeholder line shown while a `/suggest` request is in flight. `drain_suggest`
25-
/// replaces this exact line in place once the result arrives.
26-
const SUGGEST_PENDING_TEXT: &str = "Thinking about a follow-up suggestion...";
27-
2824
// ─── Input snapshot helpers ───────────────────────────────────────────────────
2925

3026
/// Push `(input, cursor)` onto `stack` iff the input is non-empty. When the
@@ -1859,13 +1855,10 @@ impl App {
18591855
self.push_info("Not enough conversation yet to suggest a follow-up.");
18601856
return;
18611857
}
1862-
if self.suggest_rx.is_some() {
1863-
self.push_info("Already working on a suggestion, hold on.");
1864-
return;
1865-
}
1866-
self.push_info(SUGGEST_PENDING_TEXT);
18671858
let client = self.client.clone();
18681859
let (tx, rx) = mpsc::channel::<Result<String, String>>();
1860+
// A second `/suggest` before the first lands drops the prior receiver;
1861+
// its worker's `send` becomes a no-op via `let _ =`.
18691862
self.suggest_rx = Some(rx);
18701863
crate::thread_util::spawn_with_pool(move || {
18711864
let result = crate::ai_chat_engine::suggestion::generate_suggestion(&client, &msgs)
@@ -1875,8 +1868,7 @@ impl App {
18751868
}
18761869

18771870
/// Drain the background `/suggest` channel. Returns true if a redraw is
1878-
/// needed. Replaces the pending placeholder line in place so the transcript
1879-
/// shows a single suggestion line rather than placeholder + result.
1871+
/// needed.
18801872
pub(crate) fn drain_suggest(&mut self) -> bool {
18811873
let rx = match self.suggest_rx.take() {
18821874
Some(rx) => rx,
@@ -1897,20 +1889,6 @@ impl App {
18971889
"Could not generate a suggestion right now.".to_string()
18981890
}
18991891
};
1900-
// Replace the placeholder wherever it sits, not just at the tail: the
1901-
// user may have produced new lines while the request was in flight, in
1902-
// which case the pending line is no longer last. Searching from the end
1903-
// targets the most recent (and only) outstanding placeholder.
1904-
if let Some(slot) = self
1905-
.messages
1906-
.iter_mut()
1907-
.rev()
1908-
.find(|m| m.is_context && m.content == SUGGEST_PENDING_TEXT)
1909-
{
1910-
slot.content = text;
1911-
self.display_lines_dirty = true;
1912-
return true;
1913-
}
19141892
self.push_info(&text);
19151893
true
19161894
}

0 commit comments

Comments
 (0)