Official

chat

Built-in chat UI (JavaScript UI plugin).

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/chat@0.2.9

Permissions in 0.2.9

  • Control chats chats.controlHighCreates chats, sends prompts and cancels runs.Send prompts, answer agent questions, and create, change, fork, revert, stop and group chats
  • Run other plugins' commands commands.runHighRuns commands of other plugins.Run the sidebar's New chat command from the title bar, and its Close Chat and Reopen Closed Chat for Cmd+W and Cmd+Shift+T on a chat's only tab
  • Read chats chats.readMediumReads your transcripts and chat lists.Show workspaces, tasks, chats and transcripts, and follow them as agents work
  • Read files fs.readMediumReads files in the listed places.Suggest workspace files for @ mentionsPlaces: the open workspace
  • Show panels ui.slotsAlways grantedShows views in the listed parts of the window.Draw the chat grid, the title bar, and the Session panel with its rail buttonSlots: centertitlerailright

Files

views/tasks.tsx25.9 KB
import * as Effect from "effect/Effect";
// Tasks rendering preserves the chat's retained tree and interaction keys.
import {
  allTasks,
  counts,
  countsLabel,
  elapsed,
  findTask,
  groupLabel,
  isLive,
  metaLine,
  nameOf,
  resultOf,
  statusOf,
  taskItems,
  tokens,
} from "../subagents.ts";
import {
  displayStatus,
  modelName,
  phaseDetail,
  phaseOpen,
  phasesOf,
  progressLabel,
  resultView,
  stripOf,
} from "../workflows.ts";
import type { Element, Chat } from "divergence";
import type { TaskInfo } from "divergence/protocol";
import type { Transcript } from "../state.ts";
import type { ChatView } from "../controller.ts";
import type { TaskGroup, TaskItem } from "../grouping.ts";
import type { Phase } from "../workflows.ts";
import { activityRow, bubble, clampedPrompt, keepLineBreaks, messageActions, reading, renderItems, toolStatus, workingRow } from "./rows.tsx";
import { workingFor } from "../transcript.ts";
import { renderApproval, renderQuestion } from "./questions.tsx";
import { terminalOutput } from "../terminal.tsx";
import {
  column,
  row,
  fill,
  HOVER,
  clickable,
  revealOnHover,
  tint,
  ROW_TEXT,
  PHASE_MARK,
  AGENT_MARK,
  TOOL_ICONS,
  RAISED,
  EDGE_WIDTH,
  corner,
} from "./styles.tsx";
// A workflow card is the raised `card` with the `md` corner (11px
// in the stock shapes) and a 0.25rem inset; its header's hover fill shares
// the card's corner centre.
// `reading` insets a row by this much at each side.
const READING_INSET = 22.5;
const INNER_RADIUS = 11 - 3.75 - EDGE_WIDTH;
export function statusMark(task: TaskInfo): Element | null {
  const status = statusOf(task);
  const mark =
    task.status === "running"
      ? <spinner activity />
      : <div {...column} gap="small" padding="small" width={6} flexShrink={0} height={6} background={tint(status.tone)} borderRadius={3} />;
  return (
    <div {...row} gap={5} padding="small">
      {mark}
      <text style="body" size="xs" weight={560} tone={status.tone === "primary" ? "muted" : status.tone}>{status.label}</text>
    </div>
  );
}

export function taskMeta(task: TaskInfo): Element | null {
  const meta = metaLine(task, Date.now());
  const activity = isLive(task) && task.activity ? `▸ ${task.activity}` : null;
  const line = [meta || null, activity].filter(Boolean).join("   ");
  return line ? <text style="body" size="xs" tone="faint" truncate>{line}</text> : null;
}

/** The mark of the agent that runs a subagent, as the picker and the sidebar draw it, the bot where it has no artwork. */
export const agentMark = (v: ChatView, chat: Chat): Element =>
  <icon name="bot" small tone="muted" svg={v.controller.state.agents[chat.agentId]?.icon} />;

