PARAS MADAN
All writing

Latest in AI

How to update Pi extensions for read-only render output

Pi 1.6.0 can reuse rendered line arrays. Update extensions that decorate container or child output, then check repeated frames and terminal resizing.

A footer you append to a terminal panel can show up twice if you accidentally append it to a cached array. The next time the panel renders, the first footer is still there.

Pi 1.6.0, released November 20, makes that ownership boundary explicit. A component's render(width) returns readonly string[]. A Container can return the same array again when its width and child output are unchanged. If your extension modifies another component's result in place, update that code before upgrading.

Find code that changes another component's lines

Start with custom panels, widgets and tool renderers. Search for calls to super.render(width) or child.render(width) and follow where the result goes. Look beyond the next line: an array passed to a helper that formats a header may still get mutated there.

Watch for push, unshift, splice, indexed assignment and in-place sorting. Removing a cast can reveal a compiler error that was already being hidden. Do not replace the new type with a mutable assertion just to make the build pass. TypeScript's read-only annotation is a contract, not a runtime freeze.

Copy only when you need to decorate

The tagged TUI implementation documents that callers must not change returned lines. A component that simply passes through an embedded renderer's output can return it directly. When you need to change those lines, create an array you own.

For example, the body of a container subclass's render method can be:

const lines = [...super.render(width)];
lines.unshift("Status");
return lines;

Use a new array for a header, footer or modified line. For line-by-line transformations, returning the result of map() also leaves the original array untouched. Avoid copying every component's output just to pass it through; copy where ownership is necessary.

Check the second frame, not only the first

Write a small test that gives your decorator the same child output twice. Each call should return one header, and the child's original lines should still be unchanged. A standalone array test can confirm that ownership rule without launching Pi or calling a model.

Then check the real extension in a disposable Pi session. Resize to a narrow terminal, change the widget contents and let the panel render again without changing anything. Look for duplicate lines, stale text and width errors. Use a fixed prompt or a deterministic display fixture so differences in model output do not obscure the rendering issue.

Invalidate your own cache when inputs change

If your extension caches formatted rows, include width and the relevant content in its cache key. The Pi TUI guide recommends clearing expensive render caches in invalidate() and requesting a redraw after a component state change. Copying a returned array does not by itself refresh a stale cache.

The release links to a report about slow rendering on long transcripts. That report gives context for the work, not a guarantee that every resize is faster on every terminal. If performance matters to your extension, compare the same transcript, terminal and settings before and after. Keep that check separate from whether the display is correct.

Write the upgrade note your users need

I'm Paras. I work at the intersection of AI, engineering and distribution.

I help developer tool teams turn compatibility changes into technical writing and product stories builders can use.

Book a 30-minute call.