Skip to content

feat: LinkedTextBlock shape with clickable rows (OSC 8) + hn_top fetcher - #148

Merged
unhappychoice merged 8 commits into
mainfrom
feat/linked-text-block
Apr 26, 2026
Merged

unhappychoice merged 8 commits into
mainfrom
feat/linked-text-block

Conversation

@unhappychoice

@unhappychoice unhappychoice commented Apr 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Adds LinkedTextBlock shape — a TextBlock sibling whose rows carry an optional URL — and a new list_links renderer that wraps linked rows in OSC 8 escape sequences so modern terminals surface them as clickable hyperlinks. Rows without a URL fall through to plain text.
  • Adds hn_top fetcher (Hacker News top / new / best / ask / show / job stories) over the public read-only Firebase API; rows link to the story URL or the HN comment page.
  • Migrates 10 existing github_* feed fetchers (my_prs, review_requests, assigned_issues, repo_prs, repo_issues, good_first_issues, recent_releases, notifications, contributors_monthly, plus the shared items.rs path) to emit LinkedTextBlock when that shape is requested. Existing shapes (TextBlock / Entries / Timeline / Bars) keep working unchanged.
  • Switches home_github (my_prs / review_queue / notifications) and project_github (repo_prs / repo_issues / releases) presets to render = "list_links" so the default templates ship with clickable rows.

Implementation note worth flagging for review: the OSC 8 sequence is collapsed into the first cell's symbol, with skip = true on the trailing cells of the linked region. ratatui's Buffer::diff computes per-cell width via unicode_width::UnicodeWidthStr::width(), which counts every printable byte inside the escape sequence as a visible column — without the skip workaround the cells immediately after the link silently drop. See src/render/list_links.rs module doc for the longer write-up.

Catalog: ticks the hn_top checkbox in #67. The 10 github_* fetchers were already shipped — this PR extends each with one more shape, no checkbox flip needed.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test (632 passed)
  • Local smoke test: cargo run --bin splashboard with a .splashboard/dashboard.toml exercising hn_top, github_my_prs, github_review_requests, github_notifications, github_recent_releases — confirmed clickable in the user's terminal.
  • Verify rendering in a terminal that does NOT support OSC 8 — the rows should render as plain text without escape-code residue. (Not validated locally; review-time check.)

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • New Features

    • Integrated Hacker News as a new data source with support for top stories, user profiles, comments, and submissions
    • GitHub widgets now render with clickable links for improved navigation
  • Improvements

    • Updated GitHub notification, pull request, and issue widgets to use link-based rendering by default

unhappychoice and others added 4 commits April 26, 2026 14:15
`LinkedTextBlock` is a sibling of `TextBlock` whose rows carry an optional
URL. The new `list_links` renderer wraps each linked row in OSC 8 escape
sequences so modern terminals surface them as clickable hyperlinks; rows
without a URL fall through to plain text. Renderers that don't understand
links can ignore the field, keeping `TextBlock` consumers untouched.

Implementation note: the OSC 8 sequence is collapsed into the first cell's
symbol with `skip = true` on the trailing cells to dodge ratatui's diff-side
width calculation, which otherwise counts printable bytes inside the escape
sequence as visible columns and silently swallows the cell after the link.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Hacker News stories — top / new / best / ask / show / job — via the public
read-only Firebase API (`hacker-news.firebaseio.com`, fixed host so safety
class stays Safe). Branches on shape: `LinkedTextBlock` (default) populates
each row's URL with the story link, falling back to the HN comment page
when absent; `TextBlock` and `Entries` keep working for non-linked
renderers. Story metadata (`Npt Mc`) is prepended to each row.

Catalog: ticks the `hn_top` checkbox in #67.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Fetchers whose rows have a canonical "open this" URL now branch on
`LinkedTextBlock` shape and populate each row with the matching HTML link:

- `items.rs` (shared by `github_my_prs`, `github_review_requests`,
  `github_assigned_issues`, `github_repo_prs`, `github_repo_issues`,
  `github_good_first_issues`) — uses `IssueItem.html_url`.
- `github_recent_releases` — uses release `html_url`.
- `github_notifications` — converts `subject.url`
  (`api.github.com/repos/...`) to the browser HTML URL
  (`github.com/...`); rows without a parseable URL render unlinked.