/** The prompt a subagent was given, as the user's message bubble and in its type: wrapped within the pane, and clamped
 * to five lines with Read more when it is longer (`clampedPrompt`). */
function promptBubble(v: ChatView, t: Transcript, task: TaskInfo): Element {
  return (
    <div {...column} paddingY="small" alignItems="end" minWidth={0}>
      {bubble(clampedPrompt(v, t, `prompt-${task.id}`, `task-prompt-more-${task.id}`, <markdown id={`md-task-prompt-${task.id}`} text={keepLineBreaks(task.prompt ?? "")} />), { id: `task-prompt-${task.id}` })}
    </div>
  );
}

export function nameChip(name: string): Element | null {
  return <div {...row} gap="small" padding={2} paddingX={6} background="muted" borderRadius={6}><text style="body" size="xs" weight={560} tone="muted">{name}</text></div>;
}

function answer(v: ChatView, chat: Chat, t: Transcript, id: string, text: string): Element {
  return (
    <reply id={id} group="hover">
      <markdown id={`md-${id}`} text={text} onQuote={(event) => v.ctx.run(v.controller.quote(chat.id, event.text))} />
      <div {...row} {...revealOnHover} gap="small" padding={0} marginLeft={-5}>{messageActions(v, chat.id, t, id, text)}</div>
    </reply>
  );
}

export function taskBody(v: ChatView, chat: Chat, t: Transcript, item: TaskItem): (Element | null)[] {
  // A finished subagent ends with the answer it gave the chat: a reply like the chat's own last one, with Copy and Reply
  // under it on hover. A last message that only says the same is that answer, drawn once.
  const result = resultOf(item, t.items);
  const items = (item.items ?? []).filter((entry) => entry.id !== result?.repeats);
  const rows = items.length ? renderItems(v, chat, t, items) : [];
  if (result) rows.push(answer(v, chat, t, `task-result-${item.task.id}`, result.text));
  // While it runs, the working row at the end of its tab says so.
  if (rows.length || item.task.status === "running") return rows;
  if (isLive(item.task)) return [activityRow({ icon: <spinner activity />, label: "Waiting for subagent output…" })];
  // Its transcript is still being read, or could not be.
  const read = v.controller.state.taskReads.get(item.task.id);
  if (read === null) return [];
  if (read) return [<callout tone="danger" text={read} />];
  return [<text style="body" size="xs" tone="muted">The subagent left no transcript.</text>];
}

// A subagent in the transcript: one activity row with its status mark, its
// name as a chip, its title and a faint line of its model, time and tokens.
// Its transcript, result, approvals and questions are in its tab, which a
// click opens; one that waits on the user says so on the row. A background
// command reads like a Run row: one mark, the spinner while it runs and the
// terminal's mark after, and a failure or a stop at the row's end. On its own
// row, outside a group, only a background command or a background subagent
// keeps its marks; any other subagent reads like a tool call on its own row,
// with no icon and its spinner or failure at the row's end.
export function renderTask(v: ChatView, chat: Chat, _t: Transcript, item: TaskItem, compact?: boolean): Element | null {
  const task = item.task;
  const terminal = task.kind === "terminal";
  const marked = compact || terminal || !!task.background;
  const model = modelName(
    v.controller.state.composers[chat.id]?.options.find((o) => o.category === "model"),
    task.model,
  );
  const meta = [model, elapsed(task, Date.now()), tokens(task.usage?.usedTokens), task.background ? "Background" : null]
    .filter(Boolean)
    .join(" · ");
  const waiting = task.status === "waiting";
  return (
    <div {...column} id={`task-${task.id}`} padding={0}>
      {activityRow({
                compact,
                icon: !marked
                  ? undefined
                  : terminal
                    ? (isLive(task) ? <spinner activity /> : TOOL_ICONS.execute)
                    : (mark(AGENT_MARK[task.status as keyof typeof AGENT_MARK]) ?? undefined),
                extra: (
                  <div {...row} {...fill} gap="medium" padding={0}>
                    {terminal || !marked ? null : agentMark(v, chat)}
                    {task.name ? nameChip(task.name) : null}
                    <text style="body" {...ROW_TEXT} tone="foreground" truncate>{task.title || nameOf(task)}</text>
                    {meta ? <text style="body" size="xs" tone="faint">{meta}</text> : null}
                  </div>
                ),
                status: waiting
                  ? <text style="body" {...ROW_TEXT} tone="warning">{statusOf(task).label}</text>
                  : (terminal || !marked) && (task.status === "failed" || task.status === "cancelled")
                    ? toolStatus(task.status)
                    : !marked && isLive(task) ? <spinner activity /> : null,
                onClick: () => v.ctx.run(v.controller.openSubagent(chat, task.id)),
              })}
    </div>
  );
}

