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 =