Skip to content

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.

Studio: edit a project from the Projects page, and sort it from the Updated column (#11443)

Michael Han2980768db1ba
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 6188ea989dd..ba47eee90a5 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -121,7 +121,6 @@ import {
import {
Tooltip,
TooltipContent,
- TooltipTrigger,
} from "@/components/ui/tooltip";
import { Tooltip as TooltipPrimitive } from "radix-ui";
import { HugeiconsIcon } from "@hugeicons/react";
@@ -136,13 +135,16 @@ import {
archiveChatItem,
ChatSearchDialog,
clearNewChatDraft,
+ chatExportOptions,
EditProjectDialog,
+ OpenChatFolderUnavailableItem,
+ exportConversationByFormat,
+ getSidebarItemThreadIds,
+ sandboxSessionIdsHolding,
deleteChatProject,
deleteChatItem,
- listStoredChatMessages,
listStoredChatThreads,
moveChatItemToProject,
- allRecordedSandboxSessionIds,
notifyChatHistoryUpdated,
renameChatItem,
useChatRuntimeStore,
@@ -167,8 +169,6 @@ import {
RECENTS_ORDER_SCOPE,
type SidebarChatSort,
type SidebarOrganizeBy,
- CONVERSATION_MARKDOWN_FORMAT,
- CONVERSATION_MARKDOWN_LABEL,
type ProjectRecord,
type SidebarItem,
type ChatNavigationState,
@@ -182,7 +182,6 @@ import {
import { sandboxSessionIdFor } from "@/components/assistant-ui/sandbox-files";
import {
revealSandbox,
- sandboxHasFiles,
} from "@/components/assistant-ui/sandbox-reveal";
import { NewProjectDialog } from "@/features/chat/components/new-project-dialog";
import {
@@ -302,13 +301,6 @@ type NavRowDef = {
children?: ReactNode;
};
-type ConversationExportFormat =
- | "raw-jsonl"
- | "messages-jsonl"
- | "csv"
- | "sharegpt-jsonl"
- | typeof CONVERSATION_MARKDOWN_FORMAT;
-
// An expanded project shows this many recent chats before "Show more".
const PROJECT_CHAT_LIMIT = 4;
// And the Projects section shows this many folders before its own "Show more".
@@ -372,29 +364,14 @@ const REVEAL_WITH_OPEN_MENU_PROJECT_CHAT =
const REVEAL_WITH_OPEN_MENU_RECENT =
"group-has-[.sidebar-row-action[data-state=open]]/recent-item:opacity-100 group-has-[.sidebar-row-action[data-state=open]]/recent-item:pointer-events-auto";
-// Every list offers the same three orders. Each says what it actually does under its name: the
-// three read as synonyms otherwise, and Manual order in particular is a rule the user writes by
-// dragging rather than one the list applies.
+// Every list offers the same three orders.
const CHAT_SORT_OPTIONS: Array<{
value: SidebarChatSort;
key: TranslationKey;
- hint: TranslationKey;
}> = [
- {
- value: "priority",
- key: "shell.organize.priority",
- hint: "shell.organize.priorityHint",
- },
- {
- value: "updated",
- key: "shell.organize.lastUpdated",
- hint: "shell.organize.lastUpdatedHint",
- },
- {
- value: "manual",
- key: "shell.organize.manualOrder",
- hint: "shell.organize.manualOrderHint",
- },
+ { value: "priority", key: "shell.organize.priority" },
+ { value: "updated", key: "shell.organize.lastUpdated" },
+ { value: "manual", key: "shell.organize.manualOrder" },
];
const ORGANIZE_OPTIONS: Array<{
value: SidebarOrganizeBy;
@@ -404,43 +381,6 @@ const ORGANIZE_OPTIONS: Array<{
{ value: "list", key: "shell.organize.inOneList" },
];
-const CHAT_EXPORT_OPTIONS: Array<{
- label: string;
- format: ConversationExportFormat;
-}> = [
- { label: "Training JSONL", format: "raw-jsonl" },
- { label: "Message JSONL", format: "messages-jsonl" },
- { label: "CSV", format: "csv" },
- { label: "ShareGPT JSONL", format: "sharegpt-jsonl" },
- { label: CONVERSATION_MARKDOWN_LABEL, format: CONVERSATION_MARKDOWN_FORMAT },
-];
-
-async function exportConversationByFormat(
- threadId: string,
- format: ConversationExportFormat,
-): Promise<void> {
- const exports = await import(
- "@/features/chat/prompt-storage/prompt-storage-dialog"
- );
- switch (format) {
- case "raw-jsonl":
- return exports.exportConversationRawJsonl(threadId);
- case "messages-jsonl":
- return exports.exportConversationMessagesJsonl(threadId);
- case "csv":
- return exports.exportConversationCsv(threadId);
- case "sharegpt-jsonl":
- return exports.exportConversationShareGPT(threadId);
- case CONVERSATION_MARKDOWN_FORMAT:
- return exports.exportConversationMarkdown(threadId);
- default: {
- // Exhaustive: a new format is a build error, not a menu item that does nothing.
- const unhandled: never = format;
- throw new Error(`Unhandled export format: ${String(unhandled)}`);
- }
- }
-}
-
async function saveChatToProjectSources(
item: SidebarItem,
projectId: string,
@@ -492,51 +432,6 @@ function preloadSilently(request: Promise<unknown>): void {
void request.catch(() => undefined);
}
-/**
- * "Open chat folder" for a browser session, where the backend's file manager is not the user's.
- * Radix's `disabled` takes the row's pointer events away and a tooltip is blocked while the menu
- * owns the screen, so the row stays enabled, refuses the select itself, and drives a controlled
- * tooltip off a pointer-events-none anchor (as the MCP rows do). The reason is carried twice: that
- * tooltip opens on hover, which a screen reader never reaches and a touch device does not have, so
- * `title` describes the row and selecting it opens the hint rather than doing nothing.
- */
-function OpenChatFolderUnavailableItem() {
- const [hintOpen, setHintOpen] = useState(false);
-
- return (
- <DropdownMenuItem
- aria-disabled={true}
- title="Only the desktop app can open a chat's files folder. In a browser, download a file from the tool result that wrote it."
- className="relative opacity-50"
- onSelect={(event) => {
- event.preventDefault();
- setHintOpen(true);
- }}
- onPointerEnter={() => setHintOpen(true)}
- onPointerLeave={() => setHintOpen(false)}
- onFocus={() => setHintOpen(true)}
- onBlur={() => setHintOpen(false)}
- >
- <HugeiconsIcon icon={FolderOpenIcon} strokeWidth={1.75} className="size-icon" />
- <span>Open chat folder</span>
- <Tooltip open={hintOpen}>
- {/* Our wrapper, not the raw primitive: it registers the trigger element,
- without which the tooltip counts itself blocked by the open menu. */}
- <TooltipTrigger asChild={true}>
- <span
- aria-hidden={true}
- className="pointer-events-none absolute inset-y-0 right-0 w-0"
- />
- </TooltipTrigger>
- <TooltipContent side="right" className="max-w-[220px]">
- Only the desktop app can open a chat's files folder. In a browser,
- download a file from the tool result that wrote it.
- </TooltipContent>
- </Tooltip>
- </DropdownMenuItem>
- );
-}
-
function NavBadge({ label, className }: { label: string; className?: string }) {
return (
<span
@@ -629,10 +524,6 @@ function NavItem({
);
}
-function getSidebarItemThreadIds(item: SidebarItem) {
- return item.threadIds?.length ? item.threadIds : [item.id];
-}
-
const WORKFLOW_UNAVAILABLE = "The loaded model cannot do this";
// Re-read cadences for the hardware verdict below. An unmeasured verdict holds Train and Video on
@@ -1397,12 +1288,12 @@ export function AppSidebar() {
);
// Pinned is one list of folders and chats, in the order they were dropped into. Folders lead
// until a drop says otherwise; a chat sort other than Manual keeps the chats after them.
+ // Pinning is its own grouping: a pinned folder stays here whichever way the sidebar organizes,
+ // and "In one list" only takes the Projects section away.
const pinnedRows = useMemo(() => {
const rows: PinnedRow[] = [];
- if (organizeBy === "project") {
- for (const project of pinnedProjectBase) {
- rows.push({ kind: "project", id: project.id, project });
- }
+ for (const project of pinnedProjectBase) {
+ rows.push({ kind: "project", id: project.id, project });
}
for (const item of sortedPinnedChatItems) {
rows.push({ kind: "chat", id: item.id, item });
@@ -1410,7 +1301,7 @@ export function AppSidebar() {
return pinnedSort === "manual"
? applyManualOrder(rows, manualOrder[PINNED_ORDER_SCOPE], (row) => row.id)
: rows;
- }, [organizeBy, pinnedProjectBase, sortedPinnedChatItems, pinnedSort, manualOrder]);
+ }, [pinnedProjectBase, sortedPinnedChatItems, pinnedSort, manualOrder]);
const pinnedRowIds = useMemo(() => pinnedRows.map((row) => row.id), [pinnedRows]);
const pinnedProjectRecords = useMemo(
() => pinnedRows.flatMap((row) => (row.kind === "project" ? [row.project] : [])),
@@ -1435,6 +1326,8 @@ export function AppSidebar() {
// disclosure, not the Projects one, so each section collects its own.
const folderChatItems = useCallback(
(open: boolean, records: ProjectRecord[]) => {
+ // Not in one list: every project chat is a Recents row there, and a folder listing them
+ // again would draw and publish each one twice.
if (!chatListsOnScreen || organizeBy !== "project" || !open) return [];
const out: SidebarItem[] = [];
for (const project of records) {
@@ -1498,24 +1391,22 @@ export function AppSidebar() {
// section closes, the sidebar organizes by date, or a "show less" takes back the overflow. The chat
// sets above say nothing about that, since a folder with no chats in view is still a row.
const renderedProjectIds = useMemo(() => {
- if (!chatListsOnScreen || organizeBy !== "project") {
- return new Set<string>();
- }
+ if (!chatListsOnScreen) return new Set<string>();
const ids = new Set<string>();
- // Each folder leaves with its own section.
+ // Each folder leaves with its own section, and Pinned keeps its folders in either organization.
if (pinnedOpen) {
for (const project of pinnedProjectRecords) ids.add(project.id);
}
- if (projectsOpen) {
+ if (projectsOpen && projectsSectionConfigured) {
for (const project of visibleProjectRecords) ids.add(project.id);
}
return ids;
}, [
chatListsOnScreen,
- organizeBy,
pinnedOpen,
pinnedProjectRecords,
projectsOpen,
+ projectsSectionConfigured,
visibleProjectRecords,
]);
// Rows wanting attention, most urgent first. Same rule the Priority sort uses.
@@ -1571,6 +1462,7 @@ export function AppSidebar() {
}, [sortedChatsByProjectId]);
// Nested rows across both sections, so the bottom fade re-measures when the list height changes.
const projectChatRowCount = useMemo(() => {
+ // Only folders list chats, and only this organization has folders that do.
if (organizeBy !== "project") return 0;
let rows = 0;
for (const project of [...pinnedProjectRecords, ...visibleProjectRecords]) {
@@ -2847,47 +2739,6 @@ export function AppSidebar() {
}
}
- /** The sandbox sessions this chat's stored tool results name, if any. */
- async function recordedSandboxSessionIds(ids: string[]): Promise<string[]> {
- const recorded: string[] = [];
- // Every id a thread names, not just its latest: one chat that ran a tool, moved between projects
- // and ran another wrote to two folders on its own, and the newest would answer for both. One at a
- // time, not Promise.all: this file's export contract forbids a concurrent await here.
- for (const threadId of ids) {
- recorded.push(
- ...allRecordedSandboxSessionIds(await listStoredChatMessages(threadId)),
- );
- }
- return [...new Set(recorded)];
- }
-
- /**
- * The folders this chat's files are actually in: what its tool results name, or, for a chat old
- * enough that they name nothing, what is on disk. Chats stored before results carried a session
- * recorded nothing, so one that ran loose and has since joined a project would be answered with
- * the project workspace; its thread sandbox is the only other candidate, and files there are this
- * chat's. The project workspace is not probed, because it belongs to every chat alike.
- *
- * A union rather than a fallback: one recorded id is not evidence that the others are recorded
- * too, and taking it alone would answer for both folders while hiding the older. Shared by "Open
- * chat folder" and "Copy session id", which drifted apart once, the copy path skipping the probe
- * and reporting success on a folder the chat had never written to.
- */
- async function sandboxSessionIdsHolding(ids: string[]): Promise<string[]> {
- const recorded = await recordedSandboxSessionIds(ids);
- // Thread folders only. A project sandbox is shared by every chat in the project, so files there are
- // no evidence that THIS chat wrote them, and counting one would report a second folder for any chat
- // that joined a project someone else had used. Both callers already fall back to the folder
- // membership gives them when nothing here names one.
- const held: string[] = [];
- for (const candidate of ids) {
- // Already named, so there is nothing a probe could add.
- if (recorded.includes(candidate)) continue;
- if (await sandboxHasFiles(candidate)) held.push(candidate);
- }
- return [...new Set([...recorded, ...held])];
- }
-
/** The sandbox session this chat's tool calls write into. */
async function copyChatSessionId(item: SidebarItem) {
const threadIds = getSidebarItemThreadIds(item);
@@ -3223,14 +3074,9 @@ export function AppSidebar() {
<DropdownMenuRadioItem
key={option.value}
value={option.value}
- className={cn(menuRadioItemClass, "items-start py-1.5")}
+ className={menuRadioItemClass}
>
- <span className="flex flex-col gap-0.5">
- <span>{t(option.key)}</span>
- <span className="text-ui-12 leading-ui-16 text-muted-foreground">
- {t(option.hint)}
- </span>
- </span>
+ {t(option.key)}
</DropdownMenuRadioItem>
))}
</DropdownMenuRadioGroup>
@@ -3734,7 +3580,7 @@ export function AppSidebar() {
<span>Export</span>
</DropdownMenuSubTrigger>
<DropdownMenuSubContent sideOffset={8} alignOffset={-4} className="unsloth-plus-menu w-52">
- {CHAT_EXPORT_OPTIONS.map(({ label, format }) => (
+ {chatExportOptions().map(({ label, format }) => (
<DropdownMenuItem
key={label}
onSelect={async () => {
@@ -3810,7 +3656,10 @@ export function AppSidebar() {
sortedChatsByProjectId.get(project.id) ?? [];
const projectChatIds =
projectChatRowIds.get(project.id) ?? [];
- const expanded = !collapsedProjectIds.has(project.id);
+ // With the sidebar in one list there is nothing to expand into: the chats are already Recents
+ // rows. The folder row stays, as a way into the project, and opens it rather than toggling.
+ const listsChats = organizeBy === "project";
+ const expanded = listsChats && !collapsedProjectIds.has(project.id);
const showAll = expandedChatProjectIds.has(project.id);
const visibleChats =
expanded && !showAll
@@ -3883,7 +3732,8 @@ export function AppSidebar() {
)
return;
clearSelection();
- toggleProjectCollapsed(project.id);
+ if (listsChats) toggleProjectCollapsed(project.id);
+ else openProject(project.id);
}}
// Same gutter whether hover or this row's menu revealed the actions.
className="sidebar-nav-btn h-[33px] rounded-full gap-[8.5px] pl-3 pr-2.5 font-medium group-hover/recent-item:pr-16 group-has-[.sidebar-row-action[data-state=open]]/recent-item:pr-16 [@media(pointer:coarse)]:pr-16"
diff --git a/studio/frontend/src/features/chat/chat-page.tsx b/studio/frontend/src/features/chat/chat-page.tsx
index a1d77648be7..1f8f3f3a4c9 100644
--- a/studio/frontend/src/features/chat/chat-page.tsx
+++ b/studio/frontend/src/features/chat/chat-page.tsx
@@ -46,14 +46,6 @@ import {
AlertDialogTitle,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
-import {
- Dialog,
- DialogContent,
- DialogFooter,
- DialogHeader,
- DialogTitle,
-} from "@/components/ui/dialog";
-import { Input } from "@/components/ui/input";
import {
ResizableHandle,
ResizablePanel,
@@ -155,6 +147,7 @@ import {
import { ContextUsageBar } from "./components/context-usage-bar";
import { ModelLoadInlineStatus } from "./components/model-load-status";
import { ProjectSwitcher } from "./components/project-switcher";
+import { EditProjectDialog } from "./components/edit-project-dialog";
import {
buildExternalModelId,
isExternalModelId,
@@ -167,7 +160,6 @@ import type { SelectedModelInput } from "./hooks/use-chat-model-runtime";
import {
deleteChatProject,
moveChatItemToProject,
- renameChatProject,
useChatProjects,
} from "./hooks/use-chat-projects";
import {
@@ -1389,8 +1381,7 @@ function ProjectLanding({
const pinnedProjectIds = usePinnedProjectsStore((s) => s.pinnedIds);
const togglePinProject = usePinnedProjectsStore((s) => s.togglePin);
const projectPinned = pinnedProjectIds.includes(projectId);
- const [renamingProject, setRenamingProject] = useState(false);
- const [projectNameDraft, setProjectNameDraft] = useState("");
+ const [editingProject, setEditingProject] = useState(false);
const [deletingProject, setDeletingProject] = useState(false);
async function handleProjectExport(
@@ -1408,23 +1399,19 @@ function ProjectLanding({
}
}
- async function commitProjectRename(): Promise<void> {
- const name = projectNameDraft.trim();
- setRenamingProject(false);
- if (!name || name === projectName) return;
- try {
- await renameChatProject(projectId, name);
- } catch (err) {
- toast.error("Failed to rename project", {
- description: err instanceof Error ? err.message : undefined,
- });
- }
+ /** A project workspace is a bigger thing to remove than a chat's sandbox, so it asks from
+ * scratch rather than following the chat preference, as the sidebar does it. */
+ function openProjectDelete(): void {
+ setDeleteFilesOnDelete(false);
+ setDeletingProject(true);
}
async function commitProjectDelete(): Promise<void> {
+ const deleteFiles = deleteFilesOnDelete;
setDeletingProject(false);
+ setDeleteFilesOnDelete(false);
try {
- await deleteChatProject(projectId);
+ await deleteChatProject(projectId, { deleteFiles });
// Refresh chat history so the project's now-deleted chats do not linger in the sidebar, matching
// the sidebar delete path.
notifyChatHistoryUpdated();
@@ -1478,6 +1465,11 @@ function ProjectLanding({
// Full chat actions, matching the sidebar chat menu.
const { projects } = useChatProjects();
+ // The record behind the header, for the Edit dialog.
+ const currentProject = useMemo(
+ () => projects.find((project) => project.id === projectId),
+ [projects, projectId],
+ );
const pinnedChatIds = usePinnedChatsStore((s) => s.pinnedIds);
const togglePinnedChat = usePinnedChatsStore((s) => s.togglePin);
const confirmDeleteChats = useChatPreferencesStore(
@@ -1755,14 +1747,9 @@ function ProjectLanding({
</button>
)}
>
- <DropdownMenuItem
- onSelect={() => {
- setProjectNameDraft(projectName);
- setRenamingProject(true);
- }}
- >
+ <DropdownMenuItem onSelect={() => setEditingProject(true)}>
<HugeiconsIcon icon={Edit03Icon} strokeWidth={1.75} className="size-icon" />
- <span>Rename project</span>
+ <span>Edit project</span>
</DropdownMenuItem>
<DropdownMenuItem onSelect={() => togglePinProject(projectId)}>
<HugeiconsIcon icon={projectPinned ? PinOffIcon : PinIcon} strokeWidth={1.75} className="size-icon" />
@@ -1787,7 +1774,7 @@ function ProjectLanding({
<DropdownMenuSeparator />
<DropdownMenuItem
variant="destructive"
- onSelect={() => setDeletingProject(true)}
+ onSelect={() => openProjectDelete()}
>
<HugeiconsIcon icon={Delete02Icon} strokeWidth={1.75} className="size-icon" />
<span>Delete project</span>
@@ -2096,47 +2083,18 @@ function ProjectLanding({
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
- <Dialog
- open={active && renamingProject}
+ {/* The sidebar's dialog, so a project is edited the same way wherever it is opened from.
+ Delete hands back here, which owns the confirmation below. */}
+ <EditProjectDialog
+ project={active && editingProject ? (currentProject ?? null) : null}
onOpenChange={(open) => {
- if (!open) setRenamingProject(false);
+ if (!open) setEditingProject(false);
}}
- >
- <DialogContent className="corner-squircle dialog-soft-surface sm:max-w-md">
- <DialogHeader>
- <DialogTitle>Rename project</DialogTitle>
- </DialogHeader>
- <Input
- value={projectNameDraft}
- onChange={(e) => setProjectNameDraft(e.target.value)}
- onKeyDown={(e) => {
- if (e.key === "Enter") {
- e.preventDefault();
- void commitProjectRename();
- }
- }}
- autoFocus={true}
- maxLength={120}
- placeholder="Project name"
- aria-label="Project name"
- className="focus-visible:border-input focus-visible:ring-0"
- />
- <DialogFooter className="flex-wrap gap-2 sm:justify-end">
- <Button type="button" variant="ghost" onClick={() => setRenamingProject(false)}>
- Cancel
- </Button>
- <Button
- type="button"
- onClick={() => void commitProjectRename()}
- disabled={
- !projectNameDraft.trim() || projectNameDraft.trim() === projectName
- }
- >
- Save
- </Button>
- </DialogFooter>
- </DialogContent>
- </Dialog>
+ onDelete={() => {
+ setEditingProject(false);
+ openProjectDelete();
+ }}
+ />
<AlertDialog
open={active && deletingProject}
onOpenChange={(open) => {
@@ -2150,10 +2108,20 @@ function ProjectLanding({
Delete "{projectName}"? Its chats will be permanently deleted.
</AlertDialogDescription>
</AlertDialogHeader>
+ {/* Same offer the sidebar makes, naming the folder when the record carries one. */}
+ <DeleteChatFilesSwitch
+ id="chat-landing-delete-project-files"
+ checked={deleteFilesOnDelete}
+ onCheckedChange={setDeleteFilesOnDelete}
+ description={
+ currentProject?.rootPath ??
+ "The project workspace folder will be removed from disk."
+ }
+ />
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction onClick={() => void commitProjectDelete()}>
- Delete
+ {deleteFilesOnDelete ? "Delete all" : "Delete"}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
diff --git a/studio/frontend/src/features/chat/components/chat-row-menu.ts b/studio/frontend/src/features/chat/components/chat-row-menu.ts
new file mode 100644
index 00000000000..34bf2af0c30
--- /dev/null
+++ b/studio/frontend/src/features/chat/components/chat-row-menu.ts
@@ -0,0 +1,112 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// What a chat row's menu is made of, wherever the row is drawn: the sidebar's rows and the
+// Projects page's. Kept in one place because the folder probe below drifted once when two callers
+// carried their own.
+
+import { sandboxHasFiles } from "@/components/assistant-ui/sandbox-reveal";
+
+import {
+ CONVERSATION_MARKDOWN_FORMAT,
+ CONVERSATION_MARKDOWN_LABEL,
+} from "../utils/conversation-markdown";
+import { allRecordedSandboxSessionIds } from "../utils/recorded-sandbox-session";
+import type { SidebarItem } from "../hooks/use-chat-sidebar-items";
+import { listStoredChatMessages } from "../utils/chat-history-storage";
+
+export type ConversationExportFormat =
+ | "raw-jsonl"
+ | "messages-jsonl"
+ | "csv"
+ | "sharegpt-jsonl"
+ | typeof CONVERSATION_MARKDOWN_FORMAT;
+
+/** Built on call, not at module scope: the markdown label arrives through the feature barrel,
+ * and reading it while this module loads throws if the cycle re-enters first. */
+export function chatExportOptions(): Array<{
+ label: string;
+ format: ConversationExportFormat;
+}> {
+ return [
+ { label: "Training JSONL", format: "raw-jsonl" },
+ { label: "Message JSONL", format: "messages-jsonl" },
+ { label: "CSV", format: "csv" },
+ { label: "ShareGPT JSONL", format: "sharegpt-jsonl" },
+ { label: CONVERSATION_MARKDOWN_LABEL, format: CONVERSATION_MARKDOWN_FORMAT },
+ ];
+}
+
+export async function exportConversationByFormat(
+ threadId: string,
+ format: ConversationExportFormat,
+): Promise<void> {
+ const exports = await import("../prompt-storage/prompt-storage-dialog");
+ switch (format) {
+ case "raw-jsonl":
+ return exports.exportConversationRawJsonl(threadId);
+ case "messages-jsonl":
+ return exports.exportConversationMessagesJsonl(threadId);
+ case "csv":
+ return exports.exportConversationCsv(threadId);
+ case "sharegpt-jsonl":
+ return exports.exportConversationShareGPT(threadId);
+ case CONVERSATION_MARKDOWN_FORMAT:
+ return exports.exportConversationMarkdown(threadId);
+ default: {
+ // Exhaustive: a new format is a build error, not a menu item that does nothing.
+ const unhandled: never = format;
+ throw new Error(`Unhandled export format: ${String(unhandled)}`);
+ }
+ }
+}
+
+/** The threads behind a row: a comparison is two, everything else is itself. */
+export function getSidebarItemThreadIds(item: SidebarItem): string[] {
+ return item.threadIds?.length ? item.threadIds : [item.id];
+}
+
+/** The sandbox sessions this chat's stored tool results name, if any. */
+export async function recordedSandboxSessionIds(
+ ids: string[],
+): Promise<string[]> {
+ const recorded: string[] = [];
+ // Every id a thread names, not just its latest: one chat that ran a tool, moved between projects
+ // and ran another wrote to two folders on its own, and the newest would answer for both. One at a
+ // time, not Promise.all: app-sidebar's export contract forbids a concurrent await on this path.
+ for (const threadId of ids) {
+ recorded.push(
+ ...allRecordedSandboxSessionIds(await listStoredChatMessages(threadId)),
+ );
+ }
+ return [...new Set(recorded)];
+}
+
+/**
+ * The folders this chat's files are actually in: what its tool results name, or, for a chat old
+ * enough that they name nothing, what is on disk. Chats stored before results carried a session
+ * recorded nothing, so one that ran loose and has since joined a project would be answered with
+ * the project workspace; its thread sandbox is the only other candidate, and files there are this
+ * chat's. The project workspace is not probed, because it belongs to every chat alike.
+ *
+ * A union rather than a fallback: one recorded id is not evidence that the others are recorded
+ * too, and taking it alone would answer for both folders while hiding the older. Shared by "Open
+ * chat folder" and "Copy session id", which drifted apart once, the copy path skipping the probe
+ * and reporting success on a folder the chat had never written to.
+ */
+export async function sandboxSessionIdsHolding(
+ ids: string[],
+): Promise<string[]> {
+ const recorded = await recordedSandboxSessionIds(ids);
+ // Thread folders only. A project sandbox is shared by every chat in the project, so files there are
+ // no evidence that THIS chat wrote them, and counting one would report a second folder for any chat
+ // that joined a project someone else had used. Both callers already fall back to the folder
+ // membership gives them when nothing here names one.
+ const held: string[] = [];
+ for (const candidate of ids) {
+ // Already named, so there is nothing a probe could add.
+ if (recorded.includes(candidate)) continue;
+ if (await sandboxHasFiles(candidate)) held.push(candidate);
+ }
+ return [...new Set([...recorded, ...held])];
+}
diff --git a/studio/frontend/src/features/chat/components/open-chat-folder-item.tsx b/studio/frontend/src/features/chat/components/open-chat-folder-item.tsx
new file mode 100644
index 00000000000..59415c2e962
--- /dev/null
+++ b/studio/frontend/src/features/chat/components/open-chat-folder-item.tsx
@@ -0,0 +1,57 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+import { DropdownMenuItem } from "@/components/ui/dropdown-menu";
+import {
+ Tooltip,
+ TooltipContent,
+ TooltipTrigger,
+} from "@/components/ui/tooltip";
+import { FolderOpenIcon } from "@hugeicons/core-free-icons";
+import { HugeiconsIcon } from "@hugeicons/react";
+import { useState } from "react";
+
+/**
+ * "Open chat folder" for a browser session, where the backend's file manager is not the user's.
+ * Radix's `disabled` takes the row's pointer events away and a tooltip is blocked while the menu
+ * owns the screen, so the row stays enabled, refuses the select itself, and drives a controlled
+ * tooltip off a pointer-events-none anchor (as the MCP rows do). The reason is carried twice: that
+ * tooltip opens on hover, which a screen reader never reaches and a touch device does not have, so
+ * `title` describes the row and selecting it opens the hint rather than doing nothing.
+ */
+export function OpenChatFolderUnavailableItem() {
+ const [hintOpen, setHintOpen] = useState(false);
+
+ return (
+ <DropdownMenuItem
+ aria-disabled={true}
+ title="Only the desktop app can open a chat's files folder. In a browser, download a file from the tool result that wrote it."
+ className="relative opacity-50"
+ onSelect={(event) => {
+ event.preventDefault();
+ setHintOpen(true);
+ }}
+ onPointerEnter={() => setHintOpen(true)}
+ onPointerLeave={() => setHintOpen(false)}
+ onFocus={() => setHintOpen(true)}
+ onBlur={() => setHintOpen(false)}
+ >
+ <HugeiconsIcon icon={FolderOpenIcon} strokeWidth={1.75} className="size-icon" />
+ <span>Open chat folder</span>
+ <Tooltip open={hintOpen}>
+ {/* Our wrapper, not the raw primitive: it registers the trigger element,
+ without which the tooltip counts itself blocked by the open menu. */}
+ <TooltipTrigger asChild={true}>
+ <span
+ aria-hidden={true}
+ className="pointer-events-none absolute inset-y-0 right-0 w-0"
+ />
+ </TooltipTrigger>
+ <TooltipContent side="right" className="max-w-[220px]">
+ Only the desktop app can open a chat&apos;s files folder. In a browser, download a
+ file from the tool result that wrote it.
+ </TooltipContent>
+ </Tooltip>
+ </DropdownMenuItem>
+ );
+}
diff --git a/studio/frontend/src/features/chat/components/project-switcher.tsx b/studio/frontend/src/features/chat/components/project-switcher.tsx
index 5b1ec3040ac..ca02899ee89 100644
--- a/studio/frontend/src/features/chat/components/project-switcher.tsx
+++ b/studio/frontend/src/features/chat/components/project-switcher.tsx
@@ -12,10 +12,13 @@ import { Folder01Icon } from "@hugeicons/core-free-icons";
import { Tick02Icon } from "@/lib/tick-icon";
import { ChevronDownStandardIcon } from "@/lib/chevron-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { type ReactElement, useState } from "react";
+import { type ReactElement, useMemo, useState } from "react";
import { useChatActive } from "../runtime-provider";
import type { ProjectRecord } from "../types";
+/** Rows before "View all projects". The list arrives newest first, so these are the recent ones. */
+const RECENT_PROJECT_LIMIT = 6;
+
export function ProjectSwitcher({
currentProject,
projects,
@@ -34,6 +37,16 @@ export function ProjectSwitcher({
open?: boolean;
onOpenChange?: (open: boolean) => void;
}): ReactElement {
+ // A switcher, not the list: the rest are a click away under "View all projects".
+ const recentProjects = useMemo(() => {
+ const recent = projects.slice(0, RECENT_PROJECT_LIMIT);
+ if (!currentProject || recent.some((p) => p.id === currentProject.id)) {
+ return recent;
+ }
+ // A project's own updatedAt only moves when it is edited, so the open one is often not among
+ // the newest. It keeps its place here: without it the switcher shows no tick at all.
+ return [...recent.slice(0, RECENT_PROJECT_LIMIT - 1), currentProject];
+ }, [projects, currentProject]);
const showLoadingRow = isLoading && projects.length === 0;
const showEmptyRow = !isLoading && projects.length === 0;
const label = currentProject?.name ?? (isLoading ? "Project" : "Projects");
@@ -97,7 +110,7 @@ export function ProjectSwitcher({
No projects yet
</DropdownMenuItem>
) : null}
- {projects.map((project) => {
+ {recentProjects.map((project) => {
const isActive = currentProject?.id === project.id;
return (
<DropdownMenuItem
diff --git a/studio/frontend/src/features/chat/index.ts b/studio/frontend/src/features/chat/index.ts
index 2a2af87d98e..70244d3059e 100644
--- a/studio/frontend/src/features/chat/index.ts
+++ b/studio/frontend/src/features/chat/index.ts
@@ -263,6 +263,15 @@ export { StopRunningChatsDialog } from "./components/stop-running-chats-dialog";
export { setTrainingCompareHandoff } from "./lib/training-compare-handoff";
export type { ProjectRecord } from "./types";
export { EditProjectDialog } from "./components/edit-project-dialog";
+export {
+ chatExportOptions,
+ exportConversationByFormat,
+ getSidebarItemThreadIds,
+ recordedSandboxSessionIds,
+ sandboxSessionIdsHolding,
+ type ConversationExportFormat,
+} from "./components/chat-row-menu";
+export { OpenChatFolderUnavailableItem } from "./components/open-chat-folder-item";
export { clearAllChats, countAllChats } from "./utils/clear-all-chats";
export { offerToDeleteKeptSandboxes } from "./utils/offer-kept-sandbox-files";
export { pasteClipboardFiles } from "./utils/clipboard-files";
diff --git a/studio/frontend/src/features/chat/projects-page.tsx b/studio/frontend/src/features/chat/projects-page.tsx
index f5dc73204aa..ed2ee0f14be 100644
--- a/studio/frontend/src/features/chat/projects-page.tsx
+++ b/studio/frontend/src/features/chat/projects-page.tsx
@@ -36,29 +36,50 @@ import { cn } from "@/lib/utils";
import { isDownloadCancelled, pickNativeChatImport } from "@/lib/native-files";
import { toast } from "@/lib/toast";
import {
+ chatExportOptions,
+ DeleteChatFilesSwitch,
+ OpenChatFolderUnavailableItem,
+ archiveChatItem,
+ deleteChatItem,
deleteChatProject,
- renameChatProject,
+ exportConversationByFormat,
+ getSidebarItemThreadIds,
+ notifyChatHistoryUpdated,
+ renameChatItem,
+ sandboxSessionIdsHolding,
+ useChatNavigationStore,
+ useChatPreferencesStore,
useChatProjects,
useChatRuntimeStore,
+ usePinnedChatsStore,
usePinnedProjectsStore,
+ type ConversationExportFormat,
type ProjectRecord,
} from "@/features/chat";
+import { useSettingsDialogStore } from "@/features/settings";
+import { sandboxSessionIdFor } from "@/components/assistant-ui/sandbox-files";
+import { revealSandbox } from "@/components/assistant-ui/sandbox-reveal";
import { GuidedTour, useGuidedTourController } from "@/features/tour";
import { buildProjectsTourSteps } from "./tour";
+import { EditProjectDialog } from "./components/edit-project-dialog";
import { NewProjectDialog } from "./components/new-project-dialog";
import {
+ Archive03Icon,
Delete02Icon,
Download01Icon,
Edit03Icon,
Folder02Icon,
FolderAddIcon,
+ FolderOpenIcon,
PinIcon,
PinOffIcon,
Search01Icon,
Upload01Icon,
+ ViewIcon,
+ ViewOffSlashIcon,
} from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
-import { ChevronDownIcon, MoreHorizontalIcon } from "lucide-react";
+import { ArrowDownIcon, ChevronDownIcon, MoreHorizontalIcon } from "lucide-react";
import { MessageCircleIcon } from "@/lib/hugeicons-derived";
import { useNavigate } from "@tanstack/react-router";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
@@ -82,8 +103,6 @@ import {
import { CHAT_HISTORY_UPDATED_EVENT } from "./api/chat-api";
import { groupThreads, type SidebarItem } from "./hooks/use-chat-sidebar-items";
-type SortMode = "activity" | "name";
-
// Reveal this many more projects each time the user scrolls near the bottom.
const PROJECTS_PAGE_STEP = 12;
// A streaming chat fires the history event per chunk; one reload per quiet window is enough.
@@ -93,9 +112,9 @@ const PROJECTS_INITIAL_FALLBACK = 8;
// Approx list row height in px, used to estimate how many rows fit the page.
const PROJECTS_ROW_HEIGHT = 68;
-// Modified column, matching a file-list feel: Today / Yesterday / N days ago, then a short date
+// Updated column, matching a file-list feel: Today / Yesterday / N days ago, then a short date
// once it is over a week old.
-function formatModified(ts: number): string {
+function formatUpdated(ts: number): string {
if (!Number.isFinite(ts)) return "";
const now = new Date();
const then = new Date(ts);
@@ -126,7 +145,8 @@ export function ProjectsPage() {
const { projects, hasLoaded } = useChatProjects();
const [query, setQuery] = useState("");
- const [sortMode, setSortMode] = useState<SortMode>("activity");
+ // Newest first, the way a file list opens.
+ const [sortDir, setSortDir] = useState<"desc" | "asc">("desc");
// Rows that fit the page height (measured), plus any revealed via Show more.
const [baseFit, setBaseFit] = useState(PROJECTS_INITIAL_FALLBACK);
const [extraCount, setExtraCount] = useState(0);
@@ -139,11 +159,26 @@ export function ProjectsPage() {
() => new Set(pinnedProjectIds),
[pinnedProjectIds],
);
+ const unreadThreadIds = useChatNavigationStore((s) => s.unreadThreadIds);
+ const markThreadsUnread = useChatNavigationStore((s) => s.markThreadsUnread);
+ const clearThreadsUnread = useChatNavigationStore((s) => s.clearThreadsUnread);
+ const confirmDeleteChats = useChatPreferencesStore((s) => s.confirmDeleteChats);
+ const alwaysDeleteChatFiles = useChatPreferencesStore(
+ (s) => s.alwaysDeleteChatFiles,
+ );
+ const pinnedChatIds = usePinnedChatsStore((s) => s.pinnedIds);
+ const togglePinChat = usePinnedChatsStore((s) => s.togglePin);
+ const unpinChat = usePinnedChatsStore((s) => s.unpin);
+ const pinnedChatIdSet = useMemo(() => new Set(pinnedChatIds), [pinnedChatIds]);
const [creating, setCreating] = useState(false);
- const [renaming, setRenaming] = useState<ProjectRecord | null>(null);
- const [renameDraft, setRenameDraft] = useState("");
+ const [editing, setEditing] = useState<ProjectRecord | null>(null);
const [deleting, setDeleting] = useState<ProjectRecord | null>(null);
+ const [renamingChat, setRenamingChat] = useState<SidebarItem | null>(null);
+ const [chatNameDraft, setChatNameDraft] = useState("");
+ const [deletingChat, setDeletingChat] = useState<SidebarItem | null>(null);
+ // Whether the open confirmation takes the files too. Seeded per delete, never left standing.
+ const [deleteFilesOnDelete, setDeleteFilesOnDelete] = useState(false);
const globalImportRef = useRef<HTMLInputElement>(null);
const projectImportRefs = useRef<Map<string, HTMLInputElement>>(new Map());
@@ -347,12 +382,10 @@ export function ProjectsPage() {
? projects.filter((p) => p.name.toLowerCase().includes(trimmed))
: projects.slice();
filtered.sort((a, b) =>
- sortMode === "name"
- ? a.name.localeCompare(b.name)
- : b.updatedAt - a.updatedAt,
+ sortDir === "asc" ? a.updatedAt - b.updatedAt : b.updatedAt - a.updatedAt,
);
return filtered;
- }, [projects, query, sortMode]);
+ }, [projects, query, sortDir]);
// Default view shows as many rows as fit the page, then loads more as the user scrolls near the
// bottom. Search always spans every project.
const isSearching = query.trim() !== "";
@@ -451,23 +484,6 @@ export function ProjectsPage() {
navigate({ to: "/chat", search: { project: projectId } });
}
- async function commitRename() {
- const target = renaming;
- const name = renameDraft.trim();
- if (!target || !name || name === target.name) {
- setRenaming(null);
- return;
- }
- setRenaming(null);
- try {
- await renameChatProject(target.id, name);
- } catch (err) {
- toast.error("Failed to rename project", {
- description: err instanceof Error ? err.message : undefined,
- });
- }
- }
-
async function handleProjectExport(project: ProjectRecord, fmt: ConvExportFormat) {
try {
const threads = await listStoredChatThreads({ projectId: project.id, includeArchived: false });
@@ -514,12 +530,114 @@ export function ProjectsPage() {
}
}
+ // Chat row actions, the same calls the sidebar's chat menu makes.
+ async function commitChatRename() {
+ const target = renamingChat;
+ const name = chatNameDraft.trim();
+ setRenamingChat(null);
+ if (!target || !name || name === target.title) return;
+ try {
+ await renameChatItem(target, name);
+ notifyChatHistoryUpdated();
+ } catch (err) {
+ toast.error("Failed to rename chat", {
+ description: err instanceof Error ? err.message : undefined,
+ });
+ }
+ }
+
+ // The open chat is the runtime's, not this page's, so its id comes from there.
+ function activeThreadId(): string | undefined {
+ return useChatRuntimeStore.getState().activeThreadId ?? undefined;
+ }
+
+ async function archiveChat(chat: SidebarItem) {
+ try {
+ await archiveChatItem(chat, activeThreadId(), () => {});
+ } catch (err) {
+ toast.error("Failed to archive chat", {
+ description: err instanceof Error ? err.message : undefined,
+ });
+ }
+ }
+
+ async function deleteChat(chat: SidebarItem, deleteFiles: boolean) {
+ try {
+ await deleteChatItem(chat, activeThreadId(), () => {}, { deleteFiles });
+ // Pins are stored apart from the chats, so a deleted one leaves its id behind forever.
+ unpinChat(chat.id);
+ } catch (err) {
+ toast.error("Failed to delete chat", {
+ description: err instanceof Error ? err.message : undefined,
+ });
+ }
+ }
+
+ /** Always through here, as the sidebar does it: a switch left over from the last delete would
+ * take files this one was never asked to. A chat follows the preference, so the dialog shows
+ * what is about to happen; a project workspace is bigger, so it asks from scratch. */
+ function openChatDelete(chat: SidebarItem) {
+ setDeleteFilesOnDelete(alwaysDeleteChatFiles);
+ setDeletingChat(chat);
+ }
+
+ function openProjectDelete(project: ProjectRecord) {
+ setDeleteFilesOnDelete(false);
+ setDeleting(project);
+ }
+
+ async function commitChatDelete() {
+ const target = deletingChat;
+ if (!target) return;
+ const deleteFiles = deleteFilesOnDelete;
+ setDeletingChat(null);
+ setDeleteFilesOnDelete(false);
+ await deleteChat(target, deleteFiles);
+ }
+
+ /** The folder this chat's tool calls wrote to, or a refusal when it wrote to two. */
+ async function openChatFolder(chat: SidebarItem, fallback: string) {
+ try {
+ const ids = getSidebarItemThreadIds(chat);
+ const distinct = await sandboxSessionIdsHolding(ids);
+ if (distinct.length > 1) {
+ toast.error("This chat wrote to more than one folder.", {
+ description:
+ "It ran tools on both sides of a move, so open the folder from a tool card instead.",
+ });
+ return;
+ }
+ await revealSandbox(distinct[0] ?? fallback);
+ } catch (error) {
+ toast.error("Could not open the chat folder.", {
+ description: error instanceof Error ? error.message : String(error),
+ });
+ }
+ }
+
+ async function handleChatExport(
+ chat: SidebarItem,
+ format: ConversationExportFormat,
+ ) {
+ try {
+ for (const id of getSidebarItemThreadIds(chat)) {
+ await exportConversationByFormat(id, format);
+ }
+ } catch (error) {
+ if (!isDownloadCancelled(error)) {
+ toast.error("Export failed.");
+ }
+ }
+ }
+
async function commitDelete() {
const target = deleting;
if (!target) return;
+ const deleteFiles = deleteFilesOnDelete;
setDeleting(null);
+ setDeleteFilesOnDelete(false);
try {
- await deleteChatProject(target.id);
+ await deleteChatProject(target.id, { deleteFiles });
} catch (err) {
toast.error("Failed to delete project", {
description: err instanceof Error ? err.message : undefined,
@@ -549,8 +667,11 @@ export function ProjectsPage() {
<h1 className="text-ui-30 font-semibold leading-[1.04] tracking-[-0.028em] text-foreground sm:text-ui-34">
Projects
</h1>
- <div className="flex items-center gap-3">
- <div className="relative">
+ {/* The Updated column orders the list, so search takes the room a sort control had.
+ Below sm the group wraps to its own row: beside the heading the two buttons left the
+ field narrower than its own padding. */}
+ <div className="flex w-full min-w-0 items-center justify-end gap-3 sm:w-auto sm:flex-1">
+ <div className="relative min-w-0 flex-1 sm:max-w-md">
<span className="pointer-events-none absolute left-3.5 top-1/2 -translate-y-1/2 text-muted-foreground">
<HugeiconsIcon icon={Search01Icon} strokeWidth={1.75} className="size-4" />
</span>
@@ -558,25 +679,10 @@ export function ProjectsPage() {
value={query}
onChange={(e) => setQuery(e.target.value)}
placeholder="Search projects"
- className="h-9 w-52 rounded-full border-none bg-muted pl-10 pr-4 shadow-none dark:bg-card sm:w-64"
+ className="h-9 w-full rounded-full border-none bg-muted pl-10 pr-4 shadow-none dark:bg-card"
aria-label="Search projects"
/>
</div>
- <div className="flex items-center gap-2">
- <span className="text-sm text-muted-foreground">Sort by</span>
- <Select
- value={sortMode}
- onValueChange={(v) => setSortMode(v as SortMode)}
- >
- <SelectTrigger className="h-9 w-[130px] rounded-full border-none bg-muted shadow-none dark:bg-card">
- <SelectValue />
- </SelectTrigger>
- <SelectContent>
- <SelectItem value="activity">Activity</SelectItem>
- <SelectItem value="name">Name</SelectItem>
- </SelectContent>
- </Select>
- </div>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
@@ -657,9 +763,11 @@ export function ProjectsPage() {
{!hasLoaded ? (
<div className="mt-16">
+ {/* The loaded header without its sort control, which has nothing to sort yet. */}
<div className="mb-1 flex items-center gap-3 px-5 pb-1 text-ui-13 font-medium text-muted-foreground">
<span className="flex-1">Name</span>
- <span className="w-40 shrink-0">Modified</span>
+ <span className="shrink-0 sm:w-40">Updated</span>
+ <span className="size-7 shrink-0" />
<span className="w-8 shrink-0" />
</div>
{Array.from({ length: 6 }).map((_, index) => (
@@ -696,11 +804,31 @@ export function ProjectsPage() {
) : (
<>
<div className="mt-16">
- {/* Column header. Name starts at the folder icon's left edge; the
- right-anchored columns keep Modified over its values. */}
+ {/* Column header. Name starts at the folder icon's left edge, and the trailing
+ spacers stand in for the row's pin and menu so Updated sits over its values.
+ Below sm the values go, since 160px of date left a nested chat row no width for
+ its title and pushed its actions off a phone screen; the control stays, shrunk to
+ its label, as the only way to turn the order around. */}
<div className="mb-1 flex items-center gap-3 px-5 pb-1 text-ui-13 font-medium text-muted-foreground">
<span className="flex-1">Name</span>
- <span className="w-40 shrink-0">Modified</span>
+ {/* The column sorts the list, and the arrow says which way. */}
+ <button
+ type="button"
+ onClick={() => setSortDir((dir) => (dir === "desc" ? "asc" : "desc"))}
+ title={sortDir === "desc" ? "Newest first" : "Oldest first"}
+ className="flex shrink-0 cursor-pointer items-center gap-1 text-left transition-colors hover:text-foreground sm:w-40"
+ >
+ Updated
+ {/* Down for newest first, up for oldest, as a sorted column reads. */}
+ <ArrowDownIcon
+ strokeWidth={1.75}
+ className={cn(
+ "size-3.5 transition-transform",
+ sortDir === "asc" && "rotate-180",
+ )}
+ />
+ </button>
+ <span className="size-7 shrink-0" />
<span className="w-8 shrink-0" />
</div>
<div ref={listRef} data-tour="projects-list">
@@ -727,53 +855,54 @@ export function ProjectsPage() {
/>
<div
key={project.id}
- role="button"
- tabIndex={0}
- onClick={() => openProject(project.id)}
- onKeyDown={(e) => {
- // A key pressed on a control inside the row is that control's.
- if (e.target !== e.currentTarget) return;
- if (e.key === "Enter" || e.key === " ") {
- e.preventDefault();
- openProject(project.id);
- }
- }}
- className="group/project-row relative flex cursor-pointer items-center gap-3 rounded-xl px-5 py-4 text-left transition-colors duration-150 hover:bg-muted/70 dark:hover:bg-white/[0.055] focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ className="group/project-row relative flex items-center gap-3 rounded-xl px-5 py-4 text-left transition-colors duration-150 hover:bg-muted/70 dark:hover:bg-white/[0.055]"
>
- <span className="mr-1 flex size-9 shrink-0 items-center justify-center rounded-[10px] bg-muted text-foreground/70 transition-colors group-hover/project-row:bg-primary/10 group-hover/project-row:text-primary">
- <HugeiconsIcon
- icon={Folder02Icon}
- strokeWidth={1.75}
- className="size-5"
- />
- </span>
- <span className="min-w-0 flex-1 truncate text-ui-15 font-semibold text-foreground">
- {project.name}
- </span>
- {/* Opens the project's chats in place, without leaving the list. */}
- <button
- type="button"
- aria-label={chatsOpen ? "Hide chats" : "Show chats"}
- aria-expanded={chatsOpen}
- onClick={(e) => {
- e.stopPropagation();
- toggleProjectChats(project.id);
- }}
- className={cn(
- "flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-black/5 hover:text-foreground focus-visible:opacity-100 group-hover/project-row:opacity-100 dark:hover:bg-white/10",
- chatsOpen ? "opacity-100" : "opacity-0",
- )}
- >
- <ChevronDownIcon
- strokeWidth={1.75}
+ {/* The disclosure belongs to the name, so it sits beside it rather than out by
+ the Updated column, where it read as another row action. */}
+ <span className="flex min-w-0 flex-1 items-center gap-2">
+ {/* A real button holding only text. Giving the whole row the button role made
+ its pin and menu presentational children: one control where there are four. */}
+ <button
+ type="button"
+ onClick={() => openProject(project.id)}
+ className="flex min-w-0 cursor-pointer items-center gap-3 rounded-lg text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ >
+ <span className="mr-1 flex size-9 shrink-0 items-center justify-center rounded-[10px] bg-muted text-foreground/70 transition-colors group-hover/project-row:bg-primary/10 group-hover/project-row:text-primary">
+ <HugeiconsIcon
+ icon={Folder02Icon}
+ strokeWidth={1.75}
+ className="size-5"
+ />
+ </span>
+ <span className="min-w-0 truncate text-ui-15 font-semibold text-foreground">
+ {project.name}
+ </span>
+ </button>
+ {/* Opens the project's chats in place, without leaving the list. */}
+ <button
+ type="button"
+ aria-label={chatsOpen ? "Hide chats" : "Show chats"}
+ aria-expanded={chatsOpen}
+ onClick={(e) => {
+ e.stopPropagation();
+ toggleProjectChats(project.id);
+ }}
className={cn(
- "size-4 transition-transform",
- !chatsOpen && "-rotate-90",
+ "flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-black/5 hover:text-foreground focus-visible:opacity-100 group-hover/project-row:opacity-100 pointer-coarse:opacity-100 dark:hover:bg-white/10",
+ chatsOpen ? "opacity-100" : "opacity-0",
)}
- />
- </button>
- <span className="w-40 shrink-0 text-sm text-muted-foreground">
- {formatModified(project.updatedAt)}
+ >
+ <ChevronDownIcon
+ strokeWidth={1.75}
+ className={cn(
+ "size-4 transition-transform",
+ !chatsOpen && "-rotate-90",
+ )}
+ />
+ </button>
+ </span>
+ <span className="hidden w-40 shrink-0 text-sm text-muted-foreground sm:block">
+ {formatUpdated(project.updatedAt)}
</span>
{/* Pinning is one click here, as it is on a sidebar row. */}
<button
@@ -783,10 +912,8 @@ export function ProjectsPage() {
e.stopPropagation();
togglePinProject(project.id);
}}
- className={cn(
- "flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-black/5 hover:text-foreground focus-visible:opacity-100 group-hover/project-row:opacity-100 dark:hover:bg-white/10",
- pinned ? "opacity-100" : "opacity-0",
- )}
+ // On show for every row, hover or not, so pinning is never hidden.
+ className="flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-black/5 hover:text-foreground dark:hover:bg-white/10"
>
<HugeiconsIcon
icon={pinned ? PinOffIcon : PinIcon}
@@ -795,16 +922,14 @@ export function ProjectsPage() {
/>
</button>
<div className="relative flex w-8 shrink-0 items-center justify-end">
- {/* Pin fades out and the kebab fades in on hover, focus, or
- menu open. Absolute + opacity gating keeps them from
- overlapping while leaving the button keyboard-focusable. */}
+ {/* On show beside the pin, so the row's actions read the same at rest. */}
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button
type="button"
onClick={(e) => e.stopPropagation()}
aria-label="Project options"
- className="absolute right-0 flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground opacity-0 transition hover:bg-black/5 hover:text-foreground focus-visible:opacity-100 group-hover/project-row:opacity-100 data-[state=open]:bg-black/5 data-[state=open]:opacity-100 dark:hover:bg-white/10 dark:data-[state=open]:bg-white/10"
+ className="absolute right-0 flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-black/5 hover:text-foreground data-[state=open]:bg-black/5 dark:hover:bg-white/10 dark:data-[state=open]:bg-white/10"
>
<MoreHorizontalIcon strokeWidth={1.75} className="size-icon" />
</button>
@@ -817,24 +942,11 @@ export function ProjectsPage() {
onKeyDown={(e) => e.stopPropagation()}
className="app-user-menu menu-soft-surface menu-flat-destructive ring-0 w-44 py-2 font-heading rounded-[14px] border-0"
>
- <DropdownMenuItem
- onSelect={() => togglePinProject(project.id)}
- >
- <HugeiconsIcon
- icon={pinned ? PinOffIcon : PinIcon}
- strokeWidth={1.75}
- className="size-icon"
- />
- <span>{pinned ? "Unpin" : "Pin"}</span>
- </DropdownMenuItem>
- <DropdownMenuItem
- onSelect={() => {
- setRenameDraft(project.name);
- setRenaming(project);
- }}
- >
+ {/* No pin item: the row's own button does it. Edit opens the sidebar's
+ dialog, which owns the name, instructions and source folders. */}
+ <DropdownMenuItem onSelect={() => setEditing(project)}>
<HugeiconsIcon icon={Edit03Icon} strokeWidth={1.75} className="size-icon" />
- <span>Rename</span>
+ <span>Edit</span>
</DropdownMenuItem>
<DropdownMenuItem
onSelect={(e) => {
@@ -867,7 +979,7 @@ export function ProjectsPage() {
<DropdownMenuSeparator />
<DropdownMenuItem
variant="destructive"
- onSelect={() => setDeleting(project)}
+ onSelect={() => openProjectDelete(project)}
>
<HugeiconsIcon icon={Delete02Icon} strokeWidth={1.75} className="size-icon" />
<span>Delete</span>
@@ -877,7 +989,7 @@ export function ProjectsPage() {
</div>
</div>
{chatsOpen && (
- <div className="mb-2 flex flex-col gap-0.5 pl-[76px] pr-5">
+ <div className="mb-2 flex flex-col gap-0.5 pl-[76px]">
{chats === undefined || chats === "loading" ? (
<Skeleton className="h-6 w-48 rounded-[8px]" />
) : chats === "error" ? (
@@ -892,21 +1004,173 @@ export function ProjectsPage() {
<p className="py-1 text-sm text-muted-foreground">No chats</p>
) : (
<>
- {chats.map((chat) => (
- <button
+ {chats.map((chat) => {
+ const chatPinned = pinnedChatIdSet.has(chat.id);
+ const chatThreadIds = getSidebarItemThreadIds(chat);
+ const chatUnread = chatThreadIds.some((id) =>
+ unreadThreadIds.has(id),
+ );
+ // Every chat here sits in a project, so the folder is the project's.
+ const chatSandboxId = sandboxSessionIdFor(
+ chatThreadIds[0] ?? chat.id,
+ project.id,
+ );
+ return (
+ <div
key={chat.id}
- type="button"
- onClick={() => openChat(chat, project.id)}
- className="flex cursor-pointer items-center gap-2 truncate rounded-lg px-2 py-1.5 text-left text-sm text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground dark:hover:bg-white/[0.055]"
+ className="group/chat-row flex items-center gap-3 rounded-xl py-1.5 pl-2 pr-5 text-left text-sm text-muted-foreground transition-colors hover:bg-muted/70 hover:text-foreground dark:hover:bg-white/[0.055]"
>
- <HugeiconsIcon
- icon={MessageCircleIcon}
- strokeWidth={1.75}
- className="size-4 shrink-0"
- />
- <span className="truncate">{chat.title}</span>
- </button>
- ))}
+ {/* A real button holding only text. Giving the whole row the button role
+ made its pin and menu presentational children. */}
+ <button
+ type="button"
+ onClick={() => openChat(chat, project.id)}
+ className="flex min-w-0 flex-1 cursor-pointer items-center gap-3 rounded-lg text-left focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
+ >
+ <HugeiconsIcon
+ icon={MessageCircleIcon}
+ strokeWidth={1.75}
+ className="size-4 shrink-0"
+ />
+ <span className="min-w-0 flex-1 truncate">{chat.title}</span>
+ {/* Same widths as a project row, so the columns line up under it, and
+ gone with it below sm, where a nested row has no room for both. */}
+ <span className="hidden w-40 shrink-0 sm:block">
+ {formatUpdated(chat.updatedAt)}
+ </span>
+ </button>
+ {/* A chat's actions belong to the row the cursor is on, so they stay
+ hover-revealed, and show outright without a cursor to hover with. */}
+ <button
+ type="button"
+ aria-label={chatPinned ? "Unpin chat" : "Pin chat"}
+ onClick={(e) => {
+ e.stopPropagation();
+ togglePinChat(chat.id);
+ }}
+ className={cn(
+ "flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground transition hover:bg-black/5 hover:text-foreground focus-visible:opacity-100 group-hover/chat-row:opacity-100 pointer-coarse:opacity-100 dark:hover:bg-white/10",
+ chatPinned ? "opacity-100" : "opacity-0",
+ )}
+ >
+ <HugeiconsIcon
+ icon={chatPinned ? PinOffIcon : PinIcon}
+ strokeWidth={1.75}
+ className="size-4"
+ />
+ </button>
+ <div className="relative flex w-8 shrink-0 items-center justify-end">
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ onClick={(e) => e.stopPropagation()}
+ aria-label="Chat options"
+ className="absolute right-0 flex size-7 shrink-0 items-center justify-center rounded-full text-muted-foreground opacity-0 transition hover:bg-black/5 hover:text-foreground focus-visible:opacity-100 group-hover/chat-row:opacity-100 pointer-coarse:opacity-100 data-[state=open]:bg-black/5 data-[state=open]:opacity-100 dark:hover:bg-white/10 dark:data-[state=open]:bg-white/10"
+ >
+ <MoreHorizontalIcon strokeWidth={1.75} className="size-icon" />
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent
+ side="bottom"
+ align="end"
+ sideOffset={0}
+ onClick={(e) => e.stopPropagation()}
+ onKeyDown={(e) => e.stopPropagation()}
+ className="app-user-menu menu-soft-surface menu-flat-destructive ring-0 w-52 py-2 font-heading rounded-[14px] border-0"
+ >
+ <DropdownMenuItem
+ onSelect={() => {
+ setChatNameDraft(chat.title);
+ setRenamingChat(chat);
+ }}
+ >
+ <HugeiconsIcon icon={Edit03Icon} strokeWidth={1.75} className="size-icon" />
+ <span>Rename</span>
+ </DropdownMenuItem>
+ {/* The dot a finished reply leaves, put back or taken off by hand. */}
+ <DropdownMenuItem
+ onSelect={() =>
+ chatUnread
+ ? clearThreadsUnread(chatThreadIds)
+ : markThreadsUnread(
+ chatThreadIds,
+ Object.fromEntries(
+ chatThreadIds.map((id) => [id, chat.id]),
+ ),
+ )
+ }
+ >
+ <HugeiconsIcon icon={chatUnread ? ViewIcon : ViewOffSlashIcon} strokeWidth={1.75} className="size-icon" />
+ <span>{chatUnread ? "Mark as read" : "Mark as unread"}</span>
+ </DropdownMenuItem>
+ {chatSandboxId ? (
+ isTauri ? (
+ <DropdownMenuItem
+ title="Open the folder this chat's tool calls read and write"
+ onSelect={() =>
+ void openChatFolder(chat, chatSandboxId)
+ }
+ >
+ <HugeiconsIcon icon={FolderOpenIcon} strokeWidth={1.75} className="size-icon" />
+ <span>Open chat folder</span>
+ </DropdownMenuItem>
+ ) : (
+ <OpenChatFolderUnavailableItem />
+ )
+ ) : null}
+ <DropdownMenuSub>
+ <DropdownMenuSubTrigger>
+ <HugeiconsIcon icon={Download01Icon} strokeWidth={1.75} className="size-icon mr-1" />
+ <span>Export</span>
+ </DropdownMenuSubTrigger>
+ <DropdownMenuSubContent className="w-52">
+ {chatExportOptions().map(({ label, format }) => (
+ <DropdownMenuItem
+ key={`${chat.id}-${label}`}
+ onSelect={(e) => {
+ e.stopPropagation();
+ void handleChatExport(chat, format);
+ }}
+ >
+ {label}
+ </DropdownMenuItem>
+ ))}
+ <DropdownMenuSeparator />
+ {/* Bulk export and import live in Settings -> Data. */}
+ <DropdownMenuItem
+ onSelect={() =>
+ useSettingsDialogStore
+ .getState()
+ .openDialog("data")
+ }
+ >
+ Export all chats…
+ </DropdownMenuItem>
+ </DropdownMenuSubContent>
+ </DropdownMenuSub>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onSelect={() => void archiveChat(chat)}>
+ <HugeiconsIcon icon={Archive03Icon} strokeWidth={1.75} className="size-icon" />
+ <span>Archive</span>
+ </DropdownMenuItem>
+ <DropdownMenuItem
+ variant="destructive"
+ onSelect={() =>
+ confirmDeleteChats
+ ? openChatDelete(chat)
+ : void deleteChat(chat, alwaysDeleteChatFiles)
+ }
+ >
+ <HugeiconsIcon icon={Delete02Icon} strokeWidth={1.75} className="size-icon" />
+ <span>Delete</span>
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ </div>
+ </div>
+ );
+ })}
{staleProjectIds.has(project.id) && (
<button
type="button"
@@ -933,40 +1197,53 @@ export function ProjectsPage() {
{/* Create project (name + drag-and-drop sources) */}
<NewProjectDialog open={creating} onOpenChange={setCreating} />
- {/* Rename project */}
+ {/* Edit project (name + instructions + source folders), the sidebar's dialog. */}
+ <EditProjectDialog
+ project={editing}
+ onOpenChange={(open) => {
+ if (!open) setEditing(null);
+ }}
+ // Delete keeps this page's own confirmation.
+ onDelete={(project) => openProjectDelete(project)}
+ />
+
+ {/* Rename chat */}
<Dialog
- open={renaming !== null}
+ open={renamingChat !== null}
onOpenChange={(open) => {
- if (!open) setRenaming(null);
+ if (!open) setRenamingChat(null);
}}
>
<DialogContent className="corner-squircle dialog-soft-surface sm:max-w-md">
<DialogHeader>
- <DialogTitle>Rename project</DialogTitle>
+ <DialogTitle>Rename chat</DialogTitle>
</DialogHeader>
<Input
- value={renameDraft}
- onChange={(e) => setRenameDraft(e.target.value)}
+ value={chatNameDraft}
+ onChange={(e) => setChatNameDraft(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") {
e.preventDefault();
- void commitRename();
+ void commitChatRename();
}
}}
autoFocus
- maxLength={120}
- placeholder="Project name"
- aria-label="Project name"
+ maxLength={200}
+ placeholder="Chat name"
+ aria-label="Chat name"
className="focus-visible:border-input focus-visible:ring-0"
/>
<DialogFooter className="flex-wrap gap-2 sm:justify-end">
- <Button type="button" variant="ghost" onClick={() => setRenaming(null)}>
+ <Button type="button" variant="ghost" onClick={() => setRenamingChat(null)}>
Cancel
</Button>
<Button
type="button"
- onClick={() => void commitRename()}
- disabled={!renameDraft.trim() || renameDraft.trim() === renaming?.name}
+ onClick={() => void commitChatRename()}
+ disabled={
+ !chatNameDraft.trim() ||
+ chatNameDraft.trim() === renamingChat?.title
+ }
>
Save
</Button>
@@ -974,6 +1251,42 @@ export function ProjectsPage() {
</DialogContent>
</Dialog>
+ {/* Delete chat */}
+ <Dialog
+ open={deletingChat !== null}
+ onOpenChange={(open) => {
+ if (!open) setDeletingChat(null);
+ }}
+ >
+ <DialogContent className="menu-flat-destructive corner-squircle dialog-soft-surface sm:max-w-md">
+ <DialogHeader>
+ <DialogTitle>Delete chat</DialogTitle>
+ </DialogHeader>
+ <p className="text-sm text-muted-foreground">
+ Are you sure you want to delete <em>{deletingChat?.title}</em>? Its messages
+ will be permanently deleted.
+ </p>
+ {/* The files are a second thing to lose, so the delete says so and can be told not to. */}
+ <DeleteChatFilesSwitch
+ id="projects-delete-chat-files"
+ checked={deleteFilesOnDelete}
+ onCheckedChange={setDeleteFilesOnDelete}
+ />
+ <DialogFooter className="flex-wrap gap-2 sm:justify-end">
+ <Button type="button" variant="ghost" onClick={() => setDeletingChat(null)}>
+ Cancel
+ </Button>
+ <Button
+ type="button"
+ variant="destructive"
+ onClick={() => void commitChatDelete()}
+ >
+ {deleteFilesOnDelete ? "Delete all" : "Delete"}
+ </Button>
+ </DialogFooter>
+ </DialogContent>
+ </Dialog>
+
{/* Import destination picker */}
<Dialog open={importFile !== null} onOpenChange={(open) => { if (!open) setImportFile(null); }}>
<DialogContent className="corner-squircle dialog-soft-surface sm:max-w-md">
@@ -1028,12 +1341,22 @@ export function ProjectsPage() {
Are you sure you want to delete <em>{deleting?.name}</em>? Its chats will
be permanently deleted.
</p>
+ {/* Same offer the sidebar makes, naming the folder when the record carries one. */}
+ <DeleteChatFilesSwitch
+ id="projects-delete-project-files"
+ checked={deleteFilesOnDelete}
+ onCheckedChange={setDeleteFilesOnDelete}
+ description={
+ deleting?.rootPath ??
+ "The project workspace folder will be removed from disk."
+ }
+ />
<DialogFooter className="flex-wrap gap-2 sm:justify-end">
<Button type="button" variant="ghost" onClick={() => setDeleting(null)}>
Cancel
</Button>
<Button type="button" variant="destructive" onClick={() => void commitDelete()}>
- Delete
+ {deleteFilesOnDelete ? "Delete all" : "Delete"}
</Button>
</DialogFooter>
</DialogContent>
diff --git a/studio/frontend/src/i18n/locales/ar.ts b/studio/frontend/src/i18n/locales/ar.ts
index b2d1894f5b7..7238a01ed44 100644
--- a/studio/frontend/src/i18n/locales/ar.ts
+++ b/studio/frontend/src/i18n/locales/ar.ts
@@ -213,9 +213,6 @@ export const ar = {
priority: "الأولوية",
lastUpdated: "آخر تحديث",
manualOrder: "ترتيب يدوي",
- priorityHint: "النشطة وغير المقروءة أولاً",
- lastUpdatedHint: "الأحدث أولاً",
- manualOrderHint: "اسحب الصفوف لإعادة ترتيبها",
switchedToManual: "الترتيب يدوي الآن: اسحب الصفوف لإعادة ترتيبها",
organizeChats: "تنظيم المحادثات",
organizeProjects: "تنظيم المشاريع",
diff --git a/studio/frontend/src/i18n/locales/de.ts b/studio/frontend/src/i18n/locales/de.ts
index 5bcb1cf97b3..d68d2d04961 100644
--- a/studio/frontend/src/i18n/locales/de.ts
+++ b/studio/frontend/src/i18n/locales/de.ts
@@ -216,9 +216,6 @@ export const de = {
priority: "Priorität",
lastUpdated: "Zuletzt aktualisiert",
manualOrder: "Manuelle Reihenfolge",
- priorityHint: "Aktive und ungelesene zuerst",
- lastUpdatedHint: "Neueste zuerst",
- manualOrderHint: "Zeilen zum Umordnen ziehen",
switchedToManual: "Manuell sortiert: Zeilen zum Umordnen ziehen",
organizeChats: "Chats organisieren",
organizeProjects: "Projekte organisieren",
diff --git a/studio/frontend/src/i18n/locales/en.ts b/studio/frontend/src/i18n/locales/en.ts
index 916e8b9696a..06d5f12b37b 100644
--- a/studio/frontend/src/i18n/locales/en.ts
+++ b/studio/frontend/src/i18n/locales/en.ts
@@ -218,9 +218,6 @@ export const en = {
priority: "Priority",
lastUpdated: "Last updated",
manualOrder: "Manual order",
- priorityHint: "Active and unread first",
- lastUpdatedHint: "Newest first",
- manualOrderHint: "Drag rows to reorder",
switchedToManual: "Sorted manually: drag rows to reorder",
organizeChats: "Organize chats",
organizeProjects: "Organize projects",
diff --git a/studio/frontend/src/i18n/locales/es.ts b/studio/frontend/src/i18n/locales/es.ts
index f175521641b..c6978e4e7f9 100644
--- a/studio/frontend/src/i18n/locales/es.ts
+++ b/studio/frontend/src/i18n/locales/es.ts
@@ -215,9 +215,6 @@ export const es = {
priority: "Prioridad",
lastUpdated: "Última actualización",
manualOrder: "Orden manual",
- priorityHint: "Activos y no leídos primero",
- lastUpdatedHint: "Más recientes primero",
- manualOrderHint: "Arrastra las filas para reordenarlas",
switchedToManual: "Orden manual: arrastra las filas para reordenarlas",
organizeChats: "Organizar chats",
organizeProjects: "Organizar proyectos",
diff --git a/studio/frontend/src/i18n/locales/fr.ts b/studio/frontend/src/i18n/locales/fr.ts
index dc208291d18..fe47b57bfd2 100644
--- a/studio/frontend/src/i18n/locales/fr.ts
+++ b/studio/frontend/src/i18n/locales/fr.ts
@@ -216,9 +216,6 @@ export const fr = {
priority: "Priorité",
lastUpdated: "Dernière mise à jour",
manualOrder: "Ordre manuel",
- priorityHint: "Actifs et non lus en premier",
- lastUpdatedHint: "Les plus récents en premier",
- manualOrderHint: "Faites glisser les lignes pour les réorganiser",
switchedToManual: "Tri manuel : faites glisser les lignes pour les réorganiser",
organizeChats: "Organiser les discussions",
organizeProjects: "Organiser les projets",
diff --git a/studio/frontend/src/i18n/locales/hi.ts b/studio/frontend/src/i18n/locales/hi.ts
index 4576e869962..0114af5f9b5 100644
--- a/studio/frontend/src/i18n/locales/hi.ts
+++ b/studio/frontend/src/i18n/locales/hi.ts
@@ -216,9 +216,6 @@ export const hi = {
priority: "प्राथमिकता",
lastUpdated: "अंतिम अपडेट",
manualOrder: "मैन्युअल क्रम",
- priorityHint: "सक्रिय और अपठित पहले",
- lastUpdatedHint: "सबसे नए पहले",
- manualOrderHint: "पंक्तियाँ खींचकर क्रम बदलें",
switchedToManual: "अब मैन्युअल क्रम: पंक्तियाँ खींचकर क्रम बदलें",
organizeChats: "चैट व्यवस्थित करें",
organizeProjects: "प्रोजेक्ट व्यवस्थित करें",
diff --git a/studio/frontend/src/i18n/locales/it.ts b/studio/frontend/src/i18n/locales/it.ts
index 78b1346b92f..9d6240498a7 100644
--- a/studio/frontend/src/i18n/locales/it.ts
+++ b/studio/frontend/src/i18n/locales/it.ts
@@ -180,9 +180,6 @@ export const it = {
priority: "Priorità",
lastUpdated: "Ultimo aggiornamento",
manualOrder: "Ordine manuale",
- priorityHint: "Prima attive e non lette",
- lastUpdatedHint: "Prima le più recenti",
- manualOrderHint: "Trascina le righe per riordinarle",
switchedToManual: "Ordinamento manuale: trascina le righe per riordinarle",
organizeChats: "Organizza le chat",
organizeProjects: "Organizza i progetti",
diff --git a/studio/frontend/src/i18n/locales/ja.ts b/studio/frontend/src/i18n/locales/ja.ts
index acb45cd3d1b..cd692e190a3 100644
--- a/studio/frontend/src/i18n/locales/ja.ts
+++ b/studio/frontend/src/i18n/locales/ja.ts
@@ -215,9 +215,6 @@ export const ja = {
priority: "優先度",
lastUpdated: "最終更新",
manualOrder: "手動で並べ替え",
- priorityHint: "実行中・未読が先頭",
- lastUpdatedHint: "新しい順",
- manualOrderHint: "行をドラッグして並べ替えます",
switchedToManual: "手動の並び順に切り替えました。行をドラッグして並べ替えます",
organizeChats: "チャットを整理",
organizeProjects: "プロジェクトを整理",
diff --git a/studio/frontend/src/i18n/locales/ko.ts b/studio/frontend/src/i18n/locales/ko.ts
index f96cba318aa..66b7c64397c 100644
--- a/studio/frontend/src/i18n/locales/ko.ts
+++ b/studio/frontend/src/i18n/locales/ko.ts
@@ -213,9 +213,6 @@ export const ko = {
priority: "우선순위",
lastUpdated: "최근 업데이트",
manualOrder: "수동 정렬",
- priorityHint: "진행 중·읽지 않음 우선",
- lastUpdatedHint: "최신순",
- manualOrderHint: "행을 끌어 순서를 바꾸세요",
switchedToManual: "수동 정렬로 전환됨: 행을 끌어 순서를 바꾸세요",
organizeChats: "채팅 정리",
organizeProjects: "프로젝트 정리",
diff --git a/studio/frontend/src/i18n/locales/pt-br.ts b/studio/frontend/src/i18n/locales/pt-br.ts
index 5798ee6caad..459f669593e 100644
--- a/studio/frontend/src/i18n/locales/pt-br.ts
+++ b/studio/frontend/src/i18n/locales/pt-br.ts
@@ -215,9 +215,6 @@ export const ptBR = {
priority: "Prioridade",
lastUpdated: "Última atualização",
manualOrder: "Ordem manual",
- priorityHint: "Ativos e não lidos primeiro",
- lastUpdatedHint: "Mais recentes primeiro",
- manualOrderHint: "Arraste as linhas para reordenar",
switchedToManual: "Ordem manual: arraste as linhas para reordenar",
organizeChats: "Organizar conversas",
organizeProjects: "Organizar projetos",
diff --git a/studio/frontend/src/i18n/locales/ru.ts b/studio/frontend/src/i18n/locales/ru.ts
index df3c5ddd5e4..911147c8e06 100644
--- a/studio/frontend/src/i18n/locales/ru.ts
+++ b/studio/frontend/src/i18n/locales/ru.ts
@@ -215,9 +215,6 @@ export const ru = {
priority: "Приоритету",
lastUpdated: "Последнему обновлению",
manualOrder: "Вручную",
- priorityHint: "Сначала активные и непрочитанные",
- lastUpdatedHint: "Сначала новые",
- manualOrderHint: "Перетащите строки, чтобы изменить порядок",
switchedToManual: "Ручной порядок: перетащите строки, чтобы изменить порядок",
organizeChats: "Настроить чаты",
organizeProjects: "Настроить проекты",
diff --git a/studio/frontend/src/i18n/locales/zh-CN.ts b/studio/frontend/src/i18n/locales/zh-CN.ts
index 3d0cf4cd9f9..5251dd1ec4f 100644
--- a/studio/frontend/src/i18n/locales/zh-CN.ts
+++ b/studio/frontend/src/i18n/locales/zh-CN.ts
@@ -211,9 +211,6 @@ export const zhCN = {
priority: "优先级",
lastUpdated: "最近更新",
manualOrder: "手动排序",
- priorityHint: "进行中和未读优先",
- lastUpdatedHint: "最新优先",
- manualOrderHint: "拖动行即可重新排序",
switchedToManual: "已改为手动排序,拖动行即可重新排序",
organizeChats: "整理对话",
organizeProjects: "整理项目",
diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.ts
index 1b744699ab8..2b3b3078f21 100644
--- a/studio/frontend/tests/keyboard-shortcuts.test.ts
+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts
@@ -1279,6 +1279,7 @@ test("a collapsed sidebar section is not published for the chords", async () =>
APP_SIDEBAR,
/folderChatItems\(projectsOpen, visibleProjectRecords\)/,
);
+ // In one list every project chat is a Recents row, so a folder must not list it again.
assert.match(APP_SIDEBAR, /if \(!chatListsOnScreen \|\| organizeBy !== "project" \|\| !open\)/);
// And the published lists are the filtered ones.
assert.match(APP_SIDEBAR, /pinnedItems: pinnedSectionChatItems,/);
@@ -1682,7 +1683,7 @@ test("a selection does not outlive the rows it was made on", async () => {
// closing, which for a pinned folder is Pinned, not Projects.
assert.match(
APP_SIDEBAR,
- /const renderedProjectIds = useMemo\(\(\) => \{\n\s*if \(!chatListsOnScreen \|\| organizeBy !== "project"\) \{\n\s*return new Set<string>\(\);\n\s*\}/,
+ /const renderedProjectIds = useMemo\(\(\) => \{\n\s*if \(!chatListsOnScreen\) return new Set<string>\(\);/,
);
assert.match(
APP_SIDEBAR,
@@ -1690,7 +1691,7 @@ test("a selection does not outlive the rows it was made on", async () => {
);
assert.match(
APP_SIDEBAR,
- /if \(projectsOpen\) \{\n\s*for \(const project of visibleProjectRecords\) ids\.add\(project\.id\);/,
+ /if \(projectsOpen && projectsSectionConfigured\) \{\n\s*for \(const project of visibleProjectRecords\) ids\.add\(project\.id\);/,
);
// Both counts feed the flag, which is why both have to be pruned.
assert.match(
diff --git a/studio/frontend/tests/project-switcher-recent-limit.test.ts b/studio/frontend/tests/project-switcher-recent-limit.test.ts
new file mode 100644
index 00000000000..d55d1b7046b
--- /dev/null
+++ b/studio/frontend/tests/project-switcher-recent-limit.test.ts
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: AGPL-3.0-only
+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
+
+// The header's project switcher listed every project, so an account with thirty of them got a
+// thirty-row menu with "View all projects" at the bottom of a scroll.
+
+import assert from "node:assert/strict";
+import test from "node:test";
+import { readSrcAsync } from "./helpers/kit.ts";
+
+const SWITCHER = await readSrcAsync("features/chat/components/project-switcher.tsx");
+
+test("the switcher lists the six most recent projects, not all of them", () => {
+ assert.match(SWITCHER, /const RECENT_PROJECT_LIMIT = 6;/);
+ assert.match(SWITCHER, /const recent = projects\.slice\(0, RECENT_PROJECT_LIMIT\);/);
+ // The menu draws the capped list, not the prop.
+ assert.match(SWITCHER, /\{recentProjects\.map\(\(project\) => \{/);
+ assert.ok(
+ !SWITCHER.includes("{projects.map("),
+ "the menu still draws every project",
+ );
+ // The rest are one click away, so the cap hides nothing.
+ assert.match(SWITCHER, /onSelect=\{onViewAllProjects\}/);
+ assert.match(SWITCHER, /View all projects/);
+});
+
+// A project's own updatedAt only moves when it is edited, so the project being looked at is
+// often not one of the six newest. Cutting it left the switcher showing no tick at all.
+test("the open project keeps its row, without pushing the count past six", () => {
+ assert.match(
+ SWITCHER,
+ /if \(!currentProject \|\| recent\.some\(\(p\) => p\.id === currentProject\.id\)\) \{\n\s*return recent;\n\s*\}/,
+ );
+ // Swapped for the oldest of the six, so the list is still six rows.
+ assert.match(
+ SWITCHER,
+ /return \[\.\.\.recent\.slice\(0, RECENT_PROJECT_LIMIT - 1\), currentProject\];/,
+ );
+ // Recomputed when either side changes, or a switch would keep the last project's rows.
+ assert.match(SWITCHER, /\}, \[projects, currentProject\]\);/);
+});
+
+// The loading and empty rows answer for the whole account, not for the slice: a capped list is
+// never empty while projects exist, and would have said "No projects yet" over six of them.
+test("the loading and empty rows still read the full list", () => {
+ assert.match(SWITCHER, /const showLoadingRow = isLoading && projects\.length === 0;/);
+ assert.match(SWITCHER, /const showEmptyRow = !isLoading && projects\.length === 0;/);
+});
diff --git a/studio/frontend/tests/projects-page-rows.test.ts b/studio/frontend/tests/projects-page-rows.test.ts
index c0068c5a019..fce8daea6fb 100644
--- a/studio/frontend/tests/projects-page-rows.test.ts
+++ b/studio/frontend/tests/projects-page-rows.test.ts
@@ -44,17 +44,129 @@ test("a project row opens its chats in place", () => {
// Each one opens the chat it names; a comparison opens as one.
assert.match(PAGE, /onClick=\{\(\) => openChat\(chat, project\.id\)\}/);
assert.match(PAGE, /search: \{ compare: item\.id, project: projectId \}/);
- // A key on a control inside the row is that control's, not the row's.
- assert.match(PAGE, /if \(e\.target !== e\.currentTarget\) return;\n\s*if \(e\.key === "Enter" \|\| e\.key === " "\)/);
+ // Opening is a real button holding only text, so Enter and Space come with it and the row's
+ // own pin and menu stay separate controls rather than its contents.
+ assert.match(
+ PAGE,
+ /<button\n\s*type="button"\n\s*onClick=\{\(\) => openChat\(chat, project\.id\)\}/,
+ );
+});
+
+// Out by the Modified column the arrow read as another row action, and said nothing about which
+// name it belonged to.
+test("the disclosure sits with the name it opens", () => {
+ const name = PAGE.indexOf("{project.name}");
+ const chevron = PAGE.indexOf("<ChevronDownIcon", name);
+ assert.notEqual(name, -1, "the name moved");
+ assert.notEqual(chevron, -1, "the disclosure moved");
+ // The two share a group that takes the row's free width, so the arrow follows the name's end
+ // rather than the column's.
+ assert.match(
+ PAGE,
+ /<span className="flex min-w-0 flex-1 items-center gap-2">[\s\S]{0,1200}?<span className="min-w-0 truncate text-ui-15 font-semibold text-foreground">\n\s*\{project\.name\}/,
+ );
+ // Opening the project is a button inside that group, so the arrow still follows the name
+ // and the row's own controls stay outside it.
+ assert.match(
+ PAGE,
+ /<button\n\s*type="button"\n\s*onClick=\{\(\) => openProject\(project\.id\)\}/,
+ );
+ assert.ok(
+ PAGE.indexOf(
+ 'className="hidden w-40 shrink-0 text-sm text-muted-foreground sm:block"',
+ ) > chevron,
+ "the arrow is still drawn after the Updated column",
+ );
+});
+
+// One project, two lists: the page edits it through the dialog the sidebar opens.
+test("the row menu edits a project rather than only renaming it", () => {
+ assert.match(PAGE, /import \{ EditProjectDialog \} from "\.\/components\/edit-project-dialog";/);
+ assert.match(PAGE, /onSelect=\{\(\) => setEditing\(project\)\}/);
+ assert.match(PAGE, /<span>Edit<\/span>/);
+ assert.match(PAGE, /<EditProjectDialog\n\s*project=\{editing\}/);
+ // Delete still routes to this page's own confirmation.
+ assert.match(PAGE, /onDelete=\{\(project\) => openProjectDelete\(project\)\}/);
+ // And the rename-only dialog it replaces is gone, with the call it wrote through.
+ assert.ok(!PAGE.includes("Rename project"));
+ assert.ok(!PAGE.includes("renameChatProject"));
});
test("pinning a project takes one click, and says which way it goes", () => {
assert.match(PAGE, /aria-label=\{pinned \? "Unpin project" : "Pin project"\}/);
assert.match(PAGE, /togglePinProject\(project\.id\);/);
- // A pinned row keeps its pin showing; the rest reveal on hover.
- assert.match(PAGE, /pinned \? "opacity-100" : "opacity-0",/);
- // And the menu no longer repeats the noun the row already is.
- assert.match(PAGE, /<span>\{pinned \? "Unpin" : "Pin"\}<\/span>/);
+ // And the menu does not repeat the button beside it.
+ assert.ok(
+ !PAGE.includes('{pinned ? "Unpin" : "Pin"}'),
+ "the row menu still carries a pin item",
+ );
+ assert.equal(
+ (PAGE.match(/togglePinProject\(project\.id\)/g) ?? []).length,
+ 1,
+ "pinning has more than one control on a row",
+ );
+});
+
+// Hover-revealed actions are invisible on a touch screen, and a row whose pin and menu only
+// appear under the cursor hides what it can do.
+test("the pin and the menu are on show, the disclosure follows the cursor", () => {
+ const start = PAGE.indexOf("{visibleProjects.map((project) => {");
+ assert.notEqual(start, -1, "the row list moved");
+ // Down to the row menu's contents, so only the row's own controls are counted.
+ const row = PAGE.slice(start, PAGE.indexOf("<DropdownMenuContent", start));
+ assert.ok(row.length > 0, "the row moved");
+ // Neither the pin nor the menu is faded out any more.
+ assert.ok(!row.includes("opacity-0 transition"), "the menu is still hover-revealed");
+ assert.ok(
+ !row.includes('pinned ? "opacity-100" : "opacity-0"'),
+ "the pin is still hover-revealed",
+ );
+ // The disclosure still follows the cursor, and shows outright without one.
+ assert.equal(
+ (row.match(/pointer-coarse:opacity-100/g) ?? []).length,
+ 1,
+ "the disclosure is not the only control left gated on hover",
+ );
+ assert.match(row, /group-hover\/project-row:opacity-100 pointer-coarse:opacity-100/);
+ assert.match(row, /chatsOpen \? "opacity-100" : "opacity-0",/);
+});
+
+// "Modified" named something the row does not track, and the header sat past its own values,
+// over the pin and the menu.
+test("the Updated column names the list's order and turns it around", () => {
+ assert.ok(!PAGE.includes(">Modified<"), "the old column name is still rendered");
+ // An arrow, not a chevron: it points the way the column is sorted.
+ assert.match(PAGE, /\n\s*Updated\n(?:\s*\{\/\*[^\n]*\*\/\}\n)?\s*<ArrowDownIcon/);
+ assert.match(PAGE, /import \{ ArrowDownIcon, ChevronDownIcon, MoreHorizontalIcon \} from "lucide-react";/);
+ // Clicking it turns the order around, and it is the only thing that orders the list.
+ assert.match(
+ PAGE,
+ /onClick=\{\(\) => setSortDir\(\(dir\) => \(dir === "desc" \? "asc" : "desc"\)\)\}/,
+ );
+ assert.match(PAGE, /sortDir === "asc" && "rotate-180",/);
+ assert.match(
+ PAGE,
+ /sortDir === "asc" \? a\.updatedAt - b\.updatedAt : b\.updatedAt - a\.updatedAt,/,
+ );
+ // The Sort by control it replaces is gone, with the mode it carried.
+ assert.ok(!PAGE.includes("Sort by"), "the sort control is still in the header");
+ assert.ok(!PAGE.includes("sortMode"), "the sort mode outlived its control");
+ // Search takes the room it leaves, on a row of its own where there is not enough of it:
+ // beside the heading the two buttons left the field narrower than its own 56px of padding.
+ assert.match(PAGE, /<div className="relative min-w-0 flex-1 sm:max-w-md">/);
+ assert.match(PAGE, /className="h-9 w-full rounded-full border-none bg-muted pl-10/);
+ assert.match(
+ PAGE,
+ /<div className="flex w-full min-w-0 items-center justify-end gap-3 sm:w-auto sm:flex-1">/,
+ );
+ // Newest first to begin with, as a file list opens.
+ assert.match(PAGE, /useState<"desc" \| "asc">\("desc"\)/);
+ // The header's trailing spacers match the row's pin and menu, so the label sits over its
+ // values instead of over them.
+ assert.match(
+ PAGE,
+ /<span className="size-7 shrink-0" \/>\n\s*<span className="w-8 shrink-0" \/>\n\s*<\/div>/,
+ );
});
// "Thought for 216 seconds" is neither what the model did nor a readable duration.
@@ -74,3 +186,169 @@ test("the reasoning header says Worked for", async () => {
assert.match(reasoning, /Worked for \{formatWorkedFor\(duration \?\? 0\)\}/);
assert.ok(!reasoning.includes("Thought for"), "the old label is still rendered");
});
+
+// A chat under an open project could only be opened: everything else meant going to the chat
+// first. ChatGPT puts the row's own actions on the right, under the cursor.
+test("a chat row carries its own actions, revealed by hovering it", async () => {
+ const start = PAGE.indexOf("{chats.map((chat) => {");
+ assert.notEqual(start, -1, "the chat list moved");
+ const row = PAGE.slice(start, PAGE.indexOf("</DropdownMenu>", start));
+ // Its own hover group, so one chat's actions do not answer for its neighbours.
+ assert.match(row, /className="group\/chat-row /);
+ assert.equal(
+ (row.match(/group-hover\/chat-row:opacity-100/g) ?? []).length,
+ 2,
+ "the pin and the menu are not both tied to the row's hover",
+ );
+ assert.match(row, /chatPinned \? "opacity-100" : "opacity-0",/);
+ assert.match(row, /aria-label="Chat options"/);
+ // role="button" on the row made its own pin and menu presentational children, so a screen
+ // reader read one control where there are three. The row is a plain container now.
+ assert.ok(!row.includes('role="button"'), "the row is a button again");
+ assert.ok(!row.includes("tabIndex={0}"), "the row is focusable again");
+ assert.ok(!row.includes("e.currentTarget"), "the row still fakes key handling");
+ assert.match(
+ row,
+ /<button\n\s*type="button"\n\s*onClick=\{\(\) => openChat\(chat, project\.id\)\}\n\s*className="flex min-w-0 flex-1 cursor-pointer items-center gap-3/,
+ );
+ // The same columns as a project row, so the two line up.
+ // Same column as the project row above it, and gone with it on a phone, where 160px of date
+ // left the title no width and pushed the actions past the screen.
+ assert.match(
+ row,
+ /<span className="hidden w-40 shrink-0 sm:block">\n\s*\{formatUpdated\(chat\.updatedAt\)\}/,
+ );
+ assert.ok(
+ PAGE.includes('className="hidden w-40 shrink-0 text-sm text-muted-foreground sm:block"'),
+ "a project row still draws its date below sm",
+ );
+ // The header keeps the control, shrunk to its label: it is the only way to turn the order
+ // around, and hiding it left a phone with no way to sort at all.
+ for (const kept of [
+ '<span className="shrink-0 sm:w-40">Updated</span>',
+ 'className="flex shrink-0 cursor-pointer items-center gap-1 text-left transition-colors hover:text-foreground sm:w-40"',
+ ]) {
+ assert.ok(PAGE.includes(kept), `the sort control does not survive below sm: ${kept}`);
+ }
+ assert.match(row, /<div className="relative flex w-8 shrink-0 items-center justify-end">/);
+});
+
+// The actions are the sidebar's, so a chat behaves the same wherever it is acted on.
+test("the chat menu writes through the shared chat helpers", () => {
+ assert.match(PAGE, /await renameChatItem\(target, name\);\n\s*notifyChatHistoryUpdated\(\);/);
+ assert.match(PAGE, /await archiveChatItem\(chat, activeThreadId\(\), \(\) => \{\}\);/);
+ assert.match(
+ PAGE,
+ /await deleteChatItem\(chat, activeThreadId\(\), \(\) => \{\}, \{ deleteFiles \}\);/,
+ );
+ // Pins live apart from the chats, so a deleted one would leave its id stored for good.
+ assert.match(
+ PAGE,
+ /await deleteChatItem\([\s\S]{0,240}?\n\s*unpinChat\(chat\.id\);/,
+ );
+ assert.match(PAGE, /const unpinChat = usePinnedChatsStore\(\(s\) => s\.unpin\);/);
+ // Deleting asks first only when the setting says so, as in the sidebar, and an unconfirmed
+ // delete is the one that follows the preference on its own.
+ assert.match(
+ PAGE,
+ /confirmDeleteChats\n\s*\? openChatDelete\(chat\)\n\s*: void deleteChat\(chat, alwaysDeleteChatFiles\)/,
+ );
+ assert.match(PAGE, /<DialogTitle>Delete chat<\/DialogTitle>/);
+ assert.match(PAGE, /<DialogTitle>Rename chat<\/DialogTitle>/);
+ // The sidebar's export list, so the same chat offers the same formats either way.
+ assert.match(PAGE, /chatExportOptions\(\)\.map\(\(\{ label, format \}\) => \(/);
+ assert.match(PAGE, /void handleChatExport\(chat, format\);/);
+ assert.match(PAGE, /Export all chats…/);
+});
+
+// Everything the sidebar's chat menu offers, minus what a project's own list already answers:
+// no "Project" submenu, since these chats are in the project being looked at.
+test("the chat menu carries the sidebar's items, without the move", () => {
+ const start = PAGE.indexOf("{chats.map((chat) => {");
+ const menu = PAGE.slice(
+ PAGE.indexOf("<DropdownMenuContent", start),
+ PAGE.indexOf("</DropdownMenuContent>", start),
+ );
+ for (const label of [
+ "<span>Rename</span>",
+ "<span>Archive</span>",
+ "<span>Delete</span>",
+ "<span>Export</span>",
+ "Export all chats…",
+ ]) {
+ assert.ok(menu.includes(label), `${label} is missing from the chat menu`);
+ }
+ assert.match(menu, /chatUnread \? "Mark as read" : "Mark as unread"/);
+ assert.match(menu, /<span>Open chat folder<\/span>/);
+ // Desktop opens the folder; the browser says why it cannot.
+ assert.match(menu, /isTauri \? \(/);
+ assert.match(menu, /<OpenChatFolderUnavailableItem \/>/);
+ // The chats listed here are already in this project.
+ assert.ok(!menu.includes("<span>Project</span>"));
+ assert.ok(!menu.includes("moveChatToProject"));
+});
+
+// "Always delete files" makes a delete destructive past the chat itself, and a project workspace
+// is a folder on disk. Both confirmations have to say so and let this one delete be told not to.
+test("both confirmations offer the files, and neither carries the last one's answer", () => {
+ // One switch state, seeded per delete rather than left standing.
+ assert.match(PAGE, /const \[deleteFilesOnDelete, setDeleteFilesOnDelete\] = useState\(false\);/);
+ assert.match(
+ PAGE,
+ /function openChatDelete\(chat: SidebarItem\) \{\n\s*setDeleteFilesOnDelete\(alwaysDeleteChatFiles\);\n\s*setDeletingChat\(chat\);/,
+ );
+ // A project workspace is bigger than a chat's sandbox, so it asks from scratch, as the sidebar does.
+ assert.match(
+ PAGE,
+ /function openProjectDelete\(project: ProjectRecord\) \{\n\s*setDeleteFilesOnDelete\(false\);\n\s*setDeleting\(project\);/,
+ );
+ // Nothing else opens either dialog: every other call closes it.
+ for (const setter of ["setDeletingChat", "setDeleting"]) {
+ const opens = (PAGE.match(new RegExp(`${setter}\\((?!null\\))`, "g")) ?? []).length;
+ assert.equal(opens, 1, `${setter} is called outside its opener`);
+ }
+ // Each commit reads the switch, then clears it.
+ assert.match(
+ PAGE,
+ /const deleteFiles = deleteFilesOnDelete;\n\s*setDeletingChat\(null\);\n\s*setDeleteFilesOnDelete\(false\);/,
+ );
+ assert.match(
+ PAGE,
+ /const deleteFiles = deleteFilesOnDelete;\n\s*setDeleting\(null\);\n\s*setDeleteFilesOnDelete\(false\);/,
+ );
+ assert.match(PAGE, /await deleteChatProject\(target\.id, \{ deleteFiles \}\);/);
+ // And both dialogs render the switch, the project one naming the folder it would remove.
+ assert.match(PAGE, /id="projects-delete-chat-files"/);
+ assert.match(
+ PAGE,
+ /id="projects-delete-project-files"[\s\S]{0,200}?deleting\?\.rootPath \?\?\n\s*"The project workspace folder will be removed from disk\."/,
+ );
+ assert.equal((PAGE.match(/deleteFilesOnDelete \? "Delete all" : "Delete"/g) ?? []).length, 2);
+});
+
+// `role="button"` puts an element in ARIA's presentational-children set, so a row carrying it
+// swallowed the roles of the pin and the menu inside it: one control where there are three.
+test("a row is a container, and each of its controls is its own button", () => {
+ const list = PAGE.slice(PAGE.indexOf("{visibleProjects.map((project) => {"));
+ assert.ok(!list.includes('role="button"'), "a row still carries the button role");
+ assert.ok(!list.includes("tabIndex={0}"), "a row is still focusable itself");
+ // With no row handler to stop, nothing fakes Enter and Space either.
+ assert.ok(!list.includes("e.currentTarget"), "a row still fakes key handling");
+ // Opening is a real button, and it holds only text: an interactive descendant would put the
+ // problem back.
+ for (const opener of [
+ /<button\n\s*type="button"\n\s*onClick=\{\(\) => openProject\(project\.id\)\}\n\s*className="flex min-w-0 cursor-pointer items-center gap-3/,
+ /<button\n\s*type="button"\n\s*onClick=\{\(\) => openChat\(chat, project\.id\)\}\n\s*className="flex min-w-0 flex-1 cursor-pointer items-center gap-3/,
+ ]) {
+ assert.match(PAGE, opener);
+ }
+ // The row keeps the hover it paints its controls from, and gives up the focus ring to them.
+ assert.match(
+ PAGE,
+ /className="group\/project-row relative flex items-center gap-3 rounded-xl px-5 py-4 text-left transition-colors duration-150 hover:bg-muted\/70 dark:hover:bg-white\/\[0\.055\]"/,
+ );
+ assert.match(
+ PAGE,
+ /className="group\/chat-row flex items-center gap-3 rounded-xl py-1\.5 pl-2 pr-5 text-left text-sm/,
+ );
+});
diff --git a/studio/frontend/tests/sandbox-reveal-path.test.ts b/studio/frontend/tests/sandbox-reveal-path.test.ts
index 4f1b4c70d23..69f8c5665d4 100644
--- a/studio/frontend/tests/sandbox-reveal-path.test.ts
+++ b/studio/frontend/tests/sandbox-reveal-path.test.ts
@@ -103,16 +103,27 @@ const SIDEBAR = readFileSync(
fileURLToPath(new URL("../src/components/app-sidebar.tsx", import.meta.url)),
"utf-8",
);
+// The probe below is shared by every chat row menu, so it lives beside the rest of them.
+const ROW_MENU = readFileSync(
+ fileURLToPath(
+ new URL("../src/features/chat/components/chat-row-menu.ts", import.meta.url),
+ ),
+ "utf-8",
+);
+const PROJECTS_PAGE = readFileSync(
+ fileURLToPath(new URL("../src/features/chat/projects-page.tsx", import.meta.url)),
+ "utf-8",
+);
test("a failed history read is reported, not mistaken for a chat that ran no tools", () => {
// No React renderer here, so this asserts on source, like ~50 sibling tests.
// A per-pane catch makes a failed read look like "never ran a tool", and the
// fallback is project membership, the answer the recorded id overrides.
// Both "Open chat folder" and "Copy session id" read through this helper.
- const start = SIDEBAR.indexOf("async function recordedSandboxSessionIds");
- const end = SIDEBAR.indexOf("\n }", start);
+ const start = ROW_MENU.indexOf("async function recordedSandboxSessionIds");
+ const end = ROW_MENU.indexOf("\n}", start);
assert.ok(start !== -1 && end > start, "the read block moved");
- const block = SIDEBAR.slice(start, end);
+ const block = ROW_MENU.slice(start, end);
assert.ok(
block.includes("allRecordedSandboxSessionIds"),
"the read block moved",
@@ -127,15 +138,16 @@ test("one thread that outlived a move counts as two folders, not one", () => {
// A chat can name two sandboxes on its own: ran a tool, moved between
// projects, ran another. Taking one id per thread would leave the refusal
// blind to that and hand out the newer id as though it were the only one.
- const start = SIDEBAR.indexOf("async function recordedSandboxSessionIds");
- const end = SIDEBAR.indexOf("\n }", start);
- const block = SIDEBAR.slice(start, end);
+ const start = ROW_MENU.indexOf("async function recordedSandboxSessionIds");
+ const end = ROW_MENU.indexOf("\n}", start);
+ const block = ROW_MENU.slice(start, end);
assert.match(
block,
/recorded\.push\(\n\s*\.\.\.allRecordedSandboxSessionIds\(await listStoredChatMessages\(threadId\)\),\n\s*\);/,
);
- // Both actions refuse on more than one, rather than picking a folder.
+ // Every action refuses on more than one, rather than picking a folder.
assert.equal(SIDEBAR.split("distinct.length > 1").length - 1, 2);
+ assert.equal(PROJECTS_PAGE.split("distinct.length > 1").length - 1, 1);
});
test("a sandbox holding files is told apart from one that was never written", async () => {
@@ -180,9 +192,9 @@ test("the legacy probe runs whichever project the chat sits in now", () => {
// there reported one folder while its older files stayed hidden. The thread
// folder is probed whichever project the chat sits in now; the project
// workspace is not, since every chat in the project writes to it.
- const start = SIDEBAR.indexOf("async function sandboxSessionIdsHolding");
+ const start = ROW_MENU.indexOf("async function sandboxSessionIdsHolding");
assert.notEqual(start, -1, "the legacy probe moved");
- const block = SIDEBAR.slice(start, SIDEBAR.indexOf("\n }", start));
+ const block = ROW_MENU.slice(start, ROW_MENU.indexOf("\n}", start));
assert.ok(!block.includes("if (!item.projectId) return recorded;"));
assert.ok(block.includes("sandboxHasFiles(candidate)"));
// Not the project workspace: it is shared by every chat in the project, so
@@ -195,8 +207,8 @@ test("a recorded session does not hide a legacy folder beside it", () => {
// moved into a project, another tool ran and recorded one. Treating the
// recorded id as proof that nothing else holds files answers for one folder
// while the older keeps the rest.
- const start = SIDEBAR.indexOf("async function sandboxSessionIdsHolding");
- const block = SIDEBAR.slice(start, SIDEBAR.indexOf("\n }", start));
+ const start = ROW_MENU.indexOf("async function sandboxSessionIdsHolding");
+ const block = ROW_MENU.slice(start, ROW_MENU.indexOf("\n}", start));
// A union, so a recorded id cannot short-circuit the probe.
assert.match(block, /return \[\.\.\.new Set\(\[\.\.\.recorded, \.\.\.held\]\)\];/);
assert.ok(
@@ -217,6 +229,12 @@ test("both the folder and the session id are answered from the same probe", () =
const at = SIDEBAR.indexOf(action);
assert.notEqual(at, -1, `${action} moved`);
}
+ // The Projects page draws the same action, and reads it from the same probe.
+ assert.equal(
+ (PROJECTS_PAGE.match(/await sandboxSessionIdsHolding\(/g) ?? []).length,
+ 1,
+ );
+ assert.notEqual(PROJECTS_PAGE.indexOf("Open chat folder"), -1);
// Neither may reach past it to the recorded ids alone.
const copyAt = SIDEBAR.indexOf("async function copyChatSessionId");
const copy = SIDEBAR.slice(copyAt, SIDEBAR.indexOf("\n }\n", copyAt));
diff --git a/studio/frontend/tests/shortcut-dispatch-guards.test.ts b/studio/frontend/tests/shortcut-dispatch-guards.test.ts
index 7690c68d198..fcaa659e19f 100644
--- a/studio/frontend/tests/shortcut-dispatch-guards.test.ts
+++ b/studio/frontend/tests/shortcut-dispatch-guards.test.ts
@@ -29,6 +29,8 @@ const { isAcceptableBinding, parseBinding } = await import(
const SRC__ROOT = readSrc("app/routes/__root.tsx");
const APP_SIDEBAR = readSrc("components/app-sidebar.tsx");
+// The chat row menu's shared parts, drawn by the sidebar and by the Projects page.
+const CHAT_ROW_MENU = readSrc("features/chat/components/chat-row-menu.ts");
const THREAD = readSrc("components/assistant-ui/thread.tsx");
const CHAT_PAGE = readSrc("features/chat/chat-page.tsx");
const USE_SHORTCUT = readSrc("features/settings/hooks/use-shortcut.ts");
@@ -150,9 +152,9 @@ test("both copy chords report a failed write", async () => {
// Current membership says nothing about where a chat's older files went: it can
// join a project, record that session, and move back out.
test("the sandbox probe does not skip a chat that is out of a project", async () => {
- const at = APP_SIDEBAR.indexOf("async function sandboxSessionIdsHolding");
+ const at = CHAT_ROW_MENU.indexOf("async function sandboxSessionIdsHolding");
assert.notEqual(at, -1);
- const body = APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n }", at));
+ const body = CHAT_ROW_MENU.slice(at, CHAT_ROW_MENU.indexOf("\n}", at));
assert.doesNotMatch(body, /if \(!item\.projectId\) return recorded;/);
assert.match(
body,
@@ -376,9 +378,9 @@ test("the sidebar's mutating chords refuse to fire under a dialog", async () =>
// thread folder and in the project one. Probing only the thread folder
// answered for one and hid the other.
test("the sandbox probe leaves the shared project folder alone", async () => {
- const at = APP_SIDEBAR.indexOf("async function sandboxSessionIdsHolding(");
+ const at = CHAT_ROW_MENU.indexOf("async function sandboxSessionIdsHolding(");
assert.notEqual(at, -1);
- const body = APP_SIDEBAR.slice(at, APP_SIDEBAR.indexOf("\n }", at));
+ const body = CHAT_ROW_MENU.slice(at, CHAT_ROW_MENU.indexOf("\n}", at));
// The shared project workspace is not probed: every chat in the project
// writes there, so its files are no evidence about this one, and counting
// them reported a second folder for any chat that joined a used project.
diff --git a/studio/frontend/tests/sidebar-row-actions.test.ts b/studio/frontend/tests/sidebar-row-actions.test.ts
index b8cc3093900..bb3736c6283 100644
--- a/studio/frontend/tests/sidebar-row-actions.test.ts
+++ b/studio/frontend/tests/sidebar-row-actions.test.ts
@@ -173,18 +173,20 @@ test("a section's chevron appears on hovering anywhere in it", () => {
});
// "the card that created it" named nothing the user can point at.
-test("the chat-folder hint names what to click instead", () => {
+test("the chat-folder hint names what to click instead", async () => {
+ // The item is shared with the Projects page's chat rows, so the hint lives with it.
+ const item = await readSrcAsync("features/chat/components/open-chat-folder-item.tsx");
assert.ok(
- !APP_SIDEBAR.includes("card that created it"),
+ !item.includes("card that created it"),
"the hint still sends the user to a card it never identifies",
);
assert.ok(
- APP_SIDEBAR.includes("download a file from the tool result that wrote it"),
+ item.includes("download a file from the tool result that wrote it"),
"the hint no longer says where the files can be had",
);
// Carried twice on purpose: the tooltip is for the pointer, the title for everything else.
assert.equal(
- (APP_SIDEBAR.match(/Only the desktop app can open a chat's files folder/g) ??
+ (item.match(/Only the desktop app can open a chat('|&apos;)s files folder/g) ??
[]).length,
2,
"the hint is no longer stated for both the pointer and the screen reader",
diff --git a/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts b/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts
index f130877c8ac..1d4aeb6177c 100644
--- a/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts
+++ b/studio/frontend/tests/sidebar-row-menu-and-pinned-folders.test.ts
@@ -260,3 +260,129 @@ test("the walk reads the rows in the order Pinned draws them", () => {
/pinnedItems: pinnedSectionChatItems,\n\s*projectItems: sectionProjectChatItems,/,
);
});
+
+// Pinning is its own grouping. Organizing in one list used to empty Pinned of its folders, so a
+// project pinned to the top vanished along with the section the setting was actually about.
+test("a pinned folder stays in Pinned when the sidebar is one list", () => {
+ const rows = APP_SIDEBAR.slice(
+ APP_SIDEBAR.indexOf("const pinnedRows = useMemo("),
+ APP_SIDEBAR.indexOf("const pinnedRowIds = useMemo("),
+ );
+ assert.ok(rows.length > 0, "pinnedRows moved");
+ assert.ok(
+ !rows.includes("organizeBy"),
+ "Pinned still drops its folders when the sidebar organizes in one list",
+ );
+ assert.match(
+ rows,
+ /for \(const project of pinnedProjectBase\) \{\n\s*rows\.push\(\{ kind: "project", id: project\.id, project \}\);/,
+ );
+ // Pinned's own folder rows are selectable wherever they are drawn, while the Projects
+ // section's leave with the section.
+ assert.match(
+ APP_SIDEBAR,
+ /if \(pinnedOpen\) \{\n\s*for \(const project of pinnedProjectRecords\) ids\.add\(project\.id\);/,
+ );
+ assert.match(
+ APP_SIDEBAR,
+ /if \(projectsOpen && projectsSectionConfigured\) \{\n\s*for \(const project of visibleProjectRecords\) ids\.add\(project\.id\);/,
+ );
+});
+
+// The three orders were each captioned with what they do. The names say it, and the captions
+// made a four-item radio group twice as tall as every other menu in the sidebar.
+test("the sort options are names, with nothing written under them", () => {
+ const options = APP_SIDEBAR.slice(
+ APP_SIDEBAR.indexOf("const CHAT_SORT_OPTIONS"),
+ APP_SIDEBAR.indexOf("const ORGANIZE_OPTIONS"),
+ );
+ assert.ok(!options.includes("hint"), "the sort options still carry captions");
+ assert.match(APP_SIDEBAR, /\{CHAT_SORT_OPTIONS\.map\(\(option\) => \(/);
+ const menu = APP_SIDEBAR.slice(APP_SIDEBAR.indexOf("{CHAT_SORT_OPTIONS.map("));
+ assert.match(
+ menu.slice(0, menu.indexOf("</DropdownMenuRadioGroup>")),
+ /className=\{menuRadioItemClass\}\n\s*>\n\s*\{t\(option\.key\)\}/,
+ );
+ // And the strings go with them, in every language.
+ for (const key of ["priorityHint", "lastUpdatedHint", "manualOrderHint"]) {
+ assert.ok(!APP_SIDEBAR.includes(key), `${key} is still read`);
+ }
+});
+
+// The project page's own header kebab still opened a name-only dialog, so the same project
+// offered two different "edit" depending on which list it was reached from.
+test("the project page edits through the same dialog the sidebar opens", async () => {
+ const page = await readSrcAsync("features/chat/chat-page.tsx");
+ assert.ok(!page.includes("Rename project"), "the rename-only dialog is still there");
+ assert.ok(!page.includes("commitProjectRename"), "the rename call is still there");
+ assert.match(page, /onSelect=\{\(\) => setEditingProject\(true\)\}/);
+ assert.match(page, /<span>Edit project<\/span>/);
+ // The record behind the header, and the dialog it feeds.
+ assert.match(
+ page,
+ /projects\.find\(\(project\) => project\.id === projectId\)/,
+ );
+ assert.match(
+ page,
+ /project=\{active && editingProject \? \(currentProject \?\? null\) : null\}/,
+ );
+ // Delete hands back to the page's own confirmation, as it does in the sidebar.
+ assert.match(
+ page,
+ /onDelete=\{\(\) => \{\n\s*setEditingProject\(false\);\n\s*openProjectDelete\(\);/,
+ );
+ // And that confirmation says what else it takes: the workspace folder, named where the record
+ // has a path. Without it, deleting from here always left the folder with nothing able to reach it.
+ assert.match(
+ page,
+ /function openProjectDelete\(\): void \{\n\s*setDeleteFilesOnDelete\(false\);\n\s*setDeletingProject\(true\);/,
+ );
+ assert.match(
+ page,
+ /const deleteFiles = deleteFilesOnDelete;\n\s*setDeletingProject\(false\);\n\s*setDeleteFilesOnDelete\(false\);/,
+ );
+ assert.match(page, /await deleteChatProject\(projectId, \{ deleteFiles \}\);/);
+ assert.match(
+ page,
+ /id="chat-landing-delete-project-files"[\s\S]{0,220}?currentProject\?\.rootPath \?\?\n\s*"The project workspace folder will be removed from disk\."/,
+ );
+ assert.match(page, /\{deleteFilesOnDelete \? "Delete all" : "Delete"\}/);
+ // Nothing opens the confirmation without seeding the switch first.
+ assert.equal(
+ (page.match(/setDeletingProject\((?!false\))/g) ?? []).length,
+ 1,
+ "setDeletingProject is called outside its opener",
+ );
+});
+
+// A pinned folder stays in one-list mode, but its chats are already Recents rows there: expanding
+// it would draw each of them twice and publish both copies to the walk and the selection.
+test("a pinned folder in one list is a way in, not a second copy of its chats", () => {
+ assert.match(
+ APP_SIDEBAR,
+ /if \(!chatListsOnScreen \|\| organizeBy !== "project" \|\| !open\) return \[\];/,
+ );
+ assert.match(APP_SIDEBAR, /const listsChats = organizeBy === "project";/);
+ assert.match(
+ APP_SIDEBAR,
+ /const expanded = listsChats && !collapsedProjectIds\.has\(project\.id\);/,
+ );
+ // Nothing to expand into, so the row opens the project instead of toggling into an empty block.
+ assert.match(
+ APP_SIDEBAR,
+ /if \(listsChats\) toggleProjectCollapsed\(project\.id\);\n\s*else openProject\(project\.id\);/,
+ );
+ // Everything a folder draws under itself hangs off that one flag.
+ for (const gated of [
+ /\{expanded &&\n\s*visibleChats\.map\(/,
+ /\{expanded && projectChats\.length === 0 && \(/,
+ /\{expanded &&\n\s*projectChats\.length > PROJECT_CHAT_LIMIT && \(/,
+ ]) {
+ assert.match(APP_SIDEBAR, gated);
+ }
+ // And the row count the scroll fade measures counts nothing where nothing is drawn.
+ assert.match(
+ APP_SIDEBAR,
+ /const projectChatRowCount = useMemo\(\(\) => \{\n[^\n]*\n\s*if \(organizeBy !== "project"\) return 0;/,
+ );
+});