Skip to content

feat(style): hyperlink PR numbers in submit output (#105)#107

Open
mvanhorn wants to merge 1 commit intoboneskull:mainfrom
mvanhorn:feat/hyperlink-pr-numbers-issue-105
Open

feat(style): hyperlink PR numbers in submit output (#105)#107
mvanhorn wants to merge 1 commit intoboneskull:mainfrom
mvanhorn:feat/hyperlink-pr-numbers-issue-105

Conversation

@mvanhorn
Copy link
Copy Markdown

Closes #105.

What changed

`submit` now wraps the `PR #N` token in its progress line with an OSC 8 terminal hyperlink, so iTerm2 / kitty / recent macOS Terminal / GNOME Terminal users can click the PR number to jump to the URL. Terminals without hyperlink support (or sessions where output is piped) get a plain `text (URL)` fallback so the URL is still visible.

Before:

```
Updating PR #3150 for boneskull/additional-locations (base: master)... ok
```

After (TTY with OSC 8): the `PR #3150` is a clickable link to the PR URL.

After (no TTY / NO_COLOR):

```
Updating PR #3150 (https://github.com/boneskull/gh-stack/pull/3150) for boneskull/additional-locations (base: master)... ok
```

How

  • New `internal/style/style.go` method `Hyperlink(text, url)`:
    • Colors/TTY enabled → `\x1b]8;;URL\x1b\TEXT\x1b]8;;\x1b\` (OSC 8).
    • Disabled → `"text (url)"`.
    • Empty URL → returns text alone, no parens.
  • `cmd/submit.go:465` updated to use `s.Hyperlink(fmt.Sprintf("PR #%d", d.prNum), ghClient.PRURL(d.prNum))` in the `Updating ...` line. The `(base: parent)` suffix and `...` / `ok` / `failed` trailers are unchanged so existing test snapshots and TTY-detection logic are unaffected.
  • `internal/style/style_test.go` (new) covers all three branches.

Why this matches the issue

Quoted from the issue (#105):

wherever terminal links are available, the text `PR #nnnn` should be the linked text.

That's the OSC 8 path. The fallback is what the issue showed as the alternate render.

Verification

  • `go build ./...` clean.
  • `go test ./internal/style/...` — 3 new tests pass.
  • `go test ./cmd/...` — `cmd` tests pass (cached, no relevant impl changes there).
  • `go test ./e2e/...` — same set of e2e dry-run tests fail on `main` as on this branch (pre-existing `git push -u origin main` env issue, unrelated to this change). Verified by stashing and re-running.

submit prints "Updating PR #N for branch (base: parent)..." with no
URL. Per the issue, the PR number should be the linked text when the
terminal supports OSC 8 hyperlinks; otherwise fall back to "text (URL)"
so the URL remains visible.

Added Hyperlink(text, url) to internal/style/style.go:

- Color/TTY enabled: emits OSC 8 escape sequence
  (\x1b]8;;URL\x1b\\TEXT\x1b]8;;\x1b\\), which renders as a clickable
  link in iTerm2, kitty, recent macOS Terminal, GNOME Terminal, etc.
- Color/TTY disabled (NO_COLOR, piped output, dumb terminal):
  falls back to "text (url)".
- Empty URL: returns text alone, no parens.

Updated cmd/submit.go:465 to wrap "PR #N" with Hyperlink() and
ghClient.PRURL(d.prNum). The (base: parent) suffix and trailing
"... ok" / "failed" are unchanged.

Added internal/style/style_test.go covering the three branches
(enabled, disabled, empty URL).

Closes boneskull#105
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.

submit should show link to PR, not just PR number, when updating PRs

1 participant