Skip to content

Commit 80532b9

Browse files
committed
fix(tui): render plugin slots and routes with component semantics
1 parent 49256c8 commit 80532b9

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

‎packages/tui/src/plugin/context.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { PluginContextProvider, type Plugin } from "@opencode-ai/plugin/tui"
22
import {
33
batch,
4+
createComponent,
45
createContext,
56
createEffect,
67
createMemo,
78
ErrorBoundary,
89
For,
10+
mergeProps,
911
on,
1012
onCleanup,
1113
onMount,
@@ -793,7 +795,7 @@ export function PluginRoute(props: { readonly fallback: (id: string, name: strin
793795
<Show keyed when={current()}>
794796
{(item) => (
795797
<PluginBoundary id={item.id} where="route">
796-
{item.render ? item.render({ data: item.data }) : props.fallback(item.id, item.name)}
798+
{item.render ? createComponent(item.render, { data: item.data }) : props.fallback(item.id, item.name)}
797799
</PluginBoundary>
798800
)}
799801
</Show>
@@ -815,7 +817,14 @@ export function PluginSlot<Name extends SlotName>(props: {
815817
<For each={renderers()}>
816818
{(item) => (
817819
<PluginBoundary id={item.id} where={`slot ${props.name}`}>
818-
{item.render(props.input)}
820+
{
821+
// Component semantics: the render body runs once and untracked, so
822+
// signals and intervals created inside are stable, while props stay
823+
// reactive through the merged getter. A bare item.render(props.input)
824+
// call would run inside the host's tracked scope and re-execute the
825+
// whole body (resetting plugin state) on every tracked read.
826+
createComponent(item.render, mergeProps(() => props.input) as SlotMap[Name])
827+
}
819828
</PluginBoundary>
820829
)}
821830
</For>

0 commit comments

Comments
 (0)