Skip to content

Commit e2c3590

Browse files
committed
revise ui
1 parent f1b76f8 commit e2c3590

File tree

2 files changed

+61
-28
lines changed

2 files changed

+61
-28
lines changed

crates/chat-cli/src/cli/chat/cli/capture.rs

Lines changed: 47 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -29,29 +29,29 @@ pub enum CaptureSubcommand {
2929
/// Initialize captures manually
3030
Init,
3131

32-
/// Restore workspace to a checkpoint
32+
/// Restore workspace to a capture
3333
#[command(
34-
about = "Restore workspace to a checkpoint",
35-
long_about = r#"Restore files to a checkpoint <tag>. If <tag> is omitted, you'll pick one interactively.
34+
about = "Restore workspace to a capture",
35+
long_about = r#"Restore files to a capture <tag>. If <tag> is omitted, you'll pick one interactively.
3636
3737
Default mode:
3838
• Restores tracked file changes
39-
• Keeps new files created after the checkpoint
39+
• Keeps new files created after the capture
4040
4141
With --hard:
42-
• Exactly matches the checkpoint state
43-
• Removes files created after the checkpoint"#
42+
• Exactly matches the capture state
43+
• Removes files created after the capture"#
4444
)]
4545
Restore {
46-
/// Checkpoint tag (e.g., 3 or 3.1). Leave empty to select interactively.
46+
/// Capture tag (e.g., 3 or 3.1). Leave empty to select interactively.
4747
tag: Option<String>,
4848

49-
/// Exactly match checkpoint state (removes newer files)
49+
/// Exactly match capture state (removes newer files)
5050
#[arg(long)]
5151
hard: bool,
5252
},
5353