// Subagents started together fold into one row like a group of tool
// calls: open while any of them works, onto the open group's surface.
export function renderTaskGroup(v: ChatView, chat: Chat, t: Transcript, entry: TaskGroup): Element | null {
  const tasks = entry.items.map((item) => item.task);
  const live = tasks.some(isLive);
  const open = t.folds.get(entry.id) ?? live;
  const status = tasks.some((task) => task.status === "waiting")
    ? <text style="body" {...ROW_TEXT} tone="warning">Needs you</text>
    : live
      ? <spinner activity />
      : tasks.some((task) => task.status === "failed")
        ? <icon name="circle-alert" small tone="muted" />
        : null;
  return (
    <div {...column} id={`task-group-${entry.id}`} gap={2} padding={0}>
      {activityRow({
                label: groupLabel(tasks),
                detail: countsLabel(counts(tasks)),
                status,
                open,
                onClick: () => {
                  t.folds.set(entry.id, !open);
                  v.controller.redraw(chat.id);
                },
              })}
      {open
                  ? <div {...column} id={`fold-scroll-${entry.id}`} followEnd gap={2} padding={5} maxHeight={400} background="card" borderRadius="md" {...RAISED} overflowY="scroll">{entry.items.map((item) => renderTask(v, chat, t, item, true))}</div>
                  : null}
    </div>
  );
}

/** What a chat still runs after its turn ("2 commands running") when no reply ends the transcript to tell it in its
 * action row: the working row, which opens onto the commands and subagents it counts, drawn as a group of them is.
 * Closed until the user opens it. */
export function renderBackground(v: ChatView, chat: Chat, t: Transcript, label: string): Element | null {
  const items = backgroundItems(t);
  if (!items.length) return activityRow({ icon: <spinner activity />, label });
  const open = t.folds.get(BACKGROUND) ?? false;
  return (
    <div {...column} id={BACKGROUND} gap={2} padding={0}>
      {activityRow({ icon: <spinner activity />, label, open, onClick: () => toggleBackground(v, chat, t) })}
      {open ? backgroundTasks(v, chat, t, items) : null}
    </div>
  );
}

/** The same count in the action row of the reply that ends the transcript, before its buttons: the spinner and the
 * count on the row's line, which open the list of what it counts under the reply (`backgroundList`). */
export function backgroundToggle(v: ChatView, chat: Chat, t: Transcript, label: string): Element {
  const opens = backgroundOpens(t);
  return (
    <div {...row} {...opens ? clickable : null} id={BACKGROUND} gap="medium" padding={0} paddingX={5} height={22.5} flexShrink={0} borderRadius={corner("field", 8)} hover={opens ? HOVER : undefined} onClick={opens ? () => toggleBackground(v, chat, t) : undefined}>
      <div {...row} padding={0} width={14} height={14} justifyContent="center"><spinner activity /></div>
      <div {...row} padding={0} opacity={0.8}><text style="body" {...ROW_TEXT} tone="foreground">{label}</text></div>
    </div>
  );
}

/** The list `backgroundToggle` opens under the reply, or null while shut. */
export function backgroundList(v: ChatView, chat: Chat, t: Transcript): Element | null {
  const items = backgroundItems(t);
  if (!items.length || !t.folds.get(BACKGROUND)) return null;
  return backgroundTasks(v, chat, t, items);
}