- `github_contributors_monthly` — links to each contributor's
  `https://github.com/{login}` profile.

Existing shapes (`TextBlock` / `Entries` / `Timeline` / `Bars`) are
unchanged, so renderers that don't request `LinkedTextBlock` see no
behaviour difference.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
`home_github` (my_prs / review_queue / notifications) and `project_github`
(repo_prs / repo_issues / releases) now use `render = "list_links"` so the
default presets ship with clickable rows out of the box. Bullet glyphs and
the timeline date label drop in exchange — clickability is the bigger win
for these queues.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@coderabbitai

coderabbitai Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

The PR introduces a new LinkedTextBlock payload shape supporting optional per-item URLs, implements a list_links renderer for terminal hyperlinks via OSC 8 sequences, updates multiple GitHub fetchers to advertise and default to this shape, adds a complete Hacker News fetcher family (four fetchers plus shared HTTP client), and wires the new shape through the rendering pipeline and templates.

Changes

Cohort / File(s) Summary
GitHub Fetcher LinkedTextBlock Support
src/fetcher/github/assigned_issues.rs, good_first_issues.rs, my_prs.rs, repo_issues.rs, repo_prs.rs, review_requests.rs
Each fetcher extends SHAPES to include LinkedTextBlock and updates default rendering from TextBlock to LinkedTextBlock when ctx.shape is unset. Consistent pattern across all six files.
GitHub Fetcher LinkedTextBlock Rendering
src/fetcher/github/contributors_monthly.rs, notifications.rs, recent_releases.rs, items.rs
Implement LinkedTextBlock handling in render_body functions with formatted LinkedLine entries and optional URLs. items.rs adds new link_for helper to extract URLs from IssueItem; notifications.rs extends Subject model with url field and includes URL parsing logic; recent_releases.rs adds release_date and link_for helpers.
Hacker News Client Infrastructure
src/fetcher/hackernews/client.rs
New shared HTTP client module defining API base URL, page URL templates, user-agent with crate version, global reqwest::Client with gzip/timeout, and generic get<T>() function for JSON deserialization with HN-specific error handling.
Hacker News Fetchers
src/fetcher/hackernews/top.rs
Implements HackernewsTopFetcher supporting configurable listing kind (top/new/best/ask/show/job) and item count (1–30). Fetches listing IDs concurrently, renders in TextBlock/LinkedTextBlock/Entries shapes with score/descendant metadata and URL fallback logic. Includes extensive option parsing and rendering tests.
Hacker News User Profile Fetcher
src/fetcher/hackernews/user.rs
Implements HackernewsUserFetcher requiring user option, outputs account data (login, karma, created date, submission count, sanitized about) in Entries/Text/TextBlock/LinkedTextBlock shapes. Includes HTML sanitization for about field and Unix timestamp formatting with fallback handling.
Hacker News User Submissions Fetcher
src/fetcher/hackernews/user_submissions.rs
Implements HackernewsUserSubmissionsFetcher with user and optional count options (clamped 1–30), filters submitted items by type (story/show_hn/ask_hn/job), and renders in LinkedTextBlock/TextBlock/Entries shapes (defaulting to LinkedTextBlock) with score/descendant metadata and URL preference logic.
Hacker News User Comments Fetcher
src/fetcher/hackernews/user_comments.rs
Implements HackernewsUserCommentsFetcher fetching and filtering user comments with configurable count (1–30), sanitizes comment bodies (HTML stripping, entity decoding, truncation), and renders as LinkedTextBlock (with optional item URL) or TextBlock (per-line snippets). Includes comprehensive sanitization and truncation tests.
Hacker News Module Registration
src/fetcher/hackernews/mod.rs
New module declaring public submodules for client, top, user, user_comments, user_submissions and exports fetchers() function to register the four concrete fetchers with the registry.
Payload Data Shapes
src/payload.rs
Adds Body::LinkedTextBlock(LinkedTextBlockData) variant with nested LinkedLine structs (text + optional URL). Serialization omits url when None. Includes round-trip and JSON-shape tests asserting correct shape label and field presence.
Render Pipeline Wiring
src/render/mod.rs
Adds Shape::LinkedTextBlock variant, maps Body::LinkedTextBlock to it, registers ListLinksRenderer as default renderer, updates shape_of() and as_str() functions, and extends empty-state detection. Includes builtin renderer registry test.
OSC 8 Hyperlink Renderer
src/render/list_links.rs
Implements ListLinksRenderer rendering LinkedTextBlock rows with optional OSC 8 terminal hyperlinks. Wraps linked rows with ESC ] 8 ; ; URL ESC \ sequences, marks subsequent cells with skip flag to prevent buffer diff issues. Includes tests for plain-text, hyperlink wrapping, truncation, multiple links, and Unicode edge cases.
Render Sample Data
src/samples.rs
Adds Shape::LinkedTextBlock fallback in canonical_sample and new linked_text_block() helper converting (&str, Option<&str>) input to LinkedLine items with optional URLs.
Fetcher Registry Update
src/fetcher/mod.rs
Exports new hackernews module and extends Registry::with_builtins to iterate and register all HN fetchers returned by hackernews::fetchers().
GitHub Template Updates
src/templates/home_github.toml, project_github.toml
Update render.type from list_plain/list_timeline to list_links for my_prs, review_queue, notifications, repo_prs, repo_issues, and releases widgets while preserving max_items limits.

