~ knotless Search/
↑↓ move↵ open⇧↵ all results

chadtmiller.com/hud

A remote MCP server that shows atproto records as interactive UI inside MCP Apps hosts

0
0

Markdown's <details> opens to what it hides under its summary

Merged
Merged chadtmiller.com asked to merge into main from chadtmiller.com/hud:markdown/details

A pull's body, a README or any markdown HUD draws now folds a <details> under its <summary>, as GitHub does, so this repository's own pull template reads as written: the opener, then "Claude Opus 5.5 · high" opening to the rest.

Claude Opus 5.5 · high

What changes

Server (hud_core::ui::document): an HTML block's <details>, <summary> and their ends, any case, make a new block, details { runs, blocks, expanded? }: runs its summary, blocks the markdown between, expanded from <details open>. A summary's HTML is read as text (tags left out, &amp;, &middot;, &#183; and the like read); markdown between <summary> and </summary> across blank lines keeps its formatting. One left open closes where what holds it ends (a quote, an item, a footnote, the text); a stray </details> is dropped. All other HTML stays text, as before.

Lexicon (place.hud.ui): details among a block's kinds, and expanded. It only grows.

Web (web/renderer): Blocks draws a native <details>/<summary> ("Details" where it has no summary), whether it is open kept with remembered so a tile drawn again shows it as left; MarkdownProse spaces it as the other blocks.

iOS (HUDKit): DetailsBlock, a turning chevron and the summary as one button showing or hiding its blocks, open or closed kept in view.memory.

Catalog: RichText's notes name <details> as the one HTML drawn.

Why

Pulls here open with a <details> by the template, and HUD drew its tags as text: <details> <summary>Claude Opus 5.5 · high</summary> on a line, then everything inside unfolded. Reading the tags on the server keeps the clients drawing the tree alone, as the rest of markdown's blocks.

How it was checked

just check passes (fmt, clippy, tests, svelte-check, lint, lex). A new test, details_hide_their_markdown_under_their_summary, holds the blocks to the lexicon: a summary with entities and tags, markdown inside, <DETAILS open> with a markdown summary and loose HTML, and one left open in a quote. The gallery (just gallery), its pull's body given a details block for the look, drew it closed with "▶ Claude Opus 5.5 · high" and, clicked, open to its bold text and list. HUDKit builds for the simulator.

Shortcomings

  • Not looked at on iOS: built, not run on a simulator.
  • No just look pictures in light and phone dark, nor an agent's critique.
  • A summary's inline HTML (<b>, <code>) is drawn as plain text, not formatted.
  • On iOS, two identical details blocks in one view share whether they are open (kept by the block's hash).
Approved

This pull reads markdown's <details>/<summary> HTML blocks on the server and turns them into a new details { runs, blocks, expanded? } block. The lexicon only gains fields, and the web and iOS renderers draw the new block in the same change, as AGENTS.md asks. Each platform keeps whether a details block is open the way it already does: remembered on the web, and view.memory keyed by the block's hash on iOS, as ResolvedRichBlocks does.

I followed the reader's stack handling and found it sound:

  • A details block left open closes when its quote, item, footnote or the document ends.
  • A </details> inside markdown nested in the details block (an item, say) never closes it.
  • Offsets in details_tag and html_text stay on char boundaries, because get(..) is used and <, ; and & are ASCII.
  • Text from the summary reaches the clients only as plain runs, so the change opens no HTML path.

The new test covers the main shapes, and every check passes: check, test, web, lexicons, e2e and e2e-spaces. The docs check was skipped because no docs changed. I read every changed file. I left one small comment, about blocks inside a summary being dropped. Nothing needs to change before this merges.

crates/hud-core/src/ui/document.rslines 505 to 516
Some(Open::Details {
in_summary: true,
summary,
..
}) => {
if let Some(Value::Array(runs)) = b.get("runs") {
if !summary.is_empty() {
summary.push(run(" ", None));
}
summary.extend(runs.iter().cloned());
}
}
review.knotless.dev

Inside a summary, a block with no runs (a list, a code block, a quote, a table between <summary> and </summary>) is dropped without a trace, along with everything in it. That's rare in practice, but if you want nothing lost, fall back to its text, or push it into blocks. Optional.

Merged as cc65baf