plan mode: show full plan before the exit prompt (claude ExitPlanMode via bridge, ask_user path)
This commit is contained in:
1 parent
36e99fc8af
commit
8a9d8fe607
6 files changed
+78
-6
No files matched your search
@@ -286,6 +286,7 @@ mod tests {
|
||||
],
|
||||
multi,
|
||||
other: true,
|
||||
plan: None,
|
||||
})
|
||||
}
|
||||
fn k(c: KeyCode) -> KeyEvent {
|
||||
@@ -405,6 +406,7 @@ mod tests {
|
||||
],
|
||||
multi: false,
|
||||
other: true,
|
||||
plan: None,
|
||||
});
|
||||
let mut term = ratatui::Terminal::new(ratatui::backend::TestBackend::new(200, 50)).unwrap();
|
||||
term.draw(|f| c.draw(f, 45)).unwrap();
|
||||
|
||||
@@ -539,7 +539,12 @@ pub async fn run(setup: Setup) -> std::io::Result<()> {
|
||||
match u {
|
||||
Ui::Ask(q, reply) => app.ask = Some((q, reply)),
|
||||
Ui::Permit(r, reply) => app.perm = Some((permit_view::Prompt::new(r), reply)),
|
||||
Ui::Choose(q, reply) => app.choose = Some((choose::Choose::new(q), reply)),
|
||||
Ui::Choose(q, reply) => {
|
||||
if let Some(p) = &q.plan {
|
||||
app.t.push(Item::Plan(p.clone()));
|
||||
}
|
||||
app.choose = Some((choose::Choose::new(q), reply))
|
||||
}
|
||||
Ui::Ev(e) => {
|
||||
if let Event::SubUsage(u) = &e {
|
||||
app.st.usage.add(u);
|
||||
|
||||
@@ -21,6 +21,8 @@ pub enum Item {
|
||||
started: Instant,
|
||||
took: Option<Duration>,
|
||||
},
|
||||
/// A finished plan, shown in full.
|
||||
Plan(String),
|
||||
Info(String),
|
||||
Error(String),
|
||||
/// Hook reports injected at turn end (`[lens] …`), shown as the lens block.
|
||||
@@ -352,12 +354,9 @@ fn render(it: &Item, expanded: bool, width: usize, out: &mut Vec<Line<'static>>)
|
||||
Item::Lens(texts) => lens_block(texts, expanded, width, out),
|
||||
Item::Error(s) => out.push(Line::styled(format!("{} {s}", th.sym.err), th.err())),
|
||||
Item::Tool { name, args, .. } if name == "exit_plan" => {
|
||||
let mut md = vec![];
|
||||
markdown(args["plan"].as_str().unwrap_or_default(), &mut md);
|
||||
out.push(Line::styled(th.rule("plan", width), th.accent()));
|
||||
lead(md, " ", th.plain(), out);
|
||||
out.push(Line::styled(th.rule("", width), th.dim()));
|
||||
plan_block(args["plan"].as_str().unwrap_or_default(), width, out)
|
||||
}
|
||||
Item::Plan(p) => plan_block(p, width, out),
|
||||
Item::Tool {
|
||||
name,
|
||||
args,
|
||||
@@ -379,6 +378,15 @@ fn render(it: &Item, expanded: bool, width: usize, out: &mut Vec<Line<'static>>)
|
||||
}
|
||||
}
|
||||
|
||||
fn plan_block(plan: &str, width: usize, out: &mut Vec<Line<'static>>) {
|
||||
let th = theme::t();
|
||||
let mut md = vec![];
|
||||
markdown(plan, &mut md);
|
||||
out.push(Line::styled(th.rule("plan", width), th.accent()));
|
||||
lead(md, " ", th.plain(), out);
|
||||
out.push(Line::styled(th.rule("", width), th.dim()));
|
||||
}
|
||||
|
||||
/// `┄ lens ┄┄┄` rule, then per report a summary line (errors red, all-pass green) and,
|
||||
/// collapsed, the first findings; `ctrl-o` shows all.
|
||||
fn lens_block(texts: &[String], expanded: bool, width: usize, out: &mut Vec<Line<'static>>) {
|
||||
|
||||
Reference in new issue
Block a user