Skip to content

--web flag opens a browser tab for every PR when submitting a multi-branch stack #44

@boneskull

Description

@boneskull

Problem

When gh stack submit --web operates on a stack with multiple branches, it opens a separate browser tab for every PR that was created or updated. For a stack of N branches, that's N tabs opened in rapid succession.

The --web flag was likely carried over from gh pr create --web semantics, where it makes perfect sense — you're creating one PR and want to see it. But for the "submit the whole stack" use case, carpet-bombing the user with browser tabs is... not great.

Current behavior

In cmd/submit.go, all successfully created/updated PR URLs are collected into a slice, and then each one is opened via browser.Browse():

if openWeb && len(prURLs) > 0 {
    b := browser.New("", os.Stdout, os.Stderr)
    for _, url := range prURLs {
        if err := b.Browse(url); err != nil {
            fmt.Fprintf(os.Stderr, "%s could not open browser for %s: %v\n", s.WarningIcon(), url, err)
        }
    }
}

This collects URLs from both newly created PRs and updated existing PRs.

Possible directions

No strong opinion yet on which approach is best. Some options:

  1. Only open newly created PRs — skip updated ones, since the user already knows about those. This is the least disruptive change.
  2. Cap the number of tabs — e.g., open up to 3 and print the remaining URLs to the terminal.
  3. Prompt before opening multiple tabs — something like "About to open 5 tabs, continue? [y/N]".
  4. Print URLs instead of opening — when N > 1, just print the URLs and let the user pick which to open.
  5. Some combination — e.g., always open newly created PRs, print URLs for updated ones.

Open to ideas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions