diff options
| author | JJ Liebig <jonathan.liebig@gmail.com> | 2026-09-04 14:54:05 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-09-04 14:54:05 +0200 |
| commit | 6045fe6a8735609507ec8600fa07205227546e8b (patch) | |
| tree | 2cbdd462a96b412e6bdf7349a581e016a97dc2ea /src/agent_resume.rs | |
| parent | 3150bd92d6162ba248bc28fd4d40bd0d6238e1af (diff) | |
fix: persist Codex resume sessions at launch (#3617)
refs #3517
Diffstat (limited to 'src/agent_resume.rs')
| -rw-r--r-- | src/agent_resume.rs | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/agent_resume.rs b/src/agent_resume.rs index cd1ae7bb..075c396f 100644 --- a/src/agent_resume.rs +++ b/src/agent_resume.rs @@ -69,6 +69,24 @@ pub fn session_ref_from_report( agent_session_id.and_then(AgentSessionRef::id) } +pub fn persisted_session_from_launch_args( + agent: crate::detect::Agent, + args: &[String], +) -> Option<PersistedAgentSession> { + let [command, session_id] = args else { + return None; + }; + if agent != crate::detect::Agent::Codex || command != "resume" || session_id.starts_with('-') { + return None; + } + + Some(PersistedAgentSession { + source: "herdr:codex".into(), + agent: "codex".into(), + session_ref: AgentSessionRef::id(session_id.clone())?, + }) +} + pub fn normalize_session_start_source(value: Option<String>) -> Option<String> { match value.as_deref().map(str::trim) { Some( @@ -283,6 +301,40 @@ mod tests { } #[test] + fn codex_noncanonical_resume_launch_has_no_explicit_session() { + assert_eq!( + persisted_session_from_launch_args( + crate::detect::Agent::Codex, + &["resume".into(), "codex-session".into()] + ) + .unwrap() + .session_ref + .value, + "codex-session" + ); + assert!(persisted_session_from_launch_args( + crate::detect::Agent::Codex, + &["resume".into(), "--last".into()] + ) + .is_none()); + assert!(persisted_session_from_launch_args( + crate::detect::Agent::Codex, + &["resume".into(), "not-a-session".into(), "--last".into()] + ) + .is_none()); + assert!(persisted_session_from_launch_args( + crate::detect::Agent::Codex, + &[ + "--remote".into(), + "ws://example.test".into(), + "resume".into(), + "remote-session".into(), + ] + ) + .is_none()); + } + + #[test] fn planner_allows_supported_agents() { let pi_session = absolute_test_path("pi-session.jsonl"); let omp_session = absolute_test_path("omp-session.jsonl"); |
