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.7
Permissions in 0.2.7
Files
views/composer.tsx31.1 KB
// Composer rendering preserves the chat's retained tree and interaction keys.
import * as Effect from "effect/Effect";
import { entries, highlighted, pillOf, segmentsOf } from "../picker.ts";
import { segmentId } from "../segments.ts";
import type { FieldChange } from "../composer.ts";
import { keywordsIn } from "../workflows.ts";
import type { Element, Chat, ConfigOption, ValueEvent, DropEvent, KeyEvent, PasteEvent, SubmitEvent } from "divergence";
import type { Composer, AnchorProps } from "../state.ts";
import type { ChatView } from "../controller.ts";
type PromptChange = ValueEvent<string> & FieldChange;
import {
HOVER,
FIELD_INSET_X,
PILL_INSET_X,
column,
row,
fill,
full,
centred,
BORDER,
EDGE_WIDTH,
corner,
headlineAnchor,
chipAnchor,
markOf,
RAISED,
} from "./styles.tsx";
import { usageMeter, contextMeter } from "./usage.tsx";
import { renderLimit, renderPending } from "./pending.tsx";
import { steeringReason } from "../composition.ts";
import { acceptPicked, pickerKey } from "../composer.ts";
import { historyKeys, recallPrompt } from "../history.ts";
import { hint, promptHint } from "../shortcuts.ts";
import { allTasks, isLive } from "../subagents.ts";
import { measureRoom, roomOf } from "./room.tsx";
/**
* The composer's own keys. An open picker moves with up and down, closes with Escape and takes its
* highlighted entry with Tab (Enter in onSubmit); without one, up and down can go through the
* chat's earlier prompts (`history.ts`). The prompt hands those keys over (`prompt`), since it would
* act on them itself first; for history only from its first line (Up) or last line (Down)
* (`edges`), so the arrows still move the caret through a recalled prompt of several lines. `around`
* hears the keys pressed elsewhere in the composer.
*/
function composerKeys(v: ChatView, chatId: string, picking: boolean) {
const around = (event: KeyEvent) => {
if (event.modifiers.meta || event.modifiers.ctrl || event.modifiers.alt || event.modifiers.shift) return;
if (event.key === "tab") v.ctx.run(acceptPicked(v.controller, chatId, false));
else pickerKey(v.controller, chatId, event.key);
};
const onPrompt = (event: KeyEvent) => {
if (!picking && (event.key === "up" || event.key === "down")) v.ctx.run(recallPrompt(v.controller, chatId, event.key));
else around(event);
};
return { prompt: picking ? ["up", "down", "tab", "escape"] : historyKeys(v.controller, chatId), edges: !picking, onPrompt, around };
}
// The composer footer's width per chat, from the probe under its pills.
const footerWidths = new Map<string, number>();
// The footer gives way in steps as it narrows: under 560px the agent and approval pills show
// only their marks; under 440px the model's does too and the meters show only their rings; under
// 340px the pickers leave out their chevrons.
const ICONS_ONLY_BELOW = 560;
const MODEL_ICON_BELOW = 440;
const BARE_BELOW = 340;
/** How far the footer at `width` has given way, 0 to 3. */
const footerStep = (width: number) => [ICONS_ONLY_BELOW, MODEL_ICON_BELOW, BARE_BELOW].filter((below) => width < below).length;
// The approval levels every agent publishes (plugins/sdk/agent.ts), drawn
// as marks when their pill has no room for a label.
const APPROVAL_ICONS: Record<string, string> = {
supervised: "shield-check",
auto_edits: "file-pen",
auto: "shield-half",
full: "shield-off",
};
// The picker floats over the transcript from the prompt box's left edge,
// one row per entry.
const PICKER_WIDTH = 400;
/// The picker's rows for its word, or a line that says why there are
/// none; nothing while there is nothing to say yet (the first file search
/// has not answered, no skill matches a `$` that may be plain text).
export function renderPicker(v: ChatView, chatId: string, c: Composer): Element | null {
const picker = c.picker;
if (!picker) return null;
const listed = entries(v.controller, c);
const selected = highlighted(c, listed.length);
const rows = listed.map(
(entry, index) => (
<div {...row} id={entry.id} gap={7} paddingX={8} height={26} borderRadius={6} background={index === selected ? "accent" : undefined} hover={index === selected ? undefined : HOVER} onClick={() => v.ctx.run(v.controller.acceptEntry(chatId, entry))}>
<icon name={entry.icon ?? "file"} small tone="muted" file={entry.file} />
<div minWidth={0} maxWidth="65%" flexShrink={0}><text style="body" size={12.5} weight={500} truncate text={entry.label} /></div>
{entry.detail ? <div {...fill}><text style="body" size="xs" tone="muted" truncate text={entry.detail} /></div> : null}
</div>
),
);
const note =
picker.kind === "files" && c.filesFor === picker.query && !listed.length
? (c.filesError ?? (picker.query ? "No matching files" : "No files in this workspace"))
: null;
if (!rows.length && !note) return null;
return (
<div {...column} id={`picker-${chatId}`} gap={1} padding={4} background="card/40" backdrop={{ blur: 6 }} borderRadius="md" {...RAISED}>
{rows.length ? rows : (
<div {...row} paddingX={8} height={26}>
<text style="body" size="xs" tone={c.filesError ? "danger" : "muted"} text={note} />
</div>
)}
</div>
);
}
// A pill ellipsizes past its width; the model's names a model and its
// reasoning, so it gets more room than one value.
const compact = (select: Element | null, maxWidth = 220) =>
<div {...row} gap="small" padding="small" maxWidth={maxWidth} minWidth={0} flexShrink={1}>{select}</div>;
// A strip over or under the prompt box: a keyword, a queued prompt.
const strip = (...children: (Element | null)[]) =>
<div {...row} gap="small" padding="small" paddingX={FIELD_INSET_X} paddingY="small" background="muted" borderRadius="md">{children}</div>;
// The footer's pills: the agent, the model menu and the approval.
// `locked` holds the agent while the chat works, prepares or sends.
function footerPills(v: ChatView, chat: Chat, c: Composer, step: number, locked: boolean): Element[] {
const chatId = chat.id;
const enabled = v.controller.state.agentList.map((a) => ({ value: a.id, label: a.name, svg: a.icon }));
const pills: Element[] = [];
// An established conversation changes native attachments, not chat identity.
// Older Alpha hosts keep their original label after the first prompt.
const fresh = !chat.sessionId && !v.controller.transcript(chatId).items.length;
const policyUnavailable = !fresh && !v.controller.canHandoff();
const iconsOnly = step >= 1;
const chevron = step >= 3 ? false : undefined;
if ((fresh || v.controller.drafts.available === true) && enabled.length) {
const tooltip = locked
? "Finish current work before changing agents"
: policyUnavailable
? "Select an available conversation policy to change agents"
: "Continue this conversation with another agent";
const current = enabled.find((agent) => agent.value === chat.agentId);
pills.push(
compact(
iconsOnly && current?.svg
? <combobox id={`agent-${chatId}`} look="toolbar" value={chat.agentId} label="" marks={[{ svg: current.svg }]} chevron={chevron} options={enabled} disabled={locked || policyUnavailable} tooltip={`${current.label}: ${tooltip}`} onChange={(e: ValueEvent<string>) => v.ctx.run(v.controller.changeAgent(chatId, e.value))} />
: <select id={`agent-${chatId}`} value={chat.agentId} placeholder="Choose an agent" small ghost options={enabled} disabled={locked || policyUnavailable} tooltip={tooltip} onChange={(e: ValueEvent<string>) => v.ctx.run(v.controller.changeAgent(chatId, e.value))} />,
),
);
} else {
pills.push(
(
<div {...row} gap="medium" padding="small" paddingX={PILL_INSET_X}>
<icon name="bot" small tone="muted" svg={v.controller.state.agents[chat.agentId]?.icon} />
<text style="body" size={12.2} weight={500} tone="muted" text={String(v.controller.state.agents[chat.agentId]?.name ?? chat.agentId ?? "")} />
</div>
),
);
}
// Model, mode, effort, speed and the other settings share one menu;
// approval (what the agent may do unasked) stays its own pill.
const options = v.controller.visibleOptions(c);
const alone = (o: ConfigOption) => o.category === "approval";
const model = options.find((o) => o.category === "model");
const together = options.filter((o) => o !== model && !alone(o));
if (model || together.length) pills.push(compact(v.controller.renderModelPicker(v, chat, model, together, step >= 3 ? "bare" : step >= 2 ? "icon" : "label"), 340));
for (const option of options.filter(alone)) {
const choices = (option.choices ?? []).map((ch) => ({ value: ch.value, label: ch.name, svg: ch.icon }));
const chosen = (option.choices ?? []).find((ch) => ch.value === option.value);
const mark = chosen?.icon ? { svg: chosen.icon } : { icon: APPROVAL_ICONS[String(option.value)] ?? "shield" };
pills.push(
compact(
iconsOnly && chosen
? <combobox id={`opt-${chatId}-${option.id}`} look="toolbar" value={String(option.value ?? "")} label="" marks={[mark]} chevron={chevron} options={choices} tooltip={`${option.name}: ${chosen.name}`} onChange={(e: ValueEvent<string>) => v.ctx.run(v.controller.setOption(chatId, option.id, e.value))} />
: <select id={`opt-${chatId}-${option.id}`} value={String(option.value ?? "")} placeholder={option.name} small ghost options={choices} onChange={(e: ValueEvent<string>) => v.ctx.run(v.controller.setOption(chatId, option.id, e.value))} />,
),
);
}
return pills;
}
// Stop, Send, Send held back and the preparing spinner in one spot.
function actionControl(v: ChatView, chatId: string, shown: string, send: Element): Element {
// The button's look alone, with nothing to press or focus.
const look = (icon: string, background: string, color: string, raised = false) =>
<div display="flex" alignItems="center" justifyContent="center" width="1.5rem" height="1.5rem" borderRadius="field" background={background} color={color} {...raised ? RAISED : {}}><icon name={icon} small /></div>;
// Stop, Send, Send held back and the preparing spinner share one spot
// and cross-fade as the chat moves between them. Only the one showing is
// the real control; the others are its look alone, fading out under it.
// A layer starts at the opacity it ends at, so a chat opened in any state
// shows it at once.
const layers: [string, Element, Element | null][] = [
[
"stop",
<button id={`stop-${chatId}`} icon="square" variant="danger" small tooltip={hint(v.controller, "Stop the run and pause the queued prompts", "chat.cancel")} onClick={() => v.ctx.run(v.controller.scheduler.stop(chatId))} />,
look("square", "danger", "dangerForeground", true),
],
["send", send, look("corner-down-left", "primary", "primaryForeground")],
["held", send, look("corner-down-left", "primary/15", "mutedForeground/50")],
[
"preparing",
(
<div {...row} id={`send-preparing-${chatId}`} gap="small" padding="small">
<spinner />
</div>
),
null,
],
];
const control = (
<div position="relative">
{layers.map(([key, real, faded]) => {
const on = key === shown;
return <div {...row} id={`action-${key}-${chatId}`} {...on ? {} : { position: "absolute", top: 0, right: 0, bottom: 0 }} opacity={on ? 1 : 0} motion={{ to: { opacity: on ? 1 : 0 }, duration: 150 }}>{on ? real : faded}</div>;
})}
</div>
);
return control;
}
function attachmentChips(v: ChatView, chatId: string, c: Composer): Element | null {
// Images waiting to go with the prompt, each with the thumbnail the
// kernel draws from the bytes it is holding.
// An image chip sits a medium inset from the prompt box's top and left,
// as the send button does from its top and right, so it shares the box's
// `xl` corner centre: the field corner. Its thumbnail is concentric with
// the default theme's field corner (8px) in turn.
const CHIP_RADIUS = corner("field", 8);
return c.attachments.length
? (
<div {...row} gap="small" padding="medium" flexWrap="wrap">
{c.attachments.map(
(image) =>
(
<div {...row} gap="small" padding={4} maxWidth={240} background="subtle" borderRadius={CHIP_RADIUS} {...RAISED}>
<image id={image.id} width={36} height={36} radius={8 - 4 - EDGE_WIDTH} />
<div {...column} {...fill} paddingX="small">
<text style="body" size="xs" truncate text={String(image.name ?? "")} />
<text style="body" size="xs" tone="muted">{`${Math.max(1, Math.round(image.bytes / 1024))} KB`}</text>
</div>
<div alignSelf="start">
<button id={`attach-drop-${chatId}-${image.id}`} icon="x" variant="ghost" small tooltip={`Remove ${image.name}`} onClick={() => v.ctx.run(v.controller.removeAttachment(chatId, image.id))} />
</div>
</div>
),
)}
</div>
)
: null;
}
/** What a prompt without text holds: "1 image", "3 images". */
const images = (count: number) => (count === 1 ? "1 image" : `${count} images`);
// What the prompt box says above itself: a failed sync, preparing,
// history delivery, why Send waits, submitting and input to restore.
function notices(v: ChatView, chat: Chat, c: Composer, typed: boolean): (Element | Element[] | null | undefined)[] {
const chatId = chat.id;
const snapshot = v.controller.scheduler.snapshots[chatId];
const reason = steeringReason(v.controller, chat);
return [
c.syncError && !c.syncing
? strip(
<icon name="triangle-alert" small tone="warning" />,
<text size="xs" tone="warning">{c.syncError}</text>,
<spacer />,
(
<button id={`sync-dismiss-${chatId}`} icon="x" variant="ghost" small tooltip="Dismiss" onClick={() => {
c.syncError = undefined;
v.controller.refresh(chatId);
}} />
),
)
: null,
c.preparing ? strip(<spinner />, <text size="xs" tone="muted">Preparing conversation · no prompt is being sent</text>) : null,
snapshot?.context && ["pending", "dispatching", "delivery_unknown"].includes(snapshot.context.state) ? strip(<icon name="rotate-ccw" small tone="muted" />, (
<text size="xs" tone={snapshot.context.state === "delivery_unknown" ? "warning" : "muted"}>
{snapshot.context.state === "pending" ? "History prepared · delivered with your next Send" : snapshot.context.state === "delivery_unknown" ? "History delivery is unknown · Send is blocked until you edit or revert an earlier message" : "History delivery in progress"}
</text>
)) : null,
reason ? <text style="body" size="xs" tone="muted">{reason}</text> : null,
c.submitting && !c.error && !c.dispatching && !c.outgoing?.preview && !c.outgoing?.intent ? <div {...row} gap="small"><spinner /><text tone="muted" size="xs">Submitting…</text></div> : null,
c.recovered?.map(
(recovered) => (
<div {...column} gap="small" padding="small" background="muted" borderRadius="md">
<text size="xs">{recovered.text || images(recovered.attachments.length + (recovered.carriedBlocks?.filter((block) => block.type === "image").length ?? 0))}</text>
<button id={`recover-${recovered.submission.id}`} label="Restore prompt" small disabled={typed || c.submitting} onClick={() => {
c.text = recovered.text;
c.attachments = recovered.attachments;
c.carriedBlocks = recovered.carriedBlocks;
c.submission = recovered.submission;
c.recovered = c.recovered?.filter((input) => input !== recovered);
v.ctx.run(v.controller.onChange(chatId, c.text));
v.ctx.run(v.controller.drafts.holdImages(chatId));
v.ctx.update();
}} />
</div>
),
),
v.controller.scheduler.available === false && c.queue.length ? (
<text style="body" size="xs" tone="muted">
Follow-ups are retained. Automatic release and active steering require an updated app.
</text>
) : null,
];
}
export function renderComposer(v: ChatView, chat: Chat): Element | null {
const chatId = chat.id;
v.ctx.run(v.controller.ensureComposer(chatId));
const c = v.controller.composer(chatId);
const running = v.controller.isRunning(chat);
const preparing = !!c.preparing || v.controller.drafts.loading.has(chatId);
const snapshot = v.controller.scheduler.snapshots[chatId];
// The host is resuming this chat's session: Send waits, typing does not.
const resuming = !!snapshot?.preparing;
const busy =
running || snapshot?.settling || allTasks(v.controller.transcript(chatId).items).some((row) => isLive(row.task));
const reason = steeringReason(v.controller, chat);
const supportedSimulation = running && v.controller.state.agents[chat.agentId]?.capabilities?.simulatedSteer;
// A narrow footer keeps every pill on its one line: the agent and the
// approval give up their labels for their marks first (the label is the
// tooltip then), the model's ellipsizes.
const step = footerStep(footerWidths.get(chatId) ?? Infinity);
const pills = footerPills(v, chat, c, step, !!busy || preparing || !!c.submitting);
const queuedChat = v.controller.state.chatQueue.find((q) => q.chatId === chatId);
// A word the agent reacts to (one of its `promptKeywords`) says what it
// will do with this prompt while it is in the text.
const keywords = keywordsIn(c.text, v.controller.state.agents[chat.agentId]?.promptKeywords).map((keyword) => strip(...keywordStrip(keyword)));
const attach = <button id={`attach-${chatId}`} icon="paperclip" variant="ghost" small tooltip="Attach an image" onClick={() => v.ctx.run(v.controller.pickAttachments(chatId))} />;
// A draft queues the chat, a started chat its prompts. While the agent
// works, what was typed turns Stop into Send, which steers; while it
// cannot steer (`reason`), Stop stays.
const draft = v.controller.isDraft(chat);
const typed = !!c.text.trim() || c.attachments.length > 0 || !!c.carriedBlocks?.length;
const held = !!reason || c.loading || c.submitting || preparing;
const shown = running && (!typed || reason) ? "stop" : resuming ? "preparing" : held ? "held" : "send";
const send = <button id={`send-${chatId}`} icon="corner-down-left" variant="primary" small disabled={held} tooltip={reason ?? promptHint(v.controller, supportedSimulation ? "Interrupt tools, settle and send in the same session" : running ? "Steer ongoing work" : "Send", "send")} onClick={() => v.ctx.run(v.controller.send(chatId))} />;
const control = actionControl(v, chatId, shown, send);
// Pinned to the card's bottom right, as far from its bottom as from its
// side, however many lines the prompt has.
const action = (
<div {...row} gap="small" padding="medium" alignSelf="end">
{attach}
{draft
? queuedChat
? null
: <button id={`queue-chat-${chatId}`} icon="list-plus" variant="ghost" small tooltip={promptHint(v.controller, "Queue this chat to start when no other chat runs", "queue")} onClick={() => v.ctx.run(v.controller.queueChat(chatId))} />
: <button id={`queue-${chatId}`} icon="list-plus" variant="ghost" small disabled={c.loading || c.submitting || preparing || resuming} tooltip={promptHint(v.controller, "Hold this prompt in the queue, even while the chat is idle", "queue")} onClick={() => v.ctx.run(v.controller.queuePrompt(chatId))} />}
{control}
</div>
);
const queued = [
...c.queue.map(({ text, attachments, blocks }, i) =>
strip(
<icon name="list-plus" small tone="muted" />,
(
<text style="body" size="xs" tone="muted">
{`Held on older app · ${text || images(blocks?.filter((block) => block.type === "image").length ?? attachments.length)}`}
</text>
),
<spacer />,
<button id={`drop-${chatId}-${i}`} icon="x" variant="ghost" small tooltip="Remove" onClick={() => v.ctx.run(v.controller.dropQueuedPrompt(chatId, i))} />,
),
),
];
const attachments = attachmentChips(v, chatId, c);
const picker = renderPicker(v, chatId, c);
const keys = composerKeys(v, chatId, !!picker);
const segments = segmentsOf(v.controller, c);
const tokens = segments.map((segment) => ({
id: segmentId(c.text, segment),
start: segment.start,
end: segment.end,
...pillOf(v.controller, c, segment),
}));
// Images dropped from Finder or a browser, and images pasted into the
// prompt, become attachments; other files become @ mentions. Typing
// with nothing focused lands in the prompt.
return (
<div {...column} id={`composer-${chatId}`} gap="small" padding="small" paddingBottom={0} position="relative" onKeyDown={keys.around} drop={{ files: true, onDrop: (event: DropEvent) => v.ctx.run(v.controller.attachFiles(chatId, "paths" in event ? event.paths : [])) }} onPaste={(event: PasteEvent) => v.ctx.run(v.controller.onPasteFiles(chatId, event))}>
{keywords}
{queued}
{renderLimit(v, chat)}
{notices(v, chat, c, typed)}
<div {...column}>
{renderPending(v, chat)}
<popover id={`picker-at-${chatId}`} open={!!picker} align="start" width={PICKER_WIDTH} onDismiss={() => v.ctx.run(Effect.sync(() => pickerKey(v.controller, chatId, "escape")))}>
<div {...column} background="card/40" backdrop={{ blur: 6 }} borderRadius="xl" {...RAISED}>
{attachments}
{(c.carriedBlocks ?? []).map((block, index) =>
strip(
<icon name={block.type === "image" ? "image" : "paperclip"} small tone="muted" />,
(
<text size="xs" tone="muted">
{block.type === "image" || block.type === "audio" ? `${block.type} · ${block.mimeType}` : block.type === "file_ref" || block.type === "resource" ? block.path : block.type === "skill" ? `$${block.name}` : "Attachment"}
</text>
),
<spacer />,
(
<button id={`carried-drop-${chatId}-${index}`} icon="x" small variant="ghost" disabled={preparing} tooltip="Remove attachment" onClick={() => {
c.carriedBlocks = c.carriedBlocks?.filter((_, at) => at !== index);
v.ctx.run(v.controller.textChanged(chatId));
v.ctx.update();
}} />
),
),
)}
<div {...row}>
<div {...column} {...fill} gap="small" padding="small" paddingY={0}>
<input id={`prompt-${chatId}`} value={c.text} multiline ghost submitOnEnter catchTyping={v.controller.state.mainPrompt === chatId} keys={keys.prompt} arrowsAtEdges={keys.edges} onKey={keys.onPrompt} tokens={tokens} caret={c.place?.text === c.text ? c.place.at : undefined} placeholder={`${v.controller.api.mentions.list().length ? "@ files and agents" : "@ files"}, / commands${c.skills.length ? ", $ skills" : ""}`} onChange={(e: PromptChange) => v.ctx.run(v.controller.onChange(chatId, e.value, e))} onSubmit={(event?: SubmitEvent) => v.ctx.run(v.controller.onSubmit(chatId, event))} />
</div>
{action}
</div>
</div>
{picker}
</popover>
</div>
<div {...row} gap="small" paddingTop={0} paddingBottom="small" position="relative">
<canvas id={`toolbar-${chatId}`} position="absolute" left={0} right={0} top={0} height={1} onResize={({ width }: { width: number }) => {
const before = footerStep(footerWidths.get(chatId) ?? Infinity);
footerWidths.set(chatId, width);
if (before !== footerStep(width)) v.controller.refreshComposer(chatId);
}} />
<div {...row} {...fill} gap="small" minWidth={0} overflow="hidden">{pills}</div>
{usageMeter(v, chat, step >= 2)}
{contextMeter(v, chat, step >= 2)}
</div>
</div>
);
}
export function workspacePicker(
v: ChatView,
chat: Chat,
place: string,
anchor: (props: AnchorProps) => Element,
): Element | null {
const id = `ws-${place}-${chat.id}`;
const list = Object.values(v.controller.state.workspaces);
// A draft's picker opens with a single workspace too: it can add a folder.
const can = !chat.sessionId;
const current = v.controller.state.workspaces[chat.workspaceId];
const trigger = anchor({ name: current?.name ?? "this workspace", mark: markOf(current), can });
if (!can) return trigger;
return (
<combobox id={id} look="toolbar" value={chat.workspaceId} width={320} options={list.map((w) => ({ value: w.id, label: w.name, description: w.path, ...markOf(w) }))} actions={[{ label: "Add workspace folder…", icon: "folder-plus", onClick: () => v.ctx.run(v.controller.moveDraftToNewWorkspace(chat)) }]} onChange={(e: { value?: string }) => {
if (e.value && e.value !== chat.workspaceId) v.ctx.run(v.controller.moveDraft(chat, e.value));
}}>{trigger}</combobox>
);
}
// A queued draft says so on the right of the workspace chip; the prompt
// below stays editable until the queue sends it.
function queuedBadge(v: ChatView, chat: Chat): Element[] | null {
const index = v.controller.state.chatQueue.findIndex((queued) => queued.chatId === chat.id);
if (index < 0) return null;
const total = v.controller.state.chatQueue.length;
return [
<spacer />,
(
<div {...row} gap="small" paddingX={PILL_INSET_X}>
<icon name="list-plus" small tone="info" />
<text style="body" size="xs" weight={500} tone="muted" text={total > 1 ? `Queued · ${index + 1} of ${total}` : "Queued"} />
<button id={`unqueue-${chat.id}`} icon="x" variant="ghost" small tooltip="Remove from the queue" onClick={() => v.ctx.run(v.controller.unqueueChat(chat.id))} />
</div>
),
];
}
// How the new chat page's stage looks: its animated background, or
// without one the transcript's flat background under the same still grain.
export function stageLook(v: ChatView): { ambient: string; grain: boolean } {
const background = v.controller.api.settings.get("landingBackground");
const ambient = background === "fog" || background === "contours" || background === "off" ? background : "caustics";
return { ambient, grain: ambient === "off" && v.controller.api.settings.get("transcriptGrain") === true };
}
// The prompt box. When the first prompt goes it travels from the centre of
// the new chat page to the foot of the transcript, taking the new width on
// the way, with the page's headline and chip riding above it as they fade.
export function dock(chat: Chat, composer: Element | null, above: (Element | null)[] = []): Element {
return <div {...column} id={`dock-${chat.id}`} travels position="relative">{above}{composer}</div>;
}
// Where the sent text starts its rise into its message: the message's
// corner when its text lies over the prompt's (the prompt's text sits
// 17.5px by 11.75px into the box, a message's 11px by 7.5px).
export const risingFrom = (chat: Chat) =>
<div id={`rising-${chat.id}`} travels position="absolute" left={6.5} top={4.25} />;
const HEADLINE = { fontSize: "1.875rem", bold: false, weight: 500, fontFamily: "Bricolage Grotesque" } as const;
const NARROW_HEADLINE = { ...HEADLINE, fontSize: "1.5rem" } as const;
// One text per word, so a narrow pane wraps the question between its words; "in" stays with the
// workspace, which its picker's own padding sets apart.
const QUESTION = ["What", "should", "we", "do"];
export function landingHeadline(v: ChatView, chat: Chat, motion?: object): Element {
const headline = roomOf(chat.id).tight ? NARROW_HEADLINE : HEADLINE;
// The question wraps between its words and the workspace when the pane is narrow; the workspace
// keeps its question mark.
return (
<div {...row} id={`landing-headline-${chat.id}`} travels motion={motion} flexWrap="wrap" columnGap={headline === HEADLINE ? 7.5 : 6} padding="small" justifyContent="center" maxWidth="100%">
{QUESTION.map((word) => <text style="body" {...headline}>{word}</text>)}
<div {...row} gap={0}>
<text style="body" {...headline}>in</text>
{workspacePicker(v, chat, "landing", headlineAnchor(headline))}
<text style="body" {...headline}>{"?"}</text>
</div>
</div>
);
}
// The chip is the same picker, not a label: it sits where the eye is
// already going, so it has to answer a press like the headline.
export function landingChips(v: ChatView, chat: Chat, motion?: object): Element {
return <div {...row} id={`landing-chip-${chat.id}`} travels motion={motion} alignSelf="stretch" gap="small" padding="small">{workspacePicker(v, chat, "chip", chipAnchor)}{queuedBadge(v, chat)}</div>;
}
/** The top of the landing's stage, where the moving background fades into the pane's surface, so
* it meets the pane's tab, which is that surface, with no line. */
export function stageTop(): Element {
return <div position="absolute" left={0} right={0} top={0} height={72} background={{ linearGradient: { angle: 180, stops: [["background", 0], ["background/0", 1]] } }} />;
}
export function renderLanding(v: ChatView, chat: Chat, composer = renderComposer(v, chat)): Element | null {
const { ambient, grain } = stageLook(v);
const { compact } = roomOf(chat.id);
return (
<div {...column} {...fill} {...full} id="landing-stage" gap={compact ? "small" : "large"} padding={compact ? "small" : "large"} alignItems="center" justifyContent="center" background={grain ? undefined : "stage"} grain={grain} ambient={ambient}>
{measureRoom(v, chat.id)}
{stageTop()}
{landingHeadline(v, chat)}
<div {...column} {...centred} gap="small" padding={compact ? 0 : "small"} maxWidth={768}>{landingChips(v, chat)}{dock(chat, composer, [risingFrom(chat)])}</div>
</div>
);
}
/** What a keyword's strip says: its mark, its label and what it does. */
function keywordStrip(keyword: { label: string; description?: string | null }): (Element | null)[] {
return [
<icon name="workflow" small tone="primary" />,
<text style="body" size="xs" weight={600} tone="primary">{keyword.label}</text>,
keyword.description ? <text style="body" size="xs" tone="muted" truncate>{keyword.description}</text> : null,
];
}Versions
| Version | Published | Plugin API | Size | Permissions | Status |
|---|---|---|---|---|---|
| 0.2.9latest | Nov 21, 2026 | >=5 <6 | 349 KB | 5 permissions | Listed |
| 0.2.8 | Nov 16, 2026 | >=5 <6 | 348.6 KB | 5 permissions | Listed |
| 0.2.7 | Nov 11, 2026 | >=5 <6 | 314.3 KB | 5 permissions | Listed |
| 0.2.6 | Nov 9, 2026 | >=5 <6 | 306.2 KB | 5 permissions | Listed |
| 0.2.5 | Oct 27, 2026 | >=2 <4 | 178.6 KB | 5 permissions | Listed |
No comments yet.