hn.today

Building a thread UI on hard mode – Zed

delta.dev8 points0 comments
Screenshot of Building a thread UI on hard mode – Zed

Delta’s thread interface treats a conversation as a shared document rather than a sequence of chat bubbles. Users can write prompts in place, annotate agent responses and tool output, and trace code changes back to the discussion that produced them. A conventional text-editor architecture proved unreliable because thread elements - streaming terminals, changing tool statuses, and foldable cards - alter the display without changing the underlying text. The team therefore rebuilt the editor around minimal state: a collaborative text buffer, selection and focus, and a formatter that decides how different ranges should appear. Formatters can style, hide, or replace text, keeping presentation rules separate from the editor and allowing it to serve other surfaces too.

The hardest problem is maintaining accurate scrolling through long, variable-height threads. The editor stores measured and unmeasured row heights in a B+ tree, grouping rows with shared heights and representing folded output as zero-height runs. It measures visible content during rendering, estimates the rest, then uses idle time to sweep through the document in small slices and refine those estimates. Changes invalidate affected ranges; while measurements catch up, only scrollbar positioning may be slightly stale. Threads themselves combine replicated CRDT data for the text, messages, and comments. Buffer anchors mark each segment’s boundaries, letting the formatter render user messages, assistant turns, thinking, and tool calls appropriately, with custom formatters available for individual tools.

Read on delta.dev0 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

Ggml v1.0.0

Ggml v1.0.0

ggml 1.0.0 removes deprecated public APIs and legacy DIAG_MASK operations, while adding configurable YaRN truncation and FP8 support. It also improves backend performance with quantized matrix multiplication, fused MoE operations, and new attention and scheduling paths. (github.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.