feat(claude): draw Claude Code plugin status lines, toasts and prompt band #15827
Closedcodeclawd(GitHub profile, opens in a new tab)wants to merge 4 commits into
main fromrefs/pull/15827/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- @@ -0,0 +59,21 @@59+60+const isRecord = (value: unknown): value is Record<string, unknown> =>61+ typeof value === "object" && value !== null && !Array.isArray(value);62+63+/**64+ * A band tree worth drawing: an element the plugins drew, not the engine's own65+ * placeholder. The SDK resolves a control request with the whole66+ * `{ subtype, request_id, response }` envelope.67+ */68+export const bandFromRenderResponse = (envelope: unknown): ClaudePluginUiElement | null => {69+ const response = isRecord(envelope) ? envelope.response : undefined;70+ if (!isRecord(response) || response.hooked !== true) return null;71+ const tree = response.tree;72+ if (!isRecord(tree) || typeof tree.type !== "string" || tree.type === "engine") return null;73+ return tree as unknown as ClaudePluginUiElement;74+};75+76+export const make = Effect.gen(function* () {77+ const threads = new Map<ThreadId, ThreadEntry>();78+ let toastCount = 0;79+ const changes = yield* PubSub.unbounded<Change>();@@ -0,0 +168,21 @@168+ entryFor(threadId).request = request;169+ return requestRender(threadId);170+ });171+172+ const detach: ClaudePluginUiShape["detach"] = (threadId, request) =>173+ Effect.suspend(() => {174+ const entry = threads.get(threadId);175+ // A replacement query may already have attached; only its own close clears it.176+ if (entry === undefined || entry.request !== request) return Effect.void;177+ entry.request = undefined;178+ return update(threadId, () => EMPTY_CLAUDE_PLUGIN_UI_SNAPSHOT);179+ });180+181+ const ingest: ClaudePluginUiShape["ingest"] = (threadId, message) => {182+ if (!isRecord(message) || message.type !== "system") return Effect.void;183+ switch (message.subtype) {184+ case "ui_status": {185+ if (typeof message.plugin !== "string") return Effect.void;186+ const plugin = message.plugin;187+ const text = typeof message.text === "string" && message.text !== "" ? message.text : null;188+ return update(threadId, (snapshot) => {
- apps/server/src/provider/ClaudePluginUi.ts lines 201 to 210Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +159,21 @@159+ }),160+ ),161+ Effect.forkDetach,162+ Effect.asVoid,163+ );164+ });165+166+ const attach: ClaudePluginUiShape["attach"] = (threadId, request) =>167+ Effect.suspend(() => {168+ entryFor(threadId).request = request;169+ return requestRender(threadId);170+ });171+172+ const detach: ClaudePluginUiShape["detach"] = (threadId, request) =>173+ Effect.suspend(() => {174+ const entry = threads.get(threadId);175+ // A replacement query may already have attached; only its own close clears it.176+ if (entry === undefined || entry.request !== request) return Effect.void;177+ entry.request = undefined;178+ return update(threadId, () => EMPTY_CLAUDE_PLUGIN_UI_SNAPSHOT);179+ });
- @@ -0,0 +52,21 @@52+ }, [hasSnapshot, toast]);53+54+ if (snapshot === null || (snapshot.band === null && snapshot.statuses.length === 0)) {55+ return null;56+ }57+58+ const press = (target: { plugin: string; handle: number }, key: string | undefined) => {59+ void pressCommand({60+ environmentId,61+ input: { threadId, ...target, ...(key === undefined ? {} : { key }) },62+ });63+ };64+65+ return (66+ <div className="mx-auto mb-1.5 flex w-full max-w-208 flex-col gap-1 px-1 font-mono text-xs leading-tight">67+ {snapshot.band === null ? null : (68+ <div className="overflow-x-auto rounded-md border border-border/60 bg-muted/30 px-2 py-1.5 leading-none [container-type:inline-size]">69+ {/* Shrink below text-xs when the composer is narrower than the plugin's columns. */}70+ <div71+ style={{72+ fontSize: `min(0.75rem, calc(100cqi / ${CLAUDE_PLUGIN_UI_BAND_COLUMNS * MONO_CH_EM}))`,
maria-rcks closed this
Sign in to join this conversation.


macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed