Skip to content

Commit 58ea878

Browse files
committed
delete all flag, add summry when fs read
1 parent 0a6e993 commit 58ea878

File tree

4 files changed

+35
-55
lines changed

4 files changed

+35
-55
lines changed

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -227,29 +227,6 @@ impl CaptureManager {
227227
Ok(())
228228
}
229229

230-
/// Delete the captures root (all sessions) and recreate it empty.
231-
pub async fn clean_all_sessions(&self, os: &Os) -> Result<()> {
232-
let root = self
233-
.shadow_repo_path
234-
.parent()
235-
.ok_or_else(|| eyre!("Could not determine captures root"))?;
236-
237-
// Safety guard: ensure last component contains "captures"
238-
if root
239-
.file_name()
240-
.and_then(|s| s.to_str())
241-
.map(|s| s.contains("captures"))
242-
!= Some(true)
243-
{
244-
bail!("Refusing to delete unexpected parent directory: {}", root.display());
245-
}
246-
247-
println!("Deleting captures root: {}", root.display());
248-
os.fs.remove_dir_all(root).await?;
249-
os.fs.create_dir_all(root).await?;
250-
Ok(())
251-
}
252-
253230
/// Produce a user-friendly diff between two tags, including `--stat`.
254231
pub fn diff_detailed(&self, tag1: &str, tag2: &str) -> Result<String> {
255232
let out = run_git(&self.shadow_repo_path, false, &["diff", "--name-status", tag1, tag2])?;

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

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,28 @@ pub enum CaptureSubcommand {
3030
/// Manually initialize captures
3131
Init,
3232

33-
/// Revert to a specified checkpoint or the most recent if none specified
34-
/// --hard: reset all files and delete any created since the checkpoint
33+
/// Restore workspace to a checkpoint
34+
#[command(
35+
about = "Restore workspace to a checkpoint",
36+
long_about = r#"Restore files to a checkpoint <tag>. If <tag> is omitted, you'll pick one interactively.
37+
38+
Default:
39+
• Revert tracked changes and restore tracked deletions.
40+
• Do NOT delete files created after the checkpoint.
41+
42+
--hard:
43+
• Make workspace exactly match the checkpoint.
44+
• Delete tracked files created after the checkpoint.
45+
46+
Notes:
47+
• Also rolls back conversation history to the checkpoint.
48+
• Tags: turn (e.g., 3) or tool (e.g., 3.1)."#
49+
)]
3550
Restore {
51+
/// Checkpoint tag (e.g., 3 or 3.1). Omit to choose interactively.
3652
tag: Option<String>,
53+
54+
/// Match checkpoint exactly; deletes tracked files created after it.
3755
#[arg(long)]
3856
hard: bool,
3957
},
@@ -44,12 +62,8 @@ pub enum CaptureSubcommand {
4462
limit: Option<usize>,
4563
},
4664

47-
/// Delete shadow repository or the whole captures root (--all)
48-
Clean {
49-
/// Delete the entire captures root (all sessions)
50-
#[arg(long)]
51-
all: bool,
52-
},
65+
/// Delete shadow repository
66+
Clean,
5367

5468
/// Display more information about a turn-level checkpoint
5569
Expand { tag: String },
@@ -157,32 +171,15 @@ impl CaptureSubcommand {
157171
return Err(ChatError::Custom(format!("Could not display all captures: {e}").into()));
158172
},
159173
},
160-
Self::Clean { all } => {
161-
let res = if all {
162-
manager.clean_all_sessions(os).await
163-
} else {
164-
manager.clean(os).await
165-
};
166-
match res {
174+
Self::Clean {} => {
175+
match manager.clean(os).await {
167176
Ok(()) => execute!(
168177
session.stderr,
169-
style::Print(
170-
if all {
171-
"Deleted all session captures under the captures root.\n"
172-
} else {
173-
"Deleted shadow repository for this session.\n"
174-
}
175-
.blue()
176-
.bold()
177-
)
178+
style::Print("Deleted shadow repository for this session.\n".bold())
178179
)?,
179180
Err(e) => {
180181
session.conversation.capture_manager = None;
181-
return Err(ChatError::Custom(if all {
182-
format!("Could not delete captures root: {e}").into()
183-
} else {
184-
format!("Could not delete shadow repo: {e}").into()
185-
}));
182+
return Err(ChatError::Custom(format!("Could not delete shadow repo: {e}").into()));
186183
},
187184
}
188185
session.conversation.capture_manager = None;

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2357,9 +2357,14 @@ impl ChatSession {
23572357
};
23582358
let tag = if has_uncommitted {
23592359
let mut tag = format!("{}.{}", manager.num_turns + 1, manager.num_tools_this_turn + 1);
2360-
let commit_message = match tool.tool.get_summary() {
2361-
Some(summary) => summary,
2362-
None => tool.tool.display_name(),
2360+
let is_fs_read = matches!(&tool.tool, Tool::FsRead(_));
2361+
let commit_message = if is_fs_read {
2362+
"External edits detected (likely manual change)".to_string()
2363+
} else {
2364+
match tool.tool.get_summary() {
2365+
Some(summary) => summary,
2366+
None => tool.tool.display_name(),
2367+
}
23632368
};
23642369

23652370
match manager.create_capture_with_stats(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ impl Tool {
193193
match self {
194194
Tool::FsWrite(fs_write) => fs_write.get_summary().cloned(),
195195
Tool::ExecuteCommand(execute_cmd) => execute_cmd.summary.clone(),
196+
Tool::FsRead(fs_read) => fs_read.summary.clone(),
196197
_ => None,
197198
}
198199
}

0 commit comments

Comments
 (0)