[AI-1283] Report the new CLI version to the server after kcap update - #512
Conversation
Adds a hidden `kcap report-version` command that makes one quiet, fail-open authenticated request so the server's version observer sees the new version immediately after `kcap update`, instead of waiting for whatever the user runs next. The npm wrapper's runUpdate spawns it right after the post-install refresh succeeds.
…e; accept no-auth tenants Switches report-version's request from the cli-setup POST (which fires a one-time onboarding-completed event) to the read-only whoami identity GET, adds it to Program.cs's offlineCommands so a no-server host still returns 0 via its own fail-open path, and accepts AuthStatus.NoAuthRequired alongside Ok so Auth:Provider=None tenants are still observed.
PR Summary by QodoReport new CLI version to server immediately after
AI Description
Diagram
High-Level Assessment
Files changed (7)
|
Code Review by Qodo
1.
|
…mments, slims the wrapper test Computes a single effectiveBaseUrl (baseUrl ?? ResolvedServerUrl ?? KCAP_URL ?? localhost) used for both auth and the probe request, so the client can no longer authenticate against one host while probing another. Bounds the whole command (discovery + GET) to one 5s budget via a shared CancellationTokenSource instead of only the GET call. Trims the verbose doc/comment blocks in ReportVersionCommand.cs and kcap.js, and slims kcap.test.js's source-shape guard to tolerant substring/ordering checks instead of an exact execFileSync literal match.
|
All qodo findings addressed in b4acedb:
|
Part of AI-1283 — companion to kcap-server#1389. Together they fix a reported bug: after
kcap update, the "your kcap CLI is out of date" web banner/notification linger.Gap this closes
The server only learns your installed CLI version from an authenticated CLI→server request carrying
X-Kcap-Cli-Version.kcap updateitself makes no such request (it only talks to the npm registry), so the server didn't re-observe the new version until your next incidental hook/status/daemon call — leaving the out-of-date surfaces stale in the meantime.Fix
report-versioncommand: makes ONE quiet, fail-open authenticated GET to a side-effect-free probe (/api/me/notification-prefs, the same readwhoamiuses) via the header-carrying client, so the server's observer middleware records the new version from theX-Kcap-Cli-Versionheader. Never prints on the happy path, always returns 0, bounded ~5s. Skips silently when not authenticated; proceeds on bothOkandNoAuthRequiredtenants; listed inofflineCommandsso a no-server host still returns 0.bin/kcap.js runUpdate) invokes the new binary'sreport-versionafter a successful install/refresh and before exit, best-effort (stdio: "ignore", timeout, try/catch) — it can never change the update's exit code.Deliberately a side-effect-free GET, not the
/api/users/me/cli-setupPOST: that endpoint fires a one-time onboarding event, which would falsely mark a login-but-never-setupuser as "Registered" (caught in review).Notes
.cs(repo lint).ReportVersionCommandTests8/8 (header-on-GET, not-authed→no-request, no-auth-tenant, no-server, error/timeout all return 0), observation-header + update-notice suites unaffected.🤖 Generated with Claude Code