Sequence Diagram

sequenceDiagram
    participant Fetcher as GitHub/HN Fetcher
    participant PayloadBuilder as Payload Constructor
    participant RenderPipeline as Render Pipeline
    participant ListLinksRenderer as ListLinksRenderer
    participant Terminal as Terminal Buffer

    Fetcher->>PayloadBuilder: Construct LinkedTextBlock<br/>(LinkedLine items with<br/>text + optional url)
    PayloadBuilder->>RenderPipeline: Return Body::LinkedTextBlock
    RenderPipeline->>RenderPipeline: shape_of() → LinkedTextBlock<br/>default_renderer() → ListLinksRenderer
    RenderPipeline->>ListLinksRenderer: Render LinkedTextBlockData
    ListLinksRenderer->>Terminal: For each row without url:<br/>Write text to buffer
    ListLinksRenderer->>Terminal: For each row with url:<br/>Wrap in OSC 8 open<br/>+ visible text<br/>+ OSC 8 close
    Terminal-->>ListLinksRenderer: Terminal display<br/>with clickable links
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • PR #34: Introduces the foundational data-shape and rendering system (Body, Shape, Renderer trait) that this PR extends by adding LinkedTextBlock variant, LinkedLine types, ListLinksRenderer, and wiring them through the same payload/render/registry infrastructure.
  • PR #28: Extends the fetcher registry (src/fetcher/mod.rs) and adds fetchers to it; this PR follows the same pattern by adding Hacker News fetchers and registering them via hackernews::fetchers().
  • PR #72: Modifies the rendering pipeline (Renderer trait, shape/renderer wiring in render/mod.rs), directly affecting how the new LinkedTextBlock shape is routed to and processed by ListLinksRenderer.

Poem

🐰 With linked text blocks and URLs in tow,
HackerNews stories and GitHub PRs flow,
Terminal hops now clickable and bright,
The renderer paints OSC 8's light,
Where bunny fetchers and shapes take flight! 🔗

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 57.87% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main changes: adding a LinkedTextBlock shape with clickable rows using OSC 8 sequences and introducing the hn_top fetcher for Hacker News.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/linked-text-block

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov

codecov Bot commented Apr 26, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 72.85364% with 332 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.72%. Comparing base (643c3da) to head (15ec674).
⚠️ Report is 11 commits behind head on main.

Files with missing lines Patch % Lines
src/fetcher/hackernews/top.rs 70.52% 79 Missing ⚠️
src/fetcher/hackernews/user_submissions.rs 67.00% 66 Missing ⚠️
src/fetcher/hackernews/user_comments.rs 69.03% 61 Missing ⚠️
src/fetcher/hackernews/user.rs 79.43% 44 Missing ⚠️
src/fetcher/hackernews/client.rs 0.00% 24 Missing ⚠️
src/fetcher/github/recent_releases.rs 0.00% 19 Missing ⚠️
src/fetcher/github/items.rs 0.00% 12 Missing ⚠️
src/fetcher/github/notifications.rs 7.69% 12 Missing ⚠️
src/render/list_links.rs 96.05% 8 Missing ⚠️
src/fetcher/github/contributors_monthly.rs 0.00% 7 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #148      +/-   ##
==========================================
- Coverage   79.30%   78.72%   -0.58%     
==========================================
  Files          98      105       +7     
  Lines       18479    19775    +1296     
