Skip to content

Commit 16c1d27

Browse files
authored
Fix create_or_join to check for existing session before auto-suffixing (#11)
The auto-suffix feature caused create_or_join to create a new suffixed session instead of joining the existing one. Check if the session already exists upfront and return early if so.
1 parent 4856576 commit 16c1d27

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/command_surface.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,11 +977,15 @@ fn create_or_join(
977977
create_args: &crate::cli::CreateArgs,
978978
registry: &WorkflowRegistry,
979979
) -> Result<String> {
980+
if crate::state::session_dir(&create_args.name)
981+
.join("state.json")
982+
.exists()
983+
{
984+
return Ok(create_args.name.clone());
985+
}
980986
match commands::create_with_registry(create_args, registry) {
981987
Ok(name) => Ok(name),
982988
Err(err) => {
983-
// NOTE: matches the bail! message in state.rs create_session_state()
984-
// ("session '{}' already exists"). If that message changes, update here.
985989
if err.to_string().contains("already exists") {
986990
Ok(create_args.name.clone())
987991
} else {

0 commit comments

Comments
 (0)