2026-10-06 23:11:07 -04:00
|
|
|
#!/bin/bash
|
|
|
|
|
# Claude Code SessionStart hook (wired in via claude-settings.json). Records the
|
|
|
|
|
# Claude session ID for the DevDesk session this Claude runs in, so that after a
|
|
|
|
|
# reboot devdesk-claude-run can `claude --resume` exactly this conversation.
|
|
|
|
|
# Fires on startup, resume, /clear and /compact. Must never block Claude.
|
|
|
|
|
|
|
|
|
|
# shellcheck source=libexec/devdesk-lib.sh
|
|
|
|
|
. "${DEVDESK_LIBEXEC:-/usr/lib/devdesk}/devdesk-lib.sh" || exit 0
|
|
|
|
|
|
|
|
|
|
input=$(cat)
|
|
|
|
|
id=$(jq -r '.session_id // empty' <<<"$input" 2>/dev/null)
|
|
|
|
|
source=$(jq -r '.source // empty' <<<"$input" 2>/dev/null)
|
|
|
|
|
[ -n "$id" ] || exit 0
|
|
|
|
|
|
2026-10-11 01:01:51 -04:00
|
|
|
# The session's name is read under the registry lock: a rename holds it too,
|
|
|
|
|
# so the id can't land under the old name after the entry moved.
|
|
|
|
|
# shellcheck disable=SC2317 # called through dd_registry_locked
|
|
|
|
|
record() {
|
|
|
|
|
local session
|
|
|
|
|
session=$(dd_current_session)
|
|
|
|
|
if [ -z "$session" ] || ! dd_valid_name "$session"; then return 0; fi
|
|
|
|
|
dd_registry_set_claude "$session" "$id" "$source"
|
|
|
|
|
}
|
|
|
|
|
dd_registry_locked record 2>/dev/null
|
|
|
|
|
dd_sweep_tmp
|
2026-10-06 23:11:07 -04:00
|
|
|
exit 0
|