From 490fda265743d0a885e0157f747802f8d84e4b09 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Fri, 16 Oct 2026 22:50:05 +0200 Subject: [PATCH] Round 8: project folder chip above the message box, Time-skip as two agents (plan, lever with its why, A and B progress, Keep A / Keep B), working view reachable while a run has no files yet --- apps/host/src/components/FolderChip.tsx | 28 ++++++++++++ apps/host/src/components/TimeSkipPanel.tsx | 21 ++++++--- apps/host/src/components/TimeSkipWorking.tsx | 44 +++++++++++++++++- apps/host/src/lib/chat-folder.ts | 48 ++++++++++++++++++++ apps/host/src/lib/store.ts | 18 ++++---- apps/host/src/lib/time-skip-activity.ts | 1 + apps/host/src/lib/time-skip.ts | 37 ++++++++++++++- apps/host/src/locales/de.json | 27 +++++++++-- apps/host/src/locales/en.json | 27 +++++++++-- apps/host/src/locales/es.json | 27 +++++++++-- apps/host/src/locales/ja.json | 27 +++++++++-- apps/host/src/locales/ko.json | 27 +++++++++-- apps/host/src/locales/pt.json | 27 +++++++++-- apps/host/src/locales/ru.json | 27 +++++++++-- apps/host/src/locales/zh.json | 27 +++++++++-- apps/host/src/screens/Chat.tsx | 6 ++- apps/host/src/styles/app.css | 33 ++++++++++++++ apps/host/tests/ui6-fork.test.mjs | 39 ++++++++++++++++ 18 files changed, 432 insertions(+), 59 deletions(-) create mode 100644 apps/host/src/components/FolderChip.tsx create mode 100644 apps/host/src/lib/chat-folder.ts create mode 100644 apps/host/tests/ui6-fork.test.mjs diff --git a/apps/host/src/components/FolderChip.tsx b/apps/host/src/components/FolderChip.tsx new file mode 100644 index 00000000..56b121c1 --- /dev/null +++ b/apps/host/src/components/FolderChip.tsx @@ -0,0 +1,28 @@ +import { useState } from 'react'; +import { tr } from '../lib/i18n'; +import { chooseChatFolder, setChatFolder, useChatFolder } from '../lib/chat-folder'; +import { pushToast } from '../lib/store'; +import { plainFailureText } from '../lib/plain-errors'; +import { Icon } from './ui'; + +/** + * The chat's project folder, above the message box on the left: its name (the full path on hover), or "Select a folder". A click opens the + * system folder picker; the small x goes back to the default folder. The assistant works inside this folder and nowhere else. + */ +export function FolderChip({ chatId, disabled }: { chatId: string | null | undefined; disabled?: boolean }) { + const folder = useChatFolder(chatId); + const [busy, setBusy] = useState(false); + if (!chatId) return null; + const run = async (fn: () => Promise) => { + setBusy(true); + try { await fn(); } catch (e) { pushToast('error', tr("The folder was not changed"), plainFailureText(e instanceof Error ? e.message : String(e)).message); } + finally { setBusy(false); } + }; + const label = folder ? folder.name : tr("Select a folder"); + return
+ + {folder ? : null} +
; +} diff --git a/apps/host/src/components/TimeSkipPanel.tsx b/apps/host/src/components/TimeSkipPanel.tsx index a12d1fbe..385e0971 100644 --- a/apps/host/src/components/TimeSkipPanel.tsx +++ b/apps/host/src/components/TimeSkipPanel.tsx @@ -4,10 +4,12 @@ import type { PreviewArtifact } from '../lib/artifacts'; import { plainTimeSkipError, replayTimeSkip, setTimeSkipResult, stopTimeSkip } from '../lib/store'; import { realTimeSkipDocuments, timeSkipCheckOutcomes, timeSkipDocumentMarkdown, timeSkipDocuments, timeSkipExample, timeSkipResultState, type TimeSkipDocument, type TimeSkipRun, type TimeSkipVersion } from '../lib/time-skip'; import { TimeSkipWorking } from './TimeSkipWorking'; +import { isForkJob } from '../lib/time-skip'; import { FloatingMenu } from './FloatingMenu'; import { TimeSkipCompare } from './TimeSkipCompare'; import { Btn, Dialog, Icon } from './ui'; -function VersionTabs({ version, onChange, done }: { +function VersionTabs({ version, onChange, done, fork }: { + fork?: boolean; version: TimeSkipVersion; onChange: (version: TimeSkipVersion) => void; done: boolean; @@ -22,7 +24,7 @@ function VersionTabs({ version, onChange, done }: { const next = event.key === 'Home' ? 0 : event.key === 'End' ? 1 : (i + 1) % 2; onChange(options[next]); event.currentTarget.parentElement?.querySelectorAll('[role="tab"]')[next]?.focus(); - }}>{tr(which === 'original' ? 'Original' : done ? 'Updated' : 'Update')}))} + }}>{tr(fork ? (which === 'original' ? 'A' : 'B') : which === 'original' ? 'Original' : done ? 'Updated' : 'Update')}))} ; } function ImageResult({ document, original, compare }: { @@ -133,6 +135,7 @@ export function TimeSkipPanel({ run, sessionId, inline, expanded, onCompare, onC // Snapshot IDs include the run clock, so replaying never reuses an old artifact. onPreview({ id: `${run.id}-${run.startedAt}-${which}`, kind: 'markdown', title: `${which}-${document.code ? 'counter' : 'launch-plan'}.md`, content: timeSkipDocumentMarkdown(document), demo: true }); } + const forkRun = isForkJob(run.job); function restore(which: TimeSkipVersion) { setTimeSkipResult(sessionId, run.id, which); setVersion(which); @@ -143,12 +146,12 @@ export function TimeSkipPanel({ run, sessionId, inline, expanded, onCompare, onC const content =