54-
/// List all checkpoints
54+
/// List all captures
5555
List {
5656
/// Limit number of results shown
5757
#[arg(short, long)]
@@ -61,18 +61,18 @@ With --hard:
6161
/// Delete the shadow repository
6262
Clean,
6363

64-
/// Show details of a checkpoint
64+
/// Show details of a capture
6565
Expand {
66-
/// Checkpoint tag to expand
66+
/// Capture tag to expand
6767
tag: String,
6868
},
6969

70-
/// Show differences between checkpoints
70+
/// Show differences between captures
7171
Diff {
72-
/// First checkpoint tag
72+
/// First capture tag
7373
tag1: String,
7474

75-
/// Second checkpoint tag (defaults to current state)
75+
/// Second capture tag (defaults to current state)
7676
#[arg(required = false)]
7777
tag2: Option<String>,
7878
},
@@ -94,7 +94,10 @@ impl CaptureSubcommand {
9494
if session.conversation.capture_manager.is_some() {
9595
execute!(
9696
session.stderr,
97-
style::Print("✓ Captures are already enabled for this session\n".blue())
97+
style::Print(
98+
"✓ Captures are already enabled for this session! Use /capture list to see current captures.\n"
99+
.blue()
100+
)
98101
)?;
99102
} else {
100103
let path = get_shadow_repo_dir(os, session.conversation.conversation_id().to_string())
@@ -110,7 +113,7 @@ impl CaptureSubcommand {
110113
execute!(
111114
session.stderr,
112115
style::Print(
113-
format!("✓ Captures enabled ({:.2}s)\n", start.elapsed().as_secs_f32())
116+
format!("✓ Captures are enabled! (took {:.2}s)\n", start.elapsed().as_secs_f32())
114117
.blue()
115118
.bold()
116119
)
@@ -145,7 +148,7 @@ impl CaptureSubcommand {
145148
// Interactive selection
146149
match gather_turn_captures(&manager) {
147150
Ok(entries) => {
148-
if let Some(idx) = select_capture(&entries, "Select checkpoint to restore:") {
151+
if let Some(idx) = select_capture(&entries, "Select capture to restore:") {
149152
Ok(entries[idx].tag.clone())
150153
} else {
151154
Err(())
@@ -172,7 +175,7 @@ impl CaptureSubcommand {
172175
Ok(_) => {
173176
execute!(
174177
session.stderr,
175-
style::Print(format!("✓ Restored to checkpoint {}\n", tag).blue().bold())
178+
style::Print(format!("✓ Restored to capture {}\n", tag).blue().bold())
176179
)?;
177180
session.conversation.capture_manager = Some(manager);
178181
},
@@ -214,9 +217,18 @@ impl CaptureSubcommand {
214217
});
215218
};
216219

220+
// Print the path that will be deleted
221+
execute!(
222+
session.stderr,
223+
style::Print(format!("Deleting: {}\n", manager.shadow_repo_path.display()))
224+
)?;
225+
217226
match manager.cleanup(os).await {
218227
Ok(()) => {
219-
execute!(session.stderr, style::Print("✓ Shadow repository deleted.\n".bold()))?;
228+
execute!(
229+
session.stderr,
230+
style::Print("✓ Deleted shadow repository for this session.\n".bold())
231+
)?;
220232
},
221233
Err(e) => {
222234
session.conversation.capture_manager = Some(manager);
@@ -270,7 +282,13 @@ impl CaptureSubcommand {
270282
if tag1 != "HEAD" && !manager.tag_index.contains_key(&tag1) {
271283
execute!(
272284
session.stderr,
273-
style::Print(format!("⚠ Checkpoint '{}' not found\n", tag1).yellow())
285+
style::Print(
286+
format!(
287+
"⚠ Capture '{}' not found! Use /capture list to see available captures\n",
288+
tag1
289+
)
290+
.yellow()
291+
)
274292
)?;
275293
return Ok(ChatState::PromptUser {
276294
skip_printing_tools: true,
@@ -280,15 +298,21 @@ impl CaptureSubcommand {
280298
if tag2 != "HEAD" && !manager.tag_index.contains_key(&tag2) {
281299
execute!(
282300
session.stderr,
283-
style::Print(format!("⚠ Checkpoint '{}' not found\n", tag2).yellow())
301+
style::Print(
302+
format!(
303+
"⚠ Capture '{}' not found! Use /capture list to see available captures\n",
304+
tag2
305+
)
306+
.yellow()
307+
)
284308
)?;
285309
return Ok(ChatState::PromptUser {
286310
skip_printing_tools: true,
287311
});
288312
}
289313

290314
let header = if tag2 == "HEAD" {
291-
format!("Changes since checkpoint {}:\n", tag1)
315+
format!("Changes since capture {}:\n", tag1)
292316
} else {
293317
format!("Changes from {} to {}:\n", tag1, tag2)
294318
};
@@ -410,7 +434,7 @@ fn expand_capture(manager: &CaptureManager, output: &mut impl Write, tag: &str)
410434
let Some(&idx) = manager.tag_index.get(tag) else {
411435
execute!(
412436
output,
413-
style::Print(format!("⚠ Checkpoint '{}' not found\n", tag).yellow())
437+
style::Print(format!("⚠ capture '{}' not found\n", tag).yellow())
414438
)?;
415439
return Ok(());
416440
};

crates/chat-cli/src/cli/chat/mod.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1329,7 +1329,7 @@ impl ChatSession {
13291329
}
13301330
}
13311331

1332-
// Initialize checkpointing if possible
1332+
// Initialize capturing if possible
13331333
let path = get_shadow_repo_dir(os, self.conversation.conversation_id().to_string())?;
13341334
let start = std::time::Instant::now();
13351335
let capture_manager = match CaptureManager::auto_init(os, &path).await {
@@ -2347,8 +2347,17 @@ impl ChatSession {
23472347
// Take manager out temporarily to avoid borrow conflicts
23482348
if let Some(mut manager) = self.conversation.capture_manager.take() {
23492349
// Check if there are uncommitted changes
2350-
let has_changes = manager.has_changes().unwrap_or(true);
2351-
2350+
let has_changes = match manager.has_changes() {
2351+
Ok(b) => b,
2352+
Err(e) => {
2353+
execute!(
2354+
self.stderr,
2355+
style::Print(format!("Could not check if uncommitted changes exist: {e}\n").yellow())
2356+
)?;
2357+
execute!(self.stderr, style::Print("Saving anyways...\n".yellow()))?;
2358+
true
2359+
},
2360+
};
23522361
let tag = if has_changes {
23532362
// Generate tag for this tool use
23542363
let tag = format!("{}.{}", manager.current_turn + 1, manager.tools_in_turn + 1);
@@ -2861,12 +2870,12 @@ impl ChatSession {
28612870
if let Err(e) = manager.create_capture(&tag, &description, history_len, true, None) {
28622871
execute!(
28632872
self.stderr,
2864-
style::Print(format!("⚠ Could not create capture: {}\n\n", e).yellow())
2873+
style::Print(format!("⚠ Could not create automatic capture: {}\n\n", e).yellow())
28652874
)?;
28662875
} else {
28672876
execute!(
28682877
self.stderr,
2869-
style::Print(format!("✓ Created checkpoint {}\n\n", tag).blue().bold())
2878+
style::Print(format!("✓ Created capture {}\n\n", tag).blue().bold())
28702879
)?;
28712880
}
28722881

0 commit comments

Comments
 (0)