export const BACKGROUND = "background-tasks";
const backgroundItems = (t: Transcript) => allTasks(taskItems(t)).filter(({ task }) => isLive(task)).map(({ item }) => item);
/** Whether the count has a list to open: the reply row that holds it is kept while this stays the same. */
export const backgroundOpens = (t: Transcript) => backgroundItems(t).length > 0;

function toggleBackground(v: ChatView, chat: Chat, t: Transcript) {
  t.folds.set(BACKGROUND, !t.folds.get(BACKGROUND));
  v.controller.redraw(chat.id);
}

function backgroundTasks(v: ChatView, chat: Chat, t: Transcript, items: TaskItem[]): Element {
  return <div {...column} id="background-tasks-list" gap={2} padding={5} maxHeight={400} background="card" borderRadius="md" {...RAISED} overflowY="scroll">{items.map((item) => renderTask(v, chat, t, item, true))}</div>;
}

export function mark(look?: { icon: string; tone: string } | null): Element | null {
  return look ? <icon name={look.icon} small tone={look.tone} /> : <spinner activity />;
}

export function workflowStrip(phases: Phase[], height: number): Element | null {
  const parts: Element[] = [];
  stripOf(phases).forEach((group, i) => {
    if (i)
      parts.push(<div {...column} gap="small" padding="small" width={4} flexShrink={0} height={height} />);
    for (const segment of group.segments) {
      const background = segment.surface === "tint" ? tint(segment.tone) : segment.surface;
      parts.push(
        <div {...column} {...fill} gap="small" padding="small" height={height} opacity={segment.opacity} background={background} borderRadius="full" />,
      );
    }
  });
  return <div {...row} {...fill} gap={2} padding={0}>{parts}</div>;
}

export function workflowHeader(
  v: ChatView,
  item: TaskItem,
  phases: Phase[],
  props: { open?: boolean; onClick?: () => void; large?: boolean },
): Element | null {
  const { open, onClick, large } = props;
  const task = item.task;
  const inset = onClick ? 20 : 0;
  const summary = !isLive(task) && task.summary ? task.summary.split("\n").find((l) => l.trim()) : null;
  const meta = [progressLabel(item, phases), metaLine(task, Date.now())].filter(Boolean).join(" · ");
  const title = large
    ? { style: "heading", truncate: true }
    : { style: "body", ...ROW_TEXT, tone: "foreground", truncate: true };
  return (
    <div {...column} {...onClick ? clickable : null} gap={3} padding="small" paddingX="medium" paddingY="small" borderRadius={INNER_RADIUS} hover={onClick ? HOVER : undefined} onClick={onClick}>
      <div {...row} gap="small" padding="small">
          {onClick ? <icon name={open ? "chevron-down" : "chevron-right"} small tone="muted" /> : null}
          <icon name="workflow" small tone={isLive(task) ? "primary" : "muted"} />
          {task.name ? nameChip(task.name) : null}
          <text {...title}>{task.title || "Workflow"}</text>
          {summary && !open ? <text style="body" {...ROW_TEXT} tone="muted" truncate>{`· ${summary}`}</text> : null}
          <spacer />
          {statusMark({ ...task, status: displayStatus(item) })}
        </div>
      {meta ? <div {...row} gap="small" padding="small" paddingX={inset}><text style="body" size="xs" tone="faint" truncate>{meta}</text></div> : null}
      <div {...row} gap="small" padding="small" paddingX={inset} paddingY={2}>{workflowStrip(phases, large ? 6 : 4)}</div>
    </div>
  );
}

