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: list at most the 12 most recently active projects and sections in Move to (#12155)

Michael Han3bf6002c6962
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index cbe20977bce..d14d9acf8e0 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -379,6 +379,8 @@ const MOVE_TO_MENU =
// which doubled the gap at both its ends; -my-0.5 gives that 2px back.
const MOVE_TO_LIST =
"no-scrollbar -my-0.5 max-h-[calc(260px*var(--ui-space-scale,1))] overflow-y-auto overscroll-contain";
+// Most projects, and most sections, a "Move to" lists: the most recent, so a long list stays light.
+const MOVE_TO_MAX = 12;
// Folder rows match their hover pill.
const DROP_INTO_ROW_CUE = `${DROP_CUE_CLASS} before:pointer-events-none before:absolute before:inset-x-0 before:top-0 before:bottom-px before:rounded-full before:bg-primary/8 before:border-[1.5px] before:border-primary before:content-['']`;
// The menu keeps a 1px gap between rows. A pointer resting on that gap would hit the section
@@ -1261,6 +1263,42 @@ export function AppSidebar() {
list.sort((a, b) => b.updatedAt - a.updatedAt);
return map;
}, [allChatItems]);
+ // A project's last activity: its own edits or its newest chat. Its updatedAt only moves when it
+ // is edited.
+ const projectActivityAt = useMemo(() => {
+ const map = new Map<string, number>();
+ for (const project of projects) {
+ const newest = chatsByProjectId.get(project.id)?.[0]?.updatedAt ?? 0;
+ map.set(project.id, Math.max(project.updatedAt ?? project.createdAt, newest));
+ }
+ return map;
+ }, [projects, chatsByProjectId]);
+ // "Move to" order: most recently active first.
+ const recentProjects = useMemo(
+ () =>
+ [...projects].sort(
+ (a, b) => (projectActivityAt.get(b.id) ?? 0) - (projectActivityAt.get(a.id) ?? 0),
+ ),
+ [projects, projectActivityAt],
+ );
+ // Sections by last activity: when made or modified, or their newest chat or project. Drag
+ // order is not recency; older sections without timestamps rank by their members' activity.
+ const recentSections = useMemo(() => {
+ const at = new Map(
+ customSections.map((section) => [
+ section.id,
+ Math.max(section.createdAt ?? 0, section.modifiedAt ?? 0),
+ ]),
+ );
+ const touch = (sectionId: string | undefined, time: number) => {
+ if (sectionId && at.has(sectionId) && time > (at.get(sectionId) ?? 0)) at.set(sectionId, time);
+ };
+ for (const item of allChatItems) touch(sectionByChatId[item.id], item.updatedAt);
+ for (const [projectId, sectionId] of Object.entries(sectionByProjectId)) {
+ touch(sectionId, projectActivityAt.get(projectId) ?? 0);
+ }
+ return [...customSections].sort((a, b) => (at.get(b.id) ?? 0) - (at.get(a.id) ?? 0));
+ }, [customSections, allChatItems, sectionByChatId, sectionByProjectId, projectActivityAt]);
// Pinned folders in pin order, then the order they were dragged into while Pinned kept
// folders apart from its chats. Pinned is one list now; this only seeds it.
const pinnedProjectBase = useMemo(() => {
@@ -1278,16 +1316,9 @@ export function AppSidebar() {
(project) => project.id,
);
}, [projects, pinnedProjectIds, manualOrder]);
- // The folders Projects still owns: unpinned, by activity, then manual order. Activity comes from
- // the member chats, since a project's own updatedAt only moves when it is edited.
+ // The folders Projects still owns: unpinned, by activity (see projectActivityAt), then manual order.
const sidebarProjectRecords = useMemo(() => {
- const lastActivityAt = (project: ProjectRecord) => {
- let latest = project.updatedAt ?? project.createdAt;
- for (const chat of chatsByProjectId.get(project.id) ?? []) {
- if (chat.updatedAt > latest) latest = chat.updatedAt;
- }
- return latest;
- };
+ const lastActivityAt = (project: ProjectRecord) => projectActivityAt.get(project.id) ?? 0;
const rest = projects
.filter((p) => !pinnedProjectIdSet.has(p.id) && !sectionByProjectId[p.id])
.sort((a, b) =>
@@ -1305,7 +1336,7 @@ export function AppSidebar() {
pinnedProjectIdSet,
sectionByProjectId,
manualOrder,
- chatsByProjectId,
+ projectActivityAt,
projectSort,
]);
// Memoised for its identity, not for the slice. It feeds the rendered-row set the selection guard
@@ -4111,7 +4142,9 @@ export function AppSidebar() {
? customSections.find((section) => section.id === config.current)
: undefined;
// The section the rows are in is not a place to move them to, so it is left out, not greyed.
- const destinations = customSections.filter((section) => section.id !== config.current);
+ const destinations = recentSections
+ .filter((section) => section.id !== config.current)
+ .slice(0, MOVE_TO_MAX);
return (
<>
{config.heading && <P.Label>{t("shell.sections.sectionsHeading")}</P.Label>}
@@ -4305,6 +4338,15 @@ export function AppSidebar() {
) {
const threadIds = getSidebarItemThreadIds(item);
const isPinned = pinnedIdSet.has(item.id);
+ const moveProjects = recentProjects
+ .filter((project) => project.id !== item.projectId)
+ .slice(0, MOVE_TO_MAX);
+ // A compare row outside a project spans two sandboxes, and there is no
+ // honest single folder to offer for it.
+ const sandboxSessionId =
+ item.type === "single" || item.projectId
+ ? sandboxSessionIdFor(threadIds[0] ?? item.id, item.projectId)
+ : undefined;
const alreadyUnread = threadIds.some((threadId) =>
unreadThreadIds.has(threadId),
);
@@ -4371,9 +4413,9 @@ export function AppSidebar() {
<span>New project</span>
</P.Item>
{/* The project the chat is in is not a place to move it to: left out, not greyed. */}
- {projects.some((project) => project.id !== item.projectId) && (
+ {moveProjects.length > 0 && (
<div className={MOVE_TO_LIST}>
- {projects.filter((project) => project.id !== item.projectId).map((project) => (
+ {moveProjects.map((project) => (
<P.Item
key={project.id}
onSelect={() => void moveChatToProjectFromMenu(item, project.id)}
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 d5f73fb3839..a20a1d368e5 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
@@ -111,7 +111,7 @@ test("a chat's Move to submenu groups projects and sections, New first and Remov
trigger: sub.indexOf('<span>{t("shell.sections.moveTo")}</span>'),
projects: sub.indexOf('<P.Label>{t("shell.navigation.projects")}</P.Label>'),
newProject: sub.indexOf("<span>New project</span>"),
- destinations: sub.indexOf("{projects.filter((project) => project.id !== item.projectId).map((project) => ("),
+ destinations: sub.indexOf("{moveProjects.map((project) => ("),
removeProject: sub.indexOf('t("shell.sections.removeFromProject")'),
rule: sub.indexOf("<P.Separator />"),
sections: sub.indexOf("{renderSectionItems(P, {"),
@@ -134,7 +134,7 @@ test("a chat's Move to submenu groups projects and sections, New first and Remov
const newSection = items.indexOf('t("shell.sections.newSection")');
const list = items.indexOf("{destinations.map((section) => (");
// The project or section the row is already in is left out, not offered greyed out.
- assert.match(items, /const destinations = customSections\.filter\(\(section\) => section\.id !== config\.current\);/);
+ assert.match(items, /const destinations = recentSections\n\s*\.filter\(\(section\) => section\.id !== config\.current\)\n\s*\.slice\(0, MOVE_TO_MAX\);/);
assert.doesNotMatch(APP_SIDEBAR, /disabled=\{config\.current === section\.id\}|disabled=\{item\.projectId === project\.id\}/);
const remove = items.indexOf("{config.anyFiled && (");
assert.ok(newSection < list && list < remove, "the Sections group is out of order");
@@ -456,3 +456,32 @@ test("a sidebar menu heading has more room above it than below", async () => {
/\.unsloth-plus-menu\.sidebar-row-menu :is\(\n\s*\[data-slot="dropdown-menu-label"\],\n\s*\[data-slot="context-menu-label"\]\n\s*\) \{\n\s*@apply pl-2\.5 pr-2\.5 pt-2 pb-1 text-ui-11;/,
);
});
+
+// A long list of projects or sections made "Move to" slow to open, so each group lists at most the
+// 12 most recently active. Neither a project's updatedAt (edits only) nor section order (drags)
+// is recency, so both rank by their chats' activity.
+test("Move to lists at most the 12 most recently active projects and sections", () => {
+ assert.match(APP_SIDEBAR, /const MOVE_TO_MAX = 12;/);
+ const activity = APP_SIDEBAR.slice(
+ APP_SIDEBAR.indexOf("const projectActivityAt = useMemo("),
+ APP_SIDEBAR.indexOf("const recentProjects = useMemo("),
+ );
+ assert.match(activity, /chatsByProjectId\.get\(project\.id\)\?\.\[0\]\?\.updatedAt/);
+ assert.match(
+ APP_SIDEBAR,
+ /\[\.\.\.projects\]\.sort\(\n\s*\(a, b\) => \(projectActivityAt\.get\(b\.id\) \?\? 0\) - \(projectActivityAt\.get\(a\.id\) \?\? 0\),/,
+ );
+ // The sidebar's own folder order reads the same activity.
+ assert.match(APP_SIDEBAR, /const lastActivityAt = \(project: ProjectRecord\) => projectActivityAt\.get\(project\.id\) \?\? 0;/);
+ const sections = APP_SIDEBAR.slice(
+ APP_SIDEBAR.indexOf("const recentSections = useMemo("),
+ APP_SIDEBAR.indexOf("const sidebarProjectRecords = useMemo("),
+ );
+ assert.match(sections, /Math\.max\(section\.createdAt \?\? 0, section\.modifiedAt \?\? 0\)/);
+ assert.match(sections, /touch\(sectionByChatId\[item\.id\], item\.updatedAt\)/);
+ assert.match(sections, /touch\(sectionId, projectActivityAt\.get\(projectId\) \?\? 0\)/);
+ assert.match(
+ APP_SIDEBAR,
+ /const moveProjects = recentProjects\n\s*\.filter\(\(project\) => project\.id !== item\.projectId\)\n\s*\.slice\(0, MOVE_TO_MAX\);/,
+ );
+});
diff --git a/tests/python/test_windows_setup_output_encoding.py b/tests/python/test_windows_setup_output_encoding.py
index 01f4a950ced..6f6ba072f2f 100644
--- a/tests/python/test_windows_setup_output_encoding.py
+++ b/tests/python/test_windows_setup_output_encoding.py
@@ -647,7 +647,9 @@ def _run_console_less(path: Path, source: str | None = None) -> tuple[int, bytes
replaced. A str keeps the lru_cache above workable; a dict would not hash.
"""
if not _CONSOLE_LESS_OPTED_IN:
- pytest.skip("the FreeConsole probe trips AV heuristics; set UNSLOTH_TEST_CONSOLE_LESS=1 to run it")
+ pytest.skip(
+ "the FreeConsole probe trips AV heuristics; set UNSLOTH_TEST_CONSOLE_LESS=1 to run it"
+ )
with tempfile.TemporaryDirectory() as workdir:
# A file written here has no Zone.Identifier, so RemoteSigned admits it.
probe = Path(workdir) / f"{path.stem}_console_less_probe.ps1"
diff --git a/tests/studio/install/test_keep_install_backcompat_9979.py b/tests/studio/install/test_keep_install_backcompat_9979.py
index af6dc0f82d8..3beb57c7478 100644
--- a/tests/studio/install/test_keep_install_backcompat_9979.py
+++ b/tests/studio/install/test_keep_install_backcompat_9979.py
@@ -105,7 +105,10 @@ def _windows_non_pe_is_refused_not_started(monkeypatch):
with open(target, "rb") as handle:
if handle.read(2) != b"MZ":
raise OSError(
- None, "%1 is not a valid Win32 application", str(target), _ERROR_BAD_EXE_FORMAT
+ None,
+ "%1 is not a valid Win32 application",
+ str(target),
+ _ERROR_BAD_EXE_FORMAT,
)
return real(command, *args, **kwargs)