Skip to content

feat(signin): short-poll for license in expansion hook (v0.12.3) - #63

Merged
minarc merged 1 commit into
mainfrom
feat/signin-short-poll-banner
May 16, 2026
Merged

minarc merged 1 commit into
mainfrom
feat/signin-short-poll-banner

Conversation

@minarc

@minarc minarc commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Closes the UX gap reported after #62: when ! bin/signin runs inside Claude Code, stdout is piped so the foreground exits immediately after detaching the background poll. The user approves on GitHub after the parent process is gone, so there's nowhere for the banner to render — they had to manually re-invoke /skillmeter:signin and hope they caught the credstore after the background child finished its token exchange.

This PR makes the banner appear automatically on the next /skillmeter:signin:

  • lib/poll-state.js — new helper. markPollStarted() writes ~/.skillbench/poll-state.json when spawnBackgroundPoll fires; markPollEnded() deletes it from a try/finally in runBackgroundPoll. isPollActive() treats files older than 16 min (GitHub device-code lifetime + 1) as stale and self-cleans. waitForLicense(credstore, timeoutMs) short-polls the credstore until a non-expired license appears, the sentinel disappears, or the timeout fires.
  • Expansion hook — after the "already signed in" check, if isPollActive(), the hook waits up to 10s (under the 12s hook timeout) for the license to land. On success → banner. On timeout → "Still waiting for GitHub approval. Approve at https://github.com/login/device, then run /skillmeter:signin again."
  • credstore.getLicenseToken — bypasses the in-process cache so a license written by the sibling background process is visible to the short-polling caller in the same hook invocation. Same convention I used earlier for getSignedOut / getTelemetryDisabled.

Test plan

  • Unit-style smoke: markPollStarted → file exists → isPollActive returns true → waitForLicense resolves true when another process calls commitSignin mid-wait, and resolves false when the poll ends without a license. Verified locally.
  • End-to-end inside Claude Code: ! bin/signin → approve on GitHub → /skillmeter:signin → banner renders within a few seconds.
  • Run /skillmeter:signin before approving → "Still waiting…" message after 10s.
  • Run /skillmeter:signin when no poll has ever started → falls through to the existing silent gh / interactive flow.
  • Stale sentinel (>16 min) is auto-cleaned the next time isPollActive() is called.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Enhanced background license approval polling with user-facing status messages guiding users through GitHub approval process
  • Improvements

    • License token verification now retrieves fresh data from credential storage rather than relying on cached values
  • Chores

    • Plugin version updated to 0.12.3

Review Change Stack

When `! bin/signin` runs inside Claude Code's non-TTY runner, the
foreground exits immediately after detaching the background poll, so
the welcome banner couldn't be surfaced when GitHub approval landed.

Fix: spawnBackgroundPoll now writes a `~/.skillbench/poll-state.json`
sentinel; runBackgroundPoll deletes it on exit. The /skillmeter:signin
UserPromptExpansion hook checks the sentinel and, if a poll is in
flight, short-polls the credstore for up to 10s (under the hook's 12s
timeout). The banner now renders the moment the license lands — user
flow is: paste code → approve on GitHub → /skillmeter:signin → banner.

Also: getLicenseToken now bypasses the in-process cache so a license
written by a sibling process is visible to a short-polling caller.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented May 16, 2026 •

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fd9b88d9-a817-418a-bf3f-480a49d1ff59

📥 Commits

Reviewing files that changed from the base of the PR and between cd1c351 and 45ca95e.

📒 Files selected for processing (5)
  • skillmeter/.claude-plugin/plugin.json
  • skillmeter/scripts/credstore.js
  • skillmeter/scripts/lib/poll-state.js
  • skillmeter/scripts/signin.js
  • skillmeter/scripts/user_prompt_expansion_signin.js

Disabled knowledge base sources:

  • Linear integration is disabled

You can enable these sources in your CodeRabbit configuration.


Walkthrough

This PR introduces a background polling mechanism to coordinate license approval across separate CLI processes. A new poll-state module manages a JSON sentinel file to track polling lifecycle, credstore now always re-reads tokens to avoid cache staleness, signin.js marks poll start/end events, and the user-facing sign-in script waits for active polls to produce a license before proceeding. The manifest version is bumped to 0.12.3.

Changes

Background Polling and License Coordination

Layer / File(s) Summary
Poll-state module: sentinel file coordination
skillmeter/scripts/lib/poll-state.js
New module exports markPollStarted(), markPollEnded(), isPollActive(), and waitForLicense() to manage a JSON sentinel file at ~/.skillbench/poll-state.json. Polls are marked stale after 16 minutes. waitForLicense() repeatedly checks the credstore for a non-expired license token until success, timeout, or poll inactivity.
Credstore uncached reads for fresh tokens
skillmeter/scripts/credstore.js
getLicenseToken() now bypasses the in-process cache and always re-reads via readStore() to ensure background-written license tokens are immediately visible to waiting processes.
Signin lifecycle: poll start and end markers
skillmeter/scripts/signin.js
signin.js imports poll-state and calls markPollStarted() when spawning the background poll and markPollEnded() on all exit branches (discard, success, error) before process termination.
User-facing sign-in with polling awareness
skillmeter/scripts/user_prompt_expansion_signin.js
During /skillmeter:signin, the script now checks if a background poll is active. If active, it waits up to 10 seconds for a license token to land in credstore, emits the welcome banner on success or a "still waiting" message on failure, then exits—skipping interactive sign-in steps.

Release Version Bump

Layer / File(s) Summary
Manifest version increment
skillmeter/.claude-plugin/plugin.json
Version field updated from 0.12.2 to 0.12.3.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • jhunlee-dev

Poem

🐰 A rabbit hops through polling states,
Watching sentinel files at the gates,
Tokens re-read, no stale cache here,
Background polls coordinate with cheer!
Sign-in waits for approval to shine,
All processes dancing in rhythm and time. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/signin-short-poll-banner

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.20.0)

OpenGrep fatal error (exit code 2):
┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m
[00.27][ERROR]: Error: exception Glob.Lexer.Syntax_error("malformed glob pattern: missing ']'")
Raised at Glob__Lexer.syntax_error in file "libs/glob/Lexer.mll", line 8, characters 2-26
Called from Glob__Lexer.__ocaml_lex_token_rec in file "libs/glob/Lexer.mll", line 29, characters 26-53
Cal


Comment @coderabbitai help to get the list of available commands and usage tips.

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.

1 participant