CLI: PR-aware upload context — concrete nudge, auto-default, and post-PR promote hint - #705
Conversation
Three upgrades to the bare-upload flow: 1. Concrete nudge: the bare-put/screenshot nudge (#393) now names the actual open PR and a ready-made follow-up command naming the actual uploaded key(s) — surfaced in the `hint` field for --format json and in the local stdio MCP put/screenshot tool responses, not just stderr. 2. Auto-PR context (default behavior change): a bare put/screenshot on a git branch that maps to exactly one open PR now behaves as if --pr <n> had been passed (stable key, managed comment sync) instead of the #403/#469 branch-staging default. Opt out with --no-pr or UPLOADS_NO_AUTO_PR=1 (env/config). Never fires with any explicit destination flag, outside a git repo, on the default branch, with --no-git, or when no single open PR resolves. 3. uploads hook pre-pr-screenshot now suggests promoting staged-but-unattached files (uploads attach --promote --pr <num>) ahead of gh pr create, alongside its existing "stage first" advisory. Adds a changeset and tests for all three behaviors across the CLI (put/screenshot) and the local stdio MCP tools.
🦋 Changeset detectedLatest commit: 47b67c8 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one) (2)
🚫 Excluded labels (none allowed) (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
uploads-auth | 47b67c8 | Commit Preview URL Branch Preview URL |
Aug 18 2026, 10:38 PM |
Closes #700.
Three upgrades to the
packages/uploadsCLI's PR-context handling for bare uploads, in the issue's order of increasing ambition.1. Concrete, machine-readable nudge
The existing bare-put nudge (#393) now names the actual open PR and appends a ready-made follow-up command naming the actual uploaded key(s):
It reuses the existing best-effort, 3s-bounded
gh pr viewlookup. It's now surfaced in thehintfield for--format jsonand in the local stdio MCPput/screenshottool responses, not just stderr. Same suppression as before (--quiet,UPLOADS_NO_NUDGE=1) and the same hint-slot precedence (a binding warning still wins where both could fire).2. Auto-assume PR context (default behavior change)
When a bare
put/screenshotruns on a branch that maps to exactly one open PR, it now behaves as if--pr <n>had been passed — stablegh/key, managed comment sync — instead of the #403/#469 branch-staging default.--no-pr, or globally withUPLOADS_NO_AUTO_PR=1(env var and config-file key, alongsideUPLOADS_NO_NUDGEetc.).--pr/--issue/--branch/--key/--ref/--prefix/--destination), outside a git repo, on the default branch, with--no-git, or when the PR lookup fails/times out — those cases fall back to the existing staging/dated-layout behavior, silently.putandscreenshot(CLI and local stdio MCP tools) are all consistent.--format jsonhint, MCP tool response).Decisions on the issue's open questions
putandscreenshot, not suggest-only forput. The branch→PR mapping viagh pr view <branch>is already unambiguous (one open PR per branch, or none) — there's no "ambiguous, more than one" state to worry about, and the fallback triggers (explicit flags,--no-pr, no PR found) cover the "this upload doesn't belong to the PR" cases well enough that suggest-only felt like it would under-deliver on the issue's actual motivating case (buildinternet/sunny#1250).gh/private/prefix resolution (resolveGhPrefixSafe) already applies uniformly to anygh/key, whether reached via explicit--pror the new auto-PR path. Auto-PR doesn't change what "attaching to this PR" means, just how often it happens automatically.--pr/--issuealways wins, never fires outside git: implemented as specified.3. Post-PR-creation promote suggestion
uploads hook pre-pr-screenshot(the existinggh pr createPreToolUse hook) now also suggests promoting staged-but-unattached files when it detects them (gh.status=staged) ahead of the PR being created:This previously stayed silent whenever anything was already staged. The existing "stage screenshots first" advisory (for the no-staged-content case) is unchanged. Same fail-open contract (
UPLOADS_HOOK_DISABLE=1, silent on any error).Tests
Added coverage for all three behaviors:
packages/uploads/test/commands-put.test.ts— auto-PR context describe block (fires, opts out both ways, never fires with explicit flags/on default branch/with--no-git, falls back when no PR)packages/uploads/test/commands-screenshot.test.ts— same matrix forscreenshotpackages/uploads/test/mcp.test.ts,test/mcp-screenshot.test.ts— local stdio MCPput/screenshottool auto-PR + hint fieldpackages/uploads/test/config-put-defaults.test.ts—UPLOADS_NO_AUTO_PRconfig/env resolutionpackages/uploads/test/hook-pre-pr-screenshot.test.ts— promote suggestion (singular/plural wording, fork note, fires even without UI-file changes)pnpm test(root, all packages) andpnpm typecheckboth pass.Docs
docs/cli.mddocuments the auto-PR default, its opt-outs, the concrete nudge, and the hook's new promote suggestion.Not requesting a CodeRabbit review for this one.