Skip to content

Resolve branch and PR identity consistently for stack discovery - #1289

Merged
ketan0 merged 5 commits into
mainfrom
codex/resolve-review-sources
Oct 23, 2026
Merged

ketan0 merged 5 commits into
mainfrom
codex/resolve-review-sources

Conversation

@ketan0

@ketan0 ketan0 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Branch and PR inputs now resolve to the same branch and PR without changing the agent-facing API or replacing an explicitly chosen comparison. PR retargeting uses the same resolver as PR creation, and a named branch discovers its matching open GitHub PR. A branch board whose PR is published later shows that PR when read and is reused when the PR is later opened by number.

What is learned is stored on the review's existing origin record. The one new field is optional, so older stores and shared bundles parse unchanged and no migration is needed: pullRequestBaseBranch, the branch the PR merges into, which can differ from the chosen comparison base.

Stack discovery uses GitHub's native stack first. Otherwise it walks open same-repository PRs by base and head branch in both directions, stopping at forks, cycles and ambiguous continuations, and lists PRs that have no whiteboard. A short-lived (60 s) cache shares one read of the repository's open PRs between PR discovery and stack walking. Optional forge reads run outside the save queue and fall back to local context when unavailable.

Known limits: PR discovery does not cover fork PRs or local branches renamed away from the PR's head branch. A PR found by discovery is shown but not saved on the board.

Review fixes preserve writes accepted before shutdown and reject new writes once closing starts. Branch-board reuse checks repository identity, while preserving reuse across worktrees and same-origin clones. The stack menu labels local branches “from branch bases” instead of “from GitHub”.

Validation: root format and lint, backend/protocol/canvas typechecks, the full backend suite (1,305 passed, 1 skipped), six selector browser tests, and a desktop build. The corrected menu was checked in the isolated Desktop in dark and light themes, including Escape and focus restoration. In an isolated Desktop against live GitHub, #1094 (no GitHub stack) shows the inferred chain #1018 → #1022 → #1093 → #1094 → #1095 → #1097, and #1355 shows its native GitHub stack #1353–#1356.

Whiteboard review: b4a369de-c96f-49d5-a334-66aedeaac5d4.

🤖 Generated with Claude Code

@ketan0
ketan0 force-pushed the codex/resolve-review-sources branch 3 times, most recently from b6264da to 5e6175a Compare October 21, 2026 06:48
thesiti92 added a commit that referenced this pull request Oct 22, 2026
When a saved review contains metadata the portable share validator
cannot read, `ShareClient.create` fails before contacting the hosted
service. The publishing host currently replaces that exception with
“Sharing failed. Check your connection and login, then retry,” sending
users back through sign-in even when their credentials are valid.

Classify local bundle-validation failures as `SharePreflightError`,
using the existing HTTP 422 handling to show a preparation error that
asks the user to report the issue. The original exception remains
available as an error cause; raw validation details are not exposed in
the response.

Related to #1289, which already includes the `origin.baseBranch` schema
fix. I reproduced a named-base export failing on current main and
passing with that one-line schema change. This PR addresses the
remaining misleading-error path for incompatible saved data.

The regression test publishes a review containing unsupported origin
metadata and verifies the response, zero hosted requests, no publication
callback, and an unchanged saved login. Existing success,
Git-verification, and expired-token tests still pass.

Validation:
- Sharing suite: 8 files, 47 tests passed.
- Final publishing regression run: 5 tests passed.
- Backend TypeScript check, root `pnpm lint`, `pnpm format`, and `git
diff --check` passed.
- Full `pnpm run ci` was attempted with the required Node 24.18.0 and
pnpm 11.1.2. Desktop dependency bootstrap exhausted local disk space
before the full suite could run. Generated Code OSS dependencies were
removed, then the publishing tests and backend typecheck passed again.

---------

Co-authored-by: thesiti92 <aiansiti@outlook.com>
ketan0 and others added 2 commits October 22, 2026 15:03
Stack discovery finds a review's PR from its branch, walks ordinary GitHub
PR base/head chains, and resolves branch and PR the same way for create and
retarget. What it learns is stored on the review's existing origin record:
two optional fields, pullRequestBaseBranch (the branch the PR merges into)
and pullRequestDetached (the user removed the PR, so its branch must not
find one again). Older stores and shared bundles parse unchanged.

Agent-Session: 01a0d12e-51ca-7230-9991-0ce7a73018b2

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: 01a0d12e-51ca-7230-9991-0ce7a73018b2
Boards whose PR the user removed no longer join a stack by branch name,
and stored branch labels are compared without their legacy origin/ prefix
everywhere stacks match boards. PR URLs are parsed and compared through
pullRequestProvider and pullRequestKey instead of local regexes, the
inferred stack walk is named inferredGitHubStack, and prepareCommand
returns a named PreparedCommand.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: 01a0d12e-51ca-7230-9991-0ce7a73018b2
@ketan0
ketan0 force-pushed the codex/resolve-review-sources branch from 5e6175a to 7f1d5dc Compare October 22, 2026 23:00
ketan0 and others added 3 commits October 22, 2026 21:35
Removing a PR from a board (pullRequestUrl: null) clears its PR fields as
it does on main, without remembering that the removal was deliberate.
Later branch discovery may find the PR again, which is acceptable; nothing
in the agent tools or the canvas detaches a PR today.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agent-Session: 01a0d12e-51ca-7230-9991-0ce7a73018b2
Agent-Session: 01a0d12e-51ca-7230-9991-0ce7a73018b2
Agent-Session: 01a0d12e-51ca-7230-9991-0ce7a73018b2
@ketan0
ketan0 enabled auto-merge (squash) October 23, 2026 06:34
@ketan0
ketan0 merged commit df0b076 into main Oct 23, 2026
3 checks passed
@ketan0
ketan0 deleted the codex/resolve-review-sources branch October 23, 2026 06:36
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