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
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Origin
Chris built a local-session "underway" heartbeat ad-hoc on the laptop — a Claude Code hook that pushes
session_runningto 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 intoworkstation-bootstrapso every bootstrapped machine installs it, confirming active tool use (not session liveness) is the correct metric.What changed
claude-cost-export/session-heartbeat.sh— the exact hook now running on the laptop. Throttled to one push per session perCOST_HEARTBEAT_SEC(30s), fire-and-forget, never spooled, off-LAN no-ops. Pushesevent="session_running"(job="claude_local",worker=<hostname>).install.sh— deploys the script and wires it intosettings.jsonon PostToolUse + UserPromptSubmit, idempotently, alongside the existing SessionEnd hook (refactored the merge intohook_present/add_hookhelpers; one backup, no duplicates on re-run).[2m]stacked dashboard query, andCOST_HEARTBEAT_SEC.Propagation
The four
setup-*.shscripts already invokeclaude-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
shellcheckclean on bothinstall.shandsession-heartbeat.sh; the hook is verified end-to-end in production (events land in Loki, drive the live pane). The dashboard pane itself ships inhomelab-observability(PR #73).🤖 Generated with Claude Code