diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-15 02:13:30 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-15 02:13:30 +0300 |
| commit | dcfc45b45d198434db5057c991e72c089b42c705 (patch) | |
| tree | 4cbdbc253bb5dc12c734a7ed1cbf82fd444d3cd2 /src/integration | |
| parent | c91348e68b9e438159ffecc3e26bc6f971e0fa2a (diff) | |
fix: preserve claude session rotations
refs #620
Diffstat (limited to 'src/integration')
| -rw-r--r-- | src/integration/assets/claude/herdr-agent-state.ps1 | 23 | ||||
| -rw-r--r-- | src/integration/assets/claude/herdr-agent-state.sh | 26 | ||||
| -rw-r--r-- | src/integration/mod.rs | 8 |
3 files changed, 44 insertions, 13 deletions
diff --git a/src/integration/assets/claude/herdr-agent-state.ps1 b/src/integration/assets/claude/herdr-agent-state.ps1 index 71417e9c..dc78efd2 100644 --- a/src/integration/assets/claude/herdr-agent-state.ps1 +++ b/src/integration/assets/claude/herdr-agent-state.ps1 @@ -2,7 +2,7 @@ # managed by herdr; reinstalling or updating the integration overwrites this file. # add custom hooks beside this file instead of editing it. # HERDR_INTEGRATION_ID=claude -# HERDR_INTEGRATION_VERSION=5 +# HERDR_INTEGRATION_VERSION=6 param([string]$Action = "") @@ -24,6 +24,25 @@ if ([string]::IsNullOrWhiteSpace($sessionId)) { exit 0 } $seq = [DateTimeOffset]::UtcNow.ToUnixTimeMilliseconds() try { - & herdr pane report-agent-session $env:HERDR_PANE_ID --source herdr:claude --agent claude --seq $seq --agent-session-id $sessionId 2>$null | Out-Null + $args = @( + "pane", + "report-agent-session", + $env:HERDR_PANE_ID, + "--source", + "herdr:claude", + "--agent", + "claude", + "--seq", + "$seq", + "--agent-session-id", + "$sessionId" + ) + if ($payload.transcript_path -is [string] -and -not [string]::IsNullOrWhiteSpace($payload.transcript_path)) { + $args += @("--agent-session-path", "$($payload.transcript_path)") + } + if ($payload.hook_event_name -eq "SessionStart" -and $payload.source -is [string] -and -not [string]::IsNullOrWhiteSpace($payload.source)) { + $args += @("--session-start-source", "$($payload.source)") + } + & herdr @args 2>$null | Out-Null } catch { } diff --git a/src/integration/assets/claude/herdr-agent-state.sh b/src/integration/assets/claude/herdr-agent-state.sh index 12068a69..ce072189 100644 --- a/src/integration/assets/claude/herdr-agent-state.sh +++ b/src/integration/assets/claude/herdr-agent-state.sh @@ -3,7 +3,7 @@ # managed by herdr; reinstalling or updating the integration overwrites this file. # add custom hooks beside this file instead of editing it. # HERDR_INTEGRATION_ID=claude -# HERDR_INTEGRATION_VERSION=5 +# HERDR_INTEGRATION_VERSION=6 set -eu @@ -59,17 +59,27 @@ request_id = f"{source}:{int(time.time() * 1000)}:{random.randrange(1_000_000):0 report_seq = time.time_ns() session_id = hook_input.get("session_id") agent_session_id = session_id if isinstance(session_id, str) and session_id else None +transcript_path = hook_input.get("transcript_path") +agent_session_path = transcript_path if isinstance(transcript_path, str) and transcript_path else None +session_start_source = hook_input.get("source") if hook_event_name == "SessionStart" else None +if not isinstance(session_start_source, str) or not session_start_source: + session_start_source = None if agent_session_id: + params = { + "pane_id": pane_id, + "source": source, + "agent": "claude", + "seq": report_seq, + "agent_session_id": agent_session_id, + } + if agent_session_path: + params["agent_session_path"] = agent_session_path + if session_start_source: + params["session_start_source"] = session_start_source request = { "id": request_id, "method": "pane.report_agent_session", - "params": { - "pane_id": pane_id, - "source": source, - "agent": "claude", - "seq": report_seq, - "agent_session_id": agent_session_id, - }, + "params": params, } else: raise SystemExit(0) diff --git a/src/integration/mod.rs b/src/integration/mod.rs index d483e503..ab1e9e2d 100644 --- a/src/integration/mod.rs +++ b/src/integration/mod.rs @@ -27,7 +27,7 @@ const CLAUDE_HOOK_ASSET: &str = if cfg!(windows) { } else { include_str!("assets/claude/herdr-agent-state.sh") }; -const CLAUDE_INTEGRATION_VERSION: u32 = 5; +const CLAUDE_INTEGRATION_VERSION: u32 = 6; const CLAUDE_CONFIG_DIR_ENV_VAR: &str = "CLAUDE_CONFIG_DIR"; const CODEX_HOOK_INSTALL_NAME: &str = if cfg!(windows) { "herdr-agent-state.ps1" @@ -4241,7 +4241,7 @@ mod tests { assert_eq!(claude.path, hook_path); assert_eq!(claude.installed_version, Some(1)); - assert_eq!(claude.expected_version, 5); + assert_eq!(claude.expected_version, 6); assert_eq!(claude.state, IntegrationStatusKind::Outdated); std::env::remove_var("HOME"); @@ -4271,7 +4271,7 @@ mod tests { assert_eq!(claude.path, hook_path); assert_eq!(claude.installed_version, Some(2)); - assert_eq!(claude.expected_version, 5); + assert_eq!(claude.expected_version, 6); assert_eq!(claude.state, IntegrationStatusKind::Outdated); std::env::remove_var("HOME"); @@ -5542,6 +5542,8 @@ mod tests { assert!(PI_EXTENSION_ASSET.contains("agent_session_id: currentAgentSessionId")); assert!(PI_EXTENSION_ASSET.contains("publishState(true)")); assert!(CLAUDE_HOOK_ASSET.contains("agent_session_id")); + assert!(CLAUDE_HOOK_ASSET.contains("agent_session_path")); + assert!(CLAUDE_HOOK_ASSET.contains("session_start_source")); assert!(CLAUDE_HOOK_ASSET.contains("pane.report_agent_session")); assert!(!CLAUDE_HOOK_ASSET.contains("\"state\": action")); assert!(!CLAUDE_HOOK_ASSET.contains("pane.release_agent")); |
