Skip to content

Comments

feat(story): unify story overlay with shared markdown pipeline (#222)#224

Merged
forketyfork merged 4 commits intomainfrom
222
Feb 19, 2026
Merged

feat(story): unify story overlay with shared markdown pipeline (#222)#224
forketyfork merged 4 commits intomainfrom
222

Conversation

@forketyfork
Copy link
Owner

@forketyfork forketyfork commented Feb 19, 2026

Summary

Replaces the standalone story_parser.zig with 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_parser now handles story-diff fenced blocks (```story-diff), HTML comment metadata (<!--{JSON}-->), code annotations (<!--ref:N-->), and prose anchors (**[N]**). Anchors are represented as regular StyledSpan/RenderRun entries with an anchor_number field, 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_RenderGeometry with animated alpha matching the line shimmer.

Search highlights now walk through each line's runs using the correct per-run font and apply fitTextureHeight scaling, so highlight rectangles align accurately with the actual rendered text regardless of font style or size.

Test plan

  • Open a story with code annotations and verify anchor pills appear inline with proper spacing (no overlap with adjacent text)
  • Verify bezier arrows connect vertically at pill top/bottom edges between matching code and prose anchors
  • Use Cmd+F search within a story and confirm highlight backgrounds align with the matched text across headings, bold/italic text, code blocks, and regular prose
  • Scroll through a story with diff blocks and verify +/- markers, syntax coloring, and diff headers render correctly

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

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 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.zig and refactored story_overlay.zig to consume markdown_parser.parseStory() + markdown_renderer.buildLines().
  • Extended markdown_parser.zig / markdown_renderer.zig with story-specific block/line kinds and anchor support via anchor_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.
@forketyfork forketyfork merged commit 30de3ba into main Feb 19, 2026
4 checks passed
@forketyfork forketyfork deleted the 222 branch February 19, 2026 15:12
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]: Unify Story overlay with shared markdown parser/renderer

1 participant