feat(tui): move assistant content into per-part quark slots

This commit is contained in:
Kit Langton 2026-07-17 22:37:04 -04:00
commit 6d043d9155
11 changed files with 547 additions and 328 deletions

View file

@ -1,10 +1,29 @@
import { For, from, type Accessor, type JSX } from "solid-js"
import { createMemo, For, from, type Accessor, type JSX } from "solid-js"
import type { Keyed } from "./keyed"
import type { Readable } from "./reactivity"
export function useValue<A>(readable: Readable<A>): Accessor<A> {
return from(readable, readable())
}
/**
* Reactive accessor for one keyed slot. Tracks structure only until the slot
* exists; afterwards value changes flow through the slot alone, so unrelated
* structural churn cannot re-render the consumer.
*/
export function useSlot<A, Key>(keyed: Keyed.Keyed<A, Key>, key: () => Key): Accessor<A | undefined> {
const structure = useValue(keyed.slots)
const slot = createMemo(() => {
structure()
return keyed.get(key())
})
const value = createMemo(() => {
const current = slot()
return current ? useValue(current) : undefined
})
return () => value()?.()
}
export function KeyedFor<A>(props: {
readonly each: Accessor<readonly Readable<A>[]>
readonly fallback?: JSX.Element