Skip to content

hackernews-TUI

Batch 8 (readers / browsers / hierarchical-navigation TUIs).

hackernews-TUI is a Rust terminal client for Hacker News built on the Cursive TUI library. It organizes browsing as a stack of specialized views: a Story View (paginated, sortable story list), an Article View (renders the linked article’s text with numbered, openable links), a Comment View (hierarchical, collapsible comment tree), and a Search View (dual-mode: an input mode and a result-navigation mode). Story categories — front page, all, Ask HN, Show HN, jobs — map to F1F5. Every view is reachable by drilling into an item and dismissable by backing out to the parent view (backspace / C-p = previous view). Keybindings are fully customizable through a TOML config (hn-tui.toml); ? shows a per-view help sheet.

The single most transferable idea here is the view stack with consistent back-navigation — exactly the shape KN-86’s nOSh runtime and cart surfaces need for drilling through nested content under the drill-into / BACK model.

  • Hierarchical drill-in / back-out as the core navigation grammar. Story → Comments, Story → Article, Search → Result: every transition pushes a view; backspace/C-p pops it. This is precisely the KN-86 drill-into (ADR-0005 FFI) + BACK key (CDR/BACK on the LEFT-half home row per Canonical Hardware Specification) interaction. hackernews-TUI is a clean reference implementation of a nav stack with a single universal “back” affordance — which the emulator already models (test_nav_stack). Carts that present nested lists (mission board → mission detail → phase detail) should follow this push/pop discipline so BACK always means “up one level,” never an ambiguous escape.
  • Collapsible tree rendering on a text grid. The Comment View shows a nested reply tree with tab to collapse/expand the focused node, l/h to move down/up the nesting level, and n/p to jump between top-level comments. A collapsible-tree widget rendered purely in monochrome glyphs is directly reusable for any KN-86 surface that needs hierarchy: a mission’s phase chain, a cart’s data namespace, a Lisp s-expression browser (see LISP angle below).
  • Link-numbering + link-overlay dialog. The Article View numbers every link inline; pressing a digit prefix then o ({link_id} o) opens that numbered link, and l raises a link dialog listing all links for selection. On a keyboard-only, no-mouse device this is the canonical pattern for “select one of N on-screen targets without a pointer” — applicable to KN-86 menu selection, citation jumps in reader content, and the bare-deck LINK tab.
  • Reader mode (planned). The roadmap calls for rendering the linked story “in reader mode on the terminal” — plain-text article rendering in-app rather than shelling to a browser. KN-86 has no browser to shell to, so an in-runtime reader-mode pager (clean text, numbered links, scroll) is the only option for any long-form content surface — and this is the reference IA.
  • TOML-config keybindings + per-view help. All commands are remappable via TOML, and ? surfaces context-sensitive help. KN-86’s input layer is already config-driven (QMK keymaps; nosh-config.toml); the per-view, context-sensitive help sheet is the lift — it pairs naturally with the context-polymorphic TERM/Lisp keys (ADR-0016) where the same physical key does different things per surface.

Cursive is color-themable but degrades cleanly to monochrome — hackernews-TUI runs fine on a single-color terminal, which is the proof KN-86 needs. The adaptations for amber-on-black:

  • Tree depth via indentation + box-drawing, not color. Render the comment/phase tree with CP437 box-drawing connectors (│ ├ └ ─) for nesting lines rather than relying on color-per-depth. Depth reads from horizontal position.
  • Focus via inversion. The focused list row / tree node is shown inverted (amber-on-black → black-on-amber) — the same single-color focus convention KN-86 already uses. No second color needed.
  • Collapsed-state glyph. A collapsed node carries a leading and an expanded one (or [+]/[-]) so collapse state is a character, not a hue.
  • Link numbering is inherently monochrome. Numbered [1][N] markers beside links carry zero color dependency; the digit is the affordance. This is a model single-color pattern — lift it wholesale for KN-86 link/target selection.
  • Unread / new via a leading mark. Where HN would tint, KN-86 uses a leading * or glyph column (see newsboat for the unread-badge treatment).
  • Cursive earns a spot on the TUI-library shortlist alongside OpenTUI — it’s a mature, themeable, view-stack-oriented Rust TUI toolkit. KN-86’s runtime is C/SDL3 (not Rust), so Cursive is a pattern reference, not a dependency: its view-stack + focus-inversion + remappable-keymap model is what we study.
  • Cross-link newsboat — the sibling feed-reader entry in this batch; both implement the same 3-level reader hierarchy (list → item → reader) with back-navigation and unread marks. newsboat is the RSS framing, hackernews-TUI the HN framing.
  • Cross-link bookokrat — for TOC-tree navigation and reader/zen mode; the comment-tree widget here and the TOC tree there are the same collapsible-hierarchy primitive.
  • LISP angle. The collapsible nested-tree widget is, structurally, an s-expression browser. A KN-86 nEmacs/REPL surface (ADR-0008/ADR-0016) that lets the operator drill into a Lisp list — CAR to enter, BACK/CDR to step, tab to collapse a sub-form — is the same widget hackernews-TUI ships for comment threads. The Fe VM (fe.md) gives us the cons-cell substrate; this entry gives us the navigation IA.