export function workflowAgent(v: ChatView, chat: Chat, agent: TaskItem): Element | null {
  const task = agent.task;
  const model = modelName(
    v.controller.state.composers[chat.id]?.options.find((o) => o.category === "model"),
    task.model,
  );
  const note = isLive(task)
    ? task.status === "queued"
      ? "Waiting for a slot"
      : task.status === "waiting"
        ? "Needs your answer"
        : task.activity
    : task.summary?.split("\n").find((l) => l.trim());
  const spend = [tokens(task.usage?.usedTokens), task.status === "queued" ? null : elapsed(task, Date.now())]
    .filter(Boolean)
    .join(" · ");
  return (
    <div {...row} {...clickable} cursor="pointer" gap="small" padding="small" paddingX={6} paddingY={4} borderRadius="md" hover={HOVER} onClick={() => v.ctx.run(v.controller.openSubagent(chat, task.id))}>
      <div {...row} gap="small" padding="small" width={14} flexShrink={0} justifyContent="center">
          {mark(task.status === "running" ? undefined : task.status ? AGENT_MARK[task.status] : undefined)}
        </div>
      <text style="body" {...ROW_TEXT} tone={task.status === "queued" ? "muted" : "foreground"}>{task.title || nameOf(task)}</text>
      {model ? <text style="body" size="xs" tone="muted">{model}</text> : null}
      <div {...row} {...fill} gap="small" padding={0}>
          {note ? <text style="body" size="xs" tone={task.status === "failed" ? "danger" : "faint"} truncate>{note}</text> : null}
        </div>
      {spend ? <text style="body" size="xs" tone="faint">{spend}</text> : null}
      <div {...column} {...revealOnHover} gap="small" padding={0}><icon name="chevron-right" small tone="muted" /></div>
    </div>
  );
}

export function workflowPhase(
  v: ChatView,
  chat: Chat,
  t: Transcript,
  item: TaskItem,
  phase: Phase,
  pane?: boolean,
): Element | null {
  const key = `wf-phase-${item.task.id}-${phase.index}`;
  const agents = phase.agents.length > 0;
  const open = agents && (t.folds.get(key) ?? (pane || phaseOpen(phase)));
  // Open, it is indented so each agent's mark sits under the phase's title.
  return (
    <div {...column} padding="small">
      <div {...row} {...agents ? clickable : null} gap="small" padding="small" paddingX={6} paddingY={4} borderRadius="md" opacity={phase.state === "pending" ? 0.7 : undefined} hover={agents ? HOVER : undefined} onClick={agents
                    ? () => {
                        t.folds.set(key, !open);
                        v.controller.redraw(chat.id);
                      }
                    : undefined}>
          <div {...row} gap="small" padding="small" width={14} flexShrink={0} justifyContent="center">{mark(phase.state === "running" ? null : PHASE_MARK[phase.state])}</div>
          <text style="body" {...ROW_TEXT} tone="foreground">{phase.title || "Agents"}</text>
          <div {...row} {...fill} gap="small" padding={0}>
              <text style="body" size="xs" tone="faint" truncate text={String(phaseDetail(phase) ?? "")} />
            </div>
          {agents
                        ? <div {...column} {...revealOnHover} gap="small" padding={0}><icon name={open ? "chevron-down" : "chevron-right"} small tone="muted" /></div>
                        : null}
        </div>
      {open ? <div {...column} padding="small" paddingX={18}>{phase.agents.map((agent) => workflowAgent(v, chat, agent))}</div> : null}
    </div>
  );
}

export function workflowOutcome(task: TaskInfo): Element | null {
  if (task.status === "failed" && task.summary) {
    return (
      <panel>
        <div {...row} gap="small" padding="small">
              <icon name="circle-x" small tone="danger" />
              <text style="body" size="xs" weight={560} tone="danger">Failed</text>
            </div>
        <text style="body" size="xs" tone="muted">{task.summary}</text>
      </panel>
    );
  }
  const result = resultView(task.workflow?.result);
  if (!result) return null;
  return (
    <panel>
      <div {...row} gap="small" padding="small">
          <icon name="circle-check" small tone="success" />
          <text style="body" size="xs" weight={560} tone="muted">Result</text>
        </div>
      {result.kind === "text" ? <markdown id={`wf-result-${task.id}`} text={result.text} /> : <code text={result.text} language="json" />}
    </panel>
  );
}

