fix: --web opens a browser tab for every PR when submitting a multi-branch stack#135
Open
mvanhorn wants to merge 1 commit into
Open
fix: --web opens a browser tab for every PR when submitting a multi-branch stack#135mvanhorn wants to merge 1 commit into
mvanhorn wants to merge 1 commit into
Conversation
Owner
|
@mvanhorn Thanks for your help! Glad you are finding this useful. |
Contributor
There was a problem hiding this comment.
Pull request overview
Adjusts gh stack submit --web to only open browser tabs for newly created PRs (not updated/adopted ones), aligning behavior with the intended UX for multi-branch stacks.
Changes:
- Restricts
--webURL collection to newly created PRs viacollectSubmitPRURL, and updates CLI help text accordingly. - Updates README flag documentation for the refined
--webbehavior. - Adds unit tests to verify which PR actions contribute URLs for browser opening.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates --web flag documentation to “newly created PRs” only. |
| cmd/submit.go | Stops collecting URLs for updated/adopted PRs; collects URLs only for successfully created PRs. |
| cmd/submit_internal_test.go | Adds unit tests covering URL collection behavior for --web across create/update/adopt/failure/dry-run cases. |
| cmd/restack.go | Adds early return for non-conflict rebase errors (plus suggested improvement to error context). |
| cmd/adopt.go | Refactors cycle detection to walk parent links directly (not described in PR scope). |
| .osc-metadata/sync.json | Adds fork-sync metadata file (appears unrelated to feature change). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+299
to
+301
| if rebaseErr != nil && !g.IsRebaseInProgress() { | ||
| return rebaseErr | ||
| } |
Comment on lines
+87
to
105
| // Check for cycles by walking configured parent links directly. A broken | ||
| // parent can disconnect branches from the trunk-rooted tree while their | ||
| // stackParent links still form a cycle. | ||
| seen := map[string]bool{} | ||
| for current := parent; current != trunk; { | ||
| if current == branchName { | ||
| return errors.New("cannot adopt: would create a cycle") | ||
| } | ||
| if seen[current] { | ||
| return errors.New("cannot adopt: parent chain contains a cycle") | ||
| } | ||
| seen[current] = true | ||
|
|
||
| parentNode := tree.FindNode(root, parent) | ||
| if parentNode != nil { | ||
| for _, ancestor := range tree.GetAncestors(parentNode) { | ||
| if ancestor.Name == branchName { | ||
| return errors.New("cannot adopt: would create a cycle") | ||
| } | ||
| next, parentErr := cfg.GetParent(current) | ||
| if parentErr != nil { | ||
| break | ||
| } | ||
| current = next | ||
| } |
Comment on lines
+1
to
+5
| { | ||
| "fork_synced_at": "2026-07-10T09:11:21.236884+00:00", | ||
| "commits_behind_before_sync": 24, | ||
| "action_taken": "synced" | ||
| } No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implement the maintainer's option 1 combined with option 5's URL-printing half, which the code already satisfies: only append to
prURLsin theprActionCreatenon-adopted path (theCreated PR #%dbranch), and stop appending in theprActionUpdateand adoption paths (bothprActionAdoptand theadoptedresult ofexecutePRCreate), since those PRs already existed and their URLs are already printed inline vias.Hyperlink/PRURLin the status lines. Update the--webflag help string incmd/submit.gofrom "open created/updated PRs in web browser" to reflect the new behavior ("open newly created PRs in web browser"), and update the matching--webrow in README.md's flag table (line ~290). Add/extend unit tests incmd/submit_internal_test.gocovering which actions collect URLs for opening.Why this matters
gh stack submit --webopens a separate browser tab for every PR that was created, adopted, or updated in the stack, so a stack of N branches carpet-bombs the user with N tabs. The maintainer (repo owner, who filed the issue) pinpointed the code: incmd/submit.go, every successfulprActionUpdate,prActionAdopt, andprActionCreatebranch appendsghClient.PRURL(...)to aprURLsslice, and a final loop callsbrowser.Browse()on each URL. The issue lists five candidate directions and names option 1 ("only open newly created PRs - skip updated ones, since the user already knows about those") as the least disruptive; a follow-up comment adds that removing--webentirely would also be acceptable.See #44.
Testing
--webwith a create failure on one branch: failed branch contributes no URL, remaining created PRs still open.Fixes #44