Repository navigation
fix(source-control): generate PR details before Create PR on a ready branch - #24215
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- New shared wrapper
use-generate-before-create-pull-request— wraps each panel's create handler; on click, when the composer still holds Orca's seeded placeholder title/body, a PR agent is configured, the branch can be created now, and this branch hasn't already failed/stopped a run, it awaits the composer's existing store-routed generation and creates with the generated title/body. Base and draft stay the user's. - Both Create PR handlers rewired —
use-hosted-review-creation.ts(Source Control) anduse-checks-panel-create-review.tsx(Checks) renamed their creator tocreatePullRequest(stacked, generated?)and delegate through the shared hook, so header button, form button, dropdown item, Cmd/Ctrl+Enter and the Checks panel all behave the same. - Generation now yields its result —
use-pull-request-generation.tsanduse-checks-panel-generation.tsxreturn{ result }read from the store record by matchingrequestIdafter the run;onGenerate/handleGeneratereturn-type plumbing updated increate-pull-request-dialog-field-model.ts,use-create-pull-request-field-generation.ts, and both composers. - Guard rails —
generatingReffor concurrent clicks,failedGenerationKeyRefso a failed/stopped run makes the next click submit as shown,mountedRef+visibleGenerationKeyRefso a closed panel or switched branch creates no PR. - Tests — new
use-hosted-review-creation.test.tsx(11 cases) and additions to the two Checks panel test files pin generate→create, failure/stop fallback, repeated-click single run, mid-run unmount/branch-switch, and blocked-branch notice.
I read all 13 files end-to-end, traced the placeholder equality against resolveCreateReviewDraftTitle / use-create-pull-request-field-seeding.ts, and confirmed the two generation paths resolve their outcome via the requestId-keyed record. The changed tests pass locally (16/16), and they fail without the new routing (the success cases do nothing to generate on main), so they pin real behavior rather than restating it. Concurrency is safe: the store's status === 'running' guard plus createPrInFlightRef prevent a duplicate agent run or a second PR.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 0b7440b44b83d44df7827ef6fd5977d9232c90cb and 155aec60d0ae32eaffa24e834149c6358b4437ea. 📒 Files selected for processing (5)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughGeneration callbacks now return outcomes that contain generated fields or a null result. Checks-panel and source-control creation flows can generate pull-request fields before creating a pull request or hosted review. Tests cover generation outcomes, fallback behavior, cancellation, duplicate clicks, and changes to the active branch or panel. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to Generation before PR creation preserves the selected base and edited Draft setting. The change is mergeable subject to normal checks. Architecture SummaryArchitecture risk: 🟡 Medium · up to The change affects 1 system. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
Reliability and maintainability
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 19443070-41ab-4309-b311-3e9a0c166477
📥 Commits
Reviewing files that changed from the base of the PR and between 95e8725 and 4dc12ee1d0b5fcadfebca78d2bbe3d6b245a8a43.
📒 Files selected for processing (13)
src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-composer-state.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-create-review.test.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-create-review.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-generation.test.tsxsrc/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-generation.tsxsrc/renderer/src/components/right-sidebar/create-pull-request-dialog-field-model.tssrc/renderer/src/components/right-sidebar/source-control/review/use-create-review-composer.tssrc/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-creation.test.tsxsrc/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-creation.tssrc/renderer/src/components/right-sidebar/source-control/review/use-pull-request-generation.tssrc/renderer/src/components/right-sidebar/source-control/review/use-review-flows.tssrc/renderer/src/components/right-sidebar/use-create-pull-request-field-generation.tssrc/renderer/src/components/right-sidebar/use-generate-before-create-pull-request.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 23fecfd3-0cb1-4c0f-9f3c-f1f53cc93b80
📥 Commits
Reviewing files that changed from the base of the PR and between 4dc12ee1d0b5fcadfebca78d2bbe3d6b245a8a43 and 29ba290dd75c7eaed4fb028f0eddb16a02303cdc.
📒 Files selected for processing (2)
src/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-creation.test.tsxsrc/renderer/src/components/right-sidebar/use-generate-before-create-pull-request.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review is a single commit scoped to the shared generation-before-create wrapper, plus one new test.
- Per-branch generation tracking — the wrapper's single
generatingRef/failedGenerationKeyRefbooleans were replaced bygeneratingKeysRef: Set<string>andfailedKeysRef: Set<string>, so clicking Create PR on one branch while another branch is still generating no longer suppresses the second run or prematurely marks it failed. Failures and stops are now remembered per branch instead of the last one seen. - Visibility guard reworked —
useMountedRef+useEffectbecame a singleuseLayoutEffectthat setsvisibleGenerationKeyRefon commit and nulls it in cleanup, so a closed panel or a mid-run branch switch still skips creation, and the update lands before any async result can observe a stale key. - Regression test added —
generates for another branch while the first branch is still generatingpins the new concurrency behavior; it would fail against the prior single-ref implementation (branch B's creation would be submitted with the placeholder title and no generation call).
I read the incremental diff and the wrapper's final state, traced it against the store record?.context.requestId === requestId outcome contract and useSourceControlPullRequestGeneration's keying, confirmed the tests pass locally (the two touched files, 14/14) and pnpm tc:web is clean. No inline comments.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
The delta since the prior pullfrog review is a single commit scoped to the shared wrapper plus one added test case.
- Branch-departure guard reworked —
visibleGenerationKeyRefwas replaced by a monotonicleftBranchCountRef, incremented in auseLayoutEffect(() => () => { … }, [generationKey])cleanup. The click capturesleftBranchCountAtClickand skipscreatePullRequestwhen the count has moved by the time generation resolves, so switch away, switch away-and-back, and unmount all suppress the create. - Regression test extended — the "does not create when the panel $name while generating"
it.eachgained aswitch-backcase that leaves the branch and returns; it fails against the previous ref-based guard, which re-set the key on switch-back and let the PR be created anyway.
I traced the counter through both directions: it cannot fail to suppress after leaving the branch (each generationKey change and unmount runs the cleanup synchronously in the commit phase), and it cannot wrongly suppress while the panel stays put (string generationKey deps compare by value, and StrictMode's one-time mount double-invoke is a constant offset applied before any click). No inline comments.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Review: the right approach, but the part between the click and the create needs workWhat's right. Reusing the composer's own ✨ generation is the correct layer: you get the store record, the field lock, Stop, and routing to the host that owns the repo, all for free. Awaiting that single run's result, rather than watching the form, avoids surprise PRs later on. Fixing the Checks panel through the same hook is also right. All three changed test files pass locally (18/18) at What needs work. The "create after generating" decision lives in the component's memory ( 1. Leaving the panel mid-run drops the create silentlyThe sidebar renders only the active tab ( This is also the opposite of the prepare-branch route this PR says it mirrors. That route keeps going across worktree navigation ( Suggestion, either:
2. "After a failed or stopped run, the next click submits as shown" is forgotten on remount, even though the store already records it
The store record already holds exactly this information (
That replaces both refs, including the "Stopped run is still winding down" special case, and behaves the same in both panels and across remounts. 3. The created PR can disagree with what the form shows
Suggestion:
4. The "untouched placeholders" check is recomputed outside the hook that set them
Smaller
Before merge, I'd ask for 1–3. They fit inside the current approach; none of them means rewriting it. |
How we found theseFor anyone who wants to check or reproduce the review above, here's what we did against 1. Read the code the hook plugs into, not just the diff.
2. Checked the assumptions behind the lifecycle.
3. Reproduced each behaviour with throwaway tests. We appended these to the setup at the top of Probe tests (P1–P5)describe('review probes', () => {
it('P1: a failed Create PR run is forgotten after the panel remounts, so the agent runs again', async () => {
const input = makeInput({
handleGeneratePullRequestFields: vi.fn(async () => ({ result: null }))
})
const first = renderHook(() => useSourceControlHostedReviewCreation(input))
await act(async () => first.result.current.handleCreatePullRequest())
first.unmount()
const second = renderHook(() => useSourceControlHostedReviewCreation(input))
await act(async () => second.result.current.handleCreatePullRequest())
expect(input.handleGeneratePullRequestFields).toHaveBeenCalledTimes(2)
expect(input.createHostedReview).not.toHaveBeenCalled()
})
it('P2: leaving mid-run drops the create without any notice', async () => {
const { generate, finish } = deferredGeneration()
const input = makeInput({ handleGeneratePullRequestFields: generate })
const { result, unmount } = renderHook(() => useSourceControlHostedReviewCreation(input))
let click: Promise<void> = Promise.resolve()
act(() => {
click = result.current.handleCreatePullRequest()
})
unmount()
await act(async () => {
finish({ result: generatedFields })
await click
})
expect(input.createHostedReview).not.toHaveBeenCalled()
expect(input.setCreatePrIntentNoticeForWorktree).not.toHaveBeenCalled()
})
it('P3: base changed during the run (compare-base sync) is ignored; click-time base is used', async () => {
const { generate, finish } = deferredGeneration()
const input = makeInput({ handleGeneratePullRequestFields: generate })
const { result, rerender } = renderHook(
(props: Input) => useSourceControlHostedReviewCreation(props),
{ initialProps: input }
)
let click: Promise<void> = Promise.resolve()
act(() => {
click = result.current.handleCreatePullRequest()
})
rerender({ ...input, prBase: 'release' })
await act(async () => {
finish({ result: generatedFields })
await click
})
expect(input.createHostedReview).toHaveBeenCalledWith(
'/repo',
expect.objectContaining({ base: 'main' })
)
})
it('P4: branch becomes blocked (dirty) during the run; PR is still created from click-time eligibility', async () => {
const { generate, finish } = deferredGeneration()
const input = makeInput({ handleGeneratePullRequestFields: generate })
const { result, rerender } = renderHook(
(props: Input) => useSourceControlHostedReviewCreation(props),
{ initialProps: input }
)
let click: Promise<void> = Promise.resolve()
act(() => {
click = result.current.handleCreatePullRequest()
})
rerender({
...input,
hostedReviewCreation: {
...readyEligibility,
canCreate: false,
blockedReason: 'dirty',
nextAction: 'commit'
}
})
await act(async () => {
finish({ result: generatedFields })
await click
})
expect(input.createHostedReview).toHaveBeenCalledTimes(1)
})
it('P5: the store already says the last run for this branch failed, but Create PR runs the agent again', async () => {
useAppStore
.getState()
.setPullRequestGenerationRecord(GENERATION_KEY, { ...runningRecord, status: 'failed' })
const input = makeInput({
handleGeneratePullRequestFields: vi.fn(async () => ({ result: null }))
})
const { result } = renderHook(() => useSourceControlHostedReviewCreation(input))
await act(async () => result.current.handleCreatePullRequest())
expect(input.handleGeneratePullRequestFields).toHaveBeenCalledTimes(1)
})
})
The base/draft mismatch in finding 3 comes from reading the code rather than a probe. Your own fixture already has the agent returning |
|
Thanks for the thorough review and the probes. All of it is addressed in e58f3a2 (the branch is now one commit), and P1–P5 now behave as you described. Two places where I went a slightly different way:
On base and draft (point 3): each run records whether Create PR started it. For those runs, the stored result keeps the user's base and never unchecks Draft, so the form and the PR always agree. That's the prepare-branch route's base rule. The Generate button is unchanged, since its result is reviewed in the form. |
There was a problem hiding this comment.
Important
The ready-branch Create PR path discards a base branch the user picked before clicking and submits the agent's generated base instead. The shipped prepare-branch route never retargets the base for exactly this reason, and the PR description promises the selected base is kept.
Reviewed changes
This run reviews the single commit pushed since the prior pullfrog review (6aeb77e529): 0b7440b44b, which reworks the generate-before-create flow to read its outcome from the store record.
- Wrapper rewritten around the store record —
use-generate-before-create-pull-request.tsreplaces the per-branchgeneratingKeysRef/failedKeysRef/leftBranchCountRefmachinery with apullRequestGenerationRecords[key]?.statusread (running = dedupe; failed/canceled = submit as shown), alatestReffor base/baseRevision/createPullRequest/generationKey, and per-run field resolution. - Generation now returns its result —
use-pull-request-generation.tsanduse-checks-panel-generation.tsxreturn{ result }read from the record byrequestId; the non-store path returns the fields shown byapplyGeneratedFields. fieldsAreSeedPlaceholders+fieldRevisionsadded — computed inuseCreatePullRequestDialogFields.tsvia the new sharedresolveCreateReviewSeedTextincreate-review-draft-title.ts, and threaded through both composers and panels.- Create handlers accept generated fields — both
createPullRequestbuilders now mergegenerated ?? composerand send the generated base/body/draft. - Tests reworked —
use-hosted-review-creation.test.tsxrewritten around record-backed generation (and now asserts the generated base/draft), plus new Checks-panel create/generation cases and afieldsAreSeedPlaceholderscase.
ℹ️ PR description no longer matches the shipped behavior
The description still says the selected base and Draft checkbox are kept, and that closing the panel mid-run creates no PR. As of 0b7440b44b, the base is retargeted (inline), the Draft checkbox value is replaced by the agent's (source-control/review/use-hosted-review-creation.ts:140, checks-panel/use-checks-panel-create-review.tsx:256), and closing the panel mid-run still creates the PR (asserted by the new "creates … when the panel closes mid-run" test). The Draft and close changes match the prepare-branch route, so they look intentional — please update the description to match, or restore the documented behavior.
Technical details
# Reconcile the PR description with the shipped behavior
## Affected sites
- `src/renderer/src/components/right-sidebar/source-control/review/use-hosted-review-creation.ts:139-140` — sends `fields.body` / `fields.draft` from the generated result
- `src/renderer/src/components/right-sidebar/checks-panel/use-checks-panel-create-review.tsx:255-256` — same
- `src/renderer/src/components/right-sidebar/use-generate-before-create-pull-request.ts:78-81` — panel-close no longer suppresses creation
- PR body "What Changed" / "Known differences / limits" — still describes the earlier contract
## Required outcome
- The PR description and the new tests describe the same base/draft/close contract, so a reviewer reading either gets the same behavior.
## Open questions for the human
- Should the Draft checkbox and panel-close behavior keep the prepare-branch semantics (generated draft, create-after-close), with the description updated, or was the draft intended to stay the user's?DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
ℹ️ No critical issues — the prior base-retargeting finding is fixed; one documentation note in the body.
Reviewed changes
This run covers the single commit pushed since the prior pullfrog review (0b7440b44b): 155aec60d0, which makes ready-branch Create PR keep the composer's chosen base and Draft.
- Base is the composer's — the shared wrapper now takes
fieldRevisions/base/draftinstead ofbaseRevision, and submits the click-time base unless a mid-run re-pick bumped the revision;outcome.result.baseis no longer read. This matches the prepare-branch route'sbase: current.basecontract and resolves the prior IMPORTANT thread. - Draft respects a user toggle — an untouched Draft box still takes the agent's suggestion, but a Draft the user set before the click is kept.
- Tests updated — the Source Control and Checks-panel generate→create cases now assert the chosen base (
mainagainst generateddevelop), plus a new "keeps a base and Draft setting chosen before the click" case.
ℹ️ PR description still describes the previous base/Draft contract
The PR body still says the agent's generated base and Draft win by default, which is exactly what 155aec60d0 reversed. A reviewer reading the description would expect a different result than the code now produces.
Technical details
# Reconcile the PR description with the shipped base/Draft behavior
## Affected sites
- PR body "Mechanism" paragraph — "the base is the agent's unless you re-picked it during the run".
- PR body "After" sentence — "its base branch unless you changed the base while it was writing".
- PR body "Known differences / limits" first bullet — "The agent's draft suggestion replaces a ticked Draft box".
- `src/renderer/src/components/right-sidebar/use-generate-before-create-pull-request.ts:90-92` — submits the click-time base and a user-toggled Draft.
## Required outcome
- The description's base/Draft text matches the code: your chosen base is kept (a mid-run re-pick wins), and a Draft you set is kept while an untouched box takes the agent's suggestion.
## Suggested approach
- Update the three body passages, or restore the documented behavior in code if the description is authoritative.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
155aec6 to
6bf8bef
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run covers the single commit pushed since the prior pullfrog review (155aec60d0): 6bf8bef1bc, which moves the ready-branch base/Draft policy out of the create wrapper and into the store's success resolver.
- Base/Draft policy centralized in the store —
resolvePullRequestGenerationSuccessnow returns{ ...result, base: record.seed.base, draft: record.seed.draft || (record.seedFieldRevisions.draft === 0 && result.draft) }, so the stored result keeps the click-time base and never unchecks a Draft the user set. Because both the composer's hydration effect and Create PR read this record, the form and the created PR now agree (the earlier form-vs-submit base nuance is gone). - Wrapper simplified —
use-generate-before-create-pull-request.tsdrops itsbase/draft/fieldRevisionsinputs and the per-run field merge; it submitsoutcome.resultverbatim. ThefieldRevisionsplumbing is removed from both panel composer states anduse-review-flows.ts. - Tests reworked —
SourceControl.pr-generation-records.test.tsgains a base/Draft truth table against the resolver directly; the wrapper's now-unreachable "base chosen before/during the click" cases were dropped (the form is disabled whileprGenerating), and the Checks-panel generation suite gains success/Stop outcome cases.
I read the incremental range-diff and the full diff end-to-end (19 files), traced the seed capture (record.seed = {...fields} at generation start, base already stripped before create) against the resolved result, and confirmed the form consumes the same record. The touched suites pass locally (41 tests across 5 files), and the PR description's base/Draft wording ("The base branch is always yours"; "✨ … keeps your base and no longer unchecks Draft") now matches the shipped behavior, closing the prior ℹ️ body finding.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…branch A pushed branch sent the placeholder title and empty body, skipping the configured agent. A run Create PR submits unreviewed keeps the user's base and never unchecks Draft; the Generate button is unchanged. Fixes stablyai#22824
6bf8bef to
e58f3a2
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run covers the single commit pushed since the prior pullfrog review (6bf8bef1bc): e58f3a2b3a, which scopes the base/Draft policy to auto-submitted runs so the ✨ Generate button behaves as it does on main.
autoSubmiton the generation record —createRunningPullRequestGenerationRecordtakes anautoSubmitargument and only the Create PR wrapper passes{ autoSubmit: true }; both generation hooks thread it through.- Base/Draft policy scoped to auto-submitted runs — the store's
resolvePullRequestGenerationSuccessappliesresolveAutoSubmittedFields(extracted intopull-request-generation-auto-submit.ts) only whenrecord.autoSubmitis set. A ✨ Generate-button run is unmarked, so its result carries the agent's suggested base and draft into the form, as onmain. - Options threaded through the generation plumbing —
PullRequestGenerationOptionsflows throughcreate-pull-request-dialog-field-model.ts, both generation hooks, and the non-storeuse-create-pull-request-field-generation.ts. - Tests — new
use-pull-request-generation.test.tsx, plus updates to the records, Checks-generation, hosted-review-creation and dialog-fields suites pin keep-base-for-Create-PR vs keep-agent-base-for-reviewed and that run options reach the external generation.
I read the incremental range-diff (6bf8bef1bc..e58f3a2b3a) and validated it against the full-diff state. The autoSubmit flag is set at generation start and read by the single resolver that both form hydration and the create handlers consume, so the form and the submitted PR agree; the create handlers stripBaseRef the base (use-hosted-review-creation.ts:100), so retaining the unstripped seed.base is harmless. The touched suites pass locally (44 tests / 5 files) and pnpm tc:web is clean.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…raft box A Draft choice made before generation started was unprotected: the form only keeps fields whose revision changed *while* a run was in flight, so a user who checked Draft and then pressed Generate had the box silently unchecked by an agent answering draft:false, and the next Create PR opened a real review ready for review. Scope the rule to provenance rather than the in-flight window, and apply it to reviewed runs and the prepare-branch route too, so the agent can still flag unfinished work but never reverts a choice the user made.
…erseded-run guards Two guards had no failing test. The Checks panel's Create PR must still send the finished run's details while its last render shows the run as generating, or the click silently creates nothing. Each panel's generation must return no result when a later run replaced its record (Stop, then Generate finishing first), or the stopped Create PR click would open a PR with the later run's details.
…r worktree Create PR on a ready branch now waits for the agent, and the create still runs if the sidebar panel closes meanwhile. When it finished, it always opened the sidebar on Checks (and, with "open after create", the review), even if the user had switched to another worktree, so Checks showed the wrong worktree and the in-app link route switched the user back. Reveal only when the created review's worktree is still selected, or the panel that made it is still mounted, like the prepare-branch route.
…the details Create PR on a ready branch generated the details and then created nothing, with no message. When generation ended, Source Control's eligibility check restarted and cleared the eligibility, and the create, which reads the panel's latest state, returned early on the missing eligibility. The click now stays in flight from the start of generation until the create settles, as the prepare-branch route does, so the eligibility check stays paused and the create sees the eligibility it started with. Repeated clicks are counted so one returning early can't release another's hold.
… own hook No behavior change. The Checks panel's create hook was at its 400-line limit; linking and refreshing a created review now lives in use-checks-panel-created-review.tsx, the way Source Control keeps it in use-hosted-review-created.ts.
…at was clicked After the agent wrote the details, Create PR read the panel's latest render instead of the state at the click. That render could have lost its eligibility (no PR, no message), still show the run as generating, or show another branch. Navigating away also gave opposite results: with the sidebar open on another worktree no PR was made; after closing the sidebar first, it was. The create now always runs through the click's own closure, so a started run creates the PR for the branch that was clicked wherever the user went, like the prepare-branch route. The reveal still follows the selected worktree, so nothing opens over another one. The "still shows generating" bypass in both panels is gone: the click's render never shows the run as generating. In the Checks panel, a create that returns after the panel moved to another worktree still links the review to the clicked worktree and clears its push-first flag; only the in-flight state, errors, opening the review and the GitLab checks refresh are skipped, since they belong to whatever the panel now shows. The same holds for a push-first create whose push finishes after the panel moved.
The click already kept Source Control's create in flight through generation, so the composer stays up instead of closing while eligibility refreshes. It did that with a per-worktree click counter next to the create's own in-flight flag, so a repeated click that returned early couldn't end the first click's hold. Now the click owns the existing in-flight flag from the click until the create settles, and a click while it is set is refused before it touches anything, so the counter is gone. This matches what the UI already did: Create PR is disabled while the flag is set, including after Stop until the stopped request returns. Since the create now runs through the click's own state, the hold only keeps the UI steady; it no longer decides whether a PR is created.
… what callers pass The Checks panel now passes whether it still shows the created review, not just whether it is mounted, since a mounted panel can have moved to another worktree while the create ran.
After Stop, Source Control's Create PR stayed disabled ("Creating...") until
the stopped generation request came back. Locally that is under a second, but
when the cancel can't reach a slow or disconnected remote host the button
stayed disabled for up to the 75 s generation timeout.
A generation run's outcome now settles as soon as its record stops running,
not when the request returns. Stop marks the record canceled at once, so the
click that started the run ends, its hold is released, and the next click
submits the form as shown. The stopped request still finishes in the
background; its late result is dropped because the record is no longer
running for that request. Both panels' generation handlers use the same
helper.
|
Thanks Kelvin — the fix is the right shape, and reusing the composer's generation (field lock, Stop, host routing) was a good call. Testing it in the real app, though, Source Control didn't create the PR: the agent filled in the title and description, then nothing happened. After generation the hook called the panel's latest create handler, and at that moment Source Control's eligibility check clears itself to refetch, so the create returned early. The Checks panel was fine. Your tests feed eligibility in directly, which is why they couldn't catch it. I've pushed commits that make the click own the run: it creates through the click-time handler instead of a latest-render ref (that also removes the Could you update the description? A few lines no longer hold (navigating away now still creates the clicked branch's PR; the "blocked mid-run" case is gone; Stop frees the button right away). Two behaviour changes I'm checking with the team before merge: the Draft rule now also applies to the ✨ button, and the Checks panel's push-then-create finishes even if you navigate away. |
| if ( | ||
| !repo || | ||
| !branch || | ||
| !createComposerOpen || | ||
| prGenerating || | ||
| (panelShowsRequest && createPrInFlightRef.current) | ||
| ) { |
There was a problem hiding this comment.
Background create bypasses guard
If Create PR starts generating details in Checks, the user switches contexts, and the run then starts creating, this check skips the in-flight guard because the panel no longer shows that request. The request also does not take the guard. If the user returns to the original branch and clicks Create PR again before the first create finishes, both requests can reach the provider, risking duplicate reviews.
| const showCreateError = (message: string): void => { | ||
| if (isCurrentCreateRequest()) { | ||
| setCreatePrError(message) | ||
| } | ||
| } |
There was a problem hiding this comment.
Background create errors disappear
If the user switches Checks contexts while a Create PR run is generating, the run still attempts to create the PR. But a later push or provider failure reaches showCreateError only after the original request is no longer current, so the error is discarded. When the user returns to the clicked branch, there is no explanation for why its generated details did not produce a PR.
There was a problem hiding this comment.
ℹ️ No code issues found in the new commits — they land cleanly and the touched suites pass. One stale sentence in the PR description.
Reviewed changes
This run re-reviews the commits pushed since the prior pullfrog review (e58f3a2b3a).
- Draft is now provenance-based on every run —
resolveGeneratedDraft/resolveGeneratedFields(pull-request-generation-auto-submit.ts) keep a Draft the user set for both Create PR and ✨ Generate runs, and the prepare-branch route mirrors it (draft: current.draft || generated.fields.draft). - The click owns the in-flight flag — both panels set the flag before generation and clear it in a
finally; the create runs through the clicked render'screatePullRequestclosure, so a started run finishes for the branch that was clicked even after the panel moved or eligibility refreshed (the oldlatestRefguard is gone). - Stop releases the caller immediately —
settlePullRequestGenerationRequestresolves when the store record leavesrunningand drops the late result byrequestId, so a cancelled run no longer keeps the Create PR click pending on a slow host. - Background creations no longer steal the panel —
createdReviewIsForegroundgates the reveal/open on the worktree still being selected (or its panel still showing the review); the Checks created-review linking moved intouseChecksPanelCreatedReview. - Tests — new coverage for Checks create-after-run, the superseded-run guard, panel-moved linking, foreground reveal, and Stop release; the blocked-mid-run suppression test was removed with the behavior.
ℹ️ Nitpicks
- The PR description's run-outcome paragraph is stale after these commits. It still says "If the panel moves to another branch or workspace, no PR is created; the generated text waits in that branch's form for one click" and "If the branch became blocked during the run … the usual blocked message shows instead of a PR." The new
use-hosted-review-creation.test.tsx:535(creates the clicked branch PR … when the panel moved to another worktree mid-run) and the Checks panel now assert the PR is created after the panel moves, and the blocked-mid-run test was removed. Please update the description to match, or restore the earlier behavior.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

ELI5
When your branch was already pushed, clicking Create PR sent Orca's placeholder text (your branch name as a title, an empty description) instead of asking your AI agent to write them. Now it asks the agent first, the same way Create PR already does when your branch still needs a commit or push.
What Changed
Before: Source Control AI agent set (Cursor, Claude, …), branch
fix-readme-typopushed, click Create PR without typing → PR titled "Fix readme typo" with an empty description (GitHub then pastes in the raw PR template). The agent was only used if you clicked the Generate button yourself or turned on "Generate details on open".After: the same click locks the form, runs the agent (the same generation the Generate button runs), and creates the PR with the agent's title and description. The base branch is always yours; the agent's suggestion never retargets it, the same as the prepare-branch route. The agent can mark unfinished work as a draft, but never unchecks Draft: a box that was checked (by you or the "Create as draft" default) stays checked, and one you unchecked stays unchecked. The form fills in exactly the same values, so what you see is what was sent.
It only does this when all of these hold; otherwise Create PR behaves exactly as before:
If generation fails or you press Stop, no PR is created. Stop frees Create PR straight away, even if the agent's host is slow to confirm the stop; the next click sends what's shown.
The click owns its run. If you switch sidebar tabs, close the panel, or move to another branch or workspace while the agent is writing, the run still finishes and creates the PR for the branch you clicked, like the prepare-branch route. The new PR is linked to its worktree, but Orca never opens Checks (or the PR in the browser) over a different workspace you have since moved to. In Source Control, Create PR stays busy from the click until the create finishes, so the form doesn't close in between while eligibility refreshes.
Draft is never reverted, on any route (review follow-up): the first round scoped this to Create PR runs only, which left the ✨ Generate button able to undo it. The form only protects fields you change while the agent is running, so a Draft box you checked before pressing Generate was fair game: an agent answering
draft: falsesilently unchecked it, and your next Create PR opened a real review ready for everyone. The rule now follows provenance (did the user set this?) instead of the in-flight window, and applies to the Generate button and the prepare-branch route as well. Title and description are still replaced by an explicit Generate click — that is what the button is for — and a Generate-button base still lands in the form where you can see and change it.Checks panel, same bug: the issue names Source Control, but the Checks panel has its own Create PR form for a ready branch, with its own create handler, and it sent the same placeholders. It's fixed here through the same shared hook, so both Create PR buttons for a branch behave the same. In Source Control this covers the header button, the form button (including stacked), the dropdown item and Cmd/Ctrl+Enter.
Mechanism: a new
useGenerateBeforeCreatePullRequesthook wraps each panel's create handler. Whether to generate reads the branch's generation record in the store (running → ignore the click; failed/stopped → submit as shown), so both panels agree and it survives remounts; "untouched placeholders" comes from the same helper the form uses to fill them in. On click it runs the composer's existing store-routed generation (same record, field lock, Stop button and owner-host routing as the Generate button) and awaits its outcome — each panel's generation now returns{ result }for its own request (nullwhen it failed or was stopped). The run is marked as auto-submitted, and the store's success resolver (resolveGeneratedFields) honours the Draft rule for every run and keeps the user's base for auto-submitted ones. The form and Create PR then read the same stored answer. The hook then creates through the create handler from the click, not a later render's: when generation ends, Source Control clears its eligibility to refetch it, so the latest handler would see "not ready" and quietly skip the create. That also means a branch that changes state mid-run (for example, an agent edits files) still gets the PR for what was clicked. A run's outcome settles as soon as its record stops running (settlePullRequestGenerationRequest), which is what lets Stop free the button immediately. A Generate-button run isn't marked, so its result still carries the agent's suggested base into the form for review, as on main — but it no longer carries the agent's draft over a Draft box you had already set (see below).Why
The two Create PR routes disagreed: a branch that needed preparing got AI details, a ready one didn't, so the result depended on branch state the user can't see (the maintainer's diagnosis in the issue). This follows the maintainer's suggested fix — generate when the fields are untouched defaults, otherwise submit what the user wrote — and mirrors the prepare-branch route's "generate, then create".
Alternatives considered:
createdReviewIsForeground), so Source Control never jumps to the old branch's PR and the Checks panel never blocks the new branch's form.Known differences / limits:
Linked Issue
Fixes #22824
Visual Proof
Real app (hidden Orca, macOS, Claude as the PR agent, private throwaway repo). The screenshots are in order:
Testing
Regression tests at both handlers:
source-control/review/use-hosted-review-creation.test.tsx(generate → create with the generated text on your base; a failed run → no PR, and the next click submits as shown even after the panel reopens; Stop → Create PR freed at once, next click submits as shown; repeated clicks → one run, one PR; panel closed mid-run → PR still created; panel moved to another worktree mid-run → PR created without revealing Checks; generation ending refreshes eligibility → still creates; edited fields / AI off / no agent / generation can't start → submit as shown; blocked branch → notice, no agent run),checks-panel/use-checks-panel-create-review.test.tsx(generate → create with the generated fields; creates with the finished run while the panel still shows it generating; reveals the PR only while its worktree is still selected or shown), each panel's generation hook,source-control/review/use-pull-request-generation.test.tsxandchecks-panel/use-checks-panel-generation.test.tsx(a Create PR run keeps the base; a Generate-button run keeps the agent's; a run stopped before the generator answers yields no result),useCreatePullRequestDialogFields.test.ts(the placeholder flag; run options reach the generation; the base stays put during a run even if the compare base changes), andSourceControl.pr-generation-records.test.ts(a Create PR run keeps the base and never unchecks Draft, and an untouched unchecked box takes the agent's suggestion; a Generate-button run keeps the agent's base and title, and still never reverts a Draft choice), plussource-control-create-pr-intent-flow.test.ts(the prepare-branch route never downgrades a "Create as draft" choice). The success-path tests fail on main; each guard was removed in turn and a test failed.pnpm tc:web,oxlinton changed files,check:code-quality:changed, oxfmt, and all 256 right-sidebar test files pass locally. The fullpnpm lint/pnpm testruns are left to CI.Real app (hidden Electron via the e2e harness, macOS): on a private throwaway repo, branch
fix-readme-typopushed, Claude as the PR agent, form untouched → clicked Create PR → fields locked with "Generating title & description…" → a real PR was created titled "Fix README typo and add contribution note" with a generated Problem/Solution/Changes description, basemain, not draft. The same run with the Checks panel's Create PR created "Add usage section to README" with a generated description. Pressing Stop mid-run created no PR (checked for 20s), and the next click sent the form as shown.Re-verified end to end in the real app after the click-owned-run changes (by @brennanb2025): create, Stop, a failing agent, an edited title, the Checks panel, and navigating away mid-run.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)