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: chat fork fixes and clearer fork affordances (#14587)
Michael Hana38820e2b608
diff --git a/studio/backend/core/rag/conversation_archive.py b/studio/backend/core/rag/conversation_archive.pyindex 417585ddd35..cd10b2cdda8 100644--- a/studio/backend/core/rag/conversation_archive.py+++ b/studio/backend/core/rag/conversation_archive.py@@ -2620,10 +2620,16 @@ def delete_thread_documents(thread_id: str, *, created_before: Optional[str] = Nreturn len(removed)-def copy_thread_documents(source_thread_id: str, thread_id: str) -> tuple[dict[str, str], bool]:+def copy_thread_documents(+ source_thread_id: str,+ thread_id: str,+ *,+ created_before: Optional[str] = None,+) -> tuple[dict[str, str], bool]:"""Copy a thread's finished uploads into another thread. Returns the source-to-copy document idmap and whether an upload still being ingested was left behind. Failed uploads are not copied- and not reported: the documents bar never shows them.+ and not reported: the documents bar never shows them. ``created_before`` (ISO-8601 UTC) leaves+ out uploads made after a fork point.Files are copied before the transaction so rag.db's write lock is never held across file I/O."""@@ -2634,8 +2640,9 @@ def copy_thread_documents(source_thread_id: str, thread_id: str) -> tuple[dict[sconn = rag_db.get_connection()try:rows = conn.execute(- "SELECT * FROM documents WHERE scope=? ORDER BY created_at",- (store.thread_scope(source_thread_id),),+ "SELECT * FROM documents WHERE scope=? AND (? IS NULL OR created_at<?) "+ "ORDER BY created_at",+ (store.thread_scope(source_thread_id), created_before, created_before),).fetchall()documents = [dict(row) for row in rows if row["status"] == "completed"]for document in documents:diff --git a/studio/backend/routes/chat_history.py b/studio/backend/routes/chat_history.pyindex bf050b9e152..ec28e290750 100644--- a/studio/backend/routes/chat_history.py+++ b/studio/backend/routes/chat_history.py@@ -67,6 +67,7 @@ from storage.studio_db import (get_chat_project,get_chat_thread,get_chat_message,+ next_message_created_at,list_chat_attachments_page,list_chat_projects,list_chat_sidebar_rows,@@ -1006,7 +1007,32 @@ def _remove_thread_rag_data(thread_ids, *, cutoff: "str | None" = None) -> None:logger.warning("Could not remove the uploaded documents for %s", thread_id)-def _copy_thread_rag_documents(source_thread_id: str, thread_id: str) -> bool:+def _fork_document_cutoff(+ source_thread_id: str, branch_message_id: Optional[str], client_now_ms: int+) -> Optional[str]:+ """Uploads made once the source moved past the fork point stay behind; None at the tip.++ Message times come from the browser's clock and upload times from this server's, so the+ cutoff is shifted by the skew the fork request itself shows (its browser ``createdAt``+ against server now)."""+ import time+ from datetime import datetime, timezone++ if not branch_message_id:+ return None+ next_at = next_message_created_at(source_thread_id, branch_message_id)+ if next_at is None:+ return None+ skew_ms = int(time.time() * 1000) - client_now_ms+ return datetime.fromtimestamp((next_at + skew_ms) / 1000, timezone.utc).isoformat()+++def _copy_thread_rag_documents(+ source_thread_id: str,+ thread_id: str,+ *,+ created_before: Optional[str] = None,+) -> bool:"""Copy the source's uploads into the fork. False when the fork should warn that some wereleft behind."""try:@@ -1016,7 +1042,7 @@ def _copy_thread_rag_documents(source_thread_id: str, thread_id: str) -> bool:if not rag_db.rag_available():return not conversation_archive.thread_has_documents(source_thread_id)document_ids, missed = conversation_archive.copy_thread_documents(- source_thread_id, thread_id+ source_thread_id, thread_id, created_before = created_before)if get_chat_thread(thread_id) is None:conversation_archive.delete_thread_documents(thread_id)@@ -2092,7 +2118,12 @@ def fork_thread(warning: Optional[str] = Noneif source.get("openaiCodeExecContainerId") or source.get("anthropicCodeExecContainerId"):warning = "Sandbox starts fresh in fork; files from parent are not carried over."- if not _copy_thread_rag_documents(thread_id, payload.newThreadId):+ created_before = _fork_document_cutoff(+ thread_id, forked.get("forkedFromMessageId"), payload.createdAt+ )+ if not _copy_thread_rag_documents(+ thread_id, payload.newThreadId, created_before = created_before+ ):warning = " ".join(filter(None, [warning, "Documents attached to the parent chat were not copied."]))diff --git a/studio/backend/storage/studio_db.py b/studio/backend/storage/studio_db.pyindex 1183553587a..4f6e8a1618c 100644--- a/studio/backend/storage/studio_db.py+++ b/studio/backend/storage/studio_db.py@@ -732,6 +732,10 @@ def _ensure_schema(conn: sqlite3.Connection) -> None:conn.execute("CREATE INDEX IF NOT EXISTS idx_chat_threads_project_id ON chat_threads(project_id)")+ conn.execute(+ "CREATE INDEX IF NOT EXISTS idx_chat_threads_forked_from "+ "ON chat_threads(forked_from_thread_id, forked_from_message_id)"+ )conn.execute("CREATE INDEX IF NOT EXISTS idx_chat_messages_thread_id_created_at ON chat_messages(thread_id, created_at)")@@ -4591,6 +4595,8 @@ class ChatForkActiveGenerationError(RuntimeError):_FORK_TITLE_SUFFIX = re.compile(r"^(?P<base>.*?)\s*\((?P<n>\d+)\)\s*$", re.DOTALL)+# The frontend auto-titles only a chat still named this (runtime-provider generateTitle).+_DEFAULT_CHAT_TITLE = "New Chat"# Roles the thread paints a row for. Mirrors threadMessageKind in# components/assistant-ui/thread-message-slot.ts, which is pinned from the other side by@@ -4717,7 +4723,11 @@ def fork_chat_thread(# Named from the row this transaction read, under the write lock: a title taken# before it could be renamed by another tab, and the number could already be gone.base = fork_base_of(src)- title = _next_fork_title(conn, base)+ # An untitled chat's fork stays untitled so its first reply still names it.+ if base in ("", _DEFAULT_CHAT_TITLE):+ title, base = _DEFAULT_CHAT_TITLE, None+ else:+ title = _next_fork_title(conn, base)# Anchor for the "Continued from chat" divider. Not derivable later: copies keep the# source's timestamps and take fresh ids. The last message that PAINTS one, not simply# the last copied: an imported chat can end on a system message, which renders as no row@@ -4849,6 +4859,24 @@ def count_forks_for_message(thread_id: str, message_id: str) -> int:conn.close()+def next_message_created_at(thread_id: str, message_id: str) -> Optional[int]:+ """created_at of the thread's first message after `message_id`; None when it is the tip."""+ conn = get_connection()+ try:+ row = conn.execute(+ """+ SELECT MIN(created_at) FROM chat_messages+ WHERE thread_id = ? AND created_at > (+ SELECT created_at FROM chat_messages WHERE thread_id = ? AND id = ?+ )+ """,+ (thread_id, thread_id, message_id),+ ).fetchone()+ return int(row[0]) if row is not None and row[0] is not None else None+ finally:+ conn.close()++def chat_thread_has_messages(thread_id: str) -> bool:"""Whether this thread has any saved message. Existence only, no rows hydrated. A temporary(incognito) chat is never written here, so this is what tells a thread whose turns can bediff --git a/studio/backend/tests/test_chat_history_storage.py b/studio/backend/tests/test_chat_history_storage.pyindex cb9c15538e1..dd0858ccaf6 100644--- a/studio/backend/tests/test_chat_history_storage.py+++ b/studio/backend/tests/test_chat_history_storage.py@@ -1672,6 +1672,23 @@ def test_fork_title_ignores_other_names_and_archived_state(tmp_path, monkeypatchassert _fork("src", "f-new", 30)["title"] == "Notes (2)"[email protected]("title", ["New Chat", ""])+def test_a_fork_of_an_untitled_chat_stays_untitled(tmp_path, monkeypatch, title):+ """The frontend auto-titles only "New Chat", so "New Chat (1)" would never get a name."""+ _reset_studio_db(tmp_path, monkeypatch)+ studio_db.upsert_chat_thread({**_thread("src"), "title": title})+ studio_db.sync_chat_messages("src", [_msg("m1", None, 1)])++ fork = _fork("src", "f", 10)+ assert fork["title"] == "New Chat"+ assert fork["forkTitleBase"] is None+ assert _fork("f", "f2", 11)["title"] == "New Chat"++ # Once auto-titled, its own forks number from the new name.+ studio_db.update_chat_thread("f", {"title": "Notes"})+ assert _fork("f", "f3", 12)["title"] == "Notes (1)"++def test_fork_records_the_last_inherited_message(tmp_path, monkeypatch):_reset_studio_db(tmp_path, monkeypatch)studio_db.upsert_chat_thread({**_thread("src"), "title": "Notes"})diff --git a/studio/backend/tests/test_rag_thread_document_cleanup.py b/studio/backend/tests/test_rag_thread_document_cleanup.pyindex f65da1e0ee2..dd458632fe2 100644--- a/studio/backend/tests/test_rag_thread_document_cleanup.py+++ b/studio/backend/tests/test_rag_thread_document_cleanup.py@@ -184,10 +184,25 @@ def _add_message(client, thread_id, message_id):assert response.status_code == 200, response.text-def _fork(client, thread_id, message_id, new_thread_id):+# The fork's clock correction carries the request's own latency, so events need to sit well apart+# from it; 10 ms was inside a CI runner's latency and the Windows clock tick.+_EVENT_GAP_S = 0.5+++def _fork(+ client,+ thread_id,+ message_id,+ new_thread_id,+ browser_skew_ms = 0,+):response = client.post(f"/api/chat/threads/{thread_id}/fork",- json = {"messageId": message_id, "newThreadId": new_thread_id, "createdAt": 2},+ json = {+ "messageId": message_id,+ "newThreadId": new_thread_id,+ "createdAt": int(time.time() * 1000) + browser_skew_ms,+ },)assert response.status_code == 200, response.textreturn response.json()@@ -228,6 +243,62 @@ def test_forking_a_thread_copies_its_uploaded_documents(client):assert copied.read() == text+def test_a_fork_leaves_behind_documents_uploaded_after_its_fork_point(client):+ _create_thread(client, "source")+ _add_message(client, "source", "m1")+ early = _upload(client, "source", "early.txt", "alpha bravo charlie " * 50)+ time.sleep(_EVENT_GAP_S)+ response = client.put(+ "/api/chat/threads/source/messages/m2",+ json = {+ "id": "m2",+ "threadId": "source",+ "parentId": "m1",+ "role": "user",+ "createdAt": int(time.time() * 1000),+ },+ )+ assert response.status_code == 200, response.text+ time.sleep(_EVENT_GAP_S)+ _upload(client, "source", "late.txt", "delta echo foxtrot " * 50)++ _fork(client, "source", "m1", "early-fork")+ _fork(client, "source", "m2", "tip-fork")++ assert [d["filename"] for d in _thread_documents(client, "early-fork")] == ["early.txt"]+ assert {d["filename"] for d in _thread_documents(client, "tip-fork")} == {+ "early.txt",+ "late.txt",+ }+ assert early not in {d["id"] for d in _thread_documents(client, "early-fork")}+++def test_the_fork_cutoff_survives_a_browser_clock_behind_the_server(client):+ skew = -60_000+ _create_thread(client, "source")+ for message_id, parent in (("m1", None), ("m2", "m1")):+ if message_id == "m2":+ _upload(client, "source", "early.txt", "alpha bravo charlie " * 50)+ time.sleep(_EVENT_GAP_S)+ response = client.put(+ f"/api/chat/threads/source/messages/{message_id}",+ json = {+ "id": message_id,+ "threadId": "source",+ "parentId": parent,+ "role": "user",+ "createdAt": int(time.time() * 1000) + skew,+ },+ )+ assert response.status_code == 200, response.text+ time.sleep(_EVENT_GAP_S)+ _upload(client, "source", "late.txt", "delta echo foxtrot " * 50)++ _fork(client, "source", "m1", "skewed-fork", browser_skew_ms = skew)++ assert [d["filename"] for d in _thread_documents(client, "skewed-fork")] == ["early.txt"]++def _vectors(document_id):conn = rag_db.get_connection()try:diff --git a/studio/frontend/scripts/check-bundle-budget.ts b/studio/frontend/scripts/check-bundle-budget.tsindex 2196f61138c..e4d7f45b776 100644--- a/studio/frontend/scripts/check-bundle-budget.ts+++ b/studio/frontend/scripts/check-bundle-budget.ts@@ -353,8 +353,11 @@ export const BUDGET = {// #14524 set transfer to its own measured build with no headroom; merged next to #14508 the startup set// compresses 7 B larger (2_071_823 B at 5ab80ffdb4, Node 24), so main is over. Measured + 189 B, raw unchanged// (already 244 B above the measured 6_879_345).- transferBytes: 2_072_012,- rawBytes: 6_879_589,+ // Chat fork affordances (the sidebar fork mark, the "Forked from" divider and the shared fork toasts) in the+ // eager chat chunk: +1_460 B raw / +361 B transfer against 77e742c8e2 (6_879_345 -> 6_880_805 raw,+ // 2_071_823 -> 2_072_184 transfer, 97 chunks). Raised by that growth.+ transferBytes: 2_072_373,+ rawBytes: 6_881_049,};// The chunk count is reported but not budgeted. Splitting a page out of the entry raises it while lowering thediff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsxindex 9ecc77db40e..5c487458745 100644--- a/studio/frontend/src/components/app-sidebar.tsx+++ b/studio/frontend/src/components/app-sidebar.tsx@@ -149,7 +149,7 @@ import {} from "@/components/ui/tooltip";import { Tooltip as TooltipPrimitive } from "radix-ui";import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";-import { ArrowRightIcon, ChevronDown, Copy, Moon } from "lucide-react";+import { ArrowRightIcon, ChevronDown, Copy, GitBranchIcon, Moon } from "lucide-react";import { ForkIcon } from "@/lib/fork-icon";import {Link,@@ -165,6 +165,7 @@ import {EditProjectDialog,forkChatRow,showForkCreatedToast,+ showForkFailedToast,getSidebarItemThreadIds,useForkInFlight,sandboxSessionIdsHolding,@@ -3643,16 +3644,9 @@ export function AppSidebar() {const result = await forkChatRow(item);setActiveThreadId(result.thread.id);navigate({ to: "/chat", search: { thread: result.thread.id } });- showForkCreatedToast(result.containerSnapshotWarning);+ showForkCreatedToast(result.containerSnapshotWarning, result.thread.title);} catch (error) {- // A chat still generating is a refusal, not a failure: say so without the alarm.- if ((error as { unslothForkRefused?: boolean } | null)?.unslothForkRefused) {- toast.info(error instanceof Error ? error.message : "Cannot fork this chat.");- } else {- toast.error("Failed to fork", {- description: error instanceof Error ? error.message : undefined,- });- }+ showForkFailedToast(error);} finally {inFlight.setForking(false);}@@ -5239,7 +5233,7 @@ export function AppSidebar() {onSelect={() => void forkChatFromRow(item)}><HugeiconsIcon icon={ForkIcon} strokeWidth={1.75} className="size-icon" />- <span>Fork</span>+ <span>{t("library.chats.menu.fork")}</span></P.Item>{/* Projects and sections in one place: both are where the chat is kept. */}<P.Sub>@@ -5385,6 +5379,8 @@ export function AppSidebar() {);const hasUnreadActivity =!isGenerating && !hasQueuedActivity && alreadyUnread;+ // The spinner and the unread dot say more, and share its spot.+ const showForkMark = Boolean(item.isFork) && !showWorkSpinner && !hasUnreadActivity;const itemClass = cn(variant === "project"? "group/project-chat-item relative"@@ -5403,7 +5399,7 @@ export function AppSidebar() {isPinned && variant !== "project" && "gap-[calc(8.5px*var(--ui-space-scale,1))]",// A spinner glyph cannot truncate, and the pin and the kebab overlay that same edge, so a// working row holds their room open whether or not it is hovered.- showWorkSpinner ? "pr-16" : hasUnreadActivity ? "pr-7" : undefined,+ showWorkSpinner ? "pr-16" : hasUnreadActivity ? "pr-7" : showForkMark ? "pr-9" : undefined,// Coarse pointers reveal the actions permanently, so the spinner drops back beside// them (right-16, ending 78px in) and the title has to clear that, not just pr-16.showWorkSpinner && "[@media(pointer:coarse)]:pr-[calc(78px*var(--ui-space-scale,1))]",@@ -5525,6 +5521,21 @@ export function AppSidebar() {<span className="size-2 rounded-full bg-primary" /></span>) : null}+ {showForkMark ? (+ // In the trailing column the spinner uses, and yields it to the pin and kebab like the unread dot.+ <span+ role="img"+ aria-label="Forked chat"+ className={cn(+ "pointer-events-none absolute right-4 top-1/2 z-10 flex -translate-y-1/2 text-muted-foreground transition-opacity [@media(pointer:coarse)]:hidden",+ variant === "project"+ ? "group-hover/project-chat-item:opacity-0 group-has-[.sidebar-row-action[data-state=open]]/project-chat-item:opacity-0 group-has-[.sidebar-row-action:focus-visible]/project-chat-item:opacity-0"+ : "group-hover/recent-item:opacity-0 group-has-[.sidebar-row-action[data-state=open]]/recent-item:opacity-0 group-has-[.sidebar-row-action:focus-visible]/recent-item:opacity-0",+ )}+ >+ <GitBranchIcon aria-hidden={true} strokeWidth={1.75} className="size-3.5" />+ </span>+ ) : null}{variant === "project" && (<buttontype="button"diff --git a/studio/frontend/src/components/assistant-ui/thread.tsx b/studio/frontend/src/components/assistant-ui/thread.tsxindex 16a5ce68f0c..1c697c97fd0 100644--- a/studio/frontend/src/components/assistant-ui/thread.tsx+++ b/studio/frontend/src/components/assistant-ui/thread.tsx@@ -333,6 +333,7 @@ import {subscribeForkCounts,useForkInFlight,showForkCreatedToast,+ showForkFailedToast,type PlusMenuItemId,usePlusMenuPrefsStore,writeComposerDraft,@@ -1929,6 +1930,21 @@ const useTrackForkBoundaryAnchor = (threadId: string | null): void => {}, [threadId, anchor]);};+// One read per source chat for the divider's label; a failed read is dropped so a later mount retries.+const forkSourceTitles = new Map<string, Promise<string | null>>();++function forkSourceTitle(sourceThreadId: string): Promise<string | null> {+ let title = forkSourceTitles.get(sourceThreadId);+ if (!title) {+ title = readBackendChatThread(sourceThreadId).then((source) => {+ if (source === undefined) forkSourceTitles.delete(sourceThreadId);+ return source?.title?.trim() || null;+ });+ forkSourceTitles.set(sourceThreadId, title);+ }+ return title;+}+// Closes the history a fork inherited. Rendered by the message it follows, since the row slot// is propless and the boundary arrives through the store.const ForkContinuationRule: FC = () => {@@ -1945,11 +1961,28 @@ const ForkContinuationRule: FC = () => {: (s.boundaryByThreadId[threadId]?.sourceThreadId ?? null),);const navigate = useNavigate();+ const isAnchor = anchor !== undefined && anchor === messageId;+ const [source, setSource] = useState<{ id: string; title: string | null } | null>(null);+ useEffect(() => {+ if (!isAnchor || !sourceThreadId) return;+ let live = true;+ void forkSourceTitle(sourceThreadId).then((title) => {+ if (live) setSource({ id: sourceThreadId, title });+ });+ return () => {+ live = false;+ };+ }, [isAnchor, sourceThreadId]);if (anchor === undefined || anchor !== messageId) return null;+ const sourceTitle = source?.id === sourceThreadId ? source.title : null;const label = (<><HugeiconsIcon icon={WorkflowCircle05Icon} strokeWidth={1.75} className="size-3.5" />- Continued from chat+ {sourceTitle ? (+ <span className="max-w-80 truncate">Forked from {sourceTitle}</span>+ ) : (+ "Continued from chat"+ )}</>);const labelClass =@@ -8589,12 +8622,10 @@ const useForkMessageAction = () => {search: { thread: result.thread.id },replace: false,});- showForkCreatedToast(result.containerSnapshotWarning);+ showForkCreatedToast(result.containerSnapshotWarning, result.thread.title);} catch (error) {console.error("Failed to fork", error);- toast.error("Failed to fork", {- description: error instanceof Error ? error.message : undefined,- });+ showForkFailedToast(error);} finally {setPending(false);}@@ -8642,7 +8673,7 @@ const ForkMessageButton: FC = () => {return (<TooltipIconButton- tooltip="Fork in new chat"+ tooltip="Fork from here"disabled={forkDisabled}onClick={forkMessage}>diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.tsindex 51e3f3c8d22..908c779e326 100644--- a/studio/frontend/src/features/chat/index.ts+++ b/studio/frontend/src/features/chat/index.ts@@ -410,7 +410,7 @@ export { BulkExportItems, exportThreads } from "./components/bulk-export-items";export { useFileProjectInSection } from "./hooks/use-file-project-in-section";export { pickAndImportChats } from "./utils/import-chats";export { useForkInFlight } from "./utils/fork-in-flight";-export { showForkCreatedToast } from "./utils/fork-toast";+export { showForkCreatedToast, showForkFailedToast } from "./utils/fork-toast";export { clearAllChats, countAllChats } from "./utils/clear-all-chats";export { stopRecoveredRun } from "./utils/chat-generation-recovery";export { readIncompleteInfo } from "./utils/continuation";diff --git a/studio/frontend/src/features/chat/utils/fork-toast.ts b/studio/frontend/src/features/chat/utils/fork-toast.tsindex f875d9c0ef5..738574e4112 100644--- a/studio/frontend/src/features/chat/utils/fork-toast.ts+++ b/studio/frontend/src/features/chat/utils/fork-toast.ts@@ -3,10 +3,42 @@import { toast } from "sonner";-export function showForkCreatedToast(containerSnapshotWarning: string | null): void {+export function showForkCreatedToast(+ containerSnapshotWarning: string | null,+ title?: string,+): void {if (containerSnapshotWarning) {toast.info("Fork created", { description: containerSnapshotWarning });} else {- toast.success("Fork created");+ // An untitled fork names itself on its first reply, so there is nothing to show yet.+ const description = title && title !== "New Chat" ? title : undefined;+ toast.success("Fork created", { description });}}++/** One wording for every fork surface: a chat still generating is a refusal, not a failure. */+export function showForkFailedToast(+ error: unknown,+ failedTitle = "Failed to fork",+): void {+ const message = error instanceof Error ? error.message : "";+ const tagged = error as {+ unslothForkRefused?: boolean;+ status?: unknown;+ } | null;+ if (tagged?.unslothForkRefused || message.includes("still generating")) {+ toast.info(+ message || "This chat is still generating. Fork it once it finishes.",+ );+ return;+ }+ if (tagged?.status === 404) {+ toast.error(failedTitle, {+ description: message.startsWith("Message ")+ ? "This message is no longer available to fork."+ : "This chat is no longer available to fork.",+ });+ return;+ }+ toast.error(failedTitle, { description: message || undefined });+}diff --git a/studio/frontend/src/features/library/chats/chats-library.tsx b/studio/frontend/src/features/library/chats/chats-library.tsxindex eb9dfa68f08..c224906250c 100644--- a/studio/frontend/src/features/library/chats/chats-library.tsx+++ b/studio/frontend/src/features/library/chats/chats-library.tsx@@ -41,6 +41,7 @@ import {removeCustomSectionWithUndo,renameChatItem,showForkCreatedToast,+ showForkFailedToast,unarchiveChatItem,useChatPreferencesStore,useChatProjects,@@ -775,13 +776,9 @@ export function ChatsLibrary({try {const result = await forkChatRow(chat);notifyChatHistoryUpdated();- showForkCreatedToast(result.containerSnapshotWarning);+ showForkCreatedToast(result.containerSnapshotWarning, result.thread.title);} catch (err) {- if ((err as { unslothForkRefused?: boolean } | null)?.unslothForkRefused) {- toast.info(err instanceof Error ? err.message : t("library.chats.toast.forkFailed"));- } else {- toast.error(t("library.chats.toast.forkFailed"), { description: errorDescription(err) });- }+ showForkFailedToast(err, t("library.chats.toast.forkFailed"));} finally {inFlight.setForking(false);}diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.tsindex 3850e385672..7d057001d5c 100644--- a/studio/frontend/src/i18n/locales/en.ts+++ b/studio/frontend/src/i18n/locales/en.ts@@ -4293,7 +4293,7 @@ export const en = {compare: "Compare",},menu: {- fork: "Fork",+ fork: "Fork chat",moveTo: "Move to project",newChatInProject: "New chat in project",edit: "Edit",diff --git a/studio/frontend/tests/sidebar-row-actions.test.ts b/studio/frontend/tests/sidebar-row-actions.test.tsindex 337536b1783..f9639d11d29 100644--- a/studio/frontend/tests/sidebar-row-actions.test.ts+++ b/studio/frontend/tests/sidebar-row-actions.test.ts@@ -90,7 +90,12 @@ test("every chat row offers the pin without opening a menu", () => {test("a chat row reserves one gutter, whatever its state", () => {assert.match(APP_SIDEBAR,- /showWorkSpinner \? "pr-16" : hasUnreadActivity \? "pr-7" : undefined,/,+ /showWorkSpinner \? "pr-16" : hasUnreadActivity \? "pr-7" : showForkMark \? "pr-9" : undefined,/,+ );+ // The fork mark sits in the trailing column in grey, not inline after the title.+ assert.match(+ APP_SIDEBAR,+ /aria-label="Forked chat"\s+className=\{cn\(\s+"pointer-events-none absolute right-4 [^"]*text-muted-foreground/,);assert.ok(!APP_SIDEBAR.includes("hasSecondaryRowAction"),@@ -242,7 +247,7 @@ test("a chat row forks from its own menu", async () => {);assert.match(APP_SIDEBAR,- /<P\.Item\n\s*disabled=\{!canForkChatRow\(item\)[^]*?<span>Fork<\/span>\n\s*<\/P\.Item>\n\s*\{\/\* Projects and sections in one place[^]*?\*\/\}\n\s*<P\.Sub>/,+ /<P\.Item\n\s*disabled=\{!canForkChatRow\(item\)[^]*?<span>\{t\("library\.chats\.menu\.fork"\)\}<\/span>\n\s*<\/P\.Item>\n\s*\{\/\* Projects and sections in one place[^]*?\*\/\}\n\s*<P\.Sub>/,);const rowMenu = APP_SIDEBAR.slice(APP_SIDEBAR.indexOf("function renderChatRowMenuItems("),@@ -307,5 +312,7 @@ test("closed-chat forks leave tip selection to the server", async () => {// Its 409 is a refusal, not a failure.assert.match(ROW_MENU, /if \(message\.includes\("still generating"\)\) throw forkRefused\(\);/);assert.match(ROW_MENU, /\{ unslothForkRefused: true \}/);- assert.match(APP_SIDEBAR, /\?\.unslothForkRefused\) \{\n\s*toast\.info\(/);+ assert.match(APP_SIDEBAR, /\} catch \(error\) \{\n\s*showForkFailedToast\(error\);/);+ const TOAST = await readSrcAsync("features/chat/utils/fork-toast.ts");+ assert.match(TOAST, /\?\.unslothForkRefused \|\| message\.includes\("still generating"\)\) \{\n\s*toast\.info\(/);});