@@ -99,6 +99,7 @@ await status.reportStatus({
9999 plugin: " mail" ,
100100 state: " busy" , // "ok" | "warn" | "error" | "busy"
101101 summary: " Syncing inbox" ,
102+ version: " 1.8.23" , // shown by StatusPanel, retained on later statuses
102103 detail: " UIDVALIDITY changed" , // JSONL log only
103104 progress: { current: 3 , total: 10 },
104105});
@@ -116,31 +117,66 @@ await status.clearStatus("mail");
116117` publish(channel, payload) ` ) and ` logger ` ; the module-level ` reportStatus ` /
117118` clearStatus ` exports use a lazily created default reporter.
118119
119- ### TUI: ` usePluginStatuses ` + ` StatusPanel ` / ` StatusLine `
120+ ` version ` is set once per plugin (pass your package version, a build-time
121+ constant). The reporter remembers it and attaches it to every later status, so
122+ ` StatusPanel ` can always show ` plugin version ` information. It is optional and
123+ ` StatusLine ` omits it.
124+
125+ ### TUI: ` StatusPanel ` / ` StatusLine ` in slots
126+
127+ ` StatusPanel ` and ` StatusLine ` are slot-safe for the opencode 1.19.6+ TUI slot
128+ renderer: they have no ` onMount ` side effects and never write a signal during
129+ mount, so mounting them cannot re-trigger the slot. Pass a ** status accessor**
130+ (not a snapshot array) and they repaint in place when it changes.
131+
132+ Reactive state must live in a component mounted by the slot renderer. Hooks
133+ called in the slot renderer function itself or in a detached ` createRoot ` never
134+ subscribe in opencode 1.19.6, and a plugin-owned signal there behaves like a
135+ snapshot.
120136
121137``` tsx
122- import { usePluginStatuses } from " @four-bytes/opencode-plugin-lib/tui" ;
123- import { StatusPanel , StatusLine } from " @four-bytes/opencode-plugin-lib/tui-components" ;
138+ import { useSlotStatusBridge } from " @four-bytes/opencode-plugin-lib/tui" ;
139+ import {
140+ StatusPanel ,
141+ StatusLine ,
142+ } from " @four-bytes/opencode-plugin-lib/tui-components" ;
124143import { createToast } from " @four-bytes/opencode-plugin-lib" ;
125144
145+ // A component, not the slot renderer, owns the status signal and the bus
146+ // subscription. `api.renderer` is the host re-render handle.
147+ const HomeStatus = (props : { api: any }) => {
148+ const bridge = useSlotStatusBridge (props .api .renderer );
149+ return <StatusPanel statuses = { bridge .statuses } title = " Plugins" />;
150+ };
151+
152+ const SidebarStatus = (props : { api: any }) => {
153+ const bridge = useSlotStatusBridge (props .api .renderer );
154+ return <StatusLine statuses = { bridge .statuses } />;
155+ };
156+
126157const tui = (api ) => {
158+ // warn/error toasts are separate from the panel components.
127159 const toast = createToast (api , " Status" );
128- const statuses = usePluginStatuses ({ toast }); // warn/error toast once
129160 api .slots .register ({
130161 slots: {
131- home_bottom : () => <StatusPanel statuses = { statuses () } />,
132- sidebar_content : () => <StatusLine statuses = { statuses () } />,
162+ home_bottom : () => <HomeStatus api = { api } />,
163+ sidebar_content : () => <SidebarStatus api = { api } />,
133164 },
134165 });
135166};
136167```
137168
138- - ` StatusPanel ` : one line per plugin — ` <symbol> <plugin>: <summary> ` with ` ✓ ` ok,
139- ` ⚠ ` warn, ` ✗ ` error, ` ⟳ ` busy, plus an optional progress label and bar.
140- - ` StatusLine ` : sidebar variant, same format (including the progress label) but only
141- ` warn ` / ` error ` / ` busy ` .
142- - Only one mounted ` StatusPanel ` and one mounted ` StatusLine ` render — each has its own
143- global render guard (a denied instance re-claims when the owner unmounts).
169+ - ` useSlotStatusBridge(api.renderer) ` returns a renderer-owned status signal
170+ (` bridge.statuses ` ), applies retained status payloads and calls
171+ ` api.renderer.requestRender() ` after every update. ` createSlotStatusBridge() `
172+ is the bus-free core for custom wiring and tests.
173+ - ` StatusPanel ` : one line per plugin — ` <symbol> <plugin> [<version>]: <summary> `
174+ with ` ✓ ` ok, ` ⚠ ` warn, ` ✗ ` error, ` ⟳ ` busy, plus an optional progress label
175+ and bar.
176+ - ` StatusLine ` : sidebar variant, same format (including the progress label) but
177+ only ` warn ` / ` error ` / ` busy ` ; it omits the version.
178+ - A plain array still works for static/test rendering, but it is a one-shot
179+ snapshot — it will not repaint.
144180- ` warn ` / ` error ` statuses toast once per distinct ` plugin + state + summary ` . An ` ok `
145181 status (or ` clearStatus ` ) forgets them, so a later failure with the same summary
146182 toasts again; ` ok ` / ` busy ` never toast.
0 commit comments