==========================================
+ Hits        14654    15568     +914     
- Misses       3825     4207     +382     
Files with missing lines Coverage Δ
src/fetcher/github/assigned_issues.rs 24.32% <ø> (ø)
src/fetcher/github/good_first_issues.rs 17.64% <ø> (ø)
src/fetcher/github/my_prs.rs 31.70% <ø> (-7.32%) ⬇️
src/fetcher/github/repo_issues.rs 34.21% <ø> (ø)
src/fetcher/github/repo_prs.rs 27.65% <ø> (-6.39%) ⬇️
src/fetcher/github/review_requests.rs 31.70% <ø> (-7.32%) ⬇️
src/fetcher/hackernews/mod.rs 100.00% <100.00%> (ø)
src/fetcher/mod.rs 82.60% <100.00%> (+0.17%) ⬆️
src/payload.rs 100.00% <100.00%> (ø)
src/render/mod.rs 89.92% <100.00%> (+0.42%) ⬆️
... and 11 more

... and 22 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

unhappychoice and others added 4 commits April 26, 2026 14:22
Spell out the family prefix to match `github_*` / `gitlab_*` / `clock_*` —
two-letter abbreviation was an outlier. No behaviour change; only the
fetcher name, struct, module path, and doc references move.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…client

Promotes `hackernews_top.rs` into `src/fetcher/hackernews/` so siblings
(`hackernews_user`, `hackernews_user_submissions`, `hackernews_user_comments`)
can share the HTTP client setup, base URL constants, and the OSC 8 / HN
user-page link helpers without each file open-coding `OnceLock<Client>` and
the Firebase host. Mirrors the layout used by the `github_*` family.

No behaviour change: only `hackernews_top` ships in this commit; the
sibling fetchers land in the next commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Three account-scoped fetchers powered by HN's `/user/{login}.json` and
`/item/{id}.json` Firebase endpoints (Safety::Safe, fixed host).

- `hackernews_user` — single-read profile rollup. Multi-shape:
  - `Text` (`@login · Npt karma`) for hero / subtitle bands.
  - `Entries` (login / karma / created / submissions count, plus `about`
    when present) for grid_table.
  - `TextBlock` for sidebar bio blocks.
  - `LinkedTextBlock` for a one-row clickable link to the HN user page.
- `hackernews_user_submissions` — fans out the `submitted` array, filters
  to story-shaped types (`story` / `show_hn` / `ask_hn` / `job`), and
  emits `LinkedTextBlock` rows linked to the article URL or HN comment
  page. `TextBlock` / `Entries` shapes also supported.
- `hackernews_user_comments` — same fan-out filtered to `type=comment`,
  rendering each comment as a tag-stripped, truncated snippet linked to
  its HN comment page.

The `submitted` walk caps at 80 candidates per call so a prolific account
with mostly-comments doesn't fan out hundreds of item requests just to
surface a handful of stories.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Adds the gaps the previous commits left thin:

- payload: round-trip + serialization-tag tests for `LinkedTextBlock`,
  plus the `url`-omitted-when-None case (mirrors the existing TextBlock /
  Entries / Timeline coverage).
- hackernews_top: empty `LinkedTextBlock` body, missing-id link drop,
  zero defaults for score / comments, every `kind` variant parses,
  and clamp semantics for `count`.
- hackernews_user: TextBlock branch with / without `about`, empty-string
  `about` is treated as missing, submission count uses `.len()` not the
  full array, minimal-payload deserialization, `decode_entities` over
  the full canonical set, and an invalid-timestamp `iso_date` fallback.
- hackernews_user_submissions: TextBlock + Entries branches, explicit
  story URL preferred over fallback, missing title placeholder, empty
  body, `UserStub` deserialization, and `deny_unknown_fields` enforced.
- hackernews_user_comments: TextBlock branch, missing text / id
  edge cases, nested-tag stripping, short-input truncate, empty body,
  unaccepted-shape fallthrough.
- list_links: multiple linked rows each get an independent OSC 8 wrap,
  mixed linked/unlinked rows only wrap the linked ones, area-height cap,
  and a CJK case that documents the wide-grapheme trailing-cell behavior.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
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.

1 participant