Skip to content

Comments

add markdown reader with links and prompt separators#219

Merged
forketyfork merged 3 commits intomainfrom
feat/reader-mode-enhancements
Feb 17, 2026
Merged

add markdown reader with links and prompt separators#219
forketyfork merged 3 commits intomainfrom
feat/reader-mode-enhancements

Conversation

@forketyfork
Copy link
Owner

@forketyfork forketyfork commented Feb 17, 2026

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

  • New reader overlay component with centered reading column, open/close animation, bottom pinning, and jump-to-bottom behavior.
  • New terminal history extraction path from session scrollback/viewport (app/terminal_history.zig) with ANSI cleanup before markdown parsing.
  • New markdown parsing and line-layout pipeline:
    • Block and inline markdown support for headings, lists, code fences, blockquotes, horizontal rules, links, strikethrough, and task checkboxes.
    • Table parsing/rendering with structured cell drawing, line-based borders, gradient row backgrounds, wrapped cell content, and dynamic row heights.
  • Reader search UX:
    • Incremental search (⌘F), next/prev navigation (Enter / Shift+Enter), result counter, and line highlights.
    • Esc closes search first; closes reader only when search is not active.
  • Prompt boundary rendering:
    • Detect prompt separators using OSC 133 markers with heuristic fallback.
    • Render left-to-right gradient separator lines before prompts.
  • Interaction polish:
    • Clickable links with hover styling and pointer cursor.
    • Shared scrollbar component behavior reused for reader overlay.
    • Reader mode toggle works for the currently selected terminal in grid mode.
    • Emoji sizing normalized in markdown overlays.

Integration and docs

  • Runtime/UI wiring for UiAction.ToggleReaderOverlay, help overlay shortcut entry, and key handling.
  • Documentation updates in README.md and docs/ARCHITECTURE.md to describe reader mode architecture and behavior.

Validation

  • zig build
  • zig build test
  • just lint

Notes

  • Image rendering in markdown is not included in this PR.

Issue Linkage

Closes #217

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.
@forketyfork forketyfork requested a review from Copilot February 17, 2026 14:47
@forketyfork forketyfork marked this pull request as ready for review February 17, 2026 14:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 ReaderOverlayComponent with 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.zig with shared fitTextureHeight helper 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.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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.
@forketyfork forketyfork merged commit 7a74936 into main Feb 17, 2026
4 checks passed
@forketyfork forketyfork deleted the feat/reader-mode-enhancements branch February 17, 2026 16:08
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.

[Feature]: Reader mode — scrollable, searchable markdown overlay for terminal history

1 participant