Skip to content

Function: renderCodeSelection()

renderCodeSelection(item, cwd?): string

Defined in: aiui-lowering-pipeline/src/render.ts:286

One contributed code selection, rendered at its position in the prose, in the shot format's design language (2026-07-17 render audit): a plain-text bracket line carries the content, XML carries derived metadata. The location stays IN the bracket — a code selection is a range of a file — and MISSING_LOCATION marks one that arrived without a locator:

[code selection at src/a.ts:5:1: const x = 1;]

A long selection (> SHORT_SELECTION_CHARS chars) turns the bracket line into a header and fences the code, elided past MAX_SELECTION_LINES lines. The only metadata block a code selection carries is the contributing view's <tab> record, when known.

Exported so any re-attacher shares THIS exact rendering — one implementation, per the defer-rendering rule (the channel's composer-era realtime resolver, which re-attached a selection the live model referenced by bare id like code_1, was the original consumer). The parameter is the ComposedItem subset the rendering reads.

Parameters

item

Pick<ComposedItem, "text" | "sourceLoc" | "lines" | "url" | "tab">

cwd?

string

Returns

string