Skip to content

Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.

C++

UI round 7: /plan card, Plan sidebar tab with step states, queued messages with cancel, floating round arrow, plain Privacy without a box

Niko122183c8f0b1208d
diff --git a/apps/host/src/components/PlanCard.tsx b/apps/host/src/components/PlanCard.tsx
new file mode 100644
index 000000000..73cf67ae7
--- /dev/null
+++ b/apps/host/src/components/PlanCard.tsx
@@ -0,0 +1,83 @@
+import { useEffect, useState } from 'react';
+import { tr } from '../lib/i18n';
+import { cancelQueued, planAction, queuedWhen, stepsDone, usePlan, useQueue, type Plan, type QueuedMessage } from '../lib/plan';
+import { pushToast } from '../lib/store';
+import { plainFailureText } from '../lib/plain-errors';
+import { Btn, Icon, IconBtn } from './ui';
+
+/** The steps with their state: a number, a check once done, a soft glow on the one being worked on. Used in the chat and in the sidebar. */
+export function PlanSteps({ plan }: { plan: Plan }) {
+ return <ol className="plan__steps">
+ {plan.steps.map((s, i) => <li key={s.id} className="plan__step" data-state={s.state}>
+ <span className="plan__no" aria-hidden="true">{s.state === 'done' ? <Icon name="check" size={12}/> : s.state === 'failed' ? <Icon name="x" size={12}/> : i + 1}</span>
+ <span className="plan__text">{s.text}{s.note ? <small>{s.note}</small> : null}<span className="sr-only"> ({tr(s.state === 'done' ? 'done' : s.state === 'active' ? 'working on it' : s.state === 'failed' ? 'failed' : 'waiting')})</span></span>
+ </li>)}
+ </ol>;
+}
+
+/** The /plan the assistant proposed, in the chat: Approve, Edit, Reject, or Start as goal. Nothing runs until the person decides. */
+export function PlanCard({ chatId }: { chatId: string | null | undefined }) {
+ const plan = usePlan(chatId);
+ const [editing, setEditing] = useState(false), [draft, setDraft] = useState<string[]>([]), [busy, setBusy] = useState(false);
+ useEffect(() => { setEditing(false); }, [chatId, plan?.id]);
+ if (!chatId || !plan || plan.state === 'rejected') return null;
+ const run = async (fn: () => Promise<unknown>) => {
+ setBusy(true);
+ try { await fn(); }
+ catch (e) { pushToast('error', tr("The plan was not changed"), plainFailureText(e instanceof Error ? e.message : String(e)).message); }
+ finally { setBusy(false); }
+ };
+ const proposed = plan.state === 'proposed';
+ if (editing) return <section className="plan" aria-label={tr("Edit the plan")}>
+ <div className="plan__head"><b>{tr("Edit the plan")}</b></div>
+ <div className="plan__edit">
+ {draft.map((text, i) => <div className="plan__row" key={i}>
+ <span className="plan__no" aria-hidden="true">{i + 1}</span>
+ <input className="st-input" value={text} aria-label={tr("Step {0}", [i + 1])} onChange={e => setDraft(d => d.map((t, j) => j === i ? e.target.value : t))}/>
+ <IconBtn name="x" size={15} title={tr("Remove this step")} disabled={draft.length < 2} onClick={() => setDraft(d => d.filter((_, j) => j !== i))}/>
+ </div>)}
+ <Btn size="sm" icon="plus" onClick={() => setDraft(d => [...d, ''])}>{tr("Add a step")}</Btn>
+ </div>
+ <div className="plan__acts">
+ <Btn size="sm" variant="primary" disabled={busy || !draft.some(t => t.trim())} onClick={() => void run(async () => { await planAction(chatId, 'edit', draft.map(t => t.trim()).filter(Boolean)); setEditing(false); })}>{tr("Save plan")}</Btn>
+ <Btn size="sm" onClick={() => setEditing(false)}>{tr("Cancel")}</Btn>
+ </div>
+ </section>;
+ return <section className="plan" data-state={plan.state} aria-label={tr("Plan")}>
+ <div className="plan__head"><b>{tr("Plan")}</b><span>{plan.state === 'proposed' ? tr('{0} steps', [plan.steps.length]) : tr('{0} of {1} done', [stepsDone(plan), plan.steps.length])}</span></div>
+ <PlanSteps plan={plan}/>
+ {proposed ? <p className="plan__note">{tr("Nothing runs until you approve.")}</p> : null}
+ {proposed ? <div className="plan__acts">
+ <Btn size="sm" variant="primary" icon="check" disabled={busy} onClick={() => void run(() => planAction(chatId, 'approve'))}>{tr("Approve")}</Btn>
+ <Btn size="sm" icon="pencil" disabled={busy} onClick={() => { setDraft(plan.steps.map(s => s.text)); setEditing(true); }}>{tr("Edit")}</Btn>
+ <Btn size="sm" disabled={busy} onClick={() => void run(() => planAction(chatId, 'reject'))}>{tr("Reject")}</Btn>
+ <span className="plan__sp"/>
+ <Btn size="sm" icon="bolt" disabled={busy} onClick={() => void run(() => planAction(chatId, 'start-goal'))}>{tr("Start as goal")}</Btn>
+ </div> : null}
+ </section>;
+}
+
+/** The same steps in the sidebar, so they stay in view while the goal runs. */
+export function PlanPanel({ chatId }: { chatId: string | null | undefined }) {
+ const plan = usePlan(chatId);
+ if (!plan) return <aside className="ts-panel plan-panel" id="plan-content" aria-label={tr("Plan")}><p className="ts-empty">{tr("There is no plan in this chat.")}</p></aside>;
+ return <aside className="ts-panel plan-panel" id="plan-content" aria-label={tr("Plan")}>
+ <div className="plan__head"><b>{tr("Plan")}</b><span>{tr('{0} of {1} done', [stepsDone(plan), plan.steps.length])}</span></div>
+ {plan.goal ? <p className="plan__goal">{plan.goal}</p> : null}
+ <PlanSteps plan={plan}/>
+ </aside>;
+}
+
+/** Messages sent while the assistant works: shown in the chat as they are, with when they will go out, and a way to take them back. */
+export function QueuedMessages({ chatId }: { chatId: string | null | undefined }) {
+ const items = useQueue(chatId), plan = usePlan(chatId);
+ if (!chatId || !items.length) return null;
+ return <>{items.map((q: QueuedMessage) => {
+ const when = queuedWhen(q, plan);
+ return <div className="queued" key={q.id}>
+ <div className="queued__bubble">{q.text}</div>
+ <div className="queued__line"><span>{tr(when.id, when.args)}</span>
+ <button type="button" className="queued__x" title={tr("Cancel this message")} aria-label={tr("Cancel this message")} onClick={() => void cancelQueued(chatId, q.id).catch(e => pushToast('error', tr("The message was not cancelled"), plainFailureText(e instanceof Error ? e.message : String(e)).message))}><Icon name="x" size={13}/></button></div>
+ </div>;
+ })}</>;
+}
diff --git a/apps/host/src/lib/client.ts b/apps/host/src/lib/client.ts
index 2748e0b20..7dd3f1caa 100644
--- a/apps/host/src/lib/client.ts
+++ b/apps/host/src/lib/client.ts
@@ -47,7 +47,7 @@ export interface StreamEvent {
export function onEvent(handler: (e: StreamEvent) => void, onStatus?: (s: 'live' | 'offline') => void) {
let source: EventSource;
let seenAt = Date.now();
- const names = ['engine', 'monitor', 'models', 'image-models', 'runtime', 'providers', 'serving', 'download', 'log', 'setup', 'skills', 'task', 'goal', 'timeskip'];
+ const names = ['engine', 'monitor', 'models', 'image-models', 'runtime', 'providers', 'serving', 'download', 'log', 'setup', 'skills', 'task', 'goal', 'timeskip', 'plan', 'queue'];
const connect = () => {
source?.close();
seenAt = Date.now();
diff --git a/apps/host/src/lib/plan.ts b/apps/host/src/lib/plan.ts
new file mode 100644
index 000000000..ca6e7340b
--- /dev/null
+++ b/apps/host/src/lib/plan.ts
@@ -0,0 +1,112 @@
+import { useEffect, useSyncExternalStore } from 'react';
+import { api } from './client';
+
+/**
+ * A chat's /plan and its queued messages as the host reports them (contract in notes-split-agent6.md and notes-split-ui5.md). Both arrive as
+ * whole snapshots, in the chat stream as {type:'plan', plan} and {type:'queue', items}, and as events {type:'plan'|'queue', chatId, ...}.
+ * A snapshot replaces what was there; null or an empty list clears it. The host owns both; every button asks it and draws the answer.
+ */
+export type PlanState = 'proposed' | 'approved' | 'running' | 'done' | 'rejected';
+export type StepState = 'pending' | 'active' | 'done' | 'failed';
+export interface PlanStep { id: string; text: string; note?: string; state: StepState }
+export interface Plan { id: string; goal: string; state: PlanState; steps: PlanStep[] }
+export interface QueuedMessage { id: string; text: string; after?: string }
+
+const PLAN_STATES = ['proposed', 'approved', 'running', 'done', 'rejected'];
+const STEP_STATES = ['pending', 'active', 'done', 'failed'];
+
+export function readPlan(raw: unknown): Plan | null {
+ if (!raw || typeof raw !== 'object') return null;
+ const p = raw as Record<string, unknown>;
+ if (typeof p.id !== 'string' || !p.id || !PLAN_STATES.includes(String(p.state)) || !Array.isArray(p.steps)) return null;
+ const steps: PlanStep[] = [];
+ p.steps.forEach((s, i) => {
+ if (!s || typeof s !== 'object') return;
+ const r = s as Record<string, unknown>;
+ if (typeof r.text !== 'string' || !r.text.trim()) return;
+ steps.push({
+ id: typeof r.id === 'string' && r.id ? r.id : String(i + 1), text: r.text,
+ state: STEP_STATES.includes(String(r.state)) ? r.state as StepState : 'pending',
+ ...(typeof r.note === 'string' && r.note ? { note: r.note } : {}),
+ });
+ });
+ if (!steps.length) return null;
+ return { id: p.id, goal: typeof p.goal === 'string' ? p.goal : '', state: p.state as PlanState, steps };
+}
+
+export function readQueue(raw: unknown): QueuedMessage[] {
+ if (!Array.isArray(raw)) return [];
+ return raw.flatMap((q): QueuedMessage[] => {
+ if (!q || typeof q !== 'object') return [];
+ const r = q as Record<string, unknown>;
+ return typeof r.id === 'string' && r.id && typeof r.text === 'string' && r.text
+ ? [{ id: r.id, text: r.text, ...(typeof r.after === 'string' && r.after ? { after: r.after } : {}) }] : [];
+ });
+}
+
+const plans = new Map<string, Plan>();
+const queues = new Map<string, QueuedMessage[]>();
+const listeners = new Set<() => void>();
+const emit = () => listeners.forEach(fn => fn());
+const subscribe = (fn: () => void) => { listeners.add(fn); return () => { listeners.delete(fn); }; };
+
+export function applyPlanFrame(chatId: string, raw: unknown) {
+ const plan = readPlan(raw), before = plans.get(chatId);
+ if (!plan) { if (plans.delete(chatId)) emit(); return; }
+ if (before && JSON.stringify(before) === JSON.stringify(plan)) return;
+ plans.set(chatId, plan);
+ emit();
+}
+
+export function applyQueueFrame(chatId: string, raw: unknown) {
+ const items = readQueue(raw), before = queues.get(chatId) ?? [];
+ if (JSON.stringify(before) === JSON.stringify(items)) return;
+ if (items.length) queues.set(chatId, items); else queues.delete(chatId);
+ emit();
+}
+
+const NONE: QueuedMessage[] = [];
+export const planOf = (chatId: string | null | undefined): Plan | null => (chatId ? plans.get(chatId) ?? null : null);
+export const queueOf = (chatId: string | null | undefined): QueuedMessage[] => (chatId ? queues.get(chatId) ?? NONE : NONE);
+
+export function usePlan(chatId: string | null | undefined): Plan | null {
+ const plan = useSyncExternalStore(subscribe, () => planOf(chatId), () => null);
+ useEffect(() => { if (chatId) void loadPlan(chatId); }, [chatId]);
+ return plan;
+}
+
+export function useQueue(chatId: string | null | undefined): QueuedMessage[] {
+ const items = useSyncExternalStore(subscribe, () => queueOf(chatId), () => NONE);
+ useEffect(() => { if (chatId) void loadQueue(chatId); }, [chatId]);
+ return items;
+}
+
+export async function loadPlan(chatId: string) {
+ try { applyPlanFrame(chatId, (await api.get<{ plan: unknown }>(`/api/plan?chatId=${encodeURIComponent(chatId)}`)).plan); }
+ catch { /* an older host has no plan route: no plan */ }
+}
+
+export async function loadQueue(chatId: string) {
+ try { applyQueueFrame(chatId, (await api.get<{ items: unknown }>(`/api/chat/queue?chatId=${encodeURIComponent(chatId)}`)).items); }
+ catch { /* an older host has no queue route: nothing queued */ }
+}
+
+/** Approve, edit (with the new step texts), reject, or start the plan as a goal. The host answers with the plan as it now is. */
+export async function planAction(chatId: string, action: 'approve' | 'edit' | 'reject' | 'start-goal', steps?: string[]) {
+ const result = await api.post<{ plan: unknown }>(`/api/plan/${action}`, { chatId, ...(steps ? { steps } : {}) });
+ applyPlanFrame(chatId, result.plan);
+}
+
+/** Take a queued message back before it is sent. */
+export async function cancelQueued(chatId: string, id: string) {
+ const result = await api.post<{ items: unknown }>('/api/chat/queue/cancel', { chatId, id });
+ applyQueueFrame(chatId, result.items);
+}
+
+/** The words under a queued message: when it will be sent. `after` is the step id it waits for, if the host names one. */
+export function queuedWhen(item: QueuedMessage, plan: Plan | null): { id: string; args?: unknown[] } {
+ const step = item.after && plan ? plan.steps.findIndex(s => s.id === item.after) : -1;
+ return step >= 0 ? { id: 'Queued — sends when step {0} finishes', args: [step + 1] } : { id: 'Queued — sends when the assistant is done' };
+}
+
+export const stepsDone = (plan: Plan) => plan.steps.filter(s => s.state === 'done').length;
diff --git a/apps/host/src/lib/store.ts b/apps/host/src/lib/store.ts
index 0224f1201..0bd46480f 100644
--- a/apps/host/src/lib/store.ts
+++ b/apps/host/src/lib/store.ts
@@ -4,6 +4,7 @@ import { updateAgent } from './agents';
import { LOOP_MAX_RUNS, LOOP_USAGE, loopEvery, parseLoop, type LoopCommand } from './loop';
import { applyStatusFrame, clearStatus } from './live-status';
import { applyGoalFrame } from './goal';
+import { applyPlanFrame, applyQueueFrame } from './plan';
import { TIME_SKIP_DURATION, timeSkipPrompt, timeSkipTabId, withTimeSkipResult, type TimeSkipFile, type TimeSkipJob, type TimeSkipRun, type TimeSkipVersion } from './time-skip';
import { PREVIEW_EXAMPLES, type PreviewArtifact } from './artifacts';
import { lifecyclePolicy } from './lifecycle';
@@ -636,6 +637,12 @@ function applyEvent(e: StreamEvent) {
case 'goal':
if (typeof data.chatId === 'string') applyGoalFrame(data.chatId, data.goal);
break;
+ case 'plan':
+ if (typeof data.chatId === 'string') applyPlanFrame(data.chatId, data.plan);
+ break;
+ case 'queue':
+ if (typeof data.chatId === 'string') applyQueueFrame(data.chatId, data.items);
+ break;
case 'timeskip':
applyTimeSkipEvent(data);
break;
@@ -1578,6 +1585,10 @@ export async function sendMessage(text: string, options: { fromLoop?: boolean; g
applyStatusFrame(sessionId, frame as Record<string, unknown>);
} else if (type === 'goal') {
applyGoalFrame(sessionId, frame.goal);
+ } else if (type === 'plan') {
+ applyPlanFrame(sessionId, frame.plan);
+ } else if (type === 'queue') {
+ applyQueueFrame(sessionId, frame.items);
} else if (type === 'reasoning') {
patchAssistant((m) => ({ ...m, reasoning: (m.reasoning ?? '') + String(frame.text ?? ''), reasoningStartedAt: m.reasoningStartedAt ?? Date.now() }));
} else if (type === 'notice') {
diff --git a/apps/host/src/locales/de.json b/apps/host/src/locales/de.json
index 9b162a823..a306e988a 100644
--- a/apps/host/src/locales/de.json
+++ b/apps/host/src/locales/de.json
@@ -3068,9 +3068,24 @@
"s3071": "Die Engine ließ sich mit diesen Einstellungen nicht starten. Es wurde nichts geändert.",
"s3072": "Die Engine wurde während der Messung beendet. Es wurde nichts geändert.",
"s3074": "Gespeichert als",
- "s3075": "Zur neuesten Nachricht scrollen",
- "s3076": "Denkzeit",
- "s3077": "Schreibzeit",
- "s3078": "{0}{1} Tok/s",
- "s3079": "{0}{1} Tok/s · letzte Antwort"
+ "s3075": "Der Plan wurde nicht geändert",
+ "s3076": "Plan bearbeiten",
+ "s3077": "Schritt {0}",
+ "s3078": "Diesen Schritt entfernen",
+ "s3079": "Schritt hinzufügen",
+ "s3080": "Plan speichern",
+ "s3081": "{0} Schritte",
+ "s3082": "{0} von {1} erledigt",
+ "s3083": "Nichts läuft, bevor Sie zustimmen.",
+ "s3084": "Ablehnen",
+ "s3085": "Als Ziel starten",
+ "s3086": "In diesem Chat gibt es keinen Plan.",
+ "s3087": "In der Warteschlange — wird gesendet, wenn Schritt {0} fertig ist",
+ "s3088": "In der Warteschlange — wird gesendet, wenn der Assistent fertig ist",
+ "s3089": "Diese Nachricht abbrechen",
+ "s3090": "Die Nachricht wurde nicht abgebrochen",
+ "s3091": "in Arbeit",
+ "s3092": "fehlgeschlagen",
+ "s3093": "wartet",
+ "s3094": "Der Assistent schreibt zuerst einen Plan; nichts läuft, bevor Sie zustimmen"
}
diff --git a/apps/host/src/locales/en.json b/apps/host/src/locales/en.json
index 1a9cc65a3..a7de667ee 100644
--- a/apps/host/src/locales/en.json
+++ b/apps/host/src/locales/en.json
@@ -3068,9 +3068,24 @@
"s3071": "The engine could not start with these settings. Nothing was changed.",
"s3072": "The engine stopped while we were measuring. Nothing was changed.",
"s3074": "Saved as",
- "s3075": "Scroll to the latest message",
- "s3076": "Thinking time",
- "s3077": "Writing time",
- "s3078": "{0}{1} tok/s",
- "s3079": "{0}{1} tok/s · last reply"
+ "s3075": "The plan was not changed",
+ "s3076": "Edit the plan",
+ "s3077": "Step {0}",
+ "s3078": "Remove this step",
+ "s3079": "Add a step",
+ "s3080": "Save plan",
+ "s3081": "{0} steps",
+ "s3082": "{0} of {1} done",
+ "s3083": "Nothing runs until you approve.",
+ "s3084": "Reject",
+ "s3085": "Start as goal",
+ "s3086": "There is no plan in this chat.",
+ "s3087": "Queued — sends when step {0} finishes",
+ "s3088": "Queued — sends when the assistant is done",
+ "s3089": "Cancel this message",
+ "s3090": "The message was not cancelled",
+ "s3091": "working on it",
+ "s3092": "failed",
+ "s3093": "waiting",
+ "s3094": "Have the assistant write a plan first; nothing runs until you approve it"
}
diff --git a/apps/host/src/locales/es.json b/apps/host/src/locales/es.json
index e4bfc1bba..01fea6265 100644
--- a/apps/host/src/locales/es.json
+++ b/apps/host/src/locales/es.json
@@ -3068,9 +3068,24 @@
"s3071": "El motor no pudo iniciarse con estos ajustes. No se cambió nada.",
"s3072": "El motor se detuvo mientras medíamos. No se cambió nada.",
"s3074": "Guardado como",
- "s3075": "Ir al mensaje más reciente",
- "s3076": "Tiempo de razonamiento",
- "s3077": "Tiempo de escritura",
- "s3078": "{0}{1} tok/s",
- "s3079": "{0}{1} tok/s · última respuesta"
+ "s3075": "No se cambió el plan",
+ "s3076": "Editar el plan",
+ "s3077": "Paso {0}",
+ "s3078": "Quitar este paso",
+ "s3079": "Añadir un paso",
+ "s3080": "Guardar el plan",
+ "s3081": "{0} pasos",
+ "s3082": "{0} de {1} hechos",
+ "s3083": "No se ejecuta nada hasta que lo apruebes.",
+ "s3084": "Rechazar",
+ "s3085": "Empezar como objetivo",
+ "s3086": "No hay ningún plan en este chat.",
+ "s3087": "En cola — se envía cuando termine el paso {0}",
+ "s3088": "En cola — se envía cuando el asistente termine",
+ "s3089": "Cancelar este mensaje",
+ "s3090": "No se canceló el mensaje",
+ "s3091": "en curso",
+ "s3092": "falló",
+ "s3093": "en espera",
+ "s3094": "El asistente escribe primero un plan; no se ejecuta nada hasta que lo apruebes"
}
diff --git a/apps/host/src/locales/ja.json b/apps/host/src/locales/ja.json
index 4d1c39d31..770518a5c 100644
--- a/apps/host/src/locales/ja.json
+++ b/apps/host/src/locales/ja.json
@@ -3068,9 +3068,24 @@
"s3071": "これらの設定ではエンジンを起動できませんでした。何も変更していません。",
"s3072": "測定中にエンジンが停止しました。何も変更していません。",
"s3074": "保存名",
- "s3075": "最新のメッセージへスクロール",
- "s3076": "思考時間",
- "s3077": "執筆時間",
- "s3078": "{0}{1} トークン/秒",
- "s3079": "{0}{1} トークン/秒 · 前回の返信"
+ "s3075": "プランは変更されませんでした",
+ "s3076": "プランを編集",
+ "s3077": "ステップ {0}",
+ "s3078": "このステップを削除",
+ "s3079": "ステップを追加",
+ "s3080": "プランを保存",
+ "s3081": "{0} ステップ",
+ "s3082": "{1} 件中 {0} 件完了",
+ "s3083": "承認するまで何も実行されません。",
+ "s3084": "却下",
+ "s3085": "ゴールとして開始",
+ "s3086": "このチャットにはプランがありません。",
+ "s3087": "待機中 — ステップ {0} の完了後に送信",
+ "s3088": "待機中 — アシスタントの作業完了後に送信",
+ "s3089": "このメッセージを取り消す",
+ "s3090": "メッセージは取り消されませんでした",
+ "s3091": "作業中",
+ "s3092": "失敗",
+ "s3093": "待機中",
+ "s3094": "まずアシスタントにプランを書かせます。承認するまで何も実行されません"
}
diff --git a/apps/host/src/locales/ko.json b/apps/host/src/locales/ko.json
index 7168adc15..a42239053 100644
--- a/apps/host/src/locales/ko.json
+++ b/apps/host/src/locales/ko.json
@@ -3068,9 +3068,24 @@
"s3071": "이 설정으로는 엔진을 시작하지 못했습니다. 아무것도 바꾸지 않았습니다.",
"s3072": "측정 중에 엔진이 멈췄습니다. 아무것도 바꾸지 않았습니다.",
"s3074": "저장 이름",
- "s3075": "최신 메시지로 스크롤",
- "s3076": "생각 시간",
- "s3077": "작성 시간",
- "s3078": "{0}{1} tok/s",
- "s3079": "{0}{1} tok/s · 마지막 응답"
+ "s3075": "계획이 변경되지 않았습니다",
+ "s3076": "계획 편집",
+ "s3077": "{0}단계",
+ "s3078": "이 단계 삭제",
+ "s3079": "단계 추가",
+ "s3080": "계획 저장",
+ "s3081": "{0}단계",
+ "s3082": "{1}개 중 {0}개 완료",
+ "s3083": "승인하기 전에는 아무것도 실행되지 않습니다.",
+ "s3084": "거부",
+ "s3085": "목표로 시작",
+ "s3086": "이 대화에는 계획이 없습니다.",
+ "s3087": "대기 중 — {0}단계가 끝나면 전송됩니다",
+ "s3088": "대기 중 — 어시스턴트가 끝나면 전송됩니다",
+ "s3089": "이 메시지 취소",
+ "s3090": "메시지가 취소되지 않았습니다",
+ "s3091": "진행 중",
+ "s3092": "실패",
+ "s3093": "대기 중",
+ "s3094": "어시스턴트가 먼저 계획을 작성합니다. 승인하기 전에는 아무것도 실행되지 않습니다"
}
diff --git a/apps/host/src/locales/pt.json b/apps/host/src/locales/pt.json
index 8d2c49b18..69a98b05f 100644
--- a/apps/host/src/locales/pt.json
+++ b/apps/host/src/locales/pt.json
@@ -3068,9 +3068,24 @@
"s3071": "O mecanismo não conseguiu iniciar com essas configurações. Nada foi alterado.",
"s3072": "O mecanismo parou durante a medição. Nada foi alterado.",
"s3074": "Salvo como",
- "s3075": "Ir para a mensagem mais recente",
- "s3076": "Tempo de raciocínio",
- "s3077": "Tempo de escrita",
- "s3078": "{0}{1} tok/s",
- "s3079": "{0}{1} tok/s · última resposta"
+ "s3075": "O plano não foi alterado",
+ "s3076": "Editar o plano",
+ "s3077": "Passo {0}",
+ "s3078": "Remover este passo",
+ "s3079": "Adicionar um passo",
+ "s3080": "Salvar o plano",
+ "s3081": "{0} passos",
+ "s3082": "{0} de {1} concluídos",
+ "s3083": "Nada é executado até você aprovar.",
+ "s3084": "Rejeitar",
+ "s3085": "Iniciar como meta",
+ "s3086": "Não há plano neste chat.",
+ "s3087": "Na fila — enviada quando o passo {0} terminar",
+ "s3088": "Na fila — enviada quando o assistente terminar",
+ "s3089": "Cancelar esta mensagem",
+ "s3090": "A mensagem não foi cancelada",
+ "s3091": "em andamento",
+ "s3092": "falhou",
+ "s3093": "aguardando",
+ "s3094": "O assistente escreve um plano primeiro; nada é executado até você aprovar"
}
diff --git a/apps/host/src/locales/ru.json b/apps/host/src/locales/ru.json
index 0768709a7..4b55b137b 100644
--- a/apps/host/src/locales/ru.json
+++ b/apps/host/src/locales/ru.json
@@ -3068,9 +3068,24 @@
"s3071": "Движок не удалось запустить с этими настройками. Ничего не изменено.",
"s3072": "Движок остановился во время измерения. Ничего не изменено.",
"s3074": "Сохранено как",
- "s3075": "К последнему сообщению",
- "s3076": "Время размышления",
- "s3077": "Время написания",
- "s3078": "{0}{1} ток/с",
- "s3079": "{0}{1} ток/с · последний ответ"
+ "s3075": "План не был изменён",
+ "s3076": "Изменить план",
+ "s3077": "Шаг {0}",
+ "s3078": "Удалить этот шаг",
+ "s3079": "Добавить шаг",
+ "s3080": "Сохранить план",
+ "s3081": "Шагов: {0}",
+ "s3082": "Готово {0} из {1}",
+ "s3083": "Ничего не запустится, пока вы не одобрите.",
+ "s3084": "Отклонить",
+ "s3085": "Запустить как цель",
+ "s3086": "В этом чате нет плана.",
+ "s3087": "В очереди — отправится после шага {0}",
+ "s3088": "В очереди — отправится, когда ассистент закончит",
+ "s3089": "Отменить это сообщение",
+ "s3090": "Сообщение не было отменено",
+ "s3091": "в работе",
+ "s3092": "не удалось",
+ "s3093": "ожидает",
+ "s3094": "Сначала ассистент пишет план; ничего не запустится, пока вы не одобрите"
}
diff --git a/apps/host/src/locales/zh.json b/apps/host/src/locales/zh.json
index b8314e86e..1eccadab0 100644
--- a/apps/host/src/locales/zh.json
+++ b/apps/host/src/locales/zh.json
@@ -3068,9 +3068,24 @@
"s3071": "引擎无法用这些设置启动。没有做任何更改。",
"s3072": "测量期间引擎停止了。没有做任何更改。",
"s3074": "保存为",
- "s3075": "滚动到最新消息",
- "s3076": "思考时间",
- "s3077": "写作时间",
- "s3078": "{0}{1} 词元/秒",
- "s3079": "{0}{1} 词元/秒 · 上次回复"
+ "s3075": "计划未更改",
+ "s3076": "编辑计划",
+ "s3077": "第 {0} 步",
+ "s3078": "删除此步骤",
+ "s3079": "添加步骤",
+ "s3080": "保存计划",
+ "s3081": "{0} 个步骤",
+ "s3082": "已完成 {0}/{1}",
+ "s3083": "在你批准之前不会运行任何内容。",
+ "s3084": "拒绝",
+ "s3085": "作为目标开始",
+ "s3086": "此对话中没有计划。",
+ "s3087": "已排队 — 第 {0} 步完成后发送",
+ "s3088": "已排队 — 助手完成后发送",
+ "s3089": "取消此消息",
+ "s3090": "消息未被取消",
+ "s3091": "进行中",
+ "s3092": "失败",
+ "s3093": "等待中",
+ "s3094": "先让助手写计划;在你批准之前不会运行任何内容"
}
diff --git a/apps/host/src/screens/Chat.tsx b/apps/host/src/screens/Chat.tsx
index d4a1c849c..b7480e3b9 100644
--- a/apps/host/src/screens/Chat.tsx
+++ b/apps/host/src/screens/Chat.tsx
@@ -20,6 +20,8 @@ import { useNative } from '../lib/native';
import { ReasoningBlock } from '../components/ReasoningBlock';
import { StatusLine } from '../components/StatusLine';
import { GoalBar } from '../components/GoalBar';
+import { PlanCard, PlanPanel, QueuedMessages } from '../components/PlanCard';
+import { usePlan } from '../lib/plan';
import { useLiveStatus } from '../lib/live-status';
import { askQuestion, askSub, askIcon } from '../lib/ask';
import { artifactFromUrl, type PreviewArtifact } from '../lib/artifacts';
@@ -106,12 +108,19 @@ export function ChatScreen() {
const [previews, setPreviews] = useState<PreviewArtifact[]>([]);
const [selectedPreview, setSelectedPreview] = useState<string | null>(null);
const timeSkipRuns = (session?.timeSkips ?? []).filter(run => session?.messages.some(m => m.timeSkipId === run.id && m.role === 'assistant') && (!run.job || (run.job.files?.length ?? 0) > 0));
- const extraTabs = timeSkipRuns.map((run, i) => ({ id: timeSkipTabId(run.id), title: timeSkipRuns.length > 1 ? `Time-skip ${i + 1}` : 'Time-skip', icon: 'branch' as const, controls: 'time-skip-content' })).filter(tab => !session?.closedPreviews?.includes(tab.id));
+ const runTabs = timeSkipRuns.map((run, i) => ({ id: timeSkipTabId(run.id), title: timeSkipRuns.length > 1 ? `Time-skip ${i + 1}` : 'Time-skip', icon: 'branch' as const, controls: 'time-skip-content' })).filter(tab => !session?.closedPreviews?.includes(tab.id));
+ const plan = usePlan(session?.id);
+ const planTabId = session ? `plan:${session.id}` : '';
+ const planTab = plan && plan.state !== 'rejected' && !session?.closedPreviews?.includes(planTabId) ? [{ id: planTabId, title: 'Plan', icon: 'check' as const, controls: 'plan-content' }] : [];
+ const planShown = planTab.length > 0 && selectedPreview === planTabId;
+ const planRunId = plan?.state === 'running' ? plan.id : '';
+ useEffect(() => { if (planRunId && planTabId && !session?.closedPreviews?.includes(planTabId)) setSelectedPreview(planTabId); }, [planRunId]);
+ const extraTabs = [...runTabs, ...planTab];
const selectedRun = timeSkipRuns.find(run => timeSkipTabId(run.id) === selectedPreview);
- const inlinePreview = splitWidth >= (selectedRun ? 760 : 1120);
+ const inlinePreview = splitWidth >= (selectedRun || planShown ? 760 : 1120);
const paneWidth = previewWidth(splitWidth, previewFraction);
const splitStyle = inlinePreview && selectedPreview && !expanded ? { gridTemplateColumns: `minmax(0,1fr) ${paneWidth}px` } : undefined;
- const resizeHandle = !setupVisible && inlinePreview && selectedPreview && !expanded ? <PreviewResizeHandle container={splitRef} total={splitWidth} fraction={previewFraction} onChange={setPreviewFraction} controls={selectedRun ? 'time-skip-content' : 'artifact-content'}/> : null;
+ const resizeHandle = !setupVisible && inlinePreview && selectedPreview && !expanded ? <PreviewResizeHandle container={splitRef} total={splitWidth} fraction={previewFraction} onChange={setPreviewFraction} controls={selectedRun ? 'time-skip-content' : planShown ? 'plan-content' : 'artifact-content'}/> : null;
const runCount = timeSkipRuns.length;
const previewCount = session?.messages.reduce((n, m) => n + (m.artifacts?.length ?? 0), 0) ?? 0;
useEffect(() => { const items = [...new Map((session?.messages.flatMap(m => m.artifacts ?? []) ?? []).map(a => [a.id, a])).values()]; setPreviews(items.filter(a => !session?.closedPreviews?.includes(a.id))); setSelectedPreview(session?.closedPreviews?.includes(session.previewOpen ?? '') ? null : session?.previewOpen?.startsWith('time-skip:') && !timeSkipRuns.some(r => timeSkipTabId(r.id) === session.previewOpen) ? null : session?.previewOpen ?? null); }, [session?.id]);
@@ -350,7 +359,7 @@ export function ChatScreen() {
</div>
<Composer draft={draft} setDraft={updateDraft} loaded={!!loaded} streaming={streaming} onSubmit={submit} onKey={onComposerKey} session={session} onPreview={openPreview} textareaRef={textarea}/>
</div>
- <ArtifactPanel items={previews} onCloseTab={closeTab} selected={setupVisible ? null : selectedPreview} onSelect={selectPreview} onClose={() => setSelectedPreview(null)} inline={inlinePreview}/>
+ <ArtifactPanel items={previews} onCloseTab={closeTab} selected={setupVisible ? null : selectedPreview} onSelect={selectPreview} onClose={() => setSelectedPreview(null)} inline={inlinePreview}/>
{tr(resizeHandle)}
</div>
</>);
@@ -376,17 +385,19 @@ export function ChatScreen() {
setAwayFromBottom(away);
}}>
- {tr(awayFromBottom ? (<button type="button" className="jumplatest" data-finished={justFinished || undefined} aria-label={tr("Scroll to the latest message")} title={tr("Scroll to the latest message")} onClick={() => scrollToLatest()}>
- <Icon name="chevron" size={18}/></button>) : null)}
<div className="chat__inner">
{tr(session.messages.length === 0 ? (session.statsAvailable === false ? <p className="small muted">{tr("Editing from an earlier message. Update the prompt below.")}</p> :
<UsageDashboard loaded={!!loaded}/>) : (session.messages.map((m, i) => (<Message key={m.id} message={m} isLast={i === session.messages.length - 1} onEditPrompt={editPrompt} onPreview={openPreview} onOpenTimeSkip={openTimeSkip} timeSkipDone={!!timeSkipRuns.find(r => r.id === m.timeSkipId)?.completedAt} timeSkipReal={!!timeSkipRuns.find(r => r.id === m.timeSkipId)?.job} timeSkipRun={timeSkipRuns.find(r => r.id === m.timeSkipId)} onOpenLink={openLink}/>))))}
+ <PlanCard chatId={session.id}/><QueuedMessages chatId={session.id}/>
</div>
</div>
+ <div className="jumplatest-row">{tr(awayFromBottom ? (<button type="button" className="jumplatest" data-finished={justFinished || undefined} aria-label={tr("Scroll to the latest message")} title={tr("Scroll to the latest message")} onClick={() => scrollToLatest()}>
+ <Icon name="chevron" size={18}/></button>) : null)}</div>
<Composer draft={draft} setDraft={updateDraft} loaded={!!loaded} streaming={streaming} onSubmit={submit} onKey={onComposerKey} session={session} onPreview={openPreview} textareaRef={textarea}/>
</div>
{tr(!setupVisible && selectedRun && session ? <TimeSkipPanel key={selectedRun.id} run={selectedRun} sessionId={session.id} inline={inlinePreview} expanded={expanded} onCompare={setExpanded} onPreview={openPreview} onClose={() => { setSelectedPreview(null); setExpanded(false); }}/> : null)}
- <ArtifactPanel items={previews} onCloseTab={closeTab} selected={setupVisible ? null : selectedPreview} onSelect={selectPreview} onClose={() => setSelectedPreview(null)} inline={inlinePreview}/>
+ {tr(!setupVisible && planShown ? <PlanPanel chatId={session?.id}/> : null)}
+ <ArtifactPanel items={previews} onCloseTab={closeTab} selected={setupVisible || planShown ? null : selectedPreview} onSelect={selectPreview} onClose={() => setSelectedPreview(null)} inline={inlinePreview}/>
{tr(resizeHandle)}
</div>
</>);
@@ -403,6 +414,7 @@ function useSlashCommands(clear: () => void, setDraft: (value: string) => void):
return [
{ id: 'time-skip', label: '/time-skip', hint: 'Try a change on a copy, check it, and keep it only if it is better', icon: 'branch', run: () => setDraft('/time-skip ') },
{ id: 'goal', label: '/goal', hint: 'Set a goal and let the assistant keep working until it is done', icon: 'bolt', run: () => setDraft('/goal ') },
+ { id: 'plan', label: '/plan', hint: 'Have the assistant write a plan first; nothing runs until you approve it', icon: 'check', run: () => setDraft('/plan ') },
{ id: 'loop', label: '/loop', hint: 'Repeat a message every few minutes while this chat is open', icon: 'refresh', run: () => setDraft('/loop 10m ') },
{ id: 'website', label: '/website', hint: 'Open a website in the preview sidebar', icon: 'link', run: () => { clear(); window.dispatchEvent(new Event('strata:open-website')); } },
{ id: 'preview', label: '/preview', hint: 'Open a local file in the preview sidebar', icon: 'file', run: () => { clear(); window.dispatchEvent(new Event('strata:open-preview')); } },
diff --git a/apps/host/src/styles/app.css b/apps/host/src/styles/app.css
index 8d5e7aa1e..d2bb05014 100644
--- a/apps/host/src/styles/app.css
+++ b/apps/host/src/styles/app.css
@@ -7331,10 +7331,44 @@ textarea {
.telepop__detail + .st-btn { margin-left: 0; }
/* the way back to the newest message: a small round arrow, shown only while scrolled up */
-.jumplatest { width: 38px; height: 38px; padding: 0; justify-content: center; gap: 0; margin: 10px auto 12px; border-radius: 50%; }
+.jumplatest-row { position: relative; height: 0; flex: none; z-index: 3; }
+.jumplatest { position: absolute; bottom: 12px; left: 50%; margin: 0 0 0 -19px; width: 38px; height: 38px; padding: 0; justify-content: center; gap: 0; border-radius: 50%; }
.jumplatest svg { flex: none; }
/* ---- chat statistics: figures that move keep their width ---- */
.telemetry__chip, .telepop__value { font-variant-numeric: tabular-nums; }
.ts-empty { margin: 12px 0; color: var(--st-ink-soft); }
+
+/* /plan: the card in the chat, the same steps in the sidebar, and queued messages */
+.plan { border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface); margin: 8px 0; }
+.plan__head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px 4px; }
+.plan__head b { font-size: var(--st-fs-md); }
+.plan__head span { color: var(--st-ink-muted); font-size: var(--st-fs-sm); }
+.plan__goal { margin: 0; padding: 2px 16px 0; color: var(--st-ink-soft); font-size: var(--st-fs-sm); }
+.plan__steps { list-style: none; margin: 0; padding: 6px 16px 10px; display: flex; flex-direction: column; }
+.plan__step { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 7px 0; align-items: start; font-size: var(--st-fs-md); line-height: 1.4; }
+.plan__no { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--st-line); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--st-ink-muted); font-variant-numeric: tabular-nums; }
+.plan__step[data-state="done"] { color: var(--st-ink-muted); }
+.plan__step[data-state="done"] .plan__no { background: var(--st-accent); border-color: transparent; color: var(--st-accent-ink); }
+.plan__step[data-state="failed"] .plan__no { border-color: var(--st-danger, #d92d20); color: var(--st-danger, #d92d20); }
+.plan__step[data-state="active"] { font-weight: 700; }
+.plan__step[data-state="active"] .plan__no { border-color: var(--st-accent); color: var(--st-accent-text); animation: plan-glow 1.8s ease-out infinite; }
+.plan__text small { display: block; font-weight: 400; color: var(--st-ink-muted); font-size: var(--st-fs-sm); margin-top: 2px; }
+@keyframes plan-glow { 0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .4); } 70%, 100% { box-shadow: 0 0 0 8px transparent; } }
+@media (prefers-reduced-motion: reduce) { .plan__step[data-state="active"] .plan__no { animation: none; } }
+.plan__note { margin: 0; padding: 0 16px 12px; color: var(--st-ink-muted); font-size: var(--st-fs-sm); }
+.plan__acts { display: flex; gap: 8px; align-items: center; padding: 10px 12px 12px 16px; border-top: 1px solid var(--st-line-soft); }
+.plan__sp { flex: 1; }
+.plan__edit { display: flex; flex-direction: column; gap: 6px; padding: 4px 16px 10px; }
+.plan__row { display: grid; grid-template-columns: 22px 1fr 28px; gap: 8px; align-items: center; }
+.plan-panel { padding: 8px 0; overflow: auto; }
+.plan-panel .plan__head, .plan-panel .plan__steps, .plan-panel .plan__goal { padding-left: 20px; padding-right: 20px; }
+.queued { align-self: flex-end; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; max-width: 80%; margin: 6px 0 0 auto; }
+.queued__bubble { background: transparent; border: 1px dashed var(--st-line); color: var(--st-ink-soft); padding: 10px 16px; border-radius: 18px 18px 4px 18px; font-weight: 500; overflow-wrap: anywhere; }
+.queued__line { display: flex; align-items: center; gap: 6px; color: var(--st-ink-muted); font-size: var(--st-fs-xs); }
+.queued__x { width: 22px; height: 22px; border: 0; background: transparent; border-radius: 50%; color: var(--st-icon); display: grid; place-items: center; cursor: pointer; }
+.queued__x:hover { background: var(--st-surface-2); }
+
+.st-card--flush:has(> .privacy-notes) { border: 0; background: transparent; box-shadow: none; }
+.privacy-notes { padding: 2px 4px; }
diff --git a/apps/host/tests/ui5-plan.test.mjs b/apps/host/tests/ui5-plan.test.mjs
new file mode 100644
index 000000000..177c226f8
--- /dev/null
+++ b/apps/host/tests/ui5-plan.test.mjs
@@ -0,0 +1,58 @@
+/** Owner round 7: /plan card, plan steps in the sidebar, queued messages. Snapshots from the host replace what was there. */
+import test from 'node:test';
+import assert from 'node:assert/strict';
+import { readFile } from 'node:fs/promises';
+import { build } from 'esbuild';
+import { fileURLToPath } from 'node:url';
+
+const src = f => fileURLToPath(new URL(`../src/${f}`, import.meta.url));
+const stub = fileURLToPath(new URL('./helpers/react-stub.mjs', import.meta.url));
+async function load(file) {
+ const result = await build({ entryPoints: [src(`lib/${file}`)], bundle: true, format: 'esm', platform: 'node', write: false, alias: { react: stub }, logLevel: 'silent', loader: { '.json': 'json' } });
+ return import(`data:text/javascript;base64,${Buffer.from(result.outputFiles[0].text).toString('base64')}`);
+}
+globalThis.window ??= globalThis; globalThis.localStorage ??= { getItem: () => null, setItem: () => {} };
+globalThis.navigator ??= { language: 'en' };
+const P = await load('plan.ts');
+
+const plan = (state, steps) => ({ id: 'p1', goal: 'Pagoda', state, steps });
+
+test('a plan snapshot is read, ordered, with step states; bad parts are dropped', () => {
+ const p = P.readPlan(plan('running', [{ id: 'a', text: 'Look', state: 'done' }, { id: 'b', text: 'Write', state: 'active', note: 'one file' }, { text: 'Check' }, { text: ' ' }, 7]));
+ assert.equal(p.steps.length, 3);
+ assert.deepEqual(p.steps.map(s => s.state), ['done', 'active', 'pending']);
+ assert.equal(p.steps[2].id, '3');
+ assert.equal(P.stepsDone(p), 1);
+ assert.equal(P.readPlan(plan('weird', [{ text: 'x' }])), null);
+ assert.equal(P.readPlan(plan('proposed', [])), null);
+ assert.equal(P.readPlan(null), null);
+});
+
+test('frames replace the plan; null clears it; the same snapshot changes nothing', () => {
+ P.applyPlanFrame('c', plan('proposed', [{ text: 'A' }, { text: 'B' }]));
+ assert.equal(P.planOf('c').state, 'proposed');
+ P.applyPlanFrame('c', plan('running', [{ id: '1', text: 'A', state: 'active' }, { text: 'B' }]));
+ assert.equal(P.planOf('c').steps[0].state, 'active');
+ assert.equal(P.planOf('other'), null);
+ P.applyPlanFrame('c', null);
+ assert.equal(P.planOf('c'), null);
+});
+
+test('queued messages: a snapshot, the words say which step they wait for, cancel empties', () => {
+ P.applyQueueFrame('c', [{ id: 'q1', text: 'Add a moon', after: '2' }, { id: 'q2', text: 'Warmer glow' }, { id: '', text: 'x' }, { id: 'q3' }]);
+ const items = P.queueOf('c');
+ assert.deepEqual(items.map(q => q.id), ['q1', 'q2']);
+ const p = P.readPlan(plan('running', [{ id: '1', text: 'A', state: 'done' }, { id: '2', text: 'B', state: 'active' }]));
+ assert.deepEqual(P.queuedWhen(items[0], p), { id: 'Queued — sends when step {0} finishes', args: [2] });
+ assert.deepEqual(P.queuedWhen(items[1], p), { id: 'Queued — sends when the assistant is done' });
+ P.applyQueueFrame('c', []);
+ assert.deepEqual(P.queueOf('c'), []);
+});
+
+test('the chat and the sidebar draw the plan from the same store, and the stream feeds it', async () => {
+ const [card, chat, store, client] = await Promise.all(['components/PlanCard.tsx', 'screens/Chat.tsx', 'lib/store.ts', 'lib/client.ts'].map(f => readFile(src(f), 'utf8')));
+ assert.match(card, /export function PlanCard/); assert.match(card, /export function PlanPanel/); assert.match(card, /export function QueuedMessages/);
+ assert.match(card, /Approve/); assert.match(card, /Start as goal/); assert.match(card, /planAction\(chatId, 'reject'\)/);
+ assert.match(chat, /<PlanPanel chatId/); assert.match(chat, /plan:\$\{session\.id\}/);
+ assert.match(store, /type === 'plan'/); assert.match(store, /type === 'queue'/); assert.match(client, /'plan', 'queue'/);
+});