UI Events
These events fire when Claude Code draws part of the interface, and when a person uses a control that a mod drew.
The second table lists the events that the $.ui methods raise.
A deny from a hook refuses a scroll, focus, or close. An invalid tree draws the engine's own drawing.
Official pages: Draw in the Interface, Mods Reference. Source: the program (types-2.1.304.d.ts).
Example
This hook adds a count to the spinner.
let calls = 0
on('tool.call', ($, e, next) => { calls += 1; return next(e) })
on('ui.render', { component: 'Spinner' }, async ($, e, next) =>
next({ ...e, props: { ...e.props, suffix: ' · tool calls: ' + calls + '…' } }))
Engine Events
| Item | Status | What it does | How it works | Where it can be used |
|---|---|---|---|---|
ui. | Documented | Fires when the engine is about to draw a component: once for each input value (props, viewport width), at plugin load, or on $.. | Input Render. Result Render: the tree to draw. next(e) gives the engine's drawing. An invalid tree draws the engine's drawing. | on('ui.. In tests: $. on the test engine (not on a hook's $). |
ui. | Documented | Fires when the plugins load (not on each draw), once for each surface, component, and plugin. e names the surface and component, never the props. | Input Resolve. Result Element: the element table of the surface. A hook may restyle an element or leave one out. | on('ui.. Also $.. |
ui. | Documented | Fires when a Button that a render hook drew is pressed on a surface. e is { plugin, element, component, surface }. element is the button's key. Set a key on buttons that share a label: until 2.1.304 a click was lost when same-label buttons with no key were redrawn unchanged. | Input Ui. Result { element }. next(e) lets the press through. Returning { element } takes it. | on('ui.. |
ui. | Documented | Fires when an Input that a render hook drew changes or is submitted. e is { plugin, element, component, surface, kind, value }. | Input Ui. Result { element, value }. next({ ... rewrites the typing. | on('ui.. |
ui. | Documented | Fires when a Select that a render hook drew is picked from. e is { plugin, element, component, surface, value }. | Input Ui. Result { element, value }. next({ ... rewrites the pick. | on('ui.. |
ui. | Documented | Fires when a Client that this plugin drew posts from its surface module (surface.). Only this plugin's hooks see it. | Input Ui. Result { props? }. next({ ... rewrites the data. One call for each instance in each frame. | on('ui.. |
ui. | Documented | Fires when a Client that this plugin drew failed on a surface: its module did not load, its drawing failed, or its code failed after it drew. | Input Ui. Result {}. Only this plugin's hooks see it. e. says when and e. says why. | on('ui.. |
ui. | Documented | Fires before the window of a site moves: the person's wheel or scroll keys on a Pane body or the Above band (at its edges too), or $.. | Input Ui. Result {} or { deny }. next({ ... scrolls elsewhere. | on('ui.. Also $.. |
ui. | Documented | Fires before the focus ring of a site moves: the person's Tab, arrows, or click in a Pane or the band, an auto element taking it, or $.. | Input Ui. Result {} or { deny }. next({ ... moves the focus to another element. | on('ui.. Also $.. |
Events Raised by UI Calls
For each call, a hook above the caller returns next(e), { deny: reason }, or { value }.
| Item | Status | The argument | Input and value |
|---|---|---|---|
ui. | Documented | $. | Input { text:. Value void. |
ui. | Documented | $.. text undefined clears the line. | Input { text:. Value void. |
ui. | Documented | $.. to is always present. next({ ... keeps a line off screen. | Input { text:. Value void. |
ui. | Documented | $. | Input { tool_. Value void. |
ui. | Documented | $. | Input { event:. Value void. |
ui. | Documented | $.. A hook above may retitle it or refuse with { deny }, never rename it. | Input Pane. Value Ui. |
ui. | Documented | $. with origin plugin. The engine raises it too, for the person (person) and for an unload (unload). | Input Pane. Value void. |
ui. | Documented | $. | Input No. Value readonly Ui. |
ui. | Documented | $. | Input No. Value Ui. |
ui. | Documented | $.. surface takes the session's first surface when left out. | Input Ui. Value Ui. |
ui. | Documented | $.: whose transcript the main view shows. None means the main conversation. | Input Site. Value Ui. |
ui. | Documented | $.. title is the plugin's name when left out. Two mods that notify again on hearing a notification can echo each other without end. | Input { text:. Value Ui. |
ui. | Documented | $.: the cells of a Raster or the source of a keyed Image. A hook above may rewrite either, or { deny }. | Input Ui. Value Ui. |
Related Pages
- Mod API Overview
- UI Methods
- Surfaces, Elements, and Render Sites
- UI Types (input and result types)