Round 8: Models navbar family dropdown, deliverable cards with Open menu, Edited summary, grouped activity lines, text in order, drop zone, image generation hidden
This commit is contained in:
1 parent
0ac98f80ee
commit
9e2d698c9e
22 files changed
+491
-65
No files matched your search
@@ -48,6 +48,7 @@ export function ComposerControls({ session, onPreview, onAttach, onError, onSlas
|
||||
const trigger = useRef<HTMLButtonElement>(null), modeTrigger = useRef<HTMLButtonElement>(null), thinkingTrigger = useRef<HTMLButtonElement>(null);
|
||||
const attachLatest = useRef(onAttach);
|
||||
attachLatest.current = onAttach;
|
||||
const addFilesLatest = useRef<(files: File[]) => Promise<void>>(async () => { });
|
||||
const mode = modes.find(m => m.value === session?.preferences?.mode) ?? modes[0];
|
||||
const effort = efforts.includes(session?.preferences?.thinking ?? '') ? session!.preferences!.thinking! : 'Medium';
|
||||
const budget = session?.preferences?.thinkingBudget ?? 0;
|
||||
@@ -117,6 +118,7 @@ export function ComposerControls({ session, onPreview, onAttach, onError, onSlas
|
||||
setReading(false);
|
||||
}
|
||||
}
|
||||
addFilesLatest.current = files => addFiles(files);
|
||||
useEffect(() => {
|
||||
folder.current?.setAttribute('webkitdirectory', '');
|
||||
const key = (e: KeyboardEvent) => {
|
||||
@@ -127,10 +129,12 @@ export function ComposerControls({ session, onPreview, onAttach, onError, onSlas
|
||||
};
|
||||
const website = () => { setUrlOpen(true); setError(''); };
|
||||
const preview = () => previewFile.current?.click();
|
||||
const dropped = (e: Event) => { if (!streaming && !reading) void addFilesLatest.current((e as CustomEvent<File[]>).detail ?? []); };
|
||||
window.addEventListener('strata:drop-files', dropped);
|
||||
window.addEventListener('keydown', key);
|
||||
window.addEventListener('strata:open-website', website);
|
||||
window.addEventListener('strata:open-preview', preview);
|
||||
return () => { window.removeEventListener('keydown', key); window.removeEventListener('strata:open-website', website); window.removeEventListener('strata:open-preview', preview); };
|
||||
return () => { window.removeEventListener('strata:drop-files', dropped); window.removeEventListener('keydown', key); window.removeEventListener('strata:open-website', website); window.removeEventListener('strata:open-preview', preview); };
|
||||
}, [streaming, reading]);
|
||||
useEffect(() => {
|
||||
if (preferences !== 'mode')
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
import { useRef, useState } from 'react';
|
||||
import { tr } from '../lib/i18n';
|
||||
import { fileAction, fileSize, fileTypeLabel, previewOf, rawUrlOf, type ActivityGroup, type Deliverable } from '../lib/deliverables';
|
||||
import type { PreviewArtifact } from '../lib/artifacts';
|
||||
import { pushToast } from '../lib/store';
|
||||
import { plainFailureText } from '../lib/plain-errors';
|
||||
import { FloatingMenu } from './FloatingMenu';
|
||||
import { Icon } from './ui';
|
||||
|
||||
const problem = (title: string, e: unknown) => pushToast('error', tr(title), plainFailureText(e instanceof Error ? e.message : String(e)).message);
|
||||
|
||||
/** A line's numbers ("+225 −0") shown as a pair of small figures; the sentence itself stays plain grey. */
|
||||
export function Plusminus({ added, removed }: { added: number; removed: number }) {
|
||||
return <span className="pm" aria-label={tr('{0} lines added, {1} removed', [added, removed])}><span className="pm__a">+{added}</span><span className="pm__d">−{removed}</span></span>;
|
||||
}
|
||||
|
||||
const showOf = (file: { path: string; name: string }, sessionId: string, onPreview: (a: PreviewArtifact) => void, kind?: string) =>
|
||||
previewOf(sessionId, file).then(onPreview, e => {
|
||||
// A file with no preview opens in its own app instead.
|
||||
if (kind === 'other') return fileAction.open(sessionId, file.path, 'app').catch(err => problem('The file was not opened', err));
|
||||
return problem('The file has no preview', e);
|
||||
});
|
||||
|
||||
/** One file the assistant made or changed: its type, name and size, and Open (in the sidebar) with a menu for the other things to do with it. */
|
||||
export function FileCard({ file, sessionId, onPreview }: { file: Deliverable; sessionId: string; onPreview: (a: PreviewArtifact) => void }) {
|
||||
const more = useRef<HTMLButtonElement>(null);
|
||||
const [menu, setMenu] = useState(false), [busy, setBusy] = useState(false);
|
||||
const run = async (fn: () => Promise<unknown>, failed: string) => { setMenu(false); try { await fn(); } catch (e) { problem(failed, e); } };
|
||||
return <div className="fcard" data-kind={file.kind}>
|
||||
<span className="fcard__type">{fileTypeLabel(file)}</span>
|
||||
<span className="fcard__name"><strong title={file.path}>{file.name}</strong><span>{fileSize(file.size)}</span></span>
|
||||
<span className="fcard__split">
|
||||
<button type="button" className="fcard__open" disabled={busy} onClick={() => { setBusy(true); void showOf(file, sessionId, onPreview, file.kind).finally(() => setBusy(false)); }}>{tr("Open")}</button>
|
||||
<button ref={more} type="button" className="fcard__more" aria-haspopup="menu" aria-expanded={menu} aria-label={tr("More ways to open {0}", [file.name])} onClick={() => setMenu(v => !v)}><Icon name="chevron" size={14} className="fcard__chev"/></button>
|
||||
</span>
|
||||
{tr(menu ? <FloatingMenu anchor={more.current} title={tr("File actions")} width={220} onClose={() => setMenu(false)}>
|
||||
<button role="menuitem" className="menu__item" onClick={() => void run(() => fileAction.open(sessionId, file.path, 'folder'), 'The folder was not opened')}><Icon name="folder"/>{tr("Show in folder")}</button>
|
||||
<button role="menuitem" className="menu__item" onClick={() => void run(async () => { await navigator.clipboard.writeText(await fileAction.fullPath(sessionId, file.path)); pushToast('info', tr('Path copied')); }, 'The path was not copied')}><Icon name="copy"/>{tr("Copy path")}</button>
|
||||
<button role="menuitem" className="menu__item" onClick={() => void run(async () => { await fileAction.attach(sessionId, file.path); pushToast('info', tr('Attached to your next message'), file.name); }, 'The file was not attached')}><Icon name="attach"/>{tr("Attach as context")}</button>
|
||||
</FloatingMenu> : null)}
|
||||
</div>;
|
||||
}
|
||||
|
||||
/** "Edited N files": each with its lines added and removed, and the total under See all. */
|
||||
export function EditedFiles({ files, sessionId, onPreview }: { files: Deliverable[]; sessionId: string; onPreview: (a: PreviewArtifact) => void }) {
|
||||
const [all, setAll] = useState(false);
|
||||
const textual = files.filter(f => f.lines !== null);
|
||||
if (textual.length < 2) return null;
|
||||
const shown = all ? textual : textual.slice(0, 3);
|
||||
const added = textual.reduce((n, f) => n + f.added, 0), removed = textual.reduce((n, f) => n + f.removed, 0);
|
||||
return <div className="edited">
|
||||
<div className="edited__head"><b>{tr('Edited {0} files', [textual.length])}</b></div>
|
||||
{shown.map(f => <button type="button" className="edited__row" key={f.path} onClick={() => void showOf(f, sessionId, onPreview, f.kind)}><Icon name="file" size={16}/><span>{f.name}</span><Plusminus added={f.added} removed={f.removed}/></button>)}
|
||||
<button type="button" className="edited__row edited__row--all" disabled={textual.length <= 3 && !all} onClick={() => setAll(v => !v)}><span>{tr(all ? 'Show fewer' : 'See all')}</span><Plusminus added={added} removed={removed}/></button>
|
||||
</div>;
|
||||
}
|
||||
|
||||
/** A run of tool use between two pieces of text, as one quiet line: "Ran 2 commands, read monitor.png", with a thumbnail when it touched a picture. */
|
||||
export function ActivityLine({ group, sessionId, onPreview }: { group: ActivityGroup; sessionId: string; onPreview: (a: PreviewArtifact) => void }) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const picture = group.files.find(f => f.kind === 'image');
|
||||
// The host's sentence may end with the numbers ("… +225 −0"): they are drawn as figures instead.
|
||||
const sentence = group.line.replace(/\s*\+\d+\s*[−-]\s*\d+\s*$/, '');
|
||||
return <div className="act" data-open={open || undefined}>
|
||||
<button type="button" className="act__line" aria-expanded={open} disabled={!group.files.length} onClick={() => setOpen(v => !v)}>
|
||||
<span>{sentence}</span>{group.added || group.removed ? <Plusminus added={group.added} removed={group.removed}/> : null}
|
||||
{group.files.length ? <Icon name="chevron" size={14} className="act__chev"/> : null}
|
||||
{!group.closed ? <span className="act__live" aria-hidden="true"/> : null}
|
||||
</button>
|
||||
{picture ? <img className="act__thumb" src={rawUrlOf(sessionId, picture.path)} alt="" loading="lazy" onClick={() => void showOf(picture, sessionId, onPreview)}/> : null}
|
||||
{open ? <ul className="act__files">{group.files.map(f => <li key={f.path}><button type="button" onClick={() => void showOf(f, sessionId, onPreview, f.kind)}><Icon name="file" size={14}/>{f.name}{f.added || f.removed ? <Plusminus added={f.added} removed={f.removed}/> : null}</button></li>)}</ul> : null}
|
||||
</div>;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { useRef, useState, type ReactNode } from 'react';
|
||||
import { tr } from '../lib/i18n';
|
||||
import { Icon } from './ui';
|
||||
|
||||
/** Files dropped on the chat go where the attach button would put them: the composer reads the 'strata:drop-files' event. */
|
||||
export const DROP_EVENT = 'strata:drop-files';
|
||||
const hasFiles = (e: React.DragEvent) => Array.from(e.dataTransfer?.types ?? []).includes('Files');
|
||||
|
||||
/** The conversation column, with a calm highlight while something is dragged over it. */
|
||||
export function DropZone({ children, className }: { children: ReactNode; className?: string }) {
|
||||
const [over, setOver] = useState(false);
|
||||
const depth = useRef(0);
|
||||
return <div className={className} data-dropping={over || undefined}
|
||||
onDragEnter={e => { if (!hasFiles(e)) return; e.preventDefault(); depth.current++; setOver(true); }}
|
||||
onDragOver={e => { if (!hasFiles(e)) return; e.preventDefault(); e.dataTransfer.dropEffect = 'copy'; }}
|
||||
onDragLeave={e => { if (!hasFiles(e)) return; depth.current = Math.max(0, depth.current - 1); if (!depth.current) setOver(false); }}
|
||||
onDrop={e => { if (!hasFiles(e)) return; e.preventDefault(); depth.current = 0; setOver(false); const files = Array.from(e.dataTransfer.files); if (files.length) window.dispatchEvent(new CustomEvent(DROP_EVENT, { detail: files })); }}>
|
||||
{children}
|
||||
{over ? <div className="dropzone" aria-hidden="true"><Icon name="attach" size={22}/><strong>{tr("Drop files to add them")}</strong><span>{tr("Pictures and text files")}</span></div> : null}
|
||||
</div>;
|
||||
}
|
||||
@@ -1,12 +1,30 @@
|
||||
import { useRef, useState } from 'react';
|
||||
import { tr } from '../lib/i18n';
|
||||
import type { CatalogModel } from '../lib/native-catalog';
|
||||
import { FloatingMenu } from './FloatingMenu';
|
||||
import { Icon } from './ui';
|
||||
|
||||
/** The model families of the catalog as a switch in the navbar (Qwen3.8-Flash-Next, Qwen3.6-35B-A3B). A single family is just its name. */
|
||||
/**
|
||||
* The model family in the Models navbar: its icon, its name and a chevron. Opening it lists the families of the catalog (Qwen3.8-Flash-Next,
|
||||
* Qwen3.6-35B-A3B, and future ones) to switch between. One family still shows as the same control, so the page looks the same as families arrive.
|
||||
*/
|
||||
export function FamilySwitch({ families, selected, onPick }: { families: CatalogModel[]; selected?: string; onPick: (family: CatalogModel) => void }) {
|
||||
const shown = families.filter(f => f.sizes.length);
|
||||
if (shown.length < 2) return shown[0] ? <span className="family-switch family-switch--single">{tr(shown[0].title)}</span> : null;
|
||||
return <div className="family-switch" role="tablist" aria-label={tr("Model family")}>
|
||||
{shown.map(f => <button key={f.family} type="button" role="tab" aria-selected={f.family === selected} tabIndex={f.family === selected ? 0 : -1} onClick={() => onPick(f)}
|
||||
onKeyDown={e => { if (e.key === 'ArrowRight' || e.key === 'ArrowLeft') { e.preventDefault(); const at = shown.findIndex(x => x.family === selected); onPick(shown[(at + (e.key === 'ArrowRight' ? 1 : shown.length - 1)) % shown.length]); } }}>{tr(f.title)}</button>)}
|
||||
</div>;
|
||||
const trigger = useRef<HTMLButtonElement>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
if (!shown.length) return null;
|
||||
const current = shown.find(f => f.family === selected) ?? shown[0];
|
||||
return <>
|
||||
<button ref={trigger} type="button" className="family-trigger" aria-haspopup="menu" aria-expanded={open} aria-label={tr("Model family")} onClick={() => setOpen(v => !v)}>
|
||||
<Icon name="models" size={20}/><strong>{tr(current.title)}</strong><Icon name="chevron" size={16} className="family-trigger__chev"/>
|
||||
</button>
|
||||
{tr(open ? <FloatingMenu anchor={trigger.current} title={tr("Model family")} width={320} onClose={() => setOpen(false)}>
|
||||
<div className="family-menu">
|
||||
{shown.map(f => <button key={f.family} type="button" role="menuitemradio" aria-checked={f.family === current.family} className="family-menu__item" onClick={() => { setOpen(false); if (f.family !== current.family) onPick(f); }}>
|
||||
<Icon name="models" size={18}/><span><strong>{tr(f.title)}</strong>{f.experimental ? <small>{tr("Experimental")}</small> : null}</span>
|
||||
{f.family === current.family ? <Icon name="check" size={16} className="family-menu__check"/> : null}
|
||||
</button>)}
|
||||
</div>
|
||||
</FloatingMenu> : null)}
|
||||
</>;
|
||||
}
|
||||
@@ -17,6 +17,7 @@ import { tuneEffective } from '../lib/native-tune';
|
||||
import { tunedFields } from '../lib/tune-values';
|
||||
import { NativeSettings } from './NativeSettings';
|
||||
import { RunImageModel } from './RunImageModel';
|
||||
import { IMAGE_GENERATION_VISIBLE } from '../lib/features';
|
||||
import { useStore } from '../lib/store';
|
||||
import { NativePresets } from './NativePresets';
|
||||
import { NativeTune } from './NativeTune';
|
||||
@@ -135,7 +136,7 @@ export function NativeModels({ onOtherModels, onReady, onImport, onConnectEngine
|
||||
{selectedSize && installed?.ready ? <NativeTuneBadge model={selectedSize.id} resourceProfile={resourceProfile} vision={selectedSize.images ? vision : 'no'}/> : null}
|
||||
<div className="native-model-actions">{tr(loadedSelected ? <><Btn disabled={pending || !!active} onClick={() => void perform(() => nativeAction(`instances/${loadedSelected.id}/unload`))}>{tr("Unload")}</Btn>{tr(onReady ? <Btn variant="primary" onClick={onReady}>{tr("Start chatting")}</Btn> : <span className="native-ready">{tr("Ready")}</span>)}</> : onReady && native?.instances.some(i => i.status === 'ready') ? <Btn variant="primary" onClick={onReady}>{tr("Start chatting")}</Btn> : <><Btn icon="gauge" disabled={!installed?.ready || !native?.available || !!active || !selectedSize} onClick={() => setTuneOpen(true)}>{tr("Tune model")}</Btn><Btn variant="primary" icon="models" disabled={pending || !native?.available || !!active || !selectedSize || expert && deviceChoice === 'split' && gpus.length < 2} onClick={() => void load()}>{tr(pending ? 'Checking…' : installed?.ready ? 'Load model' : 'Download & load')}</Btn></>)}</div>
|
||||
</section>
|
||||
{tr(expert ? <><details className="native-generation"><summary>{tr("Image generation ")}<span className="muted">{tr("Optional")}</span></summary><RunImageModel library={imageLibrary} disabled={pending || !!active} onChange={() => { }}/></details></> : null)}
|
||||
{tr(expert && IMAGE_GENERATION_VISIBLE ? <><details className="native-generation"><summary>{tr("Image generation ")}<span className="muted">{tr("Optional")}</span></summary><RunImageModel library={imageLibrary} disabled={pending || !!active} onChange={() => { }}/></details></> : null)}
|
||||
{tr(expert ? <section id="native-expert-settings" ref={expertSection} className="st-card native-execution"><h2 className="h4">{tr("Expert settings")}</h2>{tr(tunedNow ? <p className="small muted native-tuned-note">{tr("Showing the values of your tuning '{0}'.", [tunedNow.name])}</p> : null)}<label className="native-toggle"><span><strong>{tr("Run multiple models")}</strong><small>{tr("Loading another model keeps the others loaded.")}</small></span><button className="st-toggle" role="switch" aria-label={tr("Run multiple models")} aria-checked={multiple} onClick={() => setMultiple(v => !v)}/></label><h3 className="small strong">{tr("Run on")}</h3><p className="small muted">{tr("Automatic uses the installation\u2019s GPU placement. Choose a GPU, or split this model across several GPUs.")}</p><Select ariaLabel={tr("Run on")} value={deviceChoice} options={[{ value: 'auto', label: 'Automatic' }, ...(native?.hardware?.gpus ?? []).map(g => ({ value: String(g.index), label: `GPU ${g.index + 1} · ${g.name}` })), ...((native?.hardware?.gpus.length ?? 0) > 1 ? [{ value: 'split', label: 'Split across GPUs…' }] : [])]} onChange={value => { setDeviceChoice(value); setGpus(value === 'auto' ? [] : value === 'split' ? (native?.hardware?.gpus ?? []).map(g => g.index) : [Number(value)]); }}/>{tr(deviceChoice === 'split' ? <div className="native-gpu-options">{tr(native?.hardware?.gpus.map(g => <label key={g.index}><input type="checkbox" checked={gpus.includes(g.index)} onChange={e => setGpus(old => e.target.checked ? [...old, g.index] : old.filter(i => i !== g.index))}/><span>{tr("GPU ")}{tr(g.index + 1)} · {tr(g.name)}<small>{tr(g.vram_gb)}{tr(" GB VRAM")}</small></span></label>))}</div> : null)}{tr(gpus.length > 1 ? <label className="input-field"><span>{tr("Layer split")}</span><input className="st-input" value={split} placeholder={tr("auto or 16,32")} onChange={e => setSplit(e.target.value)}/></label> : null)}<div className="native-field-grid"><label className="input-field"><span>{tr("Context memory")}</span><Select ariaLabel={tr("Native KV format")} value={kv} options={[{ value: 'int8', label: 'INT8' }, { value: 'q4_0', label: 'Q4' }, { value: 'k8v4', label: 'K8 / V4' }]} onChange={setKv}/></label><label className="input-field"><span>{tr("Low-RAM mode")}</span><Select ariaLabel={tr("Native low RAM mode")} value={lowRam} options={['auto', 'resident', 'mmap'].map(v => ({ value: v, label: v === 'auto' ? 'Automatic' : v === 'resident' ? 'Keep experts in RAM' : 'Read experts from disk' }))} onChange={setLowRam}/></label></div>{tr(installed ? <NativeSettings model={installed.model}/> : <p className="small muted">{tr("More engine parameters become available after preparing this version.")}</p>)}</section> : null)}
|
||||
</div>
|
||||
<aside className="stack stack--lg"><PcFitCard gpuName={pcGpu?.name} ramGb={pcRam} vramGb={pcVram} fit={selectedSize ? fitOn(selectedSize, fitHardware) : null}/><section className="st-card"><h2 className="h4">{tr("Model files")}</h2><p className="small muted">{tr("Strata prepares all shards, the draft layer and shared files. Completed downloads are reused.")}</p><code className="native-path">{installed?.dataFolder ?? native?.downloadDirectory ?? native?.installed?.data_folder ?? 'Choose an installation'}</code><Btn size="sm" variant="ghost" onClick={() => { setSettingsSection('Storage'); go('settings'); }}>{tr("Storage settings")}</Btn></section><Btn size="sm" variant="ghost" onClick={onOtherModels}>{tr("Other local models\u2026")}</Btn></aside>
|
||||
|
||||
@@ -0,0 +1,96 @@
|
||||
import { api } from './client';
|
||||
import type { PreviewArtifact } from './artifacts';
|
||||
|
||||
/**
|
||||
* Deliverables and grouped activity (notes-split-agent8.md, item 12). The host sends `deliverable` frames for every file the assistant wrote or
|
||||
* changed and `activity-group` frames for runs of tool use between two pieces of text. A reply keeps them in the order they came, so the text
|
||||
* that arrives between activities reads as one continuous piece.
|
||||
*/
|
||||
export type DeliverableKind = 'html' | 'markdown' | 'pdf' | 'csv' | 'image' | 'code' | 'text' | 'other';
|
||||
export interface Deliverable { path: string; abs: string; name: string; kind: DeliverableKind; status: 'created' | 'changed'; size: number; lines: number | null; added: number; removed: number }
|
||||
export interface GroupFile { path: string; name: string; kind: DeliverableKind; status: string; added: number; removed: number }
|
||||
export interface ActivityGroup { id: string; closed: boolean; line: string; added: number; removed: number; files: GroupFile[] }
|
||||
export type MessageBlock = { kind: 'text'; text: string } | ({ kind: 'group' } & ActivityGroup);
|
||||
|
||||
const KINDS = ['html', 'markdown', 'pdf', 'csv', 'image', 'code', 'text', 'other'];
|
||||
const num = (v: unknown) => (Number.isFinite(Number(v)) ? Number(v) : 0);
|
||||
|
||||
export function readDeliverable(raw: unknown): Deliverable | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const f = raw as Record<string, unknown>;
|
||||
if (typeof f.path !== 'string' || !f.path) return null;
|
||||
const name = typeof f.name === 'string' && f.name ? f.name : f.path.split(/[\\/]/).at(-1) ?? f.path;
|
||||
return {
|
||||
path: f.path, abs: typeof f.abs === 'string' ? f.abs : f.path, name, kind: KINDS.includes(String(f.kind)) ? f.kind as DeliverableKind : 'other',
|
||||
status: f.status === 'changed' ? 'changed' : 'created', size: num(f.size), lines: f.lines === null || f.lines === undefined ? null : num(f.lines), added: num(f.added), removed: num(f.removed),
|
||||
};
|
||||
}
|
||||
|
||||
export function readGroup(raw: unknown): ActivityGroup | null {
|
||||
if (!raw || typeof raw !== 'object') return null;
|
||||
const g = raw as Record<string, unknown>;
|
||||
if (typeof g.id !== 'string' || !g.id) return null;
|
||||
const files = Array.isArray(g.files) ? g.files.flatMap((x): GroupFile[] => {
|
||||
const d = readDeliverable(x);
|
||||
return d ? [{ path: d.path, name: d.name, kind: d.kind, status: d.status, added: d.added, removed: d.removed }] : [];
|
||||
}) : [];
|
||||
return { id: g.id, closed: g.closed === true, line: typeof g.line === 'string' ? g.line : '', added: num(g.added), removed: num(g.removed), files };
|
||||
}
|
||||
|
||||
/** Add streamed text to the reply's ordered pieces: it continues the last text piece, or starts a new one after an activity line. */
|
||||
export function appendText(blocks: MessageBlock[] | undefined, text: string): MessageBlock[] {
|
||||
const list = blocks ?? [], last = list.at(-1);
|
||||
if (last?.kind === 'text') return [...list.slice(0, -1), { kind: 'text', text: last.text + text }];
|
||||
return [...list, { kind: 'text', text }];
|
||||
}
|
||||
|
||||
/** A group frame is re-sent while it grows: the same id replaces its line; a new id goes after what came before. */
|
||||
export function upsertGroup(blocks: MessageBlock[] | undefined, group: ActivityGroup): MessageBlock[] {
|
||||
const list = blocks ?? [], at = list.findIndex(b => b.kind === 'group' && b.id === group.id);
|
||||
const next: MessageBlock = { kind: 'group', ...group };
|
||||
return at >= 0 ? list.map((b, i) => (i === at ? next : b)) : [...list, next];
|
||||
}
|
||||
|
||||
/** The same file may be written more than once in a run: one card per path, with its latest numbers. */
|
||||
export function mergeDeliverable(list: Deliverable[] | undefined, file: Deliverable): Deliverable[] {
|
||||
const have = list ?? [], at = have.findIndex(f => f.path === file.path);
|
||||
if (at < 0) return [...have, file];
|
||||
const old = have[at];
|
||||
return have.map((f, i) => (i === at ? { ...file, status: old.status === 'created' ? 'created' : file.status, added: old.added + file.added, removed: old.removed + file.removed } : f));
|
||||
}
|
||||
|
||||
export const fileTypeLabel = (d: { kind: DeliverableKind; name: string }) => {
|
||||
const ext = d.name.includes('.') ? d.name.split('.').at(-1)!.toUpperCase() : '';
|
||||
return d.kind === 'markdown' ? 'MD' : d.kind === 'html' ? 'HTML' : d.kind === 'csv' ? 'CSV' : d.kind === 'pdf' ? 'PDF' : ext && ext.length <= 10 ? ext : d.kind.toUpperCase();
|
||||
};
|
||||
|
||||
export function fileSize(bytes: number): string {
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(bytes < 10240 ? 1 : 0)} KB`;
|
||||
return `${(bytes / 1024 / 1024).toFixed(1)} MB`;
|
||||
}
|
||||
|
||||
const csvText = (rows: string[][]) => rows.map(r => r.map(c => (/[",\n]/.test(c) ? `"${c.replace(/"/g, '""')}"` : c)).join(',')).join('\n');
|
||||
|
||||
interface PreviewAnswer { kind: DeliverableKind; name: string; path: string; size: number; url?: string; text?: string; rows?: string[][]; rawUrl?: string; note?: string }
|
||||
|
||||
/** The sidebar preview of a file: the host reads it (only inside the chat's folder) and the page draws it as a website, markdown, table, picture, PDF or code. */
|
||||
export async function previewOf(sessionId: string, file: { path: string; name: string }): Promise<PreviewArtifact> {
|
||||
const a = await api.get<PreviewAnswer>(`/api/files/preview?sessionId=${encodeURIComponent(sessionId)}&path=${encodeURIComponent(file.path)}`);
|
||||
const id = `file:${a.path}`, title = a.name || file.name;
|
||||
if (a.kind === 'image' && a.rawUrl) return { id, kind: 'image', title, url: a.rawUrl };
|
||||
if (a.kind === 'pdf' && a.rawUrl) return { id, kind: 'pdf', title, url: a.rawUrl };
|
||||
if (a.kind === 'html' && a.text !== undefined) return { id, kind: 'website', title, content: a.text };
|
||||
if (a.kind === 'markdown' && a.text !== undefined) return { id, kind: 'markdown', title, content: a.text };
|
||||
if (a.kind === 'csv' && a.rows) return { id, kind: 'table', title, content: csvText(a.rows) };
|
||||
if (a.text !== undefined) return { id, kind: 'code', title, content: a.text };
|
||||
throw new Error(a.note || 'This file has no preview. Open it in its own app.');
|
||||
}
|
||||
|
||||
export const fileAction = {
|
||||
open: (sessionId: string, path: string, how: 'browser' | 'app' | 'folder') => api.post('/api/files/open', { sessionId, path, how }),
|
||||
fullPath: async (sessionId: string, path: string) => (await api.get<{ path: string }>(`/api/files/path?sessionId=${encodeURIComponent(sessionId)}&path=${encodeURIComponent(path)}`)).path,
|
||||
attach: (sessionId: string, path: string) => api.post('/api/chat/attachments', { sessionId, path }),
|
||||
};
|
||||
|
||||
export const rawUrlOf = (sessionId: string, path: string) => `/api/files/raw?sessionId=${encodeURIComponent(sessionId)}&path=${encodeURIComponent(path)}`;
|
||||
@@ -1 +1,2 @@
|
||||
export const features = { toolAccess: false, thinkingLevels: false, sessionLog: true, demosInComposer: false } as const;
|
||||
/** Image generation is hidden everywhere in the interface for this version (round 8, item 8). The pieces stay in the code; flip this to bring them back. */
|
||||
export const IMAGE_GENERATION_VISIBLE = false;
|
||||
@@ -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 { appendText, mergeDeliverable, readDeliverable, readGroup, upsertGroup } from './deliverables';
|
||||
import { applyPlanFrame, applyQueueFrame, planApprove, queueMessage } 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';
|
||||
@@ -1650,7 +1651,13 @@ export async function sendMessage(text: string, options: { fromLoop?: boolean; g
|
||||
} else if (type === 'agent') {
|
||||
patchSession(sessionId, s => ({ ...s, agents: updateAgent(s.agents ?? [], frame.agent) }));
|
||||
} else if (type === 'delta') {
|
||||
patchAssistant((m) => { const content=m.content+String(frame.text??''); if (m.reasoningStartedAt && m.reasoningMs === undefined) m = { ...m, reasoningMs: Date.now() - m.reasoningStartedAt }; const count=Math.max(1,Math.ceil((content.length+(m.reasoning?.length??0))/4)); return {...m,content,tokens:m.usageSource==='estimated'&&m.tps?m.tokens:count,inputTokens:m.inputTokens??Math.ceil((body.length+prior.reduce((n,p)=>n+p.content.length,0))/4),usageSource:'estimated'}; });
|
||||
patchAssistant((m) => { const content=m.content+String(frame.text??''); if (m.reasoningStartedAt && m.reasoningMs === undefined) m = { ...m, reasoningMs: Date.now() - m.reasoningStartedAt }; const count=Math.max(1,Math.ceil((content.length+(m.reasoning?.length??0))/4)); return {...m,content,...(m.blocks?{blocks:appendText(m.blocks,String(frame.text??''))}:{}),tokens:m.usageSource==='estimated'&&m.tps?m.tokens:count,inputTokens:m.inputTokens??Math.ceil((body.length+prior.reduce((n,p)=>n+p.content.length,0))/4),usageSource:'estimated'}; });
|
||||
} else if (type === 'deliverable') {
|
||||
const file = readDeliverable(frame);
|
||||
if (file) patchAssistant(m => ({ ...m, deliverables: mergeDeliverable(m.deliverables, file) }));
|
||||
} else if (type === 'activity-group') {
|
||||
const group = readGroup(frame);
|
||||
if (group) patchAssistant(m => ({ ...m, blocks: upsertGroup(m.blocks ?? (m.content ? appendText(undefined, m.content) : undefined), group) }));
|
||||
} else if (type === 'artifacts' && Array.isArray(frame.artifacts)) {
|
||||
patchAssistant(m => ({ ...m, artifacts: frame.artifacts as PreviewArtifact[] }));
|
||||
} else if(type==='native-tool'){
|
||||
|
||||
@@ -320,6 +320,10 @@ export interface ChatMessage {
|
||||
timeSkipId?: string;
|
||||
/** The plan this reply proposed: shown as the plan card in place of the reply text. */
|
||||
planId?: string;
|
||||
/** The reply in the order it came: text and grouped activity lines (round 8, item 12). Absent on older replies. */
|
||||
blocks?: import('./deliverables').MessageBlock[];
|
||||
/** Files the assistant made or changed in this reply, one card each. */
|
||||
deliverables?: import('./deliverables').Deliverable[];
|
||||
/** A line from the app itself (for example from /loop), never sent to the model. */
|
||||
local?: boolean;
|
||||
ttftMs?: number;
|
||||
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "übersprungen",
|
||||
"s3092": "Pausiert · {0} von {1} erledigt",
|
||||
"s3093": "Plan genehmigt.",
|
||||
"s3094": "Der Assistent antwortet noch",
|
||||
"s3095": "Senden Sie Ihre Nachricht, wenn er fertig ist.",
|
||||
"s3096": "Die Nachricht wurde nicht eingereiht",
|
||||
"s3097": "In der Warteschlange — wird danach gesendet",
|
||||
"s3098": "In der Warteschlange — wird gesendet, wenn das Ziel erreicht ist"
|
||||
"s3094": "Experimentell",
|
||||
"s3095": "Weitere Möglichkeiten, {0} zu öffnen",
|
||||
"s3096": "Dateiaktionen",
|
||||
"s3097": "Im Ordner anzeigen",
|
||||
"s3098": "Pfad kopieren",
|
||||
"s3099": "Als Kontext anhängen",
|
||||
"s3100": "Pfad kopiert",
|
||||
"s3101": "An Ihre nächste Nachricht angehängt",
|
||||
"s3102": "Die Datei wurde nicht geöffnet",
|
||||
"s3103": "Für diese Datei gibt es keine Vorschau",
|
||||
"s3104": "Der Ordner wurde nicht geöffnet",
|
||||
"s3105": "Der Pfad wurde nicht kopiert",
|
||||
"s3106": "Die Datei wurde nicht angehängt",
|
||||
"s3107": "{0} Zeilen hinzugefügt, {1} entfernt",
|
||||
"s3108": "{0} Dateien bearbeitet",
|
||||
"s3109": "Alle anzeigen",
|
||||
"s3110": "Dateien hier ablegen, um sie hinzuzufügen",
|
||||
"s3111": "Bilder und Textdateien"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "skipped",
|
||||
"s3092": "Paused · {0} of {1} done",
|
||||
"s3093": "Approved the plan.",
|
||||
"s3094": "The assistant is still answering",
|
||||
"s3095": "Send your message when it has finished.",
|
||||
"s3096": "The message was not queued",
|
||||
"s3097": "Queued — sends after that",
|
||||
"s3098": "Queued — sends when the goal finishes"
|
||||
"s3094": "Experimental",
|
||||
"s3095": "More ways to open {0}",
|
||||
"s3096": "File actions",
|
||||
"s3097": "Show in folder",
|
||||
"s3098": "Copy path",
|
||||
"s3099": "Attach as context",
|
||||
"s3100": "Path copied",
|
||||
"s3101": "Attached to your next message",
|
||||
"s3102": "The file was not opened",
|
||||
"s3103": "The file has no preview",
|
||||
"s3104": "The folder was not opened",
|
||||
"s3105": "The path was not copied",
|
||||
"s3106": "The file was not attached",
|
||||
"s3107": "{0} lines added, {1} removed",
|
||||
"s3108": "Edited {0} files",
|
||||
"s3109": "See all",
|
||||
"s3110": "Drop files to add them",
|
||||
"s3111": "Pictures and text files"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "omitido",
|
||||
"s3092": "En pausa · {0} de {1} hechos",
|
||||
"s3093": "Plan aprobado.",
|
||||
"s3094": "El asistente aún está respondiendo",
|
||||
"s3095": "Envía tu mensaje cuando haya terminado.",
|
||||
"s3096": "No se pudo poner el mensaje en cola",
|
||||
"s3097": "En cola — se envía después",
|
||||
"s3098": "En cola — se envía cuando termine el objetivo"
|
||||
"s3094": "Experimental",
|
||||
"s3095": "Más formas de abrir {0}",
|
||||
"s3096": "Acciones del archivo",
|
||||
"s3097": "Mostrar en la carpeta",
|
||||
"s3098": "Copiar la ruta",
|
||||
"s3099": "Adjuntar como contexto",
|
||||
"s3100": "Ruta copiada",
|
||||
"s3101": "Adjunto a tu próximo mensaje",
|
||||
"s3102": "No se abrió el archivo",
|
||||
"s3103": "Este archivo no tiene vista previa",
|
||||
"s3104": "No se abrió la carpeta",
|
||||
"s3105": "No se copió la ruta",
|
||||
"s3106": "No se adjuntó el archivo",
|
||||
"s3107": "{0} líneas añadidas, {1} eliminadas",
|
||||
"s3108": "{0} archivos editados",
|
||||
"s3109": "Ver todo",
|
||||
"s3110": "Suelta archivos para añadirlos",
|
||||
"s3111": "Imágenes y archivos de texto"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "スキップ",
|
||||
"s3092": "一時停止中 · {1} 件中 {0} 件完了",
|
||||
"s3093": "プランを承認しました。",
|
||||
"s3094": "アシスタントはまだ回答中です",
|
||||
"s3095": "完了してからメッセージを送ってください。",
|
||||
"s3096": "メッセージを待機に入れられませんでした",
|
||||
"s3097": "待機中 — その後に送信",
|
||||
"s3098": "待機中 — ゴールの完了後に送信"
|
||||
"s3094": "試験的",
|
||||
"s3095": "{0} を開くその他の方法",
|
||||
"s3096": "ファイル操作",
|
||||
"s3097": "フォルダーで表示",
|
||||
"s3098": "パスをコピー",
|
||||
"s3099": "コンテキストとして添付",
|
||||
"s3100": "パスをコピーしました",
|
||||
"s3101": "次のメッセージに添付しました",
|
||||
"s3102": "ファイルを開けませんでした",
|
||||
"s3103": "このファイルはプレビューできません",
|
||||
"s3104": "フォルダーを開けませんでした",
|
||||
"s3105": "パスをコピーできませんでした",
|
||||
"s3106": "ファイルを添付できませんでした",
|
||||
"s3107": "{0} 行追加、{1} 行削除",
|
||||
"s3108": "{0} 個のファイルを編集",
|
||||
"s3109": "すべて表示",
|
||||
"s3110": "ファイルをドロップして追加",
|
||||
"s3111": "画像とテキストファイル"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "건너뜀",
|
||||
"s3092": "일시 중지 · {1}개 중 {0}개 완료",
|
||||
"s3093": "계획을 승인했습니다.",
|
||||
"s3094": "어시스턴트가 아직 답하는 중입니다",
|
||||
"s3095": "끝난 뒤에 메시지를 보내 주세요.",
|
||||
"s3096": "메시지를 대기열에 넣지 못했습니다",
|
||||
"s3097": "대기 중 — 그 다음에 전송됩니다",
|
||||
"s3098": "대기 중 — 목표가 끝나면 전송됩니다"
|
||||
"s3094": "실험적",
|
||||
"s3095": "{0}을(를) 여는 다른 방법",
|
||||
"s3096": "파일 작업",
|
||||
"s3097": "폴더에서 보기",
|
||||
"s3098": "경로 복사",
|
||||
"s3099": "컨텍스트로 첨부",
|
||||
"s3100": "경로를 복사했습니다",
|
||||
"s3101": "다음 메시지에 첨부했습니다",
|
||||
"s3102": "파일을 열지 못했습니다",
|
||||
"s3103": "이 파일은 미리 볼 수 없습니다",
|
||||
"s3104": "폴더를 열지 못했습니다",
|
||||
"s3105": "경로를 복사하지 못했습니다",
|
||||
"s3106": "파일을 첨부하지 못했습니다",
|
||||
"s3107": "{0}줄 추가, {1}줄 삭제",
|
||||
"s3108": "파일 {0}개 편집됨",
|
||||
"s3109": "모두 보기",
|
||||
"s3110": "파일을 놓아 추가하세요",
|
||||
"s3111": "사진 및 텍스트 파일"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "ignorado",
|
||||
"s3092": "Pausado · {0} de {1} concluídos",
|
||||
"s3093": "Plano aprovado.",
|
||||
"s3094": "O assistente ainda está respondendo",
|
||||
"s3095": "Envie sua mensagem quando ele terminar.",
|
||||
"s3096": "A mensagem não foi colocada na fila",
|
||||
"s3097": "Na fila — enviada depois disso",
|
||||
"s3098": "Na fila — enviada quando a meta terminar"
|
||||
"s3094": "Experimental",
|
||||
"s3095": "Mais formas de abrir {0}",
|
||||
"s3096": "Ações do arquivo",
|
||||
"s3097": "Mostrar na pasta",
|
||||
"s3098": "Copiar o caminho",
|
||||
"s3099": "Anexar como contexto",
|
||||
"s3100": "Caminho copiado",
|
||||
"s3101": "Anexado à sua próxima mensagem",
|
||||
"s3102": "O arquivo não foi aberto",
|
||||
"s3103": "Este arquivo não tem pré-visualização",
|
||||
"s3104": "A pasta não foi aberta",
|
||||
"s3105": "O caminho não foi copiado",
|
||||
"s3106": "O arquivo não foi anexado",
|
||||
"s3107": "{0} linhas adicionadas, {1} removidas",
|
||||
"s3108": "{0} arquivos editados",
|
||||
"s3109": "Ver tudo",
|
||||
"s3110": "Solte arquivos para adicioná-los",
|
||||
"s3111": "Imagens e arquivos de texto"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "пропущено",
|
||||
"s3092": "Пауза · готово {0} из {1}",
|
||||
"s3093": "План одобрен.",
|
||||
"s3094": "Ассистент ещё отвечает",
|
||||
"s3095": "Отправьте сообщение, когда он закончит.",
|
||||
"s3096": "Сообщение не удалось поставить в очередь",
|
||||
"s3097": "В очереди — отправится после этого",
|
||||
"s3098": "В очереди — отправится, когда цель будет достигнута"
|
||||
"s3094": "Экспериментально",
|
||||
"s3095": "Другие способы открыть {0}",
|
||||
"s3096": "Действия с файлом",
|
||||
"s3097": "Показать в папке",
|
||||
"s3098": "Копировать путь",
|
||||
"s3099": "Прикрепить как контекст",
|
||||
"s3100": "Путь скопирован",
|
||||
"s3101": "Прикреплено к вашему следующему сообщению",
|
||||
"s3102": "Файл не удалось открыть",
|
||||
"s3103": "У этого файла нет предпросмотра",
|
||||
"s3104": "Папку не удалось открыть",
|
||||
"s3105": "Путь не удалось скопировать",
|
||||
"s3106": "Файл не удалось прикрепить",
|
||||
"s3107": "Добавлено строк: {0}, удалено: {1}",
|
||||
"s3108": "Изменено файлов: {0}",
|
||||
"s3109": "Показать все",
|
||||
"s3110": "Перетащите файлы, чтобы добавить их",
|
||||
"s3111": "Изображения и текстовые файлы"
|
||||
}
|
||||
@@ -3087,9 +3087,22 @@
|
||||
"s3091": "已跳过",
|
||||
"s3092": "已暂停 · 已完成 {0}/{1}",
|
||||
"s3093": "已批准计划。",
|
||||
"s3094": "助手仍在回答",
|
||||
"s3095": "等它完成后再发送你的消息。",
|
||||
"s3096": "消息未能排队",
|
||||
"s3097": "已排队 — 在此之后发送",
|
||||
"s3098": "已排队 — 目标完成后发送"
|
||||
"s3094": "实验性",
|
||||
"s3095": "打开 {0} 的更多方式",
|
||||
"s3096": "文件操作",
|
||||
"s3097": "在文件夹中显示",
|
||||
"s3098": "复制路径",
|
||||
"s3099": "作为上下文附加",
|
||||
"s3100": "路径已复制",
|
||||
"s3101": "已附加到你的下一条消息",
|
||||
"s3102": "文件未能打开",
|
||||
"s3103": "此文件无法预览",
|
||||
"s3104": "文件夹未能打开",
|
||||
"s3105": "路径未能复制",
|
||||
"s3106": "文件未能附加",
|
||||
"s3107": "新增 {0} 行,删除 {1} 行",
|
||||
"s3108": "已编辑 {0} 个文件",
|
||||
"s3109": "查看全部",
|
||||
"s3110": "拖放文件即可添加",
|
||||
"s3111": "图片和文本文件"
|
||||
}
|
||||
@@ -21,6 +21,8 @@ import { ReasoningBlock } from '../components/ReasoningBlock';
|
||||
import { StatusLine } from '../components/StatusLine';
|
||||
import { GoalBar } from '../components/GoalBar';
|
||||
import { PlanCard, PlanPanel, QueuedMessages } from '../components/PlanCard';
|
||||
import { DropZone } from '../components/DropZone';
|
||||
import { ActivityLine, EditedFiles, FileCard } from '../components/Deliverables';
|
||||
import { queueMessage, usePlan, usePlanQuiet } from '../lib/plan';
|
||||
import { plainFailureText } from '../lib/plain-errors';
|
||||
import { useLiveStatus } from '../lib/live-status';
|
||||
@@ -358,7 +360,7 @@ export function ChatScreen() {
|
||||
return (<>
|
||||
<ChatToolbar previewWidth={paneWidth} extraTabs={extraTabs} session={session} items={previews} onCloseTab={closeTab} selected={setupVisible ? null : selectedPreview} onSelect={selectPreview} onClose={() => { setSelectedPreview(null); setExpanded(false); }} inline={inlinePreview} expanded={expanded} onExpand={() => setExpanded(v => !v)}/>
|
||||
<div className="chatsplit" style={splitStyle} data-timeskip={!!selectedRun || undefined} ref={splitRef} data-preview={!!selectedPreview && inlinePreview || undefined} data-expanded={expanded && !!selectedPreview && inlinePreview || undefined}>
|
||||
<div className="chatcol">
|
||||
<DropZone className="chatcol">
|
||||
<div className="main__body chat" ref={scroller}>
|
||||
{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)}
|
||||
@@ -367,7 +369,7 @@ export function ChatScreen() {
|
||||
</div>
|
||||
</div>
|
||||
<Composer draft={draft} setDraft={updateDraft} loaded={!!loaded} streaming={streaming} onSubmit={submit} onKey={onComposerKey} session={session} onPreview={openPreview} textareaRef={textarea}/>
|
||||
</div>
|
||||
</DropZone>
|
||||
<ArtifactPanel items={previews} onCloseTab={closeTab} selected={setupVisible ? null : selectedPreview} onSelect={selectPreview} onClose={() => setSelectedPreview(null)} inline={inlinePreview}/>
|
||||
{tr(resizeHandle)}
|
||||
</div>
|
||||
@@ -380,7 +382,7 @@ export function ChatScreen() {
|
||||
the context panel open, a full-width composer sat underneath the panel
|
||||
and drifted out of alignment with the transcript it belongs to. */}
|
||||
<div className="chatsplit" style={splitStyle} data-timeskip={!!selectedRun || undefined} ref={splitRef} data-preview={!!selectedPreview && inlinePreview || undefined} data-expanded={expanded && !!selectedPreview && inlinePreview || undefined}>
|
||||
<div className="chatcol">
|
||||
<DropZone className="chatcol">
|
||||
<div className="main__body chat" ref={scroller} onScroll={(e) => {
|
||||
const el = e.currentTarget;
|
||||
if (session)
|
||||
@@ -403,7 +405,7 @@ export function ChatScreen() {
|
||||
<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>
|
||||
</DropZone>
|
||||
{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)}
|
||||
{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}/>
|
||||
@@ -571,6 +573,8 @@ function Message({ message: m, isLast, onEditPrompt, onPreview, onOpenLink, onOp
|
||||
// A reply that proposed a plan shows the plan card in place of its closing text (which is the plan in prose).
|
||||
const storedPlan = usePlanQuiet(m.planId ? activeSession : null);
|
||||
const planCard = !!m.planId && storedPlan?.id === m.planId;
|
||||
// A reply with activity lines is drawn piece by piece in the order it came; one without is the plain text it always was.
|
||||
const grouped = !!m.blocks?.some(b => b.kind === 'group');
|
||||
const [sentTime, setSentTime] = useState(() => relTime(m.at));
|
||||
if (m.role === 'user') {
|
||||
return (<div className="st-msg st-msg--user" onMouseEnter={() => setSentTime(relTime(m.at))} onFocus={() => setSentTime(relTime(m.at))}>
|
||||
@@ -593,18 +597,20 @@ function Message({ message: m, isLast, onEditPrompt, onPreview, onOpenLink, onOp
|
||||
{tr(m.reasoning ? <ReasoningBlock message={m}/> : null)}
|
||||
|
||||
|
||||
{tr((m.tools ?? []).map((t) => (<ToolCard key={t.id} messageId={m.id} tool={t}/>)))}
|
||||
{tr((m.tools ?? []).filter(t => !grouped || t.state !== 'done').map((t) => (<ToolCard key={t.id} messageId={m.id} tool={t}/>)))}
|
||||
|
||||
{tr(!(m.timeSkipId && timeSkipReal && !timeSkipDone) && (m.content || m.error || !m.streaming || !liveStatus) ? <div className="st-bubble">
|
||||
{tr(planCard ? <PlanCard chatId={activeSession} planId={m.planId!}/> : null)}
|
||||
{tr(m.error ? (<ErrorNotice message={m.error} next={tr("Try sending the message again.")}/>) : null)}
|
||||
{tr(m.content && !planCard ? (<Markdown text={m.timeSkipId && !timeSkipReal ? timeSkipDone ? tr('The result is ready. Switch between Original and Updated, or compare them side by side. This example uses sample outputs and simulated checks.') : tr('Revising the saved draft. Follow the result in the sidebar. This example uses sample outputs and simulated checks.') : m.content} onOpenLink={onOpenLink} onPreviewHtml={content => onPreview({ id: m.id + '-html', kind: 'website', title: 'HTML preview', content })}/>) : !m.error && m.streaming && !liveStatus ? (<span className="typing" aria-label={tr("Generating")}>
|
||||
{tr(grouped && !planCard && !m.timeSkipId ? m.blocks!.map((b, i) => b.kind === 'group' ? <ActivityLine key={b.id} group={b} sessionId={activeSession ?? ''} onPreview={onPreview}/> : <Markdown key={i} text={b.text} onOpenLink={onOpenLink} onPreviewHtml={content => onPreview({ id: m.id + '-html-' + i, kind: 'website', title: 'HTML preview', content })}/>) : null)}
|
||||
{tr(m.content && !planCard && !grouped ? (<Markdown text={m.timeSkipId && !timeSkipReal ? timeSkipDone ? tr('The result is ready. Switch between Original and Updated, or compare them side by side. This example uses sample outputs and simulated checks.') : tr('Revising the saved draft. Follow the result in the sidebar. This example uses sample outputs and simulated checks.') : m.content} onOpenLink={onOpenLink} onPreviewHtml={content => onPreview({ id: m.id + '-html', kind: 'website', title: 'HTML preview', content })}/>) : !m.error && m.streaming && !liveStatus ? (<span className="typing" aria-label={tr("Generating")}>
|
||||
<i />
|
||||
<i />
|
||||
<i />
|
||||
</span>) : null)}
|
||||
{tr(m.streaming && m.content ? <span className="caret" aria-hidden="true"/> : null)}
|
||||
</div> : null)}
|
||||
{tr(m.deliverables?.length && !m.streaming ? <div className="deliverables">{m.deliverables.map(f => <FileCard key={f.path} file={f} sessionId={activeSession ?? ''} onPreview={onPreview}/>)}<EditedFiles files={m.deliverables} sessionId={activeSession ?? ''} onPreview={onPreview}/></div> : null)}
|
||||
{tr(m.streaming && isLast && !m.timeSkipId ? <StatusLine sessionId={activeSession} startedAt={Date.parse(m.at) || Date.now()} tokens={m.tokens}/> : null)}
|
||||
|
||||
{tr(m.timeSkipId && timeSkipReal && !timeSkipDone && timeSkipRun ? <TimeSkipWorking run={timeSkipRun} sessionId={activeSession ?? ''}/> : m.timeSkipId && (!timeSkipReal || (timeSkipRun?.job?.files?.length ?? 0) > 0) ? <button className="timeskip-chat-card" onClick={() => onOpenTimeSkip(m.timeSkipId!)}><Icon name="branch" size={20}/><span><strong>{tr("Time-skip")}</strong><span>{tr(timeSkipDone ? 'Result ready · compare versions' : 'Revising · follow progress')}</span></span><Icon name="chevron" size={16} className="timeskip-card-arrow"/></button> : null)}
|
||||
|
||||
@@ -10,6 +10,7 @@ import { RunningModels } from '../components/RunningModels';
|
||||
import { LocalModelImport } from '../components/LocalModelImport';
|
||||
import { gpuId } from '../lib/monitor-hardware';
|
||||
import { RunImageModel } from '../components/RunImageModel';
|
||||
import { IMAGE_GENERATION_VISIBLE } from '../lib/features';
|
||||
import { FloatingMenu } from '../components/FloatingMenu';
|
||||
import { ModelsScreen } from './Models';
|
||||
import { configDocument, configPatch, readConfig, type ConfigDocument } from '../lib/config';
|
||||
@@ -424,7 +425,7 @@ function LegacyModelRunScreen({ importFirst = false, initialVariant }: {
|
||||
<section className="run-card run-model-choice">
|
||||
<div className="run-version-choice"><span>{tr("Version")}</span><Select ariaLabel={tr("Model version")} value={model.id} disabled={pending} menuClassName="run-version-menu" options={[...versions.map(v => ({ value: v.id, label: `${v.name} · ${v.quant} · ${sizeGb(v.diskGb)}${v.local ? ' · Local' : ''}` })), { value: 'use-local-model', label: 'Use a local model…' }]} onChange={id => id === 'use-local-model' ? setLocalModelOpen(true) : chooseModel(id)}/></div>
|
||||
{tr(model.local ? <div className="run-local-model-note"><Icon name="model-file" size={15}/><span>{tr("Local model \u00B7 ")}{tr(model.local.architecture)}{tr(" \u00B7 Compatibility checked on load.")}</span><button className="text-btn" onClick={() => setLocalModelOpen(true)}>{tr("Change file")}</button></div> : null)}
|
||||
<RunImageModel library={imageModels} disabled={pending || imagePending || !connected} onChange={() => setStage('idle')}/>
|
||||
{IMAGE_GENERATION_VISIBLE ? <RunImageModel library={imageModels} disabled={pending || imagePending || !connected} onChange={() => setStage('idle')}/> : null}
|
||||
</section>
|
||||
<section className="run-card run-context"><div className="run-card__head"><span><Icon name="chat" size={19}/><h2>{tr("Conversation context")}</h2></span><strong>{tr(ctx / 1024)}{tr("K ")}<small>{tr("tokens")}</small></strong></div><p>{tr("How much your model can keep in mind.")}</p>
|
||||
<div className="run-context-presets" role="group" aria-label={tr("Context presets")}>{tr([32, 64, 128, 256].map(k => <button key={k} disabled={k > contextMax} aria-pressed={ctx === k * 1024} onClick={() => setContext(k)}><span>{tr(k)}{tr("K")}</span></button>))}</div>
|
||||
|
||||
@@ -2298,7 +2298,7 @@ textarea.st-input {
|
||||
.railsection__chev {
|
||||
flex: none;
|
||||
opacity: 0.45;
|
||||
transform: rotate(-90deg);
|
||||
transform: rotate(180deg);
|
||||
transition: transform var(--st-t-control) var(--st-ease-standard);
|
||||
}
|
||||
.railsection[data-open] .railsection__chev {
|
||||
@@ -3127,7 +3127,7 @@ textarea.st-input {
|
||||
.ws__chev {
|
||||
flex: none;
|
||||
opacity: 0.5;
|
||||
transform: rotate(-90deg);
|
||||
transform: rotate(180deg);
|
||||
transition: transform var(--st-t-control) var(--st-ease-standard);
|
||||
}
|
||||
.ws__chev.is-open {
|
||||
@@ -6009,7 +6009,7 @@ button.menu__item:disabled { opacity: .5; cursor: default; }
|
||||
.tunnel-stage__symbol { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 50%; background: var(--st-accent-tint); color: var(--st-accent-text); }
|
||||
.tunnel-stage .install-command { margin: 0; }
|
||||
.tunnel-stage .install-command code { overflow-wrap: anywhere; white-space: normal; }
|
||||
.wizard-next { transform: rotate(-90deg); }
|
||||
.wizard-next { transform: rotate(180deg); }
|
||||
@media (hover: none) { .artifact-tabs .artifact-tab__close { opacity: 1; } }
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.tunnel-stage { animation: none; }
|
||||
@@ -6752,7 +6752,7 @@ textarea {
|
||||
inset:0;
|
||||
width:100%;
|
||||
height:100%;
|
||||
transform:rotate(-90deg);
|
||||
transform:rotate(180deg);
|
||||
|
||||
}
|
||||
.tune-orbit circle {
|
||||
@@ -6872,7 +6872,7 @@ textarea {
|
||||
|
||||
}
|
||||
.preview-controls > .st-btn:nth-of-type(2) svg {
|
||||
transform:rotate(-90deg);
|
||||
transform:rotate(180deg);
|
||||
|
||||
}
|
||||
.pdf-controls .preview-controls {
|
||||
@@ -7384,6 +7384,60 @@ textarea {
|
||||
.native-choice__col .native-resource-choice button:focus-visible { outline: 2px solid var(--st-accent); outline-offset: 1px; }
|
||||
|
||||
/* the version dropdown's chevron turns when it opens (round 8, item 7) */
|
||||
.version-trigger__chev { transform: rotate(90deg); transition: transform var(--st-t-local, 160ms) var(--st-ease-in-out, ease); }
|
||||
.version-trigger[aria-expanded="true"] .version-trigger__chev { transform: rotate(-90deg); }
|
||||
.version-trigger__chev { transition: transform var(--st-t-local, 160ms) var(--st-ease-in-out, ease); }
|
||||
.version-trigger[aria-expanded="true"] .version-trigger__chev { transform: rotate(180deg); }
|
||||
@media (prefers-reduced-motion: reduce) { .version-trigger__chev { transition: none; } }
|
||||
|
||||
/* Models navbar: the family as an icon, a name and a chevron (round 8, item 5) */
|
||||
.family-trigger { display: inline-flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px 0 10px; border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface); color: var(--st-ink); font: 700 var(--st-fs-md) var(--st-font); cursor: pointer; }
|
||||
.family-trigger:hover { background: var(--st-surface-2); }
|
||||
.family-trigger svg:first-child { color: var(--st-icon); }
|
||||
.family-trigger__chev { color: var(--st-icon); transition: transform var(--st-t-local, 160ms) var(--st-ease-in-out, ease); }
|
||||
.family-trigger[aria-expanded="true"] .family-trigger__chev { transform: rotate(180deg); }
|
||||
@media (prefers-reduced-motion: reduce) { .family-trigger__chev { transition: none; } }
|
||||
.family-menu { display: flex; flex-direction: column; gap: 2px; padding: 6px; }
|
||||
.family-menu__item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--st-ink); text-align: left; font: inherit; cursor: pointer; }
|
||||
.family-menu__item:hover, .family-menu__item:focus-visible { background: var(--st-surface-2); }
|
||||
.family-menu__item[aria-checked="true"] { background: var(--st-surface-2); }
|
||||
.family-menu__item small { display: block; color: var(--st-ink-muted); font-size: var(--st-fs-xs); }
|
||||
.family-menu__check { margin-left: auto; color: var(--st-accent-text); }
|
||||
|
||||
/* Deliverables: file cards, the Edited summary and grouped activity lines (round 8, item 12) */
|
||||
.fcard { position: relative; display: flex; align-items: center; gap: 12px; margin: 8px 0; padding: 10px 10px 10px 14px; border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface); }
|
||||
.fcard__type { flex: none; min-width: 46px; padding: 3px 7px; border: 1px solid var(--st-line); border-radius: 6px; text-align: center; font-size: 10px; font-weight: 800; letter-spacing: .04em; color: var(--st-ink-soft); }
|
||||
.fcard__name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
|
||||
.fcard__name strong { font-size: var(--st-fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.fcard__name span { color: var(--st-ink-muted); font-size: var(--st-fs-xs); font-variant-numeric: tabular-nums; }
|
||||
.fcard__split { display: inline-flex; flex: none; }
|
||||
.fcard__open, .fcard__more { height: 32px; border: 1px solid var(--st-line); background: var(--st-surface); color: var(--st-ink); font: 600 var(--st-fs-sm) var(--st-font); cursor: pointer; }
|
||||
.fcard__open { padding: 0 16px; border-radius: 8px 0 0 8px; }
|
||||
.fcard__more { width: 30px; display: grid; place-items: center; border-left: 0; border-radius: 0 8px 8px 0; padding: 0; }
|
||||
.fcard__open:hover, .fcard__more:hover { background: var(--st-surface-2); }
|
||||
.fcard__open:disabled { opacity: .6; cursor: progress; }
|
||||
.fcard__chev { transition: transform var(--st-t-local, 160ms) ease; }
|
||||
.fcard__more[aria-expanded="true"] .fcard__chev { transform: rotate(180deg); }
|
||||
.pm { display: inline-flex; gap: 5px; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
|
||||
.pm__a { color: var(--st-success, #15803d); }
|
||||
.pm__d { color: var(--st-danger, #b42318); }
|
||||
.edited { margin: 10px 0; border: 1px solid var(--st-line); border-radius: var(--st-r-md); background: var(--st-surface); overflow: hidden; }
|
||||
.edited__head { padding: 10px 16px; border-bottom: 1px solid var(--st-line-soft); font-size: var(--st-fs-sm); }
|
||||
.edited__row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 16px; border: 0; background: transparent; color: var(--st-ink); font: inherit; font-size: var(--st-fs-sm); text-align: left; cursor: pointer; }
|
||||
.edited__row span:first-of-type { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.edited__row:hover:not(:disabled) { background: var(--st-surface-2); }
|
||||
.edited__row--all { border-top: 1px solid var(--st-line-soft); color: var(--st-ink-soft); }
|
||||
.edited__row:disabled { cursor: default; }
|
||||
.act { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0; color: var(--st-ink-muted); font-size: var(--st-fs-sm); }
|
||||
.act__line { display: inline-flex; align-items: center; gap: 8px; flex: 1; min-width: 0; padding: 2px 0; border: 0; background: transparent; color: inherit; font: inherit; text-align: left; cursor: pointer; }
|
||||
.act__line:disabled { cursor: default; }
|
||||
.act__chev { color: var(--st-icon); transition: transform var(--st-t-local, 160ms) ease; }
|
||||
.act[data-open] .act__chev { transform: rotate(180deg); }
|
||||
.act__live { width: 6px; height: 6px; border-radius: 50%; background: var(--st-accent); animation: plan-glow 1.8s ease-out infinite; }
|
||||
.act__thumb { width: 44px; height: 30px; object-fit: cover; border-radius: 6px; border: 1px solid var(--st-line); cursor: pointer; }
|
||||
.act__files { flex-basis: 100%; list-style: none; margin: 0; padding: 0 0 0 4px; display: flex; flex-direction: column; }
|
||||
.act__files button { display: inline-flex; align-items: center; gap: 8px; padding: 4px 0; border: 0; background: transparent; color: var(--st-ink-soft); font: inherit; cursor: pointer; }
|
||||
@media (prefers-reduced-motion: reduce) { .act__live, .fcard__chev, .act__chev { animation: none; transition: none; } }
|
||||
|
||||
/* Dropping files on the chat (round 8, item 8) */
|
||||
.chatcol { position: relative; }
|
||||
.dropzone { position: absolute; inset: 8px; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; border: 2px dashed var(--st-accent); border-radius: var(--st-r-lg); background: color-mix(in srgb, var(--st-surface) 88%, var(--st-accent) 12%); color: var(--st-ink); pointer-events: none; }
|
||||
.dropzone span { color: var(--st-ink-muted); font-size: var(--st-fs-sm); }
|
||||
@@ -73,7 +73,7 @@ test('a feed that cannot be reached is a failure only when there is no engine ye
|
||||
const have = await createEngineStep({ control: control({ usable: true, checkError: 'could not be read' }) }).run();
|
||||
assert.equal(have.state, 'skipped');
|
||||
assert.match(have.message, /engine for this PC is installed/);
|
||||
assert.match(have.details, /could not be reached/);
|
||||
assert.equal(have.details, undefined, 'nothing to say when an engine is installed');
|
||||
});
|
||||
|
||||
test('an engine that is already current downloads nothing; one with no package for this PC is a failure', async () => {
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/** Round 8: deliverable cards, grouped activity and the pieces of a reply in order (contract: notes-split-agent8.md, item 12). */
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
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));
|
||||
const result = await build({ entryPoints: [src('lib/deliverables.ts')], bundle: true, format: 'esm', platform: 'node', write: false, alias: { react: stub }, logLevel: 'silent' });
|
||||
const D = await import(`data:text/javascript;base64,${Buffer.from(result.outputFiles[0].text).toString('base64')}`);
|
||||
|
||||
test('a deliverable frame is read; unknown kinds become "other"; no path means no card', () => {
|
||||
const d = D.readDeliverable({ path: 'a/pagoda.html', abs: 'C:/a/pagoda.html', kind: 'html', status: 'created', size: 7270, lines: 225, added: 225, removed: 0 });
|
||||
assert.equal(d.name, 'pagoda.html'); assert.equal(D.fileTypeLabel(d), 'HTML');
|
||||
assert.equal(D.readDeliverable({ path: 'x.bin', kind: 'weird' }).kind, 'other');
|
||||
assert.equal(D.readDeliverable({ kind: 'html' }), null);
|
||||
assert.equal(D.fileTypeLabel({ kind: 'markdown', name: 'README.md' }), 'MD');
|
||||
assert.equal(D.fileSize(7270), '7.1 KB'); assert.equal(D.fileSize(512), '512 B');
|
||||
});
|
||||
|
||||
test('text between activities stays in order: text, group, text; a group frame re-sent replaces its line', () => {
|
||||
let b = D.appendText(undefined, 'Building. ');
|
||||
b = D.appendText(b, 'Now.');
|
||||
b = D.upsertGroup(b, D.readGroup({ id: 'g1', closed: false, line: 'Ran a command', files: [] }));
|
||||
b = D.appendText(b, 'Next.');
|
||||
b = D.upsertGroup(b, D.readGroup({ id: 'g1', closed: true, line: 'Ran 2 commands', files: [] }));
|
||||
assert.deepEqual(b.map(x => x.kind), ['text', 'group', 'text']);
|
||||
assert.equal(b[0].text, 'Building. Now.'); assert.equal(b[1].line, 'Ran 2 commands'); assert.equal(b[1].closed, true);
|
||||
});
|
||||
|
||||
test('one card per path; created stays created and the line counts add up', () => {
|
||||
const a = D.readDeliverable({ path: 'p.html', kind: 'html', status: 'created', size: 10, lines: 5, added: 5, removed: 0 });
|
||||
const b = D.readDeliverable({ path: 'p.html', kind: 'html', status: 'changed', size: 14, lines: 7, added: 3, removed: 1 });
|
||||
const list = D.mergeDeliverable(D.mergeDeliverable(undefined, a), b);
|
||||
assert.equal(list.length, 1); assert.equal(list[0].status, 'created'); assert.equal(list[0].added, 8); assert.equal(list[0].removed, 1); assert.equal(list[0].size, 14);
|
||||
});
|
||||
Reference in new issue
Block a user