Skip to content

feat(statusline): report session end so ShellTime summarizes it right away - #12

Merged
AnnatarHe merged 1 commit into
mainfrom
claude/relaxed-tesla-gdpksy
Oct 10, 2026
Merged

AnnatarHe merged 1 commit into
mainfrom
claude/relaxed-tesla-gdpksy

Conversation

@AnnatarHe

@AnnatarHe AnnatarHe commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a session.end hook, the mod form of Claude Code's SessionEnd event. When a session ends, the hook sends ShellTime one request:

POST <apiEndpoint>/api/v1/cc/session-end
{"sessionId": "<id>", "reason": "<clear|resume|logout|prompt_input_exit|other>"}

The server writes the session's AI title, description and summary about 30 seconds later, then updates the PR cost comment straight away. Today the summary waits for the 20-minute or 24-hour run. The server side is in shelltime/server, branch claude/relaxed-tesla-gdpksy.

Details

  • Time limit. Every session.end hook shares one 1.5 s wall-clock bound, and plugin hook timeouts can't raise it. So the hook sends one POST with no retry, and runs it alongside the engine's own end step rather than ahead of it.
  • Failures. The hook never throws, so it can't hold up or fail an exit. Failures go to the debug log through logOnce. If the request doesn't make it, the server's timed runs still summarize the session.
  • No token. Nothing is sent.
  • Reasons. It fires for every reason, since each one ends that session id.
  • Sending path. It calls $.http.fetch directly, like session-project, so it needs no CLI release or daemon.

Changes

  • hooks/api.ts: sessionEndRequest.
  • hooks/register.tsx: sendSessionEnd and the session.end hook.
  • hooks/sessionEnd.test.ts: posts for every reason with the CLI token; sends nothing without a token; a thrown fetch or a 500 still ends the session.
  • README, plugin.json and marketplace.json descriptions: a new "Session end" section, and the comment section now mentions the AI summary.

Rollout

Deploy the server first. Until it ships, the request gets a 404, which only lands in the debug log.

Test plan

  • pnpm typecheck
  • pnpm test (31 passed)
  • claude plugin validate --strict plugins/shelltime-statusline
  • claude plugin test plugins/shelltime-statusline (32 passed, 4 new)

🤖 Generated with Claude Code

https://claude.ai/code/session_016C1wVAG9ZuUfqMapByqem9


Generated by Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

… away

Register a session.end hook that POSTs {sessionId, reason} to
/api/v1/cc/session-end. ShellTime then writes the session's AI summary
about 30 seconds later and updates the PR cost comment right after,
instead of waiting for its 20-minute or 24-hour runs.

The request runs alongside the engine's own end step, inside the exit's
shared 1.5 s bound, and never throws, so an exit is never held up or
failed. Without a token nothing is sent.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016C1wVAG9ZuUfqMapByqem9
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@claude

claude Bot commented Oct 10, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@AnnatarHe
AnnatarHe merged commit 0ef5c14 into main Oct 10, 2026
3 checks passed
@AnnatarHe
AnnatarHe deleted the claude/relaxed-tesla-gdpksy branch October 10, 2026 03:51
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.

2 participants