Skip to content

Auto-detected links with new lines result in 404s when clicked #3718

Closed

Description

@heaths

Describe the bug

In gh 1.10.3 links in comments that span new lines are detected as a broken link by terminals like Windows Terminal 1.8 that support detecting URLs.

Steps to reproduce the behavior

  1. Type gh pr -R cli/cli view 3519 --comments
  2. Find the comment with an image and click on the link.
  3. The link results in a 404

image

The detected link here is only https://user-images.githubusercontent.com/1532486/116502954 which 404s. Windows Terminal 1.8 does properly detect continuous URLs that wrap lines, so I suspect this has more to do with the break in the link for formatting purposes:

image

The rendering is done by github.com/yuin/goldmark which is currently only applying coloring for rendered markdown, and I've opened more of a feature request for OSC 8 support. This might be more of a tracking bug until that issue is resolved, but I wanted to note the current behavior.

Expected vs actual behavior

Rendered links in the output are clickable and result in the proper resource being fetched.

Logs

N/A

Activity

  1. added
    bug
    on May 25, 2021
  2. mislav commented on May 26, 2021

    @mislav
    Contributor

    Thanks for reporting!

    Agreed that URLs should never get hard-wrapped, and that this needs to be solved on Glamour level.

    Ref. #3640

  3. added
    priority-3
    on May 26, 2021
  4. heaths commented on Jun 4, 2021

    @heaths
    ContributorAuthor

    Looking to address this, I see that yuin/goldmark is only providing the parsing and rendering visitor, while charmbracelet/glamour is actually doing the rendering. There's also already an issue open for this: charmbracelet/glamour#114.

  5. added
    gh-pr
    gh-issue
    on Oct 2, 2023
  6. heaths commented on Aug 14, 2026

    @heaths
    ContributorAuthor

    I see that charmbracelet/glamour is still v0.10.0 when they have a v2 available. In fact, you use several v2 charmbracelet modules currently. I updated cli/go-gh already and it was not very disruptive: cli/go-gh#281

    I recommend upgrading here. Would also likely reduce binary size a bit since it would share a single version of lipgloss. I doubt comdat folding would apply across such a large version mismatch that exists now.

    And, yes, this still repros today on that same command line above:

    Image

    My PR for go-gh fixed the issue just by upgrading glamour. The only change to output was some elision of 0 in reset codes e.g., \e[0m -> \e[m. Both are effectively equivalent.

  7. heaths commented on Aug 14, 2026

    @heaths
    ContributorAuthor

    Replacing github.com/cli/go-gh/v2 with github.com/heaths/go-gh/v2 issue279 from cli/go-gh#281 and updating both glamour and lipgloss in cli/cli, there are a couple of differences due to lipgloss itself since both v1 and v2 were used here. Lipgloss v2 appears more aggressive when wrapping lines or padding columns:

    @@ -38,4 +38,4 @@
     Bash: Check if there are any existing scripts or build files
    -$ cd /home/runner/work/foo/foo && find . -name "*.sh" -o -name "Makefile" -
    -  o -name "package.json" -o -name "*.yml" -o -name "*.yaml"
    +$ cd /home/runner/work/foo/foo && find . -name "*.sh" -o -name "Makefile"
    +  -o -name "package.json" -o -name "*.yml" -o -name "*.yaml"
    @@ -1,7 +1,7 @@
    -Assigned Issues                       │ Assigned Pull Requests
    -Nothing here ^_^                      │ Nothing here ^_^
    -                                      │
    -Review Requests                       │ Mentions
    -Nothing here ^_^                      │ Nothing here ^_^
    -                                      │
    +Assigned Issues                      │ Assigned Pull Requests
    +Nothing here ^_^                     │ Nothing here ^_^
    +                                     │
    +Review Requests                      │ Mentions
    +Nothing here ^_^                     │ Nothing here ^_^
    +                                     │

    Looking into what, if anything, could be done. Also wondering how much it matters since they are to a TTY so only visual. Should not impact programmatic reads e.g., via --json nor agentic reads. /cc @BagToad

  8. heaths commented on Aug 14, 2026

    @heaths
    ContributorAuthor

    Copilot analysis reveals these are actually due to fixes, though the new line between -o seems highly sus.


    • Reviewed Lip Gloss release notes from the old pseudo-v1 dependency
      to  charm.land/lipgloss/v2 v2.0.5 , plus the v2 upgrade guide and
      source changes.
    • Release notes point to more correct wrapping/measurement in v2
      ( v2.0.2  table wrapping fix,  v2.0.5  grapheme fixes), but they do
      not expose a compatibility mode for old layout width semantics.
    • The strongest explanation for the  status  regression is a v2
      rendering change:  Style.Render()  now subtracts horizontal border
      size from  Width()  before wrapping/alignment. With
       BorderRight(true) , that removes one content column and causes the
      earlier wraps/tighter spacing you saw.
    •  x/ansi  also moved toward  displaywidth  and grapheme-aware
      measurement, which can affect Unicode-heavy wrapping, but that is
      probably secondary for the ASCII-only  status  output.
    • There is no Lip Gloss v2 API toggle to restore the old  Width() 
      behavior globally. The practical fix is in our layout code: compensate
      for bordered blocks by adding border width back into  Width()  (for
      this case, likely  halfWidth + 1  on the bordered left column), or
      render content first and border it separately.

    Investigating further on the -o wrap it's because the line broke one cell earlier before, but with the grapheme-based measurements everything has shifted a little. Again, though, sounds like this is a warranted fix since it was wrong before and only affects TTY output. IMO, this isn't breaking:


    • The  -o  behavior is a separate transcript-rendering issue, not the
       pkg/cmd/status  border-width issue.
    • Bash transcript content is rendered as a fenced markdown code block
      and then wrapped through Glamour via go-gh; that path is not shell-
      aware.
    • Hyphens are legal wrap points in this stack, so  -o  is allowed to
      split at all.
    • I verified the moved breakpoint is not just a one-cell width
      change. Old Glamour ( github.com/charmbracelet/glamour v0.10.0 ) used
       ansi.Wordwrap(..., " ,.;-+|") ; new Glamour ( charm.land/glamour/v2
      v2.0.1 ) uses  lipgloss.Wrap(..., " ,.;-+|") .
    • At the same width, those two algorithms place the break
      differently: the old  Wordwrap  path can leave the hyphen at end-of-
      line and continue the token on the next line, while the new  Wrap 
      path can break before the hyphen-led token instead. That is why it
      split earlier before, but not now.
    • So the answer is: the breakpoint moved because the upstream
      wrapping algorithm changed, even though both still treat  -  as a
      valid breakpoint. If we need “shell switches must never be split,” the
      fix has to be in how we render shell transcript/code-block content,
      not in a Lip Gloss compatibility toggle.
  9. heaths commented on Aug 15, 2026

    @heaths
    ContributorAuthor

    go run ./cmd/gh pr -R cli/cli view 3519 --comments now works:

    Image
  10. BagToad commented on Sep 1, 2026

    @BagToad
    Member

    Thanks @heaths, these look like an acceptable amount of format changes to me. Thanks for testing it out. Let's try and get the go-gh PR merged. There's some conflicts on that PR, but it otherwise LGTM.

  11. heaths commented on Sep 4, 2026

    @heaths
    ContributorAuthor

    @BagToad I've rebased cli/go-gh#281

  12. added a commit that references this issue on Oct 8, 2026
    82b0f3e
  13. added 2 commits that reference this issue on Oct 17, 2026
    f81a23a
    389b60d
  14. added
    help wanted
    on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggh-issuegh-prhelp wantedpriority-3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions