fix(ui-tui): skip generic path segments when deriving slug fallback labels (#25606) - #25619
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds filtering of generic path segments (e.g., status, auth, login) when deriving a human-readable title from a URL slug, so that meaningful preceding segments surface instead of uninformative ones.
Changes:
- Introduce
GENERIC_PATH_SEGMENT_REto match common generic URL path segments. - Skip these segments in
urlSlugTitleLabel, falling back to host+path when no useful slug is found. - Add tests covering the new behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| ui-tui/src/lib/externalLink.ts | Adds generic-segment regex and skip logic in urlSlugTitleLabel. |
| ui-tui/src/tests/externalLink.test.ts | Adds tests for generic-segment skipping and host+path fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
9566468 to
39d11ef
Compare
39d11ef to
8094104
Compare
|
Rebased onto current main. Dropped the |
006181d to
0728cd2
Compare
…abels (NousResearch#25606) `urlSlugTitleLabel()` (introduced with PR NousResearch#24013's `ResolvedLink` / `useLinkTitle` flow) iterates URL path segments and title-cases the first one with a letter. The numeric-only filter two lines above already skips IDs like `12345`, but a generic trailing path word such as `status`, `auth`, or `item` slips through and becomes the entire user-facing label. The reported symptom: every `https://x.com/<user>/status/<id>` link in the TUI rendered as the literal word "Status", hiding which user and tweet was linked. `https://accounts.google.com/o/oauth2/auth` rendered as "Auth". Add a sibling skip for generic single-word segments (status, auth, oauth/oauth2, signin/signup/login/logout, page/pages, home/index, post/posts, tweet/tweets, view/show, comment/embed, dashboard/profile/account/settings, item, callback, redirect, …). When skipped, the loop either reaches a more meaningful preceding segment (`x.com/OpenAI/status/...` → "OpenAI") or falls through to the existing `hostPathLabel` fallback (`accounts.google.com/o/oauth2/auth`, `news.ycombinator.com/item`) so the destination stays visible instead of being masked by a one-word generic label. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0728cd2 to
bec3207
Compare
|
Housekeeping: closing to keep my open-PR set focused on actively-reviewed work. This has been open ~18d without maintainer review and the surrounding code has continued to move, so it's unlikely to land as-is. The underlying fix still stands — happy to reopen and rebase if it would be useful. Thanks! |
What does this PR do?
TUI link labels collapsed to a single generic word ("Status", "Auth", …) when title resolution fell back to
urlSlugTitleLabel(), masking which destination was linked. Extends the same-shape skip used for numeric-only segments to cover a small set of generic single-word path segments, so the loop continues to a more informative segment or falls through tohostPathLabel.PR #24013 introduced
ResolvedLink+useLinkTitle()inui-tui/src/components/markdown.tsx. When the async<title>fetch fails or is skipped (local/private hosts, non-HTML responses, errors), the display falls back todefaultLinkLabel→urlSlugTitleLabel(url).urlSlugTitleLabel()iterates path segments in reverse, already skipping pure-numeric segments, but accepts the first segment with a letter and length ≥ 4, including obviously generic trailing words likestatus,auth,item. The Web UI shows the full clickable URL in the same case.After the fix:
https://x.com/OpenAI/status/1234567890→OpenAI;https://accounts.google.com/o/oauth2/auth→accounts.google.com/o/oauth2/auth;https://news.ycombinator.com/item→news.ycombinator.com/item. Multi-word and domain-specific segments (issues,releases,pulls,commit, …) are left alone so existing readable slugs keep working.Related Issue
Fixes #25606
Type of Change
Changes Made
ui-tui/src/lib/externalLink.ts— addGENERIC_PATH_SEGMENT_REregex (status/auth/oauth/signin/signup/login/page/index/home/post/tweet/view/show/detail/comment/share/embed/dashboard/profile/account/settings/item/callback/redirect…) and acontinueskip sibling to the existing numeric-only skip inurlSlugTitleLabel().ui-tui/src/__tests__/externalLink.test.ts— 2 new cases covering the three URL classes above.How to Test
ui-tui/:npx vitest run src/__tests__/externalLink.test.ts— 12/12 pass.npx vitest run(after buildingpackages/hermes-ink) — 722/722 pass across 65 files.npm run type-check— clean."Status"and"Auth". Restore — green.urlSlugTitleLabel('https://www.getyourguide.com/.../from-fajardo-icacos-island-full-day-catamaran-trip-t19891/')still returnsFrom Fajardo Icacos Island Full Day Catamaran Trip— readable multi-word slug unaffected.Checklist
Code
fix(scope):,feat(scope):, etc.)Documentation & Housekeeping
docs/, docstrings) — N/Acli-config.yaml.exampleif I added/changed config keys — N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/ARelated / Positioning