Skip to content
This repository was archived by the owner on Jul 1, 2026. It is now read-only.

feat(cost-export): standard local-session "underway" heartbeat hook - #65

Merged
cpitzi merged 1 commit into
mainfrom
feat/local-session-heartbeat
Jun 17, 2026
Merged

feat(cost-export): standard local-session "underway" heartbeat hook#65
cpitzi merged 1 commit into
mainfrom
feat/local-session-heartbeat

Conversation

@cpitzi

@cpitzi cpitzi commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Origin

Chris built a local-session "underway" heartbeat ad-hoc on the laptop — a Claude Code hook that pushes session_running to the homelab Loki receiver so the "Local sessions underway" pane on the Claude Runner Fleet dashboard shows which workstations are actively working. He liked it as an operational standard and asked to fold it into workstation-bootstrap so every bootstrapped machine installs it, confirming active tool use (not session liveness) is the correct metric.

What changed

  • New claude-cost-export/session-heartbeat.sh — the exact hook now running on the laptop. Throttled to one push per session per COST_HEARTBEAT_SEC (30s), fire-and-forget, never spooled, off-LAN no-ops. Pushes event="session_running" (job="claude_local", worker=<hostname>).
  • install.sh — deploys the script and wires it into settings.json on PostToolUse + UserPromptSubmit, idempotently, alongside the existing SessionEnd hook (refactored the merge into hook_present/add_hook helpers; one backup, no duplicates on re-run).
  • README — documents the live "underway" signal, its active-tool-use semantics, the [2m] stacked dashboard query, and COST_HEARTBEAT_SEC.

Propagation

The four setup-*.sh scripts already invoke claude-cost-export/install.sh, so this reaches every platform (Crostini / Xubuntu / Fedora / Ubuntu laptop) with no changes to them. Idempotent: re-running install on the already-configured laptop is a no-op (hooks detected present).

Validation

shellcheck clean on both install.sh and session-heartbeat.sh; the hook is verified end-to-end in production (events land in Loki, drive the live pane). The dashboard pane itself ships in homelab-observability (PR #73).

🤖 Generated with Claude Code

Fold the local-session in-flight heartbeat into the claude-cost-export component
so every bootstrapped workstation installs it. Adds session-heartbeat.sh — a
throttled (~30s) PostToolUse + UserPromptSubmit hook that fire-and-forgets a
`session_running` event to the homelab Loki receiver while a session is actively
working, driving the "Local sessions underway" pane on the Claude Runner Fleet
dashboard. The metric is active tool use (idle/open sessions don't beat).

install.sh now deploys the script and wires both hooks idempotently alongside the
existing SessionEnd hook (one backup, no duplicates); the four setup-*.sh scripts
already call install.sh, so it propagates to every platform with no further
changes. README documents the signal, its semantics, and COST_HEARTBEAT_SEC.

Prompt-Origin: Chris liked the local-session underway heartbeat built ad-hoc on
the laptop and wanted it folded into workstation-bootstrap as an operational
standard, confirming active tool use is the correct metric.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cpitzi
cpitzi merged commit 0aeadf4 into main Jun 17, 2026
2 checks passed
@cpitzi
cpitzi deleted the feat/local-session-heartbeat branch June 17, 2026 22:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant