fix(tui): /compact <instructions> reach the compaction request
The queued /compact command drained into Effect::Compact with only the session id, so the instructions typed after the command never reached the shell's compaction prompt (which already accepts userContext). The effect carries the parsed instructions, trimmed so an edited queue row with leading whitespace still counts. Ported from upstream 1.0.22 (grok-build dispatch/queue.rs). Claude-Session: https://claude.ai/code/session_01RUqV8HVGXcAETyYbZ2tPQ4
This commit is contained in:
1 parent
4512df79e6
commit
584d0fb77e
4 files changed
+46
-6
No files matched your search
@@ -162,6 +162,12 @@ fn format_cron_prompt(prompt: &str, task_id: &str, human_schedule: &str) -> Stri
|
||||
kigi_tools::reminders::format_scheduled_task_prompt(prompt, task_id, human_schedule)
|
||||
}
|
||||
|
||||
/// `/compact <instructions>` text from a queued command; a queue edit may leave leading whitespace.
|
||||
pub(super) fn compact_user_context(text: &str) -> Option<String> {
|
||||
let inv = crate::slash::parse_invocation(text.trim_start())?;
|
||||
let args = inv.args.trim();
|
||||
(inv.token == "compact" && !args.is_empty()).then(|| args.to_string())
|
||||
}
|
||||
/// Try to send the next queued entry (prompt, command, bash, or cron) if the agent is idle.
|
||||
///
|
||||
/// Called after enqueue operations and task completions to advance the queue.
|
||||
@@ -392,10 +398,12 @@ pub(crate) fn maybe_drain_queue(agent: &mut AgentView) -> Vec<Effect> {
|
||||
agent.end_work_announced = false;
|
||||
agent.session.start_command(AgentCommand::Compact);
|
||||
agent.turn_started_at = Some(Instant::now());
|
||||
let user_context = compact_user_context(&queued.text);
|
||||
|
||||
vec![Effect::Compact {
|
||||
agent_id,
|
||||
session_id,
|
||||
user_context,
|
||||
}]
|
||||
}
|
||||
QueueEntryKind::BashCommand => {
|
||||
|
||||
Reference in new issue
Block a user