export function renderWorkflow(v: ChatView, chat: Chat, t: Transcript, item: TaskItem, pane = false): Element | null {
  const task = item.task;
  const id = `task-${task.id}`;
  const phases = phasesOf(item);
  const open = pane || (t.folds.get(id) ?? isLive(task));
  const logs = task.workflow?.logs ?? [];
  const scriptKey = `wf-script-${task.id}`;
  const logKey = `wf-log-${task.id}`;
  const flip = (key: string) => () => {
    v.controller.toggle(t.expanded, key);
    v.controller.redraw(chat.id);
  };
  // In the chat the card is capped and scrolls; its pane is all of it.
  const capped = (height: number) => (pane ? {} : { maxHeight: height, overflowY: "scroll" });
  const body = open
    ? [
        ...phases.map((phase) => workflowPhase(v, chat, t, item, phase, pane)),
        workflowOutcome(task),
        t.expanded.has(logKey) && logs.length
          ? <panel><code text={logs.join("\n")} language="text" /></panel>
          : null,
        t.expanded.has(scriptKey) && task.prompt
          ? <div {...column} gap="small" padding="small" {...capped(320)}><code text={task.prompt} language="javascript" /></div>
          : null,
      ]
    : [];
  const celebrating = t.finished?.has(task.id);
  return (
    <div {...column} id={`workflow-${task.id}`} padding="small" background={pane ? undefined : "card"} borderRadius="md" {...pane ? null : RAISED} celebrate={celebrating ? { token: `workflow-${task.id}`, onDone: () => t.finished?.delete(task.id) } : undefined}>
      {workflowHeader(v, item, phases, {
                open,
                large: pane,
                onClick: pane
                  ? undefined
                  : () => {
                      t.folds.set(id, !open);
                      v.controller.redraw(chat.id);
                    },
              })}
      {open
                  ? <div {...column} id={`workflow-body-${task.id}`} gap={2} padding="small" paddingX="small" paddingY="small" {...capped(440)}>{body}</div>
                  : null}
      {open
                  ? (
                    <div {...row} gap="small" padding="small" paddingX="medium" paddingY={3}>
                      {task.prompt
                                        ? <button id={`${scriptKey}-button`} icon="file-code" label={t.expanded.has(scriptKey) ? "Hide script" : "Script"} variant="ghost" small onClick={flip(scriptKey)} />
                                        : null}
                      {logs.length ? <button id={`${logKey}-button`} icon="scroll-text" label={`Log · ${logs.length}`} variant="ghost" small onClick={flip(logKey)} /> : null}
                      <spacer />
                      {v.controller.canStopTask(chat) && isLive(task)
                                        ? <button id={`stop-${task.id}`} icon="circle-stop" label="Stop workflow" variant="ghost" small onClick={() => v.ctx.run(v.controller.stopTask(chat, task.id))} />
                                        : null}
                      {pane ? null : <button id={`open-${task.id}`} icon="panel-right" label="Open" variant="ghost" small onClick={() => v.ctx.run(v.controller.openWorkflow(chat, task.id))} />}
                    </div>
                  )
                  : null}
    </div>
  );
}

// A subagent's or a workflow's tab can show while its chat is in no pane on screen and
// nothing read its transcript yet (after a restart, or a reload that carried only some
// rows): the tab reads it and draws again once it is in. Until then a task it cannot find
// yet is not called gone.
function readTranscript(v: ChatView, chatId: string): Transcript {
  const t = v.controller.transcript(chatId);
  if (t.snapshot.kind === "unread" && !t.loading)
    v.ctx.run(v.controller.loadTranscript(chatId, { history: false }).pipe(Effect.andThen(Effect.sync(() => v.controller.refreshSubagentTabs(chatId)))));
  return t;
}

export function renderWorkflowPane(v: ChatView, chatId: string, taskId: string): Element | null {
  const chat = v.controller.state.chats[chatId];
  const t = readTranscript(v, chatId);
  const item = findTask(taskItems(t), taskId);
  if (!chat || !item) return t.snapshot.kind === "unread" ? null : <empty>This workflow is no longer in the chat.</empty>;
  // What its agents wait for, answered here as in the chat.
  const agents = new Set(allTasks(item.items ?? []).map((r) => r.task.id));
  const rows = [renderWorkflow(v, chat, t, item, true)];
  for (const a of t.approvals) if (a.taskId && agents.has(a.taskId)) rows.push(renderApproval(chatId, a));
  for (const q of t.questions) if (q.taskId && agents.has(q.taskId)) rows.push(renderQuestion(v, chatId, t, q));
  return (
    <scroller id={`workflow-${chatId}-${taskId}`}>
      {rows.map((row) => <div {...column} gap="small" padding="small" paddingX="medium" paddingY="small">{row}</div>)}
    </scroller>
  );
}

