Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions pebrel_app/src/ai_agents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ impl AgentKind {
Self::Cursor => format!("agent --resume={session_id}"),
Self::Copilot => format!("copilot --resume {session_id}"),
Self::Grok => format!("grok --resume {session_id}"),
Self::CodeBuddy => format!("codebuddy --resume {session_id}"),
Self::Pi => format!("pi --session {session_id}"),
Self::OhMyPi => format!("omp --resume {session_id}"),
Self::Antigravity => format!("agy --conversation {session_id}"),
Expand All @@ -285,8 +286,7 @@ impl AgentKind {
| Self::Kilo
| Self::Qoder
| Self::Maki
| Self::Trae
| Self::CodeBuddy => return None,
| Self::Trae => return None,
Self::Kimi => format!("kimi --session {session_id}"),
Self::CommandCode => format!("command-code --resume {session_id}"),
})
Expand Down Expand Up @@ -1071,7 +1071,11 @@ mod tests {
assert_eq!(AgentKind::parse_command(command), None, "{command}");
}
assert_eq!(AgentKind::CodeBuddy.start_command(), None);
assert_eq!(AgentKind::CodeBuddy.resume_command("session-1"), None);
assert_eq!(
AgentKind::parse("cbc").unwrap().resume_command("session-1").as_deref(),
Some("codebuddy --resume session-1")
);
assert_eq!(AgentKind::CodeBuddy.resume_command("wrong id"), None);
assert_eq!(AgentKind::CodeBuddy.fork_command("session-1"), None);
}

Expand Down
1 change: 1 addition & 0 deletions pebrel_app/src/gpui_shell/terminal/view/startup_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,7 @@ fn cold_resume_of_supported_clis_waits_for_the_shell_and_preserves_each_target(
("cursor", "agent --resume=saved-conversation"),
("copilot", "copilot --resume saved-conversation"),
("grok", "grok --resume saved-conversation"),
("codebuddy", "codebuddy --resume saved-conversation"),
("omp", "omp --resume saved-conversation"),
("kimi", "kimi --session saved-conversation"),
] {
Expand Down
2 changes: 2 additions & 0 deletions pebrel_app/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ use serde::{Deserialize, Serialize};
use crate::display::color::Rgb;

mod identity;
#[cfg(test)]
mod recovery_tests;
mod window_layout;
pub(crate) use identity::codex_rollout_id;
pub use window_layout::WindowLayout;
Expand Down
79 changes: 79 additions & 0 deletions pebrel_app/src/session/recovery_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
//! Saved recovery contracts for every registered interactive CLI.
use super::*;
use crate::ai_agents::AgentKind;

fn expected_resume(kind: AgentKind, id: &str) -> Option<String> {
use AgentKind::*;
Some(match kind {
Claude => format!("claude --resume {id}"),
Codex => format!("codex resume {id}"),
Gemini => format!("gemini --resume {id}"),
Amp => format!("amp threads continue {id}"),
OpenCode => format!("opencode --session {id}"),
Copilot => format!("copilot --resume {id}"),
Cursor => format!("agent --resume={id}"),
Pi => format!("pi --session {id}"),
Antigravity => format!("agy --conversation {id}"),
Grok => format!("grok --resume {id}"),
CodeBuddy => format!("codebuddy --resume {id}"),
OhMyPi => format!("omp --resume {id}"),
Kimi => format!("kimi --session {id}"),
CommandCode => format!("command-code --resume {id}"),
Aider | Goose | Droid | Auggie | Hermes | Vibe | Qwen | Cline | Devin | Kiro | Kilo
| Qoder | Maki | Trae => return None,
})
}

fn leaf(kind: AgentKind, id: &str) -> LayoutSession {
LayoutSession::Pane {
cwd: "/same-project".into(),
custom_name: None,
launch: None,
agent: Some(AgentSession {
source: kind.slug().into(),
session_id: Some(id.into()),
session_file: None,
}),
}
}

#[test]
fn registered_clis_keep_native_ids_in_their_own_split_across_saves() {
let directory = tempfile::tempdir().unwrap();
let path = directory.path().join("session.json");
let upper_id = "2e7a4172-69d4-4075-b6cb-48ef244e4323";
let lower_id = "5e95c81e-dd38-41b0-97de-3dc49834a447";
let switched_id = "c594a477-9b34-4811-95fe-bd7b5de26081";
for kind in AgentKind::ALL {
let mut tab = TabSession::single("/same-project".into(), None, None);
tab.layout = Some(LayoutSession::Split {
axis: SplitAxis::TopBottom,
ratio_permille: 500,
first: Box::new(leaf(kind, upper_id)),
second: Box::new(leaf(kind, lower_id)),
});
let mut session = Session::new(0, vec![tab]);
for expected_upper in [upper_id, switched_id, switched_id] {
save_to(&path, &session).unwrap();
session = load_from(&path).unwrap();
assert_eq!(session.tabs.len(), 1);
let layout = session.tabs[0].layout.as_mut().unwrap();
let leaves = layout.leaves();
assert_eq!(leaves.len(), 2);
for (pane, id) in leaves.into_iter().zip([expected_upper, lower_id]) {
let LayoutSession::Pane { agent: Some(saved), .. } = pane else {
panic!("{kind:?} lost a split conversation");
};
assert_eq!(AgentKind::parse(&saved.source), Some(kind));
assert_eq!(saved.session_id.as_deref(), Some(id), "{kind:?}");
assert_eq!(saved.resume_command(), expected_resume(kind, id), "{kind:?}");
}
if expected_upper == upper_id {
let LayoutSession::Split { first, .. } = layout else {
panic!("lost split layout");
};
**first = leaf(kind, switched_id);
}
}
}
}
Loading