Conversation
Replace github.com/mattn/go-isatty with github.com/cli/go-gh/v2/pkg/term for terminal detection. This ensures gh-stack respects the same environment variables as the gh CLI: - GH_FORCE_TTY: Force TTY mode (useful for CI testing) - NO_COLOR: Disable color output - CLICOLOR / CLICOLOR_FORCE: Control color behavior The direct go-isatty dependency is removed (now transitive via go-gh).
Replace custom Input, Confirm, and Select implementations with github.com/cli/go-gh/v2/pkg/prompter (survey-based prompts). Benefits: - Arrow key navigation for Select instead of typing numbers - Type-to-filter in long option lists - Better handling of terminal edge cases (resizing, interrupts) - Consistent UX with gh CLI extensions The survey library is added as a transitive dependency through go-gh.
Add -w/--web flag to the submit command that opens created or updated PRs in the default web browser after submission completes. Uses github.com/cli/go-gh/v2/pkg/browser which respects: - GH_BROWSER environment variable - browser setting in gh config - BROWSER environment variable The browser package also includes security validation for URLs.
Replace manual tab-separated output with go-gh tableprinter for the --porcelain flag. The tableprinter automatically adapts to the output: - TTY mode: Nicely formatted columns with headers, current branch marked with '*' prefix, column widths fit to terminal - Non-TTY mode: Clean TSV output for scripting (unchanged behavior) This ensures consistent output formatting with other gh CLI commands.
Owner
Author
Stack
Managed by gh-stack |
There was a problem hiding this comment.
Pull request overview
This PR refactors gh-stack to use standardized packages from go-gh for terminal detection, interactive prompts, table printing, and browser launching. It also adds a new --web flag to the submit command that opens PRs in the browser after creation/update.
Changes:
- Replaced custom prompt implementations with go-gh/v2/pkg/prompter (survey-based) for better UX with arrow key navigation and type-to-filter
- Replaced go-isatty with go-gh/v2/pkg/term for terminal detection with environment variable support (GH_FORCE_TTY, NO_COLOR, etc.)
- Replaced manual TSV output with go-gh/v2/pkg/tableprinter for consistent formatting in the log command
- Added --web/-w flag to submit command using go-gh/v2/pkg/browser for opening PRs in the default browser
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/prompt/prompt.go | Refactored to use go-gh prompter and term packages, replacing custom implementations with survey-based prompts |
| cmd/log.go | Replaced manual tab-separated output with tableprinter for consistent formatting between TTY and non-TTY modes |
| cmd/submit.go | Added --web flag to open PRs in browser after creation/update, with proper flag propagation through helper functions |
| cmd/continue.go | Updated function signatures to match submit.go changes for the new openWeb parameter |
| go.mod | Added new dependencies for survey, tableprinter, browser, and related transitive dependencies |
| go.sum | Updated checksums for all new and updated dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Running `gh stack submit` while on the trunk branch would incorrectly attempt to force-push trunk and create a PR for it. Now the command: - On trunk: only submits descendant stack branches - On trunk with `--current-only`: errors with clear guidance - On trunk with no descendants: errors indicating empty stack
- log: Use large terminal width (4096) for non-TTY mode since tableprinter outputs TSV format where width is irrelevant - submit/continue: Preserve `--web` flag in cascade state so it works correctly when continuing after conflict resolution
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 9 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closed
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.
refactor(log): use go-gh pkg/tableprinter for porcelain output
Replace manual tab-separated output with go-gh tableprinter for the
--porcelain flag. The tableprinter automatically adapts to the output:
marked with '*' prefix, column widths fit to terminal
This ensures consistent output formatting with other gh CLI commands.
feat(submit): add --web flag to open PRs in browser
Add -w/--web flag to the submit command that opens created or updated
PRs in the default web browser after submission completes.
Uses github.com/cli/go-gh/v2/pkg/browser which respects:
The browser package also includes security validation for URLs.
refactor(prompt): use go-gh pkg/prompter for interactive prompts
Replace custom Input, Confirm, and Select implementations with
github.com/cli/go-gh/v2/pkg/prompter (survey-based prompts).
Benefits:
The survey library is added as a transitive dependency through go-gh.
refactor(prompt): use go-gh pkg/term for terminal detection
Replace github.com/mattn/go-isatty with github.com/cli/go-gh/v2/pkg/term
for terminal detection. This ensures gh-stack respects the same environment
variables as the gh CLI:
The direct go-isatty dependency is removed (now transitive via go-gh).