Skip to content

feat(statusline): link PRs from gh pr create to the session - #10

Merged
AnnatarHe merged 1 commit into
mainfrom
claude/great-ptolemy-pnjykq
Oct 8, 2026
Merged

AnnatarHe merged 1 commit into
mainfrom
claude/great-ptolemy-pnjykq

Conversation

@AnnatarHe

@AnnatarHe AnnatarHe commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds a PostToolUse hook (on('classic.PostToolUse')) to shelltime-statusline.

  • When a Bash call runs gh pr create, the hook takes the PR URLs printed on stdout, including several from one chained command.
  • It runs shelltime cc pr --session-id <session_id> <url>.... The CLI hands them to the ShellTime daemon, which saves them to the session on the server.
  • It reads stdout only: gh reports an already existing PR on stderr, and that one wasn't opened here.
  • It runs after next(e) and unawaited, so it never delays or changes the Bash result.
  • It runs the CLI through $.process.run. The daemon's socket speaks raw JSON, and $.http.fetch({ socketPath }) only speaks HTTP, so the hook can't write to the socket directly.
  • It tries ~/.shelltime/bin/shelltime first, then shelltime on PATH, because desktop hosts often lack ~/.shelltime/bin.
  • Each URL is sent once per session. If the CLI can't be started, the URL is tried again the next time it is printed, and the failure goes to the debug log.
  • The parsing helpers are pure functions in hooks/pullRequests.ts.
  • The plugin README, root README and manifest descriptions now mention PR links. Release-please handles the version.

Depends on https://github.com/shelltime/server/pull/514 (the endpoint) and shelltime/cli#318 (shelltime cc pr plus the daemon message). Until a CLI release with cc pr is installed, nothing is linked and the statusline is unaffected.

Test plan

  • hooks/pullRequests.test.ts (claude plugin test):
    • command and URL detection (GitHub Enterprise too, issues ignored)
    • two URLs linked in one run
    • repeats skipped, though another session still gets the same URL
    • gh pr view and non-Bash tools ignored
    • falls back to shelltime on PATH
    • retried after a failed run
  • claude plugin validate --strict . and plugins/shelltime-statusline
  • claude plugin test plugins/shelltime-statusline: 28 pass
  • tsc against the engine's API types, then pnpm typecheck and pnpm test (31 pass)

🤖 Generated with Claude Code

https://claude.ai/code/session_01DVr1QVVUbfrjJSrsj9Nxc1

A classic.PostToolUse hook watches Bash calls that run `gh pr create`.
It takes the PR URLs printed on stdout, including several from one
chained command, and runs `shelltime cc pr --session-id <id> <url>...`.
The CLI hands them to the ShellTime daemon, which links them to the
session on shelltime.xyz.

The hook runs after the tool returns and in the background, so it never
delays or changes the Bash result. It looks for
~/.shelltime/bin/shelltime first, then `shelltime` on PATH. Each URL is
sent once per session; one the CLI could not take is tried again the
next time it is printed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DVr1QVVUbfrjJSrsj9Nxc1
@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.

@AnnatarHe
AnnatarHe merged commit c00dd73 into main Oct 8, 2026
3 checks passed
@AnnatarHe
AnnatarHe deleted the claude/great-ptolemy-pnjykq branch October 8, 2026 06:17
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