Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: simpler Rewind confirm, skipped for conversation-only rewinds (#13676)
Michael Han2a2ca693f698
diff --git a/studio/frontend/src/components/assistant-ui/rewind-dialog.tsx b/studio/frontend/src/components/assistant-ui/rewind-dialog.tsxindex db625aa4357..b25a7f2c4f5 100644--- a/studio/frontend/src/components/assistant-ui/rewind-dialog.tsx+++ b/studio/frontend/src/components/assistant-ui/rewind-dialog.tsx@@ -12,7 +12,14 @@ import {DialogHeader,DialogTitle,} from "@/components/ui/dialog";-import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group";+import { Label } from "@/components/ui/label";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/components/ui/select";import {collectRewindTurnIds,defaultRewindMode,@@ -126,32 +133,25 @@ const FileList: FC<{ label: string; files: string[] }> = ({ label, files }) =></div>);-/** Mounted once per Thread; opens for requests addressed to this thread's list item. */+/** Mounted once per Thread; handles requests addressed to this thread's list item. */export const RewindDialog: FC = () => {const threadKey = useAuiState(({ threadListItem }) => threadListItem.id);const request = useRewindDialogStore((s) => s.request);const closeRewind = useRewindDialogStore((s) => s.closeRewind);- const open = request !== null && request.threadKey === threadKey;- return (- <Dialog open={open} onOpenChange={(next) => !next && closeRewind()}>- <DialogContent className="corner-squircle dialog-soft-surface gap-5 sm:max-w-md">- {/* Content unmounts on close, so each open starts from a fresh read of the branch. */}- {open ? (- <RewindDialogBody- initialMessageId={request.messageId}- onClose={closeRewind}- />- ) : null}- </DialogContent>- </Dialog>- );+ // Unmounts on close, so each request starts from a fresh read of the branch.+ return request !== null && request.threadKey === threadKey ? (+ <RewindFlow+ key={request.messageId ?? ""}+ initialMessageId={request.messageId}+ onClose={closeRewind}+ />+ ) : null;};-const RewindDialogBody: FC<{+const RewindFlow: FC<{initialMessageId: string | null;onClose: () => void;}> = ({ initialMessageId, onClose }) => {- const t = useT();const aui = useAui();const [messageId, setMessageId] = useState(initialMessageId);// Read once: subscribing would re-render this dialog on every streamed token.@@ -160,7 +160,34 @@ const RewindDialogBody: FC<{if (messageId === null) {return (- <>+ <RewindPicker+ entries={entries}+ onPick={setMessageId}+ onClose={onClose}+ />+ );+ }+ return (+ <RewindChoices+ key={messageId}+ messageId={messageId}+ preview={entries.find((entry) => entry.id === messageId)?.text ?? ""}+ turnIds={collectRewindTurnIds(branch, messageId)}+ onBack={initialMessageId === null ? () => setMessageId(null) : undefined}+ onClose={onClose}+ />+ );+};++const RewindPicker: FC<{+ entries: { id: string; preview: string; text: string }[];+ onPick: (id: string) => void;+ onClose: () => void;+}> = ({ entries, onPick, onClose }) => {+ const t = useT();+ return (+ <Dialog open={true} onOpenChange={(next) => !next && onClose()}>+ <DialogContent className="corner-squircle dialog-soft-surface gap-5 sm:max-w-md"><DialogHeader><DialogTitle className="text-ui-21">{t("rewind.title")}</DialogTitle><DialogDescription>{t("rewind.pickDescription")}</DialogDescription>@@ -173,7 +200,7 @@ const RewindDialogBody: FC<{<li key={entry.id}><buttontype="button"- onClick={() => setMessageId(entry.id)}+ onClick={() => onPick(entry.id)}className="w-full truncate rounded-[12px] px-3 py-2 text-left hover:bg-accent focus-visible:bg-accent outline-none">{entry.preview || (@@ -186,26 +213,18 @@ const RewindDialogBody: FC<{))}</ul>)}- </>- );- }- return (- <RewindChoices- key={messageId}- messageId={messageId}- turnIds={collectRewindTurnIds(branch, messageId)}- onBack={initialMessageId === null ? () => setMessageId(null) : undefined}- onClose={onClose}- />+ </DialogContent>+ </Dialog>);};const RewindChoices: FC<{messageId: string;+ preview: string;turnIds: string[];onBack?: () => void;onClose: () => void;-}> = ({ messageId, turnIds, onBack, onClose }) => {+}> = ({ messageId, preview, turnIds, onBack, onClose }) => {const t = useT();const aui = useAui();const remoteId = useAuiState(({ threadListItem }) => threadListItem.remoteId);@@ -242,12 +261,13 @@ const RewindChoices: FC<{// Rows can exist with nothing left to put back (right after a rewind): that is no change.const hasChanges = result !== null && rewindChangedCount(result) > 0;- const confirm = async () => {+ const rewind = async (chosen: RewindMode) => {if (aui.thread().getState().isRunning) {toast.error(t("rewind.waitForResponse"));+ onClose();return;}- if (rewindTouchesFiles(mode) && remoteId) {+ if (rewindTouchesFiles(chosen) && remoteId) {setBusy(true);try {const restored = await rewindChatThread(remoteId, {@@ -266,7 +286,7 @@ const RewindChoices: FC<{return;}}- if (rewindTouchesConversation(mode)) {+ if (rewindTouchesConversation(chosen)) {try {aui.thread().message({ id: messageId }).composer().beginEdit();} catch {@@ -276,76 +296,92 @@ const RewindChoices: FC<{onClose();};- const options: { value: RewindMode; label: string; files: boolean }[] = [- { value: "both", label: t("rewind.modeBoth"), files: true },- { value: "conversation", label: t("rewind.modeConversation"), files: false },- { value: "files", label: t("rewind.modeFiles"), files: true },+ // Only the conversation can go back: no choice to make, so no dialog.+ const conversationOnly = dryRun.state !== "loading" && !hasChanges;+ // biome-ignore lint/correctness/useExhaustiveDependencies: fires once, when the check settles.+ useEffect(() => {+ if (!conversationOnly) return;+ if (dryRun.state === "error") {+ toast.error(t("rewind.checkFailed", { error: dryRun.message }));+ }+ // Files changed since, but none can be put back: say so, or the rewind reads as a full restore.+ const skipped = result ? result.conflicts.length + result.untracked.length : 0;+ if (skipped > 0) {+ toast.warning(t("rewind.filesNotRestored", { count: skipped }));+ }+ void rewind("conversation");+ }, [conversationOnly]);++ if (!hasChanges || result === null) return null;++ const options: { value: RewindMode; label: string }[] = [+ { value: "both", label: t("rewind.modeBoth") },+ { value: "conversation", label: t("rewind.modeConversation") },+ { value: "files", label: t("rewind.modeFiles") },];return (- <>- <DialogHeader>- <DialogTitle className="text-ui-21">{t("rewind.title")}</DialogTitle>- <DialogDescription>{t("rewind.chooseDescription")}</DialogDescription>- </DialogHeader>- <RadioGroup- value={mode}- onValueChange={(value) => setMode(value as RewindMode)}- disabled={busy}- >- {options.map((option) => (- <label- key={option.value}- className="flex cursor-pointer items-center gap-3 has-[button:disabled]:cursor-not-allowed has-[button:disabled]:opacity-50"+ <Dialog open={true} onOpenChange={(next) => !next && !busy && onClose()}>+ <DialogContent className="corner-squircle dialog-soft-surface gap-4 sm:max-w-md">+ <DialogHeader>+ <DialogTitle className="text-ui-21">+ {t("rewind.confirmTitle")}+ </DialogTitle>+ </DialogHeader>+ <p className="line-clamp-3 rounded-[14px] bg-muted px-4 py-3 text-sm wrap-break-word">+ {preview || (+ <span className="text-muted-foreground">+ {t("rewind.attachmentOnly")}+ </span>+ )}+ </p>+ <div className="grid gap-2">+ <Label htmlFor="rewind-restore">{t("rewind.restoreLabel")}</Label>+ <Select+ value={mode}+ onValueChange={(value) => setMode(value as RewindMode)}+ disabled={busy}>- <RadioGroupItem- value={option.value}- disabled={option.files && !hasChanges}- />- {option.label}- </label>- ))}- </RadioGroup>- <div className="grid gap-2 text-sm">- {dryRun.state === "loading" ? (- <p className="text-muted-foreground">{t("rewind.checking")}</p>- ) : dryRun.state === "error" ? (- <p className="text-destructive">- {t("rewind.checkFailed", { error: dryRun.message })}+ <SelectTrigger id="rewind-restore" className="w-full">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ {options.map((option) => (+ <SelectItem key={option.value} value={option.value}>+ {option.label}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ <div className="grid gap-2 text-sm">+ <p>+ {t("rewind.summary", {+ restore: result.restored.length,+ remove: result.deleted.length,+ recreate: result.recreated.length,+ })}</p>- ) : !result?.has_changes ? (- <p className="text-muted-foreground">{t("rewind.noFileChanges")}</p>- ) : (- <>- <p>- {t("rewind.summary", {- restore: result.restored.length,- remove: result.deleted.length,- recreate: result.recreated.length,- })}- </p>- <FileList label={t("rewind.conflicts")} files={result.conflicts} />- <FileList label={t("rewind.untracked")} files={result.untracked} />- </>- )}- <p className="text-muted-foreground text-xs">{t("rewind.scopeNote")}</p>- </div>- <DialogFooter>- {onBack ? (- <Button variant="ghost" onClick={onBack} disabled={busy}>- {t("rewind.back")}+ <FileList label={t("rewind.conflicts")} files={result.conflicts} />+ <FileList label={t("rewind.untracked")} files={result.untracked} />+ <DialogDescription className="text-xs">+ {t("rewind.scopeNote")}+ </DialogDescription>+ </div>+ <DialogFooter>+ {onBack ? (+ <Button variant="ghost" onClick={onBack} disabled={busy}>+ {t("rewind.back")}+ </Button>+ ) : null}+ <Button variant="outline" onClick={onClose} disabled={busy}>+ {t("rewind.cancel")}</Button>- ) : null}- <Button variant="outline" onClick={onClose} disabled={busy}>- {t("rewind.cancel")}- </Button>- <Button- onClick={() => void confirm()}- disabled={busy || dryRun.state === "loading"}- >- {t("rewind.confirm")}- </Button>- </DialogFooter>- </>+ <Button onClick={() => void rewind(mode)} disabled={busy}>+ {t("rewind.confirm")}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>);};diff --git a/studio/frontend/src/features/chat/utils/rewind.ts b/studio/frontend/src/features/chat/utils/rewind.tsindex 20b1afee861..4ccfb1f181e 100644--- a/studio/frontend/src/features/chat/utils/rewind.ts+++ b/studio/frontend/src/features/chat/utils/rewind.ts@@ -65,13 +65,15 @@ function messageText(content: unknown): string {/** One line per user message on the branch, newest first; an empty preview is attachment-only. */export function rewindPickerEntries(branch: readonly BranchMessage[],-): { id: string; preview: string }[] {+): { id: string; preview: string; text: string }[] {return branch.filter((message) => message.role === "user").map((message) => {const line = messageText(message.content).replace(/\s+/g, " ").trim();return {id: message.id,+ // Untruncated, for the confirm dialog's line-clamped quote.+ text: line,preview:line.length > PREVIEW_MAX_CHARS? `${line.slice(0, PREVIEW_MAX_CHARS - 1).trimEnd()}…`diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.tsindex 2a0dca5b8f6..eba8bd160d3 100644--- a/studio/frontend/src/i18n/locales/ar.ts+++ b/studio/frontend/src/i18n/locales/ar.ts@@ -555,20 +555,19 @@ export const ar = {},rewind: {title: "إرجاع",+ confirmTitle: "الإرجاع إلى هذه الرسالة؟",+ restoreLabel: "استعادة",pickDescription: "اختر رسالة للرجوع إليها.",pickEmpty: "لا توجد رسائل للرجوع إليها بعد.",attachmentOnly: "مرفقات فقط",- chooseDescription: "تُفتح الرسالة للتعديل حتى تتمكن من إعادة إرسالها. تظل الردود الحالية متاحة عبر أسهم الفروع.",modeBoth: "المحادثة والملفات",modeConversation: "المحادثة فقط",modeFiles: "الملفات فقط",- checking: "جارٍ التحقق من تغييرات الملفات…",checkFailed: "تعذر التحقق من تغييرات الملفات: {error}",- noFileChanges: "لا توجد تغييرات على الملفات بعد هذه الرسالة",summary: "ملفات للاستعادة: {restore}. للإزالة: {remove}. لإعادة الإنشاء: {recreate}.",conflicts: "تغيرت منذ ذلك الحين، وسيتم تخطيها",untracked: "لا يمكن استعادتها",- scopeNote: "لا تتغير البرامج قيد التشغيل والحزم المثبتة وأي شيء خارج مجلد هذه المحادثة.",+ scopeNote: "تشمل الملفات الشيفرة البرمجية. لا تتغير البرامج والحزم والملفات خارج مجلد هذه الدردشة.",back: "رجوع",cancel: "إلغاء",confirm: "إرجاع",@@ -577,6 +576,7 @@ export const ar = {restoredMany: "تمت استعادة {count} ملفات",nothingRestored: "لم تكن هناك ملفات تحتاج إلى استعادة",skippedCount: "تم تخطي {count}",+ filesNotRestored: "لا يمكن استعادة {count} من الملفات المعدّلة وستبقى كما هي.",restoreFailed: "تعذرت استعادة الملفات",undo: "تراجع",undone: "تم التراجع عن استعادة الملفات",diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.tsindex 1411137bb5d..b05d5e0a442 100644--- a/studio/frontend/src/i18n/locales/de.ts+++ b/studio/frontend/src/i18n/locales/de.ts@@ -555,20 +555,19 @@ export const de = {},rewind: {title: "Zurückspulen",+ confirmTitle: "Zu dieser Nachricht zurückspulen?",+ restoreLabel: "Wiederherstellen",pickDescription: "Wähle eine Nachricht, zu der zurückgespult werden soll.",pickEmpty: "Es gibt noch keine Nachrichten zum Zurückspulen.",attachmentOnly: "Nur Anhänge",- chooseDescription: "Die Nachricht wird zum Bearbeiten geöffnet, damit du sie erneut senden kannst. Die aktuellen Antworten bleiben über die Verzweigungspfeile erreichbar.",modeBoth: "Unterhaltung und Dateien",modeConversation: "Nur Unterhaltung",modeFiles: "Nur Dateien",- checking: "Dateiänderungen werden geprüft…",checkFailed: "Dateiänderungen konnten nicht geprüft werden: {error}",- noFileChanges: "Keine Dateiänderungen nach dieser Nachricht",summary: "Wiederherzustellende Dateien: {restore}. Zu entfernen: {remove}. Neu zu erstellen: {recreate}.",conflicts: "Seitdem geändert, wird übersprungen",untracked: "Kann nicht wiederhergestellt werden",- scopeNote: "Laufende Programme, installierte Pakete und alles außerhalb des Ordners dieses Chats werden nicht geändert.",+ scopeNote: "Dateien schließen Code ein. Programme, Pakete und Dateien außerhalb des Chat-Ordners werden nicht geändert.",back: "Zurück",cancel: "Abbrechen",confirm: "Zurückspulen",@@ -577,6 +576,7 @@ export const de = {restoredMany: "{count} Dateien wiederhergestellt",nothingRestored: "Keine Dateien mussten wiederhergestellt werden",skippedCount: "{count} übersprungen",+ filesNotRestored: "{count} geänderte Dateien können nicht wiederhergestellt werden und bleiben unverändert.",restoreFailed: "Dateien konnten nicht wiederhergestellt werden",undo: "Rückgängig",undone: "Wiederherstellung der Dateien rückgängig gemacht",diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex aee301e1b6d..88dff86bc18 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -607,22 +607,19 @@ export const en = {// /rewind and the prompt More menu's Rewind item.rewind: {title: "Rewind",+ confirmTitle: "Rewind to this message?",+ restoreLabel: "Restore",pickDescription: "Choose a message to rewind to.",pickEmpty: "There are no messages to rewind to yet.",attachmentOnly: "Attachments only",- chooseDescription:- "The message opens for editing so you can resend it. The current replies stay available with the branch arrows.",modeBoth: "Conversation and files",modeConversation: "Conversation only",modeFiles: "Files only",- checking: "Checking file changes…",checkFailed: "Could not check file changes: {error}",- noFileChanges: "No file changes after this message",summary: "Files to restore: {restore}. To remove: {remove}. To recreate: {recreate}.",conflicts: "Changed since, will be skipped",untracked: "Cannot be restored",- scopeNote:- "Running programs, installed packages and anything outside this chat's folder are not changed.",+ scopeNote: "Files include code. Programs, packages and files outside this chat's folder are not changed.",back: "Back",cancel: "Cancel",confirm: "Rewind",@@ -631,6 +628,7 @@ export const en = {restoredMany: "Restored {count} files",nothingRestored: "No files needed restoring",skippedCount: "{count} skipped",+ filesNotRestored: "{count} changed files can't be restored and stay as they are.",restoreFailed: "Could not restore files",undo: "Undo",undone: "File restore undone",diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.tsindex 663084f8f6a..58d60abecd5 100644--- a/studio/frontend/src/i18n/locales/es.ts+++ b/studio/frontend/src/i18n/locales/es.ts@@ -555,20 +555,19 @@ export const es = {},rewind: {title: "Rebobinar",+ confirmTitle: "¿Rebobinar hasta este mensaje?",+ restoreLabel: "Restaurar",pickDescription: "Elige un mensaje al que volver.",pickEmpty: "Todavía no hay mensajes a los que volver.",attachmentOnly: "Solo archivos adjuntos",- chooseDescription: "El mensaje se abre para editarlo y que puedas reenviarlo. Las respuestas actuales siguen disponibles con las flechas de rama.",modeBoth: "Conversación y archivos",modeConversation: "Solo conversación",modeFiles: "Solo archivos",- checking: "Comprobando cambios en archivos…",checkFailed: "No se pudieron comprobar los cambios en archivos: {error}",- noFileChanges: "No hay cambios en archivos después de este mensaje",summary: "Archivos que restaurar: {restore}. Que eliminar: {remove}. Que recrear: {recreate}.",conflicts: "Cambiados desde entonces, se omitirán",untracked: "No se pueden restaurar",- scopeNote: "Los programas en ejecución, los paquetes instalados y todo lo que esté fuera de la carpeta de este chat no se modifican.",+ scopeNote: "Los archivos incluyen código. Los programas, paquetes y archivos fuera de la carpeta de este chat no se modifican.",back: "Atrás",cancel: "Cancelar",confirm: "Rebobinar",@@ -577,6 +576,7 @@ export const es = {restoredMany: "{count} archivos restaurados",nothingRestored: "No había archivos que restaurar",skippedCount: "{count} omitidos",+ filesNotRestored: "{count} archivos modificados no se pueden restaurar y se quedan como están.",restoreFailed: "No se pudieron restaurar los archivos",undo: "Deshacer",undone: "Restauración de archivos deshecha",diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.tsindex 49beaed6cd8..6468f31cf3c 100644--- a/studio/frontend/src/i18n/locales/fr.ts+++ b/studio/frontend/src/i18n/locales/fr.ts@@ -555,20 +555,19 @@ export const fr = {},rewind: {title: "Revenir en arrière",+ confirmTitle: "Revenir à ce message ?",+ restoreLabel: "Restaurer",pickDescription: "Choisissez un message auquel revenir.",pickEmpty: "Il n'y a pas encore de message auquel revenir.",attachmentOnly: "Pièces jointes uniquement",- chooseDescription: "Le message s'ouvre en modification pour que vous puissiez le renvoyer. Les réponses actuelles restent accessibles avec les flèches de branche.",modeBoth: "Conversation et fichiers",modeConversation: "Conversation uniquement",modeFiles: "Fichiers uniquement",- checking: "Vérification des modifications de fichiers…",checkFailed: "Impossible de vérifier les modifications de fichiers : {error}",- noFileChanges: "Aucune modification de fichier après ce message",summary: "Fichiers à restaurer : {restore}. À supprimer : {remove}. À recréer : {recreate}.",conflicts: "Modifiés depuis, seront ignorés",untracked: "Impossible à restaurer",- scopeNote: "Les programmes en cours, les paquets installés et tout ce qui se trouve hors du dossier de ce chat ne sont pas modifiés.",+ scopeNote: "Les fichiers incluent le code. Les programmes, paquets et fichiers hors du dossier de ce chat ne sont pas modifiés.",back: "Retour",cancel: "Annuler",confirm: "Revenir en arrière",@@ -577,6 +576,7 @@ export const fr = {restoredMany: "{count} fichiers restaurés",nothingRestored: "Aucun fichier à restaurer",skippedCount: "{count} ignorés",+ filesNotRestored: "{count} fichiers modifiés ne peuvent pas être restaurés et restent en l'état.",restoreFailed: "Impossible de restaurer les fichiers",undo: "Annuler",undone: "Restauration des fichiers annulée",diff --git a/studio/frontend/src/i18n/locales/he.ts b/studio/frontend/src/i18n/locales/he.tsindex 06e13a236cf..ae7bd63c7c4 100644--- a/studio/frontend/src/i18n/locales/he.ts+++ b/studio/frontend/src/i18n/locales/he.ts@@ -641,20 +641,19 @@ export const he = {},rewind: {title: "החזרה לאחור",+ confirmTitle: "לחזור להודעה הזו?",+ restoreLabel: "שחזור",pickDescription: "בחרו הודעה לחזור אליה.",pickEmpty: "עדיין אין הודעות לחזור אליהן.",attachmentOnly: "קבצים מצורפים בלבד",- chooseDescription: "ההודעה תיפתח לעריכה כדי שתוכלו לשלוח אותה שוב. התשובות הנוכחיות יישארו זמינות דרך חיצי הענפים.",modeBoth: "שיחה וקבצים",modeConversation: "שיחה בלבד",modeFiles: "קבצים בלבד",- checking: "בודק שינויים בקבצים…",checkFailed: "לא ניתן היה לבדוק שינויים בקבצים: {error}",- noFileChanges: "אין שינויים בקבצים אחרי הודעה זו",summary: "קבצים לשחזור: {restore}. להסרה: {remove}. ליצירה מחדש: {recreate}.",conflicts: "השתנו מאז, ידולגו",untracked: "לא ניתן לשחזר",- scopeNote: "תוכנות פועלות, חבילות מותקנות וכל מה שמחוץ לתיקייה של הצ'אט הזה לא משתנים.",+ scopeNote: "קבצים כוללים קוד. תוכנות, חבילות וקבצים מחוץ לתיקייה של הצ'אט הזה לא משתנים.",back: "חזרה",cancel: "ביטול",confirm: "החזרה לאחור",@@ -663,6 +662,7 @@ export const he = {restoredMany: "שוחזרו {count} קבצים",nothingRestored: "לא היו קבצים לשחזור",skippedCount: "{count} דולגו",+ filesNotRestored: "לא ניתן לשחזר {count} קבצים ששונו, והם יישארו כפי שהם.",restoreFailed: "לא ניתן היה לשחזר את הקבצים",undo: "ביטול פעולה",undone: "שחזור הקבצים בוטל",diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.tsindex f2bf2cd86da..d12b9882aa8 100644--- a/studio/frontend/src/i18n/locales/hi.ts+++ b/studio/frontend/src/i18n/locales/hi.ts@@ -555,20 +555,19 @@ export const hi = {},rewind: {title: "रिवाइंड करें",+ confirmTitle: "इस संदेश तक रिवाइंड करें?",+ restoreLabel: "पुनर्स्थापित करें",pickDescription: "वह संदेश चुनें जिस पर वापस जाना है।",pickEmpty: "अभी वापस जाने के लिए कोई संदेश नहीं है।",attachmentOnly: "केवल अटैचमेंट",- chooseDescription: "संदेश संपादन के लिए खुलता है ताकि आप उसे फिर से भेज सकें। मौजूदा जवाब ब्रांच तीरों से उपलब्ध रहते हैं।",modeBoth: "बातचीत और फ़ाइलें",modeConversation: "केवल बातचीत",modeFiles: "केवल फ़ाइलें",- checking: "फ़ाइल बदलाव जाँचे जा रहे हैं…",checkFailed: "फ़ाइल बदलाव जाँचे नहीं जा सके: {error}",- noFileChanges: "इस संदेश के बाद कोई फ़ाइल बदलाव नहीं",summary: "पुनर्स्थापित करने वाली फ़ाइलें: {restore}। हटाने वाली: {remove}। फिर से बनाने वाली: {recreate}।",conflicts: "बाद में बदली गई, छोड़ दी जाएँगी",untracked: "पुनर्स्थापित नहीं की जा सकतीं",- scopeNote: "चल रहे प्रोग्राम, इंस्टॉल किए गए पैकेज और इस चैट के फ़ोल्डर के बाहर की कोई भी चीज़ नहीं बदलती।",+ scopeNote: "फ़ाइलों में कोड भी शामिल है। प्रोग्राम, पैकेज और इस चैट के फ़ोल्डर के बाहर की फ़ाइलें नहीं बदलतीं।",back: "वापस",cancel: "रद्द करें",confirm: "रिवाइंड करें",@@ -577,6 +576,7 @@ export const hi = {restoredMany: "{count} फ़ाइलें पुनर्स्थापित की गईं",nothingRestored: "किसी फ़ाइल को पुनर्स्थापित करने की ज़रूरत नहीं थी",skippedCount: "{count} छोड़ी गईं",+ filesNotRestored: "{count} बदली गई फ़ाइलें पुनर्स्थापित नहीं की जा सकतीं और जैसी हैं वैसी रहेंगी।",restoreFailed: "फ़ाइलें पुनर्स्थापित नहीं की जा सकीं",undo: "पूर्ववत करें",undone: "फ़ाइल पुनर्स्थापना पूर्ववत की गई",diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.tsindex eca8608e848..8c2ec044e07 100644--- a/studio/frontend/src/i18n/locales/it.ts+++ b/studio/frontend/src/i18n/locales/it.ts@@ -2776,6 +2776,7 @@ export const it = {working: "Elaborazione...",loadFailed: "Impossibile caricare gli elementi archiviati",loadMoreFailed: "Impossibile caricare altri elementi archiviati",+ filesNotRestored: "{count} file modificati non possono essere ripristinati e restano come sono.",restoreFailed: "Impossibile ripristinare gli elementi selezionati",deleteFailed: "Impossibile eliminare gli elementi selezionati",projectsFailed: "Impossibile caricare i progetti archiviati",@@ -3127,20 +3128,19 @@ export const it = {},rewind: {title: "Riavvolgi",+ confirmTitle: "Riavvolgere fino a questo messaggio?",+ restoreLabel: "Ripristina",pickDescription: "Scegli un messaggio a cui tornare.",pickEmpty: "Non ci sono ancora messaggi a cui tornare.",attachmentOnly: "Solo allegati",- chooseDescription: "Il messaggio si apre in modifica così puoi inviarlo di nuovo. Le risposte attuali restano disponibili con le frecce dei rami.",modeBoth: "Conversazione e file",modeConversation: "Solo conversazione",modeFiles: "Solo file",- checking: "Controllo delle modifiche ai file…",checkFailed: "Impossibile controllare le modifiche ai file: {error}",- noFileChanges: "Nessuna modifica ai file dopo questo messaggio",summary: "File da ripristinare: {restore}. Da rimuovere: {remove}. Da ricreare: {recreate}.",conflicts: "Modificati nel frattempo, verranno saltati",untracked: "Non ripristinabili",- scopeNote: "Programmi in esecuzione, pacchetti installati e tutto ciò che è fuori dalla cartella di questa chat non vengono modificati.",+ scopeNote: "I file includono il codice. Programmi, pacchetti e file fuori dalla cartella di questa chat non vengono modificati.",back: "Indietro",cancel: "Annulla",confirm: "Riavvolgi",diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.tsindex ff75c7ea6de..b913af1ff48 100644--- a/studio/frontend/src/i18n/locales/ja.ts+++ b/studio/frontend/src/i18n/locales/ja.ts@@ -556,20 +556,19 @@ export const ja = {},rewind: {title: "巻き戻す",+ confirmTitle: "このメッセージまで巻き戻しますか?",+ restoreLabel: "復元",pickDescription: "巻き戻す先のメッセージを選択してください。",pickEmpty: "巻き戻せるメッセージはまだありません。",attachmentOnly: "添付ファイルのみ",- chooseDescription: "メッセージが編集モードで開き、再送信できます。現在の返信はブランチの矢印からいつでも表示できます。",modeBoth: "会話とファイル",modeConversation: "会話のみ",modeFiles: "ファイルのみ",- checking: "ファイルの変更を確認しています…",checkFailed: "ファイルの変更を確認できませんでした: {error}",- noFileChanges: "このメッセージ以降のファイル変更はありません",summary: "復元するファイル: {restore}。削除: {remove}。再作成: {recreate}。",conflicts: "その後変更されたためスキップします",untracked: "復元できません",- scopeNote: "実行中のプログラム、インストール済みのパッケージ、このチャットのフォルダー外のものは変更されません。",+ scopeNote: "ファイルにはコードも含まれます。プログラム、パッケージ、このチャットのフォルダー外のファイルは変更されません。",back: "戻る",cancel: "キャンセル",confirm: "巻き戻す",@@ -578,6 +577,7 @@ export const ja = {restoredMany: "{count} 件のファイルを復元しました",nothingRestored: "復元が必要なファイルはありませんでした",skippedCount: "{count} 件をスキップしました",+ filesNotRestored: "変更された {count} 個のファイルは復元できないため、そのまま残ります。",restoreFailed: "ファイルを復元できませんでした",undo: "元に戻す",undone: "ファイルの復元を元に戻しました",diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.tsindex e1145b1a500..d21afa585dd 100644--- a/studio/frontend/src/i18n/locales/ko.ts+++ b/studio/frontend/src/i18n/locales/ko.ts@@ -555,20 +555,19 @@ export const ko = {},rewind: {title: "되감기",+ confirmTitle: "이 메시지로 되감을까요?",+ restoreLabel: "복원",pickDescription: "되돌아갈 메시지를 선택하세요.",pickEmpty: "아직 되돌아갈 메시지가 없습니다.",attachmentOnly: "첨부 파일만",- chooseDescription: "메시지가 편집 모드로 열려 다시 보낼 수 있습니다. 현재 답변은 브랜치 화살표로 계속 볼 수 있습니다.",modeBoth: "대화와 파일",modeConversation: "대화만",modeFiles: "파일만",- checking: "파일 변경 사항 확인 중…",checkFailed: "파일 변경 사항을 확인하지 못했습니다: {error}",- noFileChanges: "이 메시지 이후 파일 변경 사항이 없습니다",summary: "복원할 파일: {restore}. 삭제: {remove}. 다시 만들기: {recreate}.",conflicts: "이후 변경되어 건너뜀",untracked: "복원할 수 없음",- scopeNote: "실행 중인 프로그램, 설치된 패키지, 이 채팅 폴더 밖의 항목은 변경되지 않습니다.",+ scopeNote: "파일에는 코드도 포함됩니다. 프로그램, 패키지, 이 채팅 폴더 밖의 파일은 변경되지 않습니다.",back: "뒤로",cancel: "취소",confirm: "되감기",@@ -577,6 +576,7 @@ export const ko = {restoredMany: "파일 {count}개를 복원했습니다",nothingRestored: "복원할 파일이 없었습니다",skippedCount: "{count}개 건너뜀",+ filesNotRestored: "변경된 파일 {count}개는 복원할 수 없어 그대로 유지됩니다.",restoreFailed: "파일을 복원하지 못했습니다",undo: "실행 취소",undone: "파일 복원을 취소했습니다",diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.tsindex 5df0c9c1e78..cfbc33833cc 100644--- a/studio/frontend/src/i18n/locales/pt-br.ts+++ b/studio/frontend/src/i18n/locales/pt-br.ts@@ -555,20 +555,19 @@ export const ptBR = {},rewind: {title: "Voltar no tempo",+ confirmTitle: "Voltar para esta mensagem?",+ restoreLabel: "Restaurar",pickDescription: "Escolha uma mensagem para a qual voltar.",pickEmpty: "Ainda não há mensagens para as quais voltar.",attachmentOnly: "Somente anexos",- chooseDescription: "A mensagem abre para edição para que você possa reenviá-la. As respostas atuais continuam disponíveis pelas setas de ramificação.",modeBoth: "Conversa e arquivos",modeConversation: "Somente conversa",modeFiles: "Somente arquivos",- checking: "Verificando alterações nos arquivos…",checkFailed: "Não foi possível verificar as alterações nos arquivos: {error}",- noFileChanges: "Nenhuma alteração de arquivo após esta mensagem",summary: "Arquivos a restaurar: {restore}. A remover: {remove}. A recriar: {recreate}.",conflicts: "Alterados desde então, serão ignorados",untracked: "Não podem ser restaurados",- scopeNote: "Programas em execução, pacotes instalados e tudo fora da pasta deste chat não são alterados.",+ scopeNote: "Arquivos incluem código. Programas, pacotes e arquivos fora da pasta deste chat não são alterados.",back: "Voltar",cancel: "Cancelar",confirm: "Voltar no tempo",@@ -577,6 +576,7 @@ export const ptBR = {restoredMany: "{count} arquivos restaurados",nothingRestored: "Nenhum arquivo precisou ser restaurado",skippedCount: "{count} ignorados",+ filesNotRestored: "{count} arquivos alterados não podem ser restaurados e ficam como estão.",restoreFailed: "Não foi possível restaurar os arquivos",undo: "Desfazer",undone: "Restauração dos arquivos desfeita",diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.tsindex 7624e08c350..54099017617 100644--- a/studio/frontend/src/i18n/locales/ru.ts+++ b/studio/frontend/src/i18n/locales/ru.ts@@ -555,20 +555,19 @@ export const ru = {},rewind: {title: "Откатить",+ confirmTitle: "Откатить к этому сообщению?",+ restoreLabel: "Восстановить",pickDescription: "Выберите сообщение, к которому нужно вернуться.",pickEmpty: "Пока нет сообщений, к которым можно вернуться.",attachmentOnly: "Только вложения",- chooseDescription: "Сообщение откроется для редактирования, чтобы вы могли отправить его снова. Текущие ответы останутся доступны через стрелки ветвей.",modeBoth: "Беседу и файлы",modeConversation: "Только беседу",modeFiles: "Только файлы",- checking: "Проверка изменений файлов…",checkFailed: "Не удалось проверить изменения файлов: {error}",- noFileChanges: "После этого сообщения файлы не менялись",summary: "Файлов к восстановлению: {restore}. К удалению: {remove}. К воссозданию: {recreate}.",conflicts: "Изменены с тех пор, будут пропущены",untracked: "Невозможно восстановить",- scopeNote: "Запущенные программы, установленные пакеты и всё за пределами папки этого чата не изменяются.",+ scopeNote: "Файлы включают код. Программы, пакеты и файлы вне папки этого чата не изменяются.",back: "Назад",cancel: "Отмена",confirm: "Откатить",@@ -577,6 +576,7 @@ export const ru = {restoredMany: "Восстановлено файлов: {count}",nothingRestored: "Восстанавливать было нечего",skippedCount: "Пропущено: {count}",+ filesNotRestored: "Изменённые файлы ({count}) нельзя восстановить, они останутся как есть.",restoreFailed: "Не удалось восстановить файлы",undo: "Отменить",undone: "Восстановление файлов отменено",diff --git a/studio/frontend/src/i18n/locales/sv.ts b/studio/frontend/src/i18n/locales/sv.tsindex fc023cbeded..be077ffa498 100644--- a/studio/frontend/src/i18n/locales/sv.ts+++ b/studio/frontend/src/i18n/locales/sv.ts@@ -657,20 +657,19 @@ export const sv = {},rewind: {title: "Spola tillbaka",+ confirmTitle: "Spola tillbaka till det här meddelandet?",+ restoreLabel: "Återställ",pickDescription: "Välj ett meddelande att spola tillbaka till.",pickEmpty: "Det finns inga meddelanden att spola tillbaka till än.",attachmentOnly: "Endast bilagor",- chooseDescription: "Meddelandet öppnas för redigering så att du kan skicka det igen. De nuvarande svaren finns kvar via grenpilarna.",modeBoth: "Konversation och filer",modeConversation: "Endast konversation",modeFiles: "Endast filer",- checking: "Kontrollerar filändringar…",checkFailed: "Det gick inte att kontrollera filändringar: {error}",- noFileChanges: "Inga filändringar efter det här meddelandet",summary: "Filer att återställa: {restore}. Att ta bort: {remove}. Att återskapa: {recreate}.",conflicts: "Ändrade sedan dess, hoppas över",untracked: "Kan inte återställas",- scopeNote: "Program som körs, installerade paket och allt utanför den här chattens mapp ändras inte.",+ scopeNote: "Filer omfattar kod. Program, paket och filer utanför den här chattens mapp ändras inte.",back: "Tillbaka",cancel: "Avbryt",confirm: "Spola tillbaka",@@ -679,6 +678,7 @@ export const sv = {restoredMany: "Återställde {count} filer",nothingRestored: "Inga filer behövde återställas",skippedCount: "{count} överhoppade",+ filesNotRestored: "{count} ändrade filer kan inte återställas och lämnas som de är.",restoreFailed: "Det gick inte att återställa filerna",undo: "Ångra",undone: "Filåterställningen ångrades",diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.tsindex 43132f36eab..d932c2c0c34 100644--- a/studio/frontend/src/i18n/locales/zh-CN.ts+++ b/studio/frontend/src/i18n/locales/zh-CN.ts@@ -555,20 +555,19 @@ export const zhCN = {},rewind: {title: "回退",+ confirmTitle: "回退到这条消息?",+ restoreLabel: "恢复",pickDescription: "选择要回退到的消息。",pickEmpty: "还没有可以回退到的消息。",attachmentOnly: "仅附件",- chooseDescription: "该消息会进入编辑状态,方便你重新发送。当前回复仍可通过分支箭头查看。",modeBoth: "对话和文件",modeConversation: "仅对话",modeFiles: "仅文件",- checking: "正在检查文件更改…",checkFailed: "无法检查文件更改:{error}",- noFileChanges: "此消息之后没有文件更改",summary: "要恢复的文件:{restore}。要删除:{remove}。要重新创建:{recreate}。",conflicts: "之后已被更改,将跳过",untracked: "无法恢复",- scopeNote: "正在运行的程序、已安装的软件包以及此聊天文件夹之外的内容都不会更改。",+ scopeNote: "文件包括代码。程序、软件包以及此聊天文件夹之外的文件不会更改。",back: "返回",cancel: "取消",confirm: "回退",@@ -577,6 +576,7 @@ export const zhCN = {restoredMany: "已恢复 {count} 个文件",nothingRestored: "没有需要恢复的文件",skippedCount: "已跳过 {count} 个",+ filesNotRestored: "{count} 个已更改的文件无法恢复,将保持原样。",restoreFailed: "无法恢复文件",undo: "撤销",undone: "已撤销文件恢复",diff --git a/studio/frontend/tests/chat-rewind.test.ts b/studio/frontend/tests/chat-rewind.test.tsindex be365921ed3..75d5899209b 100644--- a/studio/frontend/tests/chat-rewind.test.ts+++ b/studio/frontend/tests/chat-rewind.test.ts@@ -19,7 +19,14 @@ test("only the bare /rewind command matches", () => {for (const text of ["/rewind", " /rewind\n", "/REWIND", "/Rewind "]) {assert.equal(isRewindCommand(text), true, JSON.stringify(text));}- for (const text of ["", "/rewind now", "rewind", "/rewinds", "please /rewind", "/ rewind"]) {+ for (const text of [+ "",+ "/rewind now",+ "rewind",+ "/rewinds",+ "please /rewind",+ "/ rewind",+ ]) {assert.equal(isRewindCommand(text), false, JSON.stringify(text));}});@@ -27,7 +34,11 @@ test("only the bare /rewind command matches", () => {const branch = [{ id: "u1", role: "user", content: [{ type: "text", text: "first" }] },{ id: "a1", role: "assistant", content: [] },- { id: "u2", role: "user", content: [{ type: "text", text: "second\n line" }] },+ {+ id: "u2",+ role: "user",+ content: [{ type: "text", text: "second\n line" }],+ },{ id: "a2", role: "assistant", content: [] },{ id: "u3", role: "user", content: [{ type: "image", image: "x" }] },{ id: "a3", role: "assistant", content: [] },@@ -46,13 +57,17 @@ test("an assistant id or a message off the branch yields no turns", () => {test("the picker lists prompts newest first on one line", () => {assert.deepEqual(rewindPickerEntries(branch), [- { id: "u3", preview: "" },- { id: "u2", preview: "second line" },- { id: "u1", preview: "first" },+ { id: "u3", text: "", preview: "" },+ { id: "u2", text: "second line", preview: "second line" },+ { id: "u1", text: "first", preview: "first" },+ ]);+ const long = rewindPickerEntries([+ { id: "u", role: "user", content: "x".repeat(200) },]);- const long = rewindPickerEntries([{ id: "u", role: "user", content: "x".repeat(200) }]);assert.ok(long[0].preview.length <= 80);assert.ok(long[0].preview.endsWith("…"));+ // The confirm dialog quotes the whole prompt and clamps it by lines instead.+ assert.equal(long[0].text, "x".repeat(200));});test("files are offered by default only when the turns changed files", () => {@@ -91,10 +106,41 @@ test("the completion payload carries user_message_id on the local and external ttest("the composer opens the rewind picker instead of sending /rewind", () => {const thread = readSrc("components/assistant-ui/thread.tsx");- const submit = thread.slice(thread.indexOf("const handleSubmit = useCallback("));+ const submit = thread.slice(+ thread.indexOf("const handleSubmit = useCallback("),+ );const intercept = submit.indexOf("isRewindCommand(composerText)");assert.ok(intercept > 0);assert.ok(intercept < submit.indexOf("if (disabled || shouldBlockSend())"));assert.ok(intercept < submit.indexOf("interceptSend(event)"));- assert.match(thread, /<RewindMessageButton \/>\s*<ForkCountBadge \/>\s*<ForkMessageButton \/>/);+ assert.match(+ thread,+ /<RewindMessageButton \/>\s*<ForkCountBadge \/>\s*<ForkMessageButton \/>/,+ );+});++test("the dialog lists only options that can run and skips itself for a conversation-only rewind", () => {+ const dialog = readSrc("components/assistant-ui/rewind-dialog.tsx");+ // No disabled radio rows: the dialog renders only when files changed, so every option can run.+ assert.ok(!dialog.includes("RadioGroupItem"));+ assert.match(dialog, /if \(!hasChanges \|\| result === null\) return null;/);+ assert.match(dialog, /void rewind\("conversation"\);/);+ assert.match(dialog, /t\("rewind\.confirmTitle"\)/);+ assert.match(dialog, /<SelectTrigger id="rewind-restore"/);+});++test("an all-skipped rewind still says which files stay, though it skips the dialog", () => {+ const dialog = readSrc("components/assistant-ui/rewind-dialog.tsx");+ const effect = dialog.slice(dialog.indexOf("const conversationOnly ="));+ const warn = effect.indexOf('toast.warning(t("rewind.filesNotRestored"');+ const go = effect.indexOf('void rewind("conversation");');+ assert.ok(+ warn > 0 && go > 0,+ "the warning and the rewind are both in the conversation-only effect",+ );+ assert.ok(warn < go);+ assert.match(+ effect,+ /result\.conflicts\.length \+ result\.untracked\.length/,+ );});