feat(story): unify story overlay with shared markdown pipeline (#222)#224
feat(story): unify story overlay with shared markdown pipeline (#222)#224forketyfork merged 4 commits intomainfrom
Conversation
Issue: The story overlay used a standalone parser (story_parser.zig) that duplicated markdown parsing logic, making it hard to maintain and extend with features like rich formatting and search. Solution: Migrate story overlay to the shared markdown_parser/renderer pipeline by extending both with story-specific constructs (story-diff blocks, code annotations, prose anchors). Anchors are now inline styled spans with pill backgrounds rather than separate graphical elements, which simplifies positioning and integrates naturally with word wrapping. Search highlights use per-run font measurement with fitTextureHeight scaling for accurate alignment across mixed font styles.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f8e855c348
ℹ️ 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".
There was a problem hiding this comment.
Pull request overview
This PR migrates the Story overlay off the bespoke story_parser.zig onto the shared markdown parse/render pipeline (used by Reader mode), adding story-specific markdown extensions (diff fences, metadata, and anchors) and modern overlay features like inline styling, search, and links.
Changes:
- Removed
src/ui/story_parser.zigand refactoredstory_overlay.zigto consumemarkdown_parser.parseStory()+markdown_renderer.buildLines(). - Extended
markdown_parser.zig/markdown_renderer.zigwith story-specific block/line kinds and anchor support viaanchor_number. - Updated bezier arrow rendering to use a filled triangle arrowhead and updated architecture docs.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
src/ui/story_parser.zig |
Deleted the old standalone story parser implementation. |
src/ui/components/story_overlay.zig |
Rebuilt story overlay around RenderLine runs; added link clicks + Cmd+F search + anchor pill rendering and arrow attachment updates. |
src/ui/components/markdown_renderer.zig |
Added story-specific line kinds and propagated anchor_number into render runs/lines. |
src/ui/components/markdown_parser.zig |
Added parseStory() mode, story-diff handling, code ref stripping, and prose anchor parsing into spans. |
src/gfx/primitives.zig |
Switched arrowhead rendering to a filled triangle with animated alpha. |
docs/ARCHITECTURE.md |
Documented the unified story content pipeline and updated module boundaries. |
CLAUDE.md |
Updated/retitled agent guidance content (now conflicting with existing AGENTS.md). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Issue: Review identified an off-by-one in diff-line highlight positioning, an unused layout_char_w_px field with its per-frame measurement call, and a stale LineAnchor reference in ARCHITECTURE.md. Solution: Fix byteOffsetToPixelX boundary condition so matches starting right after a diff marker get the correct post-marker x position. Remove the unused layout_char_w_px field and measureCharWidth function that were left over from an earlier approach. Drop LineAnchor from the docs API table since that type no longer exists.
Summary
Replaces the standalone
story_parser.zigwith the shared markdown parser/renderer pipeline, extended to handle story-specific constructs. This brings rich markdown formatting, proportional font rendering, and Cmd+F search to the story overlay while eliminating ~660 lines of duplicated parsing logic.Closes #222
Changes
The shared
markdown_parsernow handles story-diff fenced blocks (```story-diff), HTML comment metadata (<!--{JSON}-->), code annotations (<!--ref:N-->), and prose anchors (**[N]**). Anchors are represented as regularStyledSpan/RenderRunentries with ananchor_numberfield, so they flow naturally through word wrapping and font selection.The story overlay renders anchor runs as text with rounded pill backgrounds, connected by bezier arrows that attach at pill edges. The arrowhead is a filled triangle rendered via
SDL_RenderGeometrywith animated alpha matching the line shimmer.Search highlights now walk through each line's runs using the correct per-run font and apply
fitTextureHeightscaling, so highlight rectangles align accurately with the actual rendered text regardless of font style or size.Test plan