Skip to content

Commit 3b14ab2

Browse files
authored
feat(cli, conversation): add conversation fork command (#374)
Introduce the `jp conversation fork` command, allowing users to create a new conversation based on the contents of an existing one. This is useful for exploring different paths or isolating specific parts of a discussion. The command supports time-based filtering of events using the `--from` and `--until` flags, which accept both relative (e.g., "5mins") and absolute timestamps. Users can also immediately switch to the new fork using the `--activate` flag. ```shell # Fork the active conversation jp conversation fork --activate # Fork a specific conversation with events from 10 minutes ago jp conversation fork <id> --from 10mins ``` Internally, changes are made to make it easier to test code that relies on the current timestamp, such as `Workspace::set_active_conversation_id`, and `Workspace::create_conversation`. Additionally, the persistence logic was moved from `Ctx` to `Workspace` to ensure state is saved even when the workspace is dropped outside of the CLI context. --------- Signed-off-by: Jean Mertz <[email protected]>
1 parent c2ca0f8 commit 3b14ab2

File tree

12 files changed

+572
-23
lines changed

12 files changed

+572
-23
lines changed

Cargo.lock

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/jp_cli/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,12 @@ url = { workspace = true }
8787
which = { workspace = true, features = ["real-sys"] }
8888

8989
[dev-dependencies]
90+
assert_matches = { workspace = true }
9091
indoc = { workspace = true }
9192
insta = { workspace = true, features = ["toml"] }
9293
pretty_assertions = { workspace = true, features = ["std"] }
9394
serial_test = { workspace = true }
95+
tempfile = { workspace = true }
9496
test-log = { workspace = true }
9597

9698
[lints]

crates/jp_cli/src/cmd/conversation.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use super::Output;
22
use crate::ctx::Ctx;
33

44
mod edit;
5+
mod fork;
56
mod ls;
67
mod rm;
78
mod show;
@@ -21,6 +22,7 @@ impl Conversation {
2122
Commands::List(args) => args.run(ctx),
2223
Commands::Use(args) => args.run(ctx),
2324
Commands::Edit(args) => args.run(ctx).await,
25+
Commands::Fork(args) => args.run(ctx),
2426
}
2527
}
2628
}
@@ -46,4 +48,7 @@ enum Commands {
4648
/// Edit conversation details.
4749
#[command(name = "edit")]
4850
Edit(edit::Edit),
51+
52+
/// Fork a conversation.
53+
Fork(fork::Fork),
4954
}

0 commit comments

Comments
 (0)