/** A terminal's row: 1.3 times its mono text, as the kernel's terminal draws its grid. */
const TERMINAL_ROW = "type.monoSize * 1.3";

export function renderSubagentPane(v: ChatView, chatId: string, taskId: string): Element | null {
  const chat = v.controller.state.chats[chatId];
  const t = readTranscript(v, chatId);
  const item = findTask(taskItems(t), taskId);
  if (!chat || !item) return t.snapshot.kind === "unread" ? null : <empty>This subagent is no longer in the chat.</empty>;
  const task = item.task;
  // Read like a terminal pane: the same small inset, the command typed at
  // the prompt as its first line, then the output in the same mono lines,
  // as tall as the terminal's rows, following the end as it grows.
  if (task.kind === "terminal")
    return (
      <scroller id={`terminal-${chatId}-${taskId}`}>
        <div paddingX="small" paddingTop="small" lineHeight={TERMINAL_ROW}><text style="mono" text={`$ ${task.command || task.title}`} /></div>
        {terminalOutput(task.output ?? "").map((line) => <div paddingX="small" lineHeight={TERMINAL_ROW}>{line}</div>)}
        <div height={3.75} />
      </scroller>
    );
  // Read like the chat's own transcript, in its reading column: who it is and how it went, the
  // prompt it was given as the user's message, then its work and its answer.
  const stoppable = v.controller.canStopTask(chat) && isLive(task) && !v.controller.inWorkflow(chatId, task);
  const header = (
    <div {...column} gap={2} paddingY="medium">
      <div {...row} gap="small">
        {agentMark(v, chat)}
        {task.name ? nameChip(task.name) : null}
        <text style="body" {...ROW_TEXT} weight={560} tone="foreground" truncate>{task.title || nameOf(task)}</text>
        <spacer />
        {stoppable ? <button id={`pane-stop-${task.id}`} icon="circle-stop" variant="ghost" small tooltip="Stop subagent" onClick={() => v.ctx.run(v.controller.stopTask(chat, task.id))} /> : null}
        {statusMark(task)}
      </div>
      {taskMeta(task)}
    </div>
  );
  const rows: (Element | null)[] = [
    header,
    task.prompt ? promptBubble(v, t, task) : null,
    ...taskBody(v, chat, t, item),
  ];
  // What this subagent waits for, answered here as in the chat.
  for (const a of t.approvals) if (a.taskId === taskId) rows.push(renderApproval(chatId, a));
  for (const q of t.questions) if (q.taskId === taskId) rows.push(renderQuestion(v, chatId, t, q));
  // While it runs it ends as a running chat does, with how long it has been working.
  if (task.status === "running") rows.push(workingRow(workingFor({ started: task.startedAt ? Date.parse(task.startedAt) : undefined })));
  // The scroller ends one reading inset below its last row, as wide as the inset at its sides.
  return <scroller id={`subagent-${chatId}-${taskId}`}>{rows.map((row) => reading([row]))}<div height={READING_INSET} flexShrink={0} /></scroller>;
}

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.2.9latestNov 21, 2026>=5 <6349 KB5 permissionsListed
0.2.8Nov 16, 2026>=5 <6348.6 KB5 permissionsListed
0.2.7Nov 11, 2026>=5 <6314.3 KB5 permissionsListed
0.2.6Nov 9, 2026>=5 <6306.2 KB5 permissionsListed
0.2.5Oct 27, 2026>=2 <4178.6 KB5 permissionsListed

Reviews and comments

0 threads · 0 reviews

No comments yet.