- approval cards: one plain question per tool call (server/agent/ask.mjs maps commands and files to sentences; src/lib/ask.ts holds the translated templates), a compact calm card, the exact command under Details - Tasks: the opened task shows schedule, what it may do, last result, instructions and last answer; back link before the title like the chat's navbar; pause/resume and delete icons, Edit, Run now; pause and play icons added to the sprite - Models: 'This computer' shows graphics memory and RAM bars with what the chosen version takes, and one plain line about the SSD (src/lib/native-fit.ts, from the catalog's memory_gb and the hardware report; the n-gram table is not counted) - Models: one-line version list: Recommended (the fixed four), Swift, GSQ-RCO, NVFP4, Gyro, Unsloth groups, Use your own GGUF; RAM+VRAM in bold, download size muted, 'Uses SSD N GB' only where it applies - Tune: five steps with their own animated icons and states, a live speed readout and sparkline, a result card with the gain and what it was saved as; reduced motion respected; the tuner now reports each measurement's speed - catalog: memory_gb and mem_total per version (tools/strata_mcp.py) - tests: ask, native-fit, tune-phase, autotune speeds, memory figures; headless checks (ui-flows ui2/ui2d, scripts/approval-flow.mjs), light and dark
65 lines
3.3 KiB
TypeScript
65 lines
3.3 KiB
TypeScript
import { tr } from './i18n';
|
|
import type { IconName } from '../components/ui';
|
|
|
|
/** The question and its one muted line for an approval card. The host names a sentence (server/agent/ask.mjs); the words are here, translated. */
|
|
export interface Ask { id: string; params?: (string | number)[]; why?: string; detail?: string }
|
|
|
|
export function askQuestion(ask: Ask): string {
|
|
const p = (ask.params ?? []).map(String);
|
|
switch (ask.id) {
|
|
case 'open-known-folder': return tr("Open your {0} folder in File Explorer?", p);
|
|
case 'open-folder': return tr("Open the folder {0} in File Explorer?", p);
|
|
case 'open-file': return tr("Open the file {0}?", p);
|
|
case 'open-explorer': return tr("Open File Explorer?");
|
|
case 'run-program': return tr("Run a program: {0}?", p);
|
|
case 'run-script': return tr("Run the script {0}?", p);
|
|
case 'run-steps': return tr("Run {0} steps on your computer?", p);
|
|
case 'run-command': return tr("Run a command on your computer?");
|
|
case 'delete': return tr("Delete {0}?", p);
|
|
case 'create-file': return tr("Create the file {0}?", p);
|
|
case 'create-folder': return tr("Create the folder {0}?", p);
|
|
case 'write-file': return tr("Write to the file {0}?", p);
|
|
case 'change-file': return tr("Change the file {0}?", p);
|
|
case 'copy': return tr("Copy {0}?", p);
|
|
case 'move': return tr("Move {0}?", p);
|
|
case 'rename': return tr("Rename {0}?", p);
|
|
case 'git': return tr("Run git {0}?", p);
|
|
case 'install': return tr("Install packages with {0}?", p);
|
|
case 'stop-task': return tr("Stop a background task?");
|
|
case 'open-page': return tr("Open the web page {0}?", p);
|
|
case 'use-tool': return tr("Use the connected tool {0}?", p);
|
|
default: return tr("Use the tool {0}?", p);
|
|
}
|
|
}
|
|
|
|
function askWhy(id?: string): string | null {
|
|
switch (id) {
|
|
case 'opens-window': return tr("A window will open. Nothing is changed.");
|
|
case 'run-program-why': return tr("It can change your computer.");
|
|
case 'delete-why': return tr("It is removed from your computer.");
|
|
case 'replaces-if-exists': return tr("Replaces the file if it already exists.");
|
|
case 'changes-repo': return tr("It changes the project's files or history.");
|
|
case 'install-why': return tr("It downloads software and changes your computer.");
|
|
case 'run-steps-why': return tr("More than one thing happens. Details shows each step.");
|
|
case 'run-command-why': return tr("Details shows exactly what it does.");
|
|
case 'use-tool-why': return tr("It can act on the service you connected.");
|
|
default: return null;
|
|
}
|
|
}
|
|
|
|
/** The muted line under the question: the folder or file for "open" questions, otherwise what to know before answering. */
|
|
export function askSub(ask: Ask): string {
|
|
const why = askWhy(ask.why);
|
|
if (ask.id.startsWith('open-') && ask.detail) return ask.detail;
|
|
return why ?? ask.detail ?? '';
|
|
}
|
|
|
|
export function askIcon(ask: Ask): IconName {
|
|
if (ask.id.startsWith('open-')) return ask.id === 'open-page' ? 'link' : 'folder';
|
|
if (ask.id === 'delete') return 'trash';
|
|
if (['create-file', 'write-file', 'change-file', 'copy', 'move', 'rename'].includes(ask.id)) return 'file';
|
|
if (ask.id === 'create-folder') return 'folder-plus';
|
|
if (['run-program', 'run-script', 'run-steps', 'run-command', 'git', 'install'].includes(ask.id)) return 'bolt';
|
|
return 'tool';
|
|
}
|