Skip to Content
InternalsLayout and Rendering

Layout and Rendering

Ansiq rendering is not one step. The current pipeline is:

render retained tree -> rerender dirty subtrees -> partial relayout -> invalidated regions -> redraw framebuffer -> diff -> terminal patch emission
The Ansiq rendering pipeline
1reactive flush / input / messages
2dirty scope collection
3subtree rerender or full rerender
4partial relayout
5invalidated regions
6redraw framebuffer
7framebuffer diff
8terminal patch emission

Continue the NotesApp

Assume NotesApp now has:

  • a List on the left
  • an input area on the right
  • a footer

In other words, the same version of the app that now has multiple interactive regions.

When you type one extra character, the desired behavior is not:

  • rebuild the whole app
  • recompute the whole layout
  • redraw the whole terminal surface

It should be much closer to:

input signal changed -> dirty component scope -> rerender only the composer subtree -> relayout only affected ancestors if geometry changed -> redraw only invalidated regions -> emit the minimal terminal patch
The ideal path for a small input change
1input signal changed
2dirty scope
3subtree rerender
4ancestor relayout if needed
5region redraw
6minimal patch

Partial relayout

After subtree replacement, the nodes that may need layout work are usually:

  • the replaced subtree
  • its ancestor chain
  • siblings affected by geometry shifts

That is very different from treating all layout work as global.

This is also why the previous pages kept separating local signals from app-level state.
Cleaner state boundaries make cleaner dirty-scope and relayout boundaries possible.

Damage model

Layout changes and redraw changes are related but not identical.

Ansiq also needs to answer:

  • which regions are actually invalidated
  • which regions need redraw
  • which regions can remain untouched

Framebuffer diff

Even after redraw, the runtime still computes framebuffer diffs before terminal patch emission.

So the goal is local work all the way down:

  • local rerender
  • local relayout
  • local redraw
  • minimal patch emission

If you read this page together with the streaming page, Ansiq’s position becomes clearer:

  • async work brings messages back
  • the app turns messages into state
  • the runtime turns state changes into the smallest practical terminal update

Next

Continue with Viewport and History.
The same app will now be pushed toward transcript and shell-like behavior so the surface layer becomes easier to understand.

Last updated on