# The review window

Everything a person can do in the window `lamino review` opens.

`lamino review <comp>` is a separate process for looking at a comp and checking it.
The window does not change the comp.
The window's state lives only in memory and is not saved.
An agent reads that state with `lamino viewer`.

## Starting and options

Open it with `lamino review [OPTIONS] <COMP_FILE>`.
The options common to every command (`--json`, `--project` and so on) are left out here.
When the window ends with an error, the exit code is 1.
A GPU device loss that recovered stays in `lastError`, but the exit code is 0.

| Flag | Meaning |
|---|---|
| `<COMP_FILE>` | The comp file to show |
| `--node <NODE>` | The node to show (default: the comp's output). A node that does not exist stops the start with `E_NODE_NOT_FOUND` |
| `--frame <FRAME>` | The first frame to show (default: the comp's first frame) |
| `--display <DISPLAY>` | The display to use first (default: the colour config's default) |
| `--view <VIEW>` | The view to use first (default: the colour config's default) |
| `--backend <auto\|cpu\|gpu\|gpu-software>` | The evaluation backend. The order of precedence is this flag, then `eval.backend` in `lamino.jsonc`, then `auto`. When `LAMINO_GPU` is not set, `lamino review` tries the hardware GPU first |
| `--proxy <1\|2\|4\|8>` | The proxy factor for evaluation (`1` is full resolution). When left out, a default follows from the comp's resolution |
| `--scopes` | Start with the scopes panel open (toggle with `S`) |
| `--ab <TARGET>` | The A/B comparison target at start: `git:<rev>`, an alias image path, another node ID, or `no-overrides` (the comp without the session overrides). A value that cannot be parsed stops the start |
| `--audio <ALIAS>` | Reference audio (an alias path; WAV, AAC-LC, MP3). It only plays in sync; it is neither mixed nor written out |
| `--audio-offset <FRAMES>` | Play sample 0 of the audio at comp frame `first frame + offset`. Default `0`; negative values are allowed |
| `--ndi [<NAME>]` | Also send the picture as an NDI source. Without a name, the default name is used. Write it after the comp file, or as `--ndi=NAME` |

The window title is `lamino review — <relative comp path>`.
The initial size is 1280 × 800 and the minimum size is 480 × 320.
At start, the channel is `RGB`, exposure is `0`, gamma is `1`, the view is fitted and loop is on.
The nodes panel is closed.

## Layout

| Area | What it shows |
|---|---|
| Top bar, row 1 | The `nodes` button, the `controls` button (only when there are controls; `controls · N overridden` while overridden), the node selector, the channel buttons `RGB` `R` `G` `B` `A` `Luma`, the display selector, the view selector, the `exposure` field, the `gamma` field, the proxy selector (`proxy 1/N`), `fit`, `1:1` |
| Top bar, row 2 | The `A/B` input field, `set`, `off` (only while A/B is on), the modes `toggle` `wipe` `side by side`, the `wipe` field (only in wipe mode), the A/B status, `loop`, `changes / lint`, `scopes` |
| Left panel (`nodes`) | The node tree. Solo and mute buttons |
| Right panel (`changes / lint`) | Changes since the previous git revision, and diagnostics. Read-only |
| Right panel (`controls`) | The controls the agent offered |
| Right panel (`scopes`) | Waveform, parade, vectorscope, histogram |
| Viewport | The frame on screen. With A/B, A and B |
| Bottom bar, row 1 | The seek bar (timeline) |
| Bottom bar, row 2 | Transport (`Play` / `Pause`, `\|<`, `<`, `>`, `>\|`, `loop`), the frame number field, range and fps, the cache line, pre-render progress, where the frame on screen came from, the warning count, audio information, the `NDI` button |
| Bottom bar, row 3 | Status figures, then an error (red) or the status text |
| Bottom bar, row 4 | The pixel value under the cursor |

The bottom bar always has 4 rows; its height does not change when the cursor enters the image or an error appears.
The left panel reaches the bottom edge of the window, and the bottom bar sits to its right.
The right panels sit above the bottom bar, in the order `changes / lint`, `controls`, `scopes` from the outside (the right edge).
While there is no frame yet, the status text appears in the centre of the viewport.

## Keyboard shortcuts

The window-wide shortcuts are these 19.

| Key | Action |
|---|---|
| `Space` | Play and pause |
| `ArrowLeft` | Pause and go back 1 frame (wraps to the other end at the end of the range) |
| `ArrowRight` | Pause and go forward 1 frame (wraps to the other end at the end of the range) |
| `Home` | Go to the first frame of the range |
| `End` | Go to the last frame of the range |
| `F` | Return to the fitted view and set the pan to 0 |
| `R` | Channel R. Pressing it again while on R gives RGB |
| `G` | Channel G. Returns to RGB the same way |
| `B` | Channel B. Returns to RGB the same way |
| `A` | Channel A (alpha). Returns to RGB the same way |
| `L` | Channel Luma. Returns to RGB the same way |
| `C` | Channel RGB |
| `Tab` | A/B flip. In toggle it shows the other of A and B; in wipe and side by side it swaps left and right. Does nothing without a comparison target |
| `W` | Cycle the A/B mode through toggle, wipe and side by side. Changing the mode undoes the flip |
| `O` | Loop on and off |
| `N` | Open and close the nodes panel |
| `I` | Open and close the `changes / lint` panel |
| `K` | Open and close the `controls` panel (the panel is drawn only when there are controls) |
| `S` | Open and close the `scopes` panel |

They stop working in these cases.

- While a text field has the keyboard focus (the `A/B` field, a number field being typed into), none of the 19 work.
- While an input widget (number field, knob, two-value button, swatch) is being dragged, and for 0.25 seconds after, none of the 19 work. This is because the widget being dragged reads `Q`, `X`, `Y`, `A`, `R`, `H`, `S`, `V`, `G`, `B` and `F` itself.
- `Tab` is accepted only without modifier keys. `Tab` is never passed to input widgets; when the conditions above disable it, it is discarded.
- The 18 keys other than `Tab` do not distinguish modifier keys.

The `S` and `M` in the nodes panel are button names, not keys.
The key `S` opens and closes the scopes, and no key is assigned to `M`.

### Keys in text fields

| Where | Key | Action |
|---|---|---|
| `A/B` field | `Enter` | Apply the comparison target typed in (same as the `set` button) |
| Number field, typing | `Enter`, or a click outside the field | Commit the input |
| Number field, typing | `Escape` | Return to the value when typing started |
| Number field, typing | `ArrowUp` / `ArrowDown` | Up or down 1 unit |
| Number field, typing | `Shift` + `ArrowUp` / `ArrowDown` | Up or down 10 units |
| Number field, typing | `Alt` + `ArrowUp` / `ArrowDown` | Up or down 0.1 unit. In a field with a step, 1 step |

The unit is the step in a field with a step, and otherwise a round number close to 1/100 of the range.

### Keys held while dragging

Number field (scrubbing):

| Key | Action |
|---|---|
| `Alt` | 1/10 of the speed |
| `Shift` or `Q` | Snap to round values (increments of about 1/10 of the range) |

Angle knob:

| Key | Action |
|---|---|
| `Shift` or `Q` | Snap to 45-degree increments |
| `A` | Absolute mode whatever the press position (takes the pointer's angle as it is) |
| `R` | Relative mode whatever the press position (turns from the current angle) |

Two-value button:

| Key | Action |
|---|---|
| `Shift` | 5 times the speed |
| `Alt` | 1/10 of the speed |
| `X` | Move horizontally only |
| `Y` | Move vertically only |

Colour swatch:

| Key | Action |
|---|---|
| None | Saturation horizontally, value vertically |
| `Shift`, `H`, `F` | Hue only |
| `S` | Saturation only |
| `V` | Value only |
| `R` / `G` / `B` | That component only |
| `Alt`, `A` | Alpha only |

While a swatch is being dragged, the mouse wheel turns the hue.

## Mouse

Viewport:

| Action | Effect |
|---|---|
| Drag | Pan. Fit is turned off |
| Wheel | Zoom about the cursor position. The zoom ranges from 0.01× to 64×. Fit is turned off |
| `Ctrl` + wheel, pinch | Zoom, as with the wheel |
| `Shift` + drag (wipe mode) | Move the wipe line. No pan happens then |
| Hover | Show the pixel value under the cursor in row 4 of the bottom bar |

The viewport has no click, double-click or right-click actions.
Dragging in the fitted view switches the zoom to the last zoom set (1 right after start).
Wheel zoom starts from the fitted zoom.

Seek bar:

| Action | Effect |
|---|---|
| Click, drag | Pause and go to that frame |
| Hover | Show a vertical line and the tooltip `frame N (cached)` or `frame N (not cached)` |

The seek bar draws frame ticks and numbers, the frames cached for A (green band), the frames cached for B (blue band, only while A/B is on), the frame being evaluated (amber), and the playhead (red line and number).

The frame number field in the bottom bar (`frame N`) is a numeric drag field; moving it pauses and goes to that frame.

The mouse actions of number fields, labels and control widgets are described in the "Controls" section.

## Display settings

### Channel

Shows one of `RGB`, `R`, `G`, `B`, `A`, `Luma`.
A top bar button selects that channel; a key returns to `RGB` when the same key is pressed again.
`Luma` is computed from the scene-linear RGB with the AP1 weights.
The processing order is: black outside the data window, the exposure gain on the premultiplied RGB, channel selection, the colour config's display transform, a clamp to 0..1 (non-finite values become 0), then the display gamma.
The alpha of the display texture is 1, and the frame is drawn opaque.

### display and view

The two selectors in the top bar choose the display and the view of the colour config.
When the display changes and the current view is not in that display, the view becomes that display's first view.
When the colour config is reloaded and the current pair no longer exists, the view becomes the first view of the same display, or, failing that, the new config's default pair.

### exposure and gamma

`exposure` runs from -8 to 8 in steps of 0.25, default 0 (the unit is stops).
`gamma` runs from 0.25 to 4 in steps of 0.05, default 1.
Both are for viewing only and enter neither the comp nor a render.
Changing them redraws the frame on screen without evaluating it again.
The other cached frames are discarded and are fetched again once the setting has stayed still for 0.3 seconds.

### Zoom and 1:1

`fit` returns to the view that fits the viewport and sets the pan to 0 (the key is `F`).
`1:1` sets the zoom to 1 and the pan to 0.
Zoom 1 maps 1 pixel of the evaluated picture (the proxy picture) to 1 screen pixel; it is not 1:1 at full resolution.

### Proxy display

The top bar selector shows the current proxy (`proxy 1/N`).
Choosing from `1/1`, `1/2`, `1/4`, `1/8` pauses, discards the whole cache and evaluates again.
A frame that is heavy to evaluate (the previous evaluation took 150 ms or more, or it has not been measured yet) first shows a preview at a proxy 4 times coarser (at most 1/8).
During the preview, `proxy 1/N preview` appears at the top left of the viewport.

### Guides

There is no display of guides (safe areas and so on).

### A/B

Write a comparison target in the `A/B` field on row 2 of the top bar and apply it with `Enter` or `set`.
Applying an empty field, or pressing `off`, turns A/B off.
These 4 comparison targets are accepted.

| Form | What appears as B |
|---|---|
| `git:<rev>` | The comp file at that revision, the same node, no overrides |
| A path starting with `$` | An alias image path. Its frame is read |
| A node ID of this comp | Another node |
| `no-overrides` | The current comp file, the same node, without the session overrides |

Anything else is refused with `E_INVALID_ARGUMENT`, and the status shows `A/B: ...`.
`git:` alone without a revision is also refused.
A new comparison target starts on the A side.

There are 3 modes, and no difference mode.

| Mode | Display |
|---|---|
| `toggle` | Shows one of the two. `Tab` flips them |
| `wipe` | A left of the line, B right of it. Move the line with the `wipe` field (0 to 1, default 0.5) or `Shift` + drag. `Tab` swaps left and right |
| `side by side` | Splits the viewport into left and right, places A and B side by side, and writes `A` and `B` at the top left. `Tab` swaps left and right |

The A/B status takes these forms.

- toggle: `showing A (Tab: <target>)`, `showing B (<target>)`
- wipe: `wipe A|B 50% (B = <target>)`
- side by side: `A | B (B = <target>)`

B evaluates only the frame on screen and is not pre-rendered.
Where B is not there yet, `B: evaluating…` (in wipe, also `A: evaluating…`) appears with a frame.
A failure of B is not retried on that frame, and it does not stop A's evaluation or pre-rendering.

## Node list, solo and mute

The `nodes` button or `N` opens a panel on the left.
Below its heading, `output at the top, inputs below · S solo · M mute (session only)` appears.

- The first row is the comp's output, and below each node its inputs are listed.
- One of the inputs continues in the same column (the trunk). The trunk of a merge is B (the background), and A becomes a branch indented one level. For other nodes the trunk is the first input.
- The first row of a branch shows the port name in small type.
- A node used by several inputs is listed in one place only; the other places become a `→ id` reference row. Clicking a reference row moves the list to that node's row. The picture does not change.
- A node used by two or more inputs gets `×n`.
- The ID namespace (`<instance>/`) appears faintly before the name.
- Nodes not connected to the output are listed under the heading `not connected to the output`.
- A row with branches has a collapse marker; clicking it collapses the branches. The trunk does not collapse.
- When the node on screen is inside a collapsed part, the list opens down to it and scrolls there.
- Clicking a node name shows that node. The row also shows the node's type name.

Each row starts with the buttons `S` and `M`.

| Button | Action |
|---|---|
| `S` | Solo. Shows that node. Pressing it again on the same node clears the solo and returns to the node shown before the solo |
| `M` | Mute. Passes the input through unchanged. Pressing it again undoes it |

The `M` of a source (a node that cannot be bypassed) cannot be pressed; hovering it shows `a source cannot be muted`.
Solo and mute are session-only settings; pressing them pauses, discards the cache and evaluates again.
The status shows `solo <id>`, `solo cleared, showing <id>`, `muted <id>` or `unmuted <id>`.
The node selector in the top bar also changes the node shown.

## Pixel readout and status lines

### Bottom bar, row 4 (the value at the cursor)

When the cursor is over the image, it shows this form.

`px X,Y  wu X,Y  linear R G B A  display R G B  [source]`

| Item | Meaning |
|---|---|
| `px` | Pixel coordinates. For a proxy picture, the pixels of that picture; for a full-resolution ROI, full-resolution pixels |
| `wu` | Coordinates in width units. Both x and y are divided by the image width |
| `linear` | The 4 scene-linear components. Read from the float image in memory, not from the 8-bit display values |
| `display` | The 3 components of the 8-bit display texture (0 to 255) |
| Source | Which picture the values were read from |

Outside the image it shows `px –  wu –  linear –  display –`.
Values are read only while paused.
During playback it shows `linear –` and `display –`, and `, values when paused` is added to the source.
While waiting for the values to arrive, `, reading` is added to the source.

The source is written as follows.

- `A proxy 1/N`, `B proxy 1/N`: read from the proxy picture
- `A full-res`, `B full-res`: read from a picture evaluated at full resolution
- `A full-res ROI`: read from the full-resolution ROI used when zoomed in
- `A full-res ROI, reading`: reading the display values of the ROI
- `A full-res pending`: waiting for the ROI to be evaluated

When a picture evaluated at a proxy is zoomed in beyond 1:1, on the A side only, the 32 × 32 pixels around the cursor are evaluated again at full resolution and read from there.
While the cursor stays inside that area, the same ROI is reused.
In wipe, A or B is chosen by which side of the line the cursor is on.

### Bottom bar, row 3 (status figures and text)

From the left: the figures, a separator, then an error or the status text.
The figures take this form.

`eval X ms (mean Y ms, Z fps)  play N fps  |  engine ... VRAM ...  |  window ... VRAM N MB  |  node <id>`

| Part | Meaning |
|---|---|
| `eval X ms (mean Y ms, Z fps)` | The evaluator's last and mean frame times, and the fps they give. `eval –` when nothing has been evaluated yet |
| `play N fps` | Only during playback. The measured number of frames put on screen in the last second |
| `engine GPU VRAM used / budget MB`, `engine WARP VRAM ...` | The texture memory of the evaluating device and its budget (`limits.gpuMb`, or the automatic budget). `GPU` is the hardware GPU, `WARP` the software adapter |
| `engine on CPU` | Evaluation runs on the CPU reference |
| `(left GPU)` | The hardware GPU was lost or ran out of memory, and this session's evaluation moved to the CPU reference. Example: `engine on CPU (left GPU)` |
| `engine VRAM –` | Nothing has been evaluated yet and the backend is not known |
| `window GPU VRAM N MB`, `window WARP VRAM N MB` | The texture memory of the window's own presentation device (the cached 8-bit frames and so on) |
| `node <id>` | The node the evaluator is building now. `…` between nodes, `–` when idle. IDs longer than 32 characters are cut |

Hovering the figures shows an explanation of which device does what.
When there is an error, it appears in red as `CODE: what   |   status text`.
The text is cut to fit on one line.

The main status texts are these.

| Text | When |
|---|---|
| `starting` | Right after start |
| `evaluating frame N`, `evaluating frame N (proxy 1/M preview)`, `evaluating B (<target>) frame N`, `evaluating full-res readout at frame N` | An evaluation started |
| `reading the float image of frame N` | Fetching the float image of a cached frame again |
| `re-evaluating ... after the warm-up` | The first pipeline creation went over the budget, so the frame is evaluated again |
| `frame N ready (<source>)`, `frame N ready` | A frame appeared |
| `frame N: proxy 1/M preview, evaluating the frame` | The preview is shown and the frame itself is being evaluated |
| `frame N: ...`, `B (<target>) frame N: ...`, `preview frame N: ...`, `readout frame N: ...` | An evaluation failed |
| `display failed: ...` | The display transform failed |
| `playing`, `paused at frame N` | Play and pause |
| `paused: frame N is not pre-rendered yet` | Stopped because the next frame was not pre-rendered |
| `stopped at the last frame N (loop off)` | Played to the end with loop off |
| `paused: audio device error or underrun (N)` | An audio device error or underrun |
| `loop on`, `loop off` | Loop toggled |
| `A/B against <target>`, `A/B off`, `A/B: ...` | A/B applied, turned off, failed |
| `comparing with the comp as written: Tab flips, W cycles toggle / wipe / side by side` | `compare with the comp` was pressed |
| `N control(s) from the agent`, `controls removed`, `controls refused: ...` | Controls received |
| `NDI source <name>`, `NDI output off`, `NDI: ... (...)` | NDI started, stopped, failed |
| `changed: <path>` | A watched file changed |
| `comp changed, re-evaluating` | The comp changed and is being reloaded |
| `dependencies changed, re-evaluating` | A dependency file changed |
| `colour config reloaded, re-evaluating` | The colour config was reloaded |
| `configuration reloaded` | The configuration was reloaded |
| `check failed: ...` | The check after a save failed |
| `watch: ...`, `watcher stopped: ...` | A watch error, or the watcher stopped |
| `left the hardware GPU (lost or out of memory): evaluating on the CPU reference` | Evaluation moved to the CPU reference |
| `the engine's GPU device was lost and rebuilt (N×)` | The evaluating device was rebuilt |
| `the window's presentation device was lost and rebuilt (N×); showing the frames again` | The window's own presentation device was rebuilt |
| `the window's presentation device was lost; rebuilding it failed` | The presentation device could not be rebuilt |
| `colour config: ...`, `audio: ...` | Colour config and audio errors |

On every save, the window reloads the comp and evaluates again.

### Information in bottom bar, row 2

| Shown | Meaning |
|---|---|
| `S-E  F fps` | Frame range and fps (3 decimal places when not an integer) |
| `cache N/M (x MB of y MB)` | N frames cached for A out of the M frames of the range, the memory used and the budget. With B, `+K B` is added |
| `pre-rendering N/M` | Pre-render progress |
| `cache hit`, `disk cache`, `bake`, `evaluated`, `evaluated, lock pending`, `skipped` | Where the frame on screen came from |
| `N warning(s)` | The number of warnings for the frame on screen |
| `audio <path> (X Hz → Y Hz, latency Z ms)` | The reference audio file, the sample rates of the file and the device, and the latency |

## Playback, cache and reference audio

### Playback

Playback advances only to cached A frames.
When the next frame is not in the cache, playback stops and the status says so.
Loop is on by default and wraps from the end of the range to the start.
With loop off, playback stops at the last frame.
With loop off and the last frame on screen, `Space` plays again from the start.
When the range has only one frame, `Space` does nothing.
Every action that moves the frame (arrow keys, `Home`, `End`, seeking, the frame field, the buttons) pauses.

### Cache

The cache holds only the 8-bit display frames (4 bytes per display pixel).
Float images are held only for the frame on screen, and that share is set aside from the budget.
The budget is `review.displayCacheGib`; omitted, it is a quarter of the memory the frames live in.
That memory is the video memory this process plans to use when the window presents on the hardware GPU, and the session's RAM budget on the software adapter.
It is decided when the window opens and when the configuration is reloaded.
Pre-rendering fills the range from ahead of the playhead, wrapping round, while the evaluator is free.
It stops when a frame would only fit by evicting frames nearer the playhead, and it resumes when the playhead moves or the cache is discarded.
Right after the playhead moves, it waits 0.2 to 1.5 seconds (1/10 of the frame's evaluation time) before it starts evaluating the frame itself behind the preview, and pre-rendering.
This is because an evaluation cannot be cancelled midway.

The whole cache is discarded and evaluation starts again on a change of node, proxy, solo, mute or the comp, and on a configuration reload.
Changing a control value also discards it, but the previous picture stays on screen until the new one arrives.

### Reference audio

The WAV, AAC-LC (ADTS or MP4) or MP3 given with `--audio` is decoded once at start.
It plays on the default output device and is resampled to the device rate by linear interpolation.
During playback, the audio clock decides the frame on screen.
When playback reaches a frame that is not pre-rendered, or a device error or underrun happens, both audio and picture stop.
The audio loops according to `loop`.
When the comp's fps or range changes, the audio clock is realigned to match.
There is no mixing or writing out.

## Scopes

The `scopes` button, `S` or `--scopes` opens a panel on the right.

| Scope | Content | Default |
|---|---|---|
| `waveform` | Horizontal is the horizontal position in the image, vertical is the level. Choose `RGB` (R', G', B' overlaid) or `Y'` | Shown |
| `parade` | A waveform with R', G', B' side by side | Hidden |
| `vectorscope` | Cb and Cr. Boxes at the 75% colour bar positions (`R` `Mg` `B` `Cy` `G` `Yl`), circles, axes, the skin tone line (123 degrees) | Shown |
| `histogram` | Histograms of RGB and Y' | Shown |

The 4 buttons at the top of the panel show and hide each scope.
The `brightness` field (-4 to 4, steps of 0.25, default 0, in stops) changes the brightness of the traces.
The waveform and the parade have lines at 0, 25, 50, 75 and 100; the histogram has lines at 25, 50 and 75.

What is measured is the picture on screen, that is the 8-bit display texture the viewport draws.

- The values are after the display transform, and anything outside 0..1 is already clipped.
- The resolution is 8 bits.
- When the viewing exposure, gamma or channel is not at its default, it is part of the measured values too. Then an amber note such as `includes the viewing exposure +1.00, gamma 2.20, channel R` appears.
- Y', Cb and Cr are computed with the BT.709 weights whatever the display. This is not the same as the viewport's `Luma` (AP1 weights, scene-linear).
- With A/B, A is measured. B is measured only while toggle shows B. In wipe and side by side it is A.
- While a frame is being evaluated, the previous picture or the preview picture is measured.
- What is measured appears in the form `the picture on screen, 8-bit display values: <display> / <view> · A · W × H`.
- When there is no picture to measure, `no picture on screen yet` appears.

The scopes follow playback too, and do not evaluate again.
The scope figures are not part of the `lamino viewer` state.

## Controls

Controls are widgets for a person to move the parameters an agent offered with `lamino controls <comp> node.param=min..max ...`.
There is no way to offer a parameter the person chooses.
A value moved is a session override of this window and enters neither the comp file nor a render.
When controls arrive, the panel opens by itself; `K` or the `controls` button opens and closes it.

The syntax and rules of `lamino controls` are these.

- Numbers, vectors and colours are written `node.param=<min>..<max>`. `:<step>` can be appended.
- bool, enum, and numbers whose node declares both the lower and upper limits can be written as just `node.param`.
- `param` can also be a uniform that a shader node declared with `#pragma lamino param`.
- The list sent replaces the window's controls as a whole. Either all of it goes through, or nothing changes.
- Writing the same target twice is refused.
- A control that stays in the list keeps the value the person set. If that value does not fit the new range, the whole list is refused.
- A control dropped from the list loses its override.
- `--clear` removes every control and also discards the values set in the window.
- When no window answers, the result is an `E_REVIEW_NOT_CONNECTED` error. Unlike `lamino viewer`, it does not return `connected: false`.
- On success it returns the state after the replacement (the same shape as `lamino viewer`).

### Common parts of the panel

- Below the heading, `session only: not in the comp file, not in a render` appears.
- `reset all`: returns every control to the comp's value. It cannot be pressed when there is no override.
- `compare with the comp`: turns on and off an A/B (`no-overrides`) against the picture of the current comp file without overrides. `Tab` and `W` work as usual.
- Each control's name row holds a marker, `node.param`, the link button and the `reset` button.
- The marker is an amber filled dot while overridden, and a hollow dot while at the comp's value.
- The name is amber while overridden, and a double-click returns it to the comp's value. The right-click menu resets it and copies `node.param = value`.
- The `reset` button appears only while overridden.
- Changing a value pauses and evaluates again, keeping the previous picture. While a preview is shown, evaluation of the frame itself and pre-rendering waits until the value stops moving. A comp that evaluates fast is evaluated again each time the value moves.
- `compare with the comp` replaces the A/B comparison target set before.

### Parameter kinds and widgets

| Kind | Widget |
|---|---|
| bool | A checkbox (`on` / `off`). While overridden, `comp: <value>` is shown next to it |
| enum | A row of options. Press one, or press and slide to choose. When they do not fit across, they stack vertically. While overridden, `comp: <value>` is shown next to it |
| int | A number field. Integer steps (default 1) |
| float | A number field. A parameter whose unit is degrees gets an angle knob in front |
| vec2 | A two-value button and the number fields `X`, `Y` |
| vec3, vec4 | The number fields `X`, `Y`, `Z` (, `W`) |
| colour | A swatch (only when the lower bound of the range is 0 or more) and the number fields `R`, `G`, `B`, `A` |

A field with a single number shows its unit (width units ` wu`, degrees `°`, frames ` f`).
vec2, vec3 and vec4 have a `link all` button, and colour has a `link rgb` button; when on, one field moves the components together.
The rgb of colour does not include alpha.
When the comp's colour is grey, colour starts linked.
When a swatch or a two-value button makes the components differ, the link turns off.

What cannot be a control (strings, paths, JSON, shaders, cameras, shapes, animated parameters, colours written as sRGB hex) is refused on the agent's side.

### Number fields

A number field is itself a slider.

- Drag horizontally to move the value. Pressing away from the handle first jumps to the value at that position. Pressing the handle moves from the current value.
- During a drag, moving down makes it finer and moving up makes it coarser. Each point down multiplies the speed by 0.98. The lower limit is 4 decimal places (1 step in a field with a step), and the upper limit is the speed at which the field's width covers the whole range. During a drag, the dots in the field mark ticks at every factor of 10.
- `Alt` gives 1/10 of the speed, and `Shift` or `Q` snaps to round values.
- A click starts typing. Besides numbers, an expression can be written. An expression can use `x` (the value when typing started), `pi`, `+ - * / %`, `**` or `^`, unary minus, brackets, the functions `sqrt abs floor ceil round sin cos tan exp ln log10`, and the two-argument `min max pow`. A leading `Math.` is allowed. Angles are in radians.
- While typing, the value is applied each time. When an expression cannot be read, the text turns red, and hovering shows why.
- A double-click returns to the default (for a control, the comp's value).
- The right-click menu has `Reset to ...` and `Copy value`.
- When the value is not the default, a tick at the bottom edge of the field marks where the default is.
- When steps are 10 points or more apart, a line is drawn at each step.
- The value does not leave the range, and with a step it lands on a multiple of it.

The `exposure`, `gamma` and `wipe` fields in the top bar and `brightness` in the scopes are the same number fields, and the label in front also returns to the default with a double-click and the right-click menu.

### Angle knob

- The tip shows the angle. 0 is up, and it increases clockwise.
- Drag around the knob to turn it. Pressing the half on the tip's side takes the pointer's angle (absolute); pressing elsewhere turns from the current angle (relative). `A` and `R` choose the mode whatever the press position.
- It counts the number of turns. 720 is 2 turns from 0.
- `Shift` or `Q`, or moving the pointer out to the outer tick ring (96 to 160 points), gives 45-degree increments.
- During a drag, ticks, an arc for the amount turned, and an angle label (for example `2x 45.0°`) appear.
- A double-click and the right-click menu reset it.

### Two-value button

- Dragging moves the two values with the pointer. The whole range corresponds to 240 points of movement.
- `Shift` gives 5 times the speed and `Alt` 1/10. Holding `X` or `Y` moves only that axis.
- During a drag, a grid of dots, the frame of the range and labels for the two values appear.
- The ends of the range are walls; it moves the other way without first taking back the amount pushed against them.
- A double-click and the right-click menu reset it.

### Colour swatch

- Drag to change the colour. Horizontal is saturation, vertical is value, and the edge of a saturation-value square and a hue ring appear around the pointer. Keys move a single component only (see "Keyboard shortcuts"). The wheel turns the hue.
- A click opens the picker. It has a saturation-value square, a hue slider, an alpha slider, the number fields `R` `G` `B` `A`, and the number fields `H` (degrees), `S` (%) and `V`. A click outside closes it.
- The right-click menu resets and copies. The swatch itself has no double-click reset.
- The colour is scene-linear numbers and may go above 1. Hue, saturation and value are computed from the linear components, and value maps up to the upper end of the range onto 0 to 1.
- The colours of the square and the sliders are a guide to position, not a preview of the picture. The swatch draws the colour clipped at 1.

### States

| State | On screen | `lamino viewer` |
|---|---|---|
| At the comp's value | A hollow dot | `overridden: false`, `value` equals `compValue` |
| Overridden | Amber dot and name, `controls · N overridden` | `overridden: true`, `value` is the override value. The same value is also in `overrides.params` |
| Unavailable | The name struck through, the reason in red, `the comp changed: ask the agent for the controls again` | The reason in `unavailable`. The override is removed |

When the comp changes, every control is checked again before evaluation.
A control becomes unavailable when its node or parameter is gone, it became animated, or the comp's value left the range.
When the comp comes to hold the overridden value, it is no longer an override.
`uniform` is the JSON field that marks a uniform of a shader node; the panel does not show it.

## NDI output

Start with `--ndi [NAME]`, or use the `NDI` button in the bottom bar, to send the picture as an NDI source on the local network.
The button turns it on and off at any time, and while sending it shows `NDI · N` (N is the number of receivers).
Hovering the button shows the NDI trademark note.

- What is sent is the 8-bit display texture of the frame on screen, without the window's bars, panels, zoom or pan. The display and view transform, exposure, gamma and channel are included.
- The size is the size of the proxy the window evaluates, and the format is opaque `RGBX`.
- A is sent. B is sent only while toggle shows B. In wipe and side by side it is A.
- While a preview is drawn during a frame's evaluation, the last frame is held. Previews are not sent.
- One frame is sent for each frame put on screen. It carries the comp's fps and a timecode made from the frame number.
- While there are no receivers, nothing is read back or sent. When a receiver connects, the frame on screen is sent. While stopped, the same frame is sent again every second.
- No colour tag is attached. The receiver shows it as ordinary video. For a Rec.709 or sRGB display that is fine as it is; for a wide-gamut or HDR display, set up the receiver by hand.
- NDI compression is lossy (4:2:2).

The default name is `lamino ` followed by the project-relative comp path with `.comp.ts` removed and the separators turned into spaces (for example `lamino shots 010 shot`).
An empty name, a name with control characters, and a name with leading or trailing spaces are refused.
A name the runtime rewrites (for example `/` turning into a space) is also refused, and the name the runtime accepts is shown.
When the runtime cannot create the source, for example because a source with the same name already exists, the result is `E_IO`.

The NDI runtime is not included in Laminolith.
The runtime installed with NDI Tools is looked up in `NDI_RUNTIME_DIR_V6`, then `NDI_RUNTIME_DIR_V5`, and loaded at run time.
When it is not found, the result is `E_CODEC_UNAVAILABLE`, with where to get it.
When a start with `--ndi` fails, the window does not open.
When the button fails, the status shows why.

## The state lamino viewer returns

`lamino viewer <comp>` returns the state of the window showing that comp.
Without `--session`, it asks the newest window on this host.
Field names are camelCase, as in the JSON.

| Field | Type | Meaning |
|---|---|---|
| `connected` | boolean | A window answered |
| `reason` | string (may be omitted) | Why `connected` is false (`no review window for ...`, `session '...' (pid ..., port ...): ...` and so on) |
| `session` | string (may be omitted) | The session ID of the window that answered |
| `compFile` | string (may be omitted) | The comp file the window shows (project-relative) |
| `generation` | number | The window's generation. It increases on a reload, a comp change, a change of node or proxy, solo and mute, and a change of a control value |
| `frame` | number | The frame on screen |
| `region` | array (4 numbers) | The visible area `[x0, y0, x1, y1]`, in width units. `[0, 0, 1, height/width]` while there is no image yet |
| `node` | string (may be omitted) | The node shown |
| `nodeKey` | string (may be omitted) | The cache key of the frame on screen. Omitted until a frame appears |
| `frameReady` | boolean | The frame on screen is an evaluated result |
| `playing` | boolean | Playing |
| `ab` | string (may be omitted) | The A/B comparison target (`git:<rev>`, an image path, a node ID, `no-overrides`). Omitted when A/B is off |
| `proxy` | number | The proxy factor for evaluation |
| `channel` | string | `rgb`, `r`, `g`, `b`, `a`, `luma` |
| `display` | string | display |
| `view` | string | view |
| `exposure` | number | exposure (stops) |
| `gamma` | number | gamma |
| `cursor` | array (2 numbers, may be omitted) | The cursor position, in width units |
| `overrides` | object | The session overrides |
| `overrides.params` | object (omitted when empty) | A map from `"node.param"` to value. Holds the values moved with controls |
| `overrides.solo` | string (may be omitted) | The soloed node |
| `overrides.mute` | array of string (omitted when empty) | The muted nodes |
| `controls` | array (omitted when empty) | The controls, in the order they were offered |
| `lastError` | object (may be omitted) | The error that explains why the frame on screen is not current. A recovered device loss also stays here |
| `sessions` | array (omitted when empty) | The connection files for this comp. The window itself returns it empty, and `lamino viewer` fills it in |

Each element of `controls`:

| Field | Type | Meaning |
|---|---|---|
| `target` | string | `node.param` |
| `node` | string | The node ID |
| `param` | string | The parameter name |
| `uniform` | boolean (omitted when false) | A uniform of a shader node. Its value is written in the shader's `params` |
| `kind` | string | `bool`, `int`, `float`, `vec2`, `vec3`, `vec4`, `color`, `enum` |
| `min` | number (may be omitted) | The lower bound of the range (numeric kinds) |
| `max` | number (may be omitted) | The upper bound of the range |
| `step` | number (may be omitted) | The step |
| `options` | array of string (omitted when empty) | The options of an enum |
| `compValue` | any JSON value | The value in the comp file (defaults filled in; colours as `[r, g, b, a]`) |
| `value` | any JSON value | The value on screen. The override value while overridden, otherwise `compValue` |
| `overridden` | boolean | The person moved it. `value` is the session override |
| `unavailable` | string (may be omitted) | Why it became unavailable after the comp changed |

Each element of `sessions`:

| Field | Type | Meaning |
|---|---|---|
| `session` | string | The session ID |
| `pid` | number | The process ID of `lamino review` |
| `startedAt` | number | The start time (milliseconds since the Unix epoch) |
| `host` | string | The host name |
| `compFile` | string | The comp file |
| `reachable` | boolean | The window of this connection file answered |

Connection files of other hosts are listed but not connected to.
No window is not an error; it returns `connected: false` and `reason`.
Without a comp file, it also returns `connected: false`.
When `connected: false`, everything other than `reason`, `compFile` and `sessions` keeps its default value.

## Panel (lint, errors, what changed)

A read-only panel that the `changes / lint` button or `I` opens on the right.
It neither edits the comp nor writes files.

### changes

- The revision compared against is `HEAD`, or that `<rev>` when A/B is `git:<rev>`.
- While the panel is open, the comparison runs on the evaluator thread. It compares again when the comp, the session overrides or the revision changes.
- `refresh` compares again (after a commit, for example). During the comparison, `comparing…` appears.
- The first line of the result is `<comp> against <rev> (<commit>), with the session's solo / mute`, followed by a summary.
- Per-node changes are listed in the forms `~ node: params [inputs] [type]`, `+ node` and `- node`. When the comp's settings changed, `~ comp settings (fps, resolution, frames or working space)` appears.
- Opening `comp file diff` shows the diff in colour (up to the first 400 lines; the rest is `… N more lines: lamino changes <comp>`).
- A failed comparison stays in the panel as `CODE: what`, the reason, and `fix: ...`. It does not become a window error and changes neither evaluation nor the exit code.

### lint and errors

- The counts appear as `N error(s), M warning(s): the last check, the frame on screen and the window`.
- It covers the last check after a save (script errors and lint), the lint report, the diagnostics of the frame on screen, and the window's own errors.
- Each line takes the form `CODE  node: what  (file:line)`; errors are red, warnings yellow, information grey. Below it, the reason and `fix: ...` appear in small type.
- Identical lines are merged into one, and errors come first.
- When there is nothing, `no diagnostics` appears.

## What it cannot do

- It does not change the comp file. Control values, solo and mute are session-only too.
- The window's state is not saved.
- A person cannot pick any parameter they like and move it. Controls are only those the agent offered.
- String, path, JSON, shader, camera and shape parameters, animated parameters, and colours written as sRGB hex cannot be controls. A number without a range cannot be a control either.
- Renders and previews do not run inside the window. They run in a separate `lamino` process.
- A/B has no difference mode (only toggle, wipe and side by side).
- B is not pre-rendered. The full-resolution readout when zoomed in is for A only.
- Playback advances only to cached frames. Pixel values are not read during playback.
- An evaluation that has started cannot be cancelled.
- Reference audio is neither mixed nor written out.
- The scopes measure 8-bit display values, so nothing outside 0..1 is visible. The scope figures do not appear in `lamino viewer`.
- NDI sends no colour tag. It is proxy-sized, 8-bit, and meant for viewing.
- The viewport shows no guides or safe areas.
- No number field lacks a range, and there is no multiple selection.
