add markdown reader with links and prompt separators#219
Conversation
Issue: Reader mode needed to handle real terminal markdown output better: task checkboxes, links, shared scrollbar behavior, prompt separators, and correct sizing/wrapping in both full and grid workflows. Solution: Added a terminal-history extraction pipeline and new markdown parser/renderer modules, then integrated a dedicated reader overlay with search, clickable links, and shared scrollbar interactions. Implemented OSC 133 prompt marker support with heuristic fallback and render-time gradient separators before prompts. Enabled reader mode from grid for the selected terminal, improved text wrapping, and clamped oversized glyph textures so emoji markers render within line height across markdown overlays.
There was a problem hiding this comment.
Pull request overview
This PR adds a comprehensive reader mode feature to the terminal, enabling users to view terminal history as formatted markdown in a centered, scrollable overlay. The implementation includes a complete markdown parser, renderer, and fullscreen overlay component with live updates, search functionality, and clickable links.
Changes:
- Adds markdown parsing and rendering pipeline (
markdown_parser.zig,markdown_renderer.zig) supporting headings, lists, tables, blockquotes, code blocks, inline formatting (bold/italic/strikethrough/links), and prompt separators - Implements
ReaderOverlayComponentwith live terminal history updates, centered reading layout, search (Cmd+F), scrollbar integration, and link handling - Adds terminal text extraction module (
terminal_history.zig) with ANSI escape stripping and OSC 133 prompt marker detection - Updates
story_overlay.zigwith sharedfitTextureHeighthelper to normalize emoji/text rendering across overlays - Integrates reader mode toggle (Cmd+R) into runtime, help overlay, and keybinding system
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/app/terminal_history.zig |
New module for extracting and sanitizing terminal scrollback+viewport text with ANSI stripping and OSC 133 prompt marker conversion |
src/ui/components/markdown_parser.zig |
New markdown parser supporting headings, lists (including task checkboxes), tables, blockquotes, code blocks, inline styles, and prompt separators with heuristic detection |
src/ui/components/markdown_renderer.zig |
Line layout engine that wraps parsed markdown blocks into renderable lines with proper text flow and style preservation |
src/ui/components/reader_overlay.zig |
Main reader overlay component with live updates, search, scrollbar, link handling, table rendering, and prompt separator gradients |
src/ui/components/story_overlay.zig |
Added fitTextureHeight helper and DrawSize struct to constrain emoji/text rendering within line heights |
src/ui/types.zig |
Added ToggleReaderOverlay action to UI action enum |
src/ui/mod.zig |
Exported reader_overlay module |
src/app/runtime.zig |
Registered reader overlay component and added toggle handler with toast messages |
src/c.zig |
Added SDLK_F and SDLK_R key constants |
src/ui/components/help_overlay.zig |
Added Cmd+R shortcut documentation |
docs/ARCHITECTURE.md |
Documented reader mode content path, new modules, and updated component count to 16+ |
README.md |
Added reader mode feature description with detailed capabilities |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11722d1987
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Issue: Unresolved PR review comments identified a parser/renderer table column limit mismatch, per-line character-width measurement in the hot render path, and an unsafe temporary buffer lifetime for the search counter. Solution: Export and reuse a single max table column limit between parser and reader rendering to keep behavior consistent. Reuse cached layout character width during line rendering instead of measuring per visible line, avoiding repeated texture churn. Keep the search counter buffer alive for the full renderSearchBar function scope before creating the text texture.
Issue: Reader mode tables rendered cell text as plain strings, so markdown styles like bold, italic, and inline code were lost in table content. Solution: Parse table cells into styled runs during markdown layout and render wrapped runs per cell with style-aware font/color handling. Reused the existing inline parser, added safe span cleanup APIs, and preserved table link hit testing in wrapped cells. Updated docs and added a renderer test covering inline styles inside table cells.
Summary
This PR introduces Reader Mode (⌘R) for terminal history and closes issue #217. It adds a dedicated, live-updating markdown reading overlay for the selected terminal (full view and grid selection), so long agent output is readable, searchable, and easier to navigate.
What’s included
app/terminal_history.zig) with ANSI cleanup before markdown parsing.⌘F), next/prev navigation (Enter/Shift+Enter), result counter, and line highlights.Esccloses search first; closes reader only when search is not active.Integration and docs
UiAction.ToggleReaderOverlay, help overlay shortcut entry, and key handling.README.mdanddocs/ARCHITECTURE.mdto describe reader mode architecture and behavior.Validation
zig buildzig build testjust lintNotes
Issue Linkage
Closes #217