Skip to content

Fix hook timeout units: seconds, not milliseconds (#98) - #102

Merged
JayantDevkar merged 2 commits into
mainfrom
fix/hook-timeout-units-98
Sep 18, 2026
Merged

JayantDevkar merged 2 commits into
mainfrom
fix/hook-timeout-units-98

Conversation

@the-non-expert

Copy link
Copy Markdown
Collaborator

Summary

Claude Code's hook timeout field is in seconds, not milliseconds. SETUP.md and captain-hook's docs told users to install "timeout": 5000 (intended as 5s), which actually installs an 83-minute cancellation window instead. This was live on real systems, not just theoretical — verified on two machines where karma-installed hooks carried the exact 5000/15000 values straight from the docs.

  • Corrects all 144 example timeout values (and the prose claiming milliseconds) across SETUP.md, api/SETUP.md, api/scripts/SETUP.md, captain-hook/README.md, captain-hook/docs/hooks/*, and docs/about/hooks-guide.md.
  • Fixes a related real code bug this same confusion caused in karma's own /hooks browser page: HookRegistration.timeout_ms stored the raw (seconds) value from settings.json with no conversion, then displayed it suffixed ms — silently reinforcing the same mistake for anyone using karma to audit their own hooks. Renamed to timeout_seconds end-to-end (Pydantic model, api-types.ts, hooks page template).

Test plan

  • pytest -k hook passes (no dedicated hook.py test file exists; ran shell-cron tests to confirm the unrelated timeout_ms field on background_shell was untouched)
  • Sanity-instantiated HookRegistration with timeout_seconds and confirmed routers/hooks.py still imports cleanly
  • Grepped repo-wide to confirm no remaining 5000/15000-style ms-mistake values or stray timeout_ms references tied to hooks

Fixes #98

🤖 Generated with Claude Code

https://claude.ai/code/session_01Gv24uWUqNLigGcTtnGEHQv

the-non-expert and others added 2 commits September 12, 2026 11:27
…arma's own mislabeled field

Claude Code's hook `timeout` field is in seconds, not milliseconds.
SETUP.md and captain-hook's docs told users to install "timeout": 5000
(intended as 5s), which actually installs an 83-minute cancellation
window. Fixes all 144 example values across SETUP.md, api/SETUP.md,
api/scripts/SETUP.md, captain-hook/README.md, captain-hook/docs/hooks/*,
and docs/about/hooks-guide.md, plus the prose claiming milliseconds.

Also fixes a real bug this caused in karma's own /hooks browser:
HookRegistration.timeout_ms stored the raw (seconds) value from
settings.json with no conversion, then displayed it suffixed "ms" —
silently reinforcing the same unit confusion. Renamed to
timeout_seconds end-to-end (model, api-types.ts, hooks page display).

Fixes #98

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv24uWUqNLigGcTtnGEHQv
…ook sweep

The bulk seconds-conversion in the previous commit incorrectly divided
the Bash tool's own tool_input.timeout example (120000ms = 120s) as if
it were a hook-registration timeout. That field is genuinely
milliseconds -- a different, adjacent concept from the hook config's
timeout (seconds). Restores 120000.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gv24uWUqNLigGcTtnGEHQv

@JayantDevkar JayantDevkar left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified against the Claude Code hooks reference: timeout is seconds, so the old docs really did install 83-minute windows. Approving.

What I checked:

  • All 136 changed doc values are an exact ÷1000 (5000→5, 2000→2, 15000→15, …) — no stray edits.
  • The Bash tool_input.timeout: 120000 example is correctly left in ms (good catch in the second commit).
  • timeout_ms → timeout_seconds is renamed end-to-end (model, parser, api-types.ts, hooks page). The remaining timeout_ms refs are background_shells, which is genuinely ms — untouched, correct.
  • No installer/script in the repo writes hook timeouts, so docs were the only source of bad values.

Non-blocking follow-ups:

  • docs/feature/hooks-page/ui-design.md (not in this diff) still shows timeout: 5000ms / 15000ms / 30000ms in the mockups at lines 223, 231, 240, 284.
  • Users who already pasted the old config still have 5000s timeouts. A one-line note in SETUP.md (or a check on the /hooks page flagging timeouts > 600) would help them find it.

Comment thread docs/feature/hooks-page/plan.md
@JayantDevkar
JayantDevkar merged commit 8379f71 into main Sep 18, 2026
20 checks passed
the-non-expert added a commit that referenced this pull request Sep 19, 2026
…n, no orphan menu

Review feedback on #101, plus the rebase onto main (#99/#100/#102).

- Memoize the transcript scan on (path, st_mtime_ns, st_size). The single-
  session GET is polled ~1s per open tab and, when RC has never been used,
  found no bridge_status line anywhere — so every uncached hit re-read and
  decoded the whole multi-MB chain. A JSONL transcript is append-only, so an
  unchanged transcript is now scanned exactly once.
- Verify a tmux pane still owns the recorded pid before enabling the toggle.
  pid_is_live_claude accepts node/bun/deno, so a recycled pid in a recycled
  pane could have enabled RC on a *different* Claude session. The pane's
  pane_pid must now be that pid or an ancestor of it; unverifiable => refused.
- Require Origin on the toggle, not just "trusted if present". For a
  keystroke-injecting endpoint, no-Origin isn't worth the benefit of the
  doubt: this closes DNS-rebinding and the no-Origin-same-origin-POST corner.
- Drop the "Esc-dismisses" claim in read_remote_control_state — nothing here
  sends Esc. A stale "off" (session launched with --remote-control, no
  bridge_status line) meant the ON click opened the *disconnect* menu and left
  it open in an unfocused terminal, where the user's next Enter picks an item.
  Unconfirmed ON now raises the terminal like the OFF path and says so.

ConversationHeader: #100's ResumeSessionButton supersedes this branch's
live-session hide (it focuses the terminal when live, which is useful), so the
rebase keeps #100's version outright and drops the copy-resume block.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SETUP.md documents hook timeout as milliseconds, but it is seconds (5000 = 83 minutes)

2 participants