Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Repair the two frontend CI breaks main inherited from #11373 (#11416)
Daniel Han598e8ed6a4db
diff --git a/studio/frontend/smoke-tool-activity-main.tsx b/studio/frontend/smoke-tool-activity-main.tsxindex cdf592d98a3..1515b185898 100644--- a/studio/frontend/smoke-tool-activity-main.tsx+++ b/studio/frontend/smoke-tool-activity-main.tsx@@ -32,6 +32,7 @@ import { useChatPreferencesStore } from "@/features/chat/stores/chat-preferencesimport { TerminalIcon } from "lucide-react";import { StrictMode, useEffect, useState } from "react";import { createRoot } from "react-dom/client";+import { AuiProvider, type AssistantClient } from "@assistant-ui/react";const params = new URLSearchParams(window.location.search);const fillers = Number.parseInt(params.get("fillers") ?? "60", 10);@@ -264,6 +265,25 @@ function App() {);}+// ToolGroupRoot reads `message.status` through useAuiState, which throws outside an AuiProvider,+// so rendering this page bare crashes before it can publish __probeReady. The page has no+// message and no runtime: it renders the disclosure primitives on their own, and "no message is+// running" is the scene it wants. useAuiState needs two things from the client, a subscribe it+// can hand to useSyncExternalStore and the symbol-keyed state its selector reads, so that is all+// this provides. Anything else a component reaches for should fail loudly rather than be faked+// here: the assertion belongs in the app, not in the harness.+const HARNESS_STATE = { message: { status: undefined } };+const harnessAui = new Proxy(+ {},+ {+ get(_target, prop) {+ if (prop === "subscribe" || prop === "on") return () => () => {};+ if (typeof prop === "symbol") return HARNESS_STATE;+ return () => ({ getState: () => undefined });+ },+ },+) as unknown as AssistantClient;+const root = document.getElementById("root");if (!root) {throw new Error("missing #root");@@ -273,11 +293,13 @@ if (!root) {// what the render-phase setState in ToolFallbackRoot/ToolGroupRoot has to// survive, but it also doubles every effect and would muddy the measurements.createRoot(root).render(- strict ? (- <StrictMode>+ <AuiProvider value={harnessAui}>+ {strict ? (+ <StrictMode>+ <App />+ </StrictMode>+ ) : (<App />- </StrictMode>- ) : (- <App />- ),+ )}+ </AuiProvider>,);diff --git a/studio/frontend/tests/sidebar-row-drag.test.ts b/studio/frontend/tests/sidebar-row-drag.test.tsindex f9ed6a43691..39c5eda486c 100644--- a/studio/frontend/tests/sidebar-row-drag.test.ts+++ b/studio/frontend/tests/sidebar-row-drag.test.ts@@ -16,6 +16,8 @@ import {sectionRingKey,STAY,type SidebarDragItem,+ type SidebarDropOutcome,+ type SidebarDropPlan,type SidebarDropContext,type SidebarDropZone,} from "../src/features/chat/lib/sidebar-drag.ts";@@ -28,6 +30,24 @@ import {} from "../src/features/chat/stores/sidebar-organization-store.ts";import { readSrcAsync } from "./helpers/kit.ts";+/** The outcome as a plan, failing the test when the planner answered STAY or null.+ *+ * `planSidebarDrop` returns `SidebarDropPlan | STAY | null`, so reading `.action` off the+ * result is a type error until the other two are ruled out. `assert.ok` alone only rules out+ * null. Asserting it here rather than casting keeps a STAY where a plan was expected a test+ * failure that names what came back, instead of a cast that would read `undefined` off a+ * string and fail somewhere less obvious. */+function plannedDrop(+ outcome: SidebarDropOutcome,+ message?: string,+): SidebarDropPlan {+ assert.ok(+ outcome !== null && outcome !== STAY,+ message ?? `expected a drop plan, got ${String(outcome)}`,+ );+ return outcome;+}+const APP_SIDEBAR = await readSrcAsync("components/app-sidebar.tsx");const HOOK = await readSrcAsync("features/chat/hooks/use-sidebar-drag.ts");const EN = await readSrcAsync("i18n/locales/en.ts");@@ -65,7 +85,13 @@ const folder = (id: string,section: SidebarDragItem["section"],scope: string,-): SidebarDragItem => ({ kind: "project", id, section, scope, projectId: null });+): SidebarDragItem => ({+ kind: "project",+ id,+ section,+ scope,+ projectId: null,+});const chatRow = (section: SidebarDropZone["section"],@@ -96,13 +122,14 @@ test("the edge is which half of the row the pointer is over", () => {});test("a chat reorders within its own list, on the edge under the pointer", () => {- const plan = planSidebarDrop(- chat("r2", "recents", RECENTS_ORDER_SCOPE, null),- chatRow("recents", RECENTS_ORDER_SCOPE, "r1"),- "top",- context({ chatSort: "manual" }),+ const plan = plannedDrop(+ planSidebarDrop(+ chat("r2", "recents", RECENTS_ORDER_SCOPE, null),+ chatRow("recents", RECENTS_ORDER_SCOPE, "r1"),+ "top",+ context({ chatSort: "manual" }),+ ),);- assert.ok(plan);assert.deepEqual(plan.action, { kind: "reorder" });assert.deepEqual(plan.cue, {line: { rowKey: rowKey(RECENTS_ORDER_SCOPE, "r1"), edge: "top" },@@ -117,33 +144,37 @@ test("a chat reorders within its own list, on the edge under the pointer", () =>test("a reorder in a sorted list switches it to Manual order, or is refused", () => {const drag = chat("r2", "recents", RECENTS_ORDER_SCOPE, null);const zone = chatRow("recents", RECENTS_ORDER_SCOPE, "r1");- const switching = planSidebarDrop(drag, zone, "top", context());- assert.equal(switching?.effects.switchSort, "chats");+ const switching = plannedDrop(planSidebarDrop(drag, zone, "top", context()));+ assert.equal(switching.effects.switchSort, "chats");const pinnedDrag = chat("p1", "pinned", PINNED_ORDER_SCOPE, null);const pinnedZone = chatRow("pinned", PINNED_ORDER_SCOPE, "p2");- const pinnedSwitch = planSidebarDrop(- pinnedDrag,- pinnedZone,- "bottom",- context({- pinnedSort: "updated",- pinnedChatIds: new Set(["p1", "p2"]),- orders: { ...context().orders, pinned: ["work", "p1", "p2"] },- }),+ const pinnedSwitch = plannedDrop(+ planSidebarDrop(+ pinnedDrag,+ pinnedZone,+ "bottom",+ context({+ pinnedSort: "updated",+ pinnedChatIds: new Set(["p1", "p2"]),+ orders: { ...context().orders, pinned: ["work", "p1", "p2"] },+ }),+ ),);- assert.equal(pinnedSwitch?.effects.switchSort, "pinned");+ assert.equal(pinnedSwitch.effects.switchSort, "pinned");assert.equal(planSidebarDrop(drag, zone, "top", context({ reorderSwitchesSort: false })),null,);// And a list already on Manual never asks.assert.equal(- planSidebarDrop(- drag,- zone,- "top",- context({ chatSort: "manual", reorderSwitchesSort: false }),- )?.action.kind,+ plannedDrop(+ planSidebarDrop(+ drag,+ zone,+ "top",+ context({ chatSort: "manual", reorderSwitchesSort: false }),+ ),+ ).action.kind,"reorder",);});@@ -201,11 +232,15 @@ test("a chat dropped on a folder, its chats or its empty line is filed there", (}),{ section: "projects", folderId: "misc" } as SidebarDropZone,// A pinned folder files it from its chats, or from the lower half of its row.- chatRow("pinned", projectOrderScope("work"), "c1", "work", { index: 0, count: 2 }),+ chatRow("pinned", projectOrderScope("work"), "c1", "work", {+ index: 0,+ count: 2,+ }),{ ...folderRow("pinned", PINNED_ORDER_SCOPE, "work"), edge: "bottom" },] as Array<SidebarDropZone & { edge?: "top" | "bottom" }>) {- const plan = planSidebarDrop(drag, zone, zone.edge ?? "top", context());- assert.ok(plan, `no plan for ${JSON.stringify(zone)}`);+ const plan = plannedDrop(+ planSidebarDrop(drag, zone, zone.edge ?? "top", context()),+ );assert.deepEqual(plan.action, { kind: "move", projectId: zone.folderId });assert.deepEqual(plan.cue, { ring: folderRingKey(zone.folderId!) });assert.deepEqual(plan.effects.moveChat, {@@ -228,16 +263,17 @@ test("a chat dropped on a folder, its chats or its empty line is filed there", (// A folder on Manual order has real slots, so an arriving chat lands in the one under the pointer.test("a chat filed into a folder on Manual order lands in the slot it dropped on", () => {- const plan = planSidebarDrop(- chat("r1", "recents", RECENTS_ORDER_SCOPE, null),- chatRow("pinned", projectOrderScope("work"), "c2", "work", {- index: 1,- count: 2,- }),- "top",- context({ chatSort: "manual" }),+ const plan = plannedDrop(+ planSidebarDrop(+ chat("r1", "recents", RECENTS_ORDER_SCOPE, null),+ chatRow("pinned", projectOrderScope("work"), "c2", "work", {+ index: 1,+ count: 2,+ }),+ "top",+ context({ chatSort: "manual" }),+ ),);- assert.ok(plan);assert.deepEqual(plan.cue, {line: { rowKey: rowKey(projectOrderScope("work"), "c2"), edge: "top" },});@@ -253,35 +289,42 @@ test("a chat filed into a folder on Manual order lands in the slot it dropped ontest("a chat dropped on Recents leaves its folder and its pin", () => {// Out of a folder.- const unfiled = planSidebarDrop(- chat("c3", "projects", projectOrderScope("home"), "home"),- { section: "recents" },- "top",- context(),+ const unfiled = plannedDrop(+ planSidebarDrop(+ chat("c3", "projects", projectOrderScope("home"), "home"),+ { section: "recents" },+ "top",+ context(),+ ),);- assert.ok(unfiled);assert.deepEqual(unfiled.action, { kind: "move", projectId: null });assert.deepEqual(unfiled.cue, { ring: sectionRingKey("recents") });assert.deepEqual(unfiled.effects.moveChat, { chatId: "c3", projectId: null });// Out of Pinned: the pin goes, and so does the folder that would keep it out of Recents.- const unpinned = planSidebarDrop(- chat("p1", "pinned", PINNED_ORDER_SCOPE, "home"),- chatRow("recents", RECENTS_ORDER_SCOPE, "r1"),- "top",- context(),+ const unpinned = plannedDrop(+ planSidebarDrop(+ chat("p1", "pinned", PINNED_ORDER_SCOPE, "home"),+ chatRow("recents", RECENTS_ORDER_SCOPE, "r1"),+ "top",+ context(),+ ),);- assert.ok(unpinned);assert.equal(unpinned.effects.unpinChat, "p1");- assert.deepEqual(unpinned.effects.moveChat, { chatId: "p1", projectId: null });+ assert.deepEqual(unpinned.effects.moveChat, {+ chatId: "p1",+ projectId: null,+ });// With folders off every chat is already a Recents row, so only the pin goes.- const listMode = planSidebarDrop(- chat("p1", "pinned", PINNED_ORDER_SCOPE, "home"),- { section: "recents", header: true },- "top",- context({ organizeBy: "list" }),- );- assert.deepEqual(listMode?.action, { kind: "unpin" });- assert.equal(listMode?.effects.moveChat, undefined);+ const listMode = plannedDrop(+ planSidebarDrop(+ chat("p1", "pinned", PINNED_ORDER_SCOPE, "home"),+ { section: "recents", header: true },+ "top",+ context({ organizeBy: "list" }),+ ),+ );+ assert.deepEqual(listMode.action, { kind: "unpin" });+ assert.equal(listMode.effects.moveChat, undefined);// A Recents row dropped on the section itself has no slot to move to.assert.equal(planSidebarDrop(@@ -296,13 +339,14 @@ test("a chat dropped on Recents leaves its folder and its pin", () => {test("a chat dropped into Pinned is pinned where it lands", () => {const drag = chat("r1", "recents", RECENTS_ORDER_SCOPE, null);- const onRow = planSidebarDrop(- drag,- chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),- "top",- context(),+ const onRow = plannedDrop(+ planSidebarDrop(+ drag,+ chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),+ "top",+ context(),+ ),);- assert.ok(onRow);assert.deepEqual(onRow.action, { kind: "pin" });assert.equal(onRow.effects.pinChat, "r1");assert.deepEqual(onRow.cue, {@@ -314,30 +358,42 @@ test("a chat dropped into Pinned is pinned where it lands", () => {// Pinned is one list, so the very top is above its first row whatever kind that is: the// header, or the upper half of a folder row, both draw the line there.for (const zone of [- { section: "pinned", header: true, row: { id: "work", kind: "project", scope: PINNED_ORDER_SCOPE } },+ {+ section: "pinned",+ header: true,+ row: { id: "work", kind: "project", scope: PINNED_ORDER_SCOPE },+ },folderRow("pinned", PINNED_ORDER_SCOPE, "work"),] as SidebarDropZone[]) {- const plan = planSidebarDrop(drag, zone, "top", context());- assert.deepEqual(plan?.action, { kind: "pin" });- assert.deepEqual(plan?.cue, {+ const plan = plannedDrop(planSidebarDrop(drag, zone, "top", context()));+ assert.deepEqual(plan.action, { kind: "pin" });+ assert.deepEqual(plan.cue, {line: { rowKey: rowKey(PINNED_ORDER_SCOPE, "work"), edge: "top" },});- assert.deepEqual(plan?.effects.orders, [+ assert.deepEqual(plan.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["r1", "work", "p1"] },]);}// The space under the rows lands it last, with a line under the last row, never a ring.- const under = planSidebarDrop(drag, { section: "pinned" }, "bottom", context());- assert.deepEqual(under?.cue, {+ const under = plannedDrop(+ planSidebarDrop(drag, { section: "pinned" }, "bottom", context()),+ );+ assert.deepEqual(under.cue, {line: { rowKey: rowKey(PINNED_ORDER_SCOPE, "p1"), edge: "bottom" },});- assert.deepEqual(under?.effects.orders, [+ assert.deepEqual(under.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["work", "p1", "r1"] },]);// Pinned sorted by a rule would move the row again, so the drop takes it to Manual.assert.equal(- planSidebarDrop(drag, { section: "pinned" }, "bottom", context({ pinnedSort: "updated" }))- ?.effects.switchSort,+ plannedDrop(+ planSidebarDrop(+ drag,+ { section: "pinned" },+ "bottom",+ context({ pinnedSort: "updated" }),+ ),+ ).effects.switchSort,"pinned",);// A chat already pinned is not pinned again: it reorders, and the last row stays last.@@ -359,32 +415,38 @@ test("a pinned chat dragged onto a folder is unpinned, and filed when the folderpinnedChatIds: new Set(["p1", "c3"]),orders: { ...context().orders, pinned: ["work", "p1", "c3"] },});- const ownFolder = planSidebarDrop(- chat("c3", "pinned", PINNED_ORDER_SCOPE, "home"),- folderRow("projects", PROJECT_ORDER_SCOPE, "home"),- "top",- ctx,- );- assert.deepEqual(ownFolder?.action, { kind: "unpin" });- assert.equal(ownFolder?.effects.unpinChat, "c3");- assert.equal(ownFolder?.effects.moveChat, undefined);- const otherFolder = planSidebarDrop(- chat("c3", "pinned", PINNED_ORDER_SCOPE, "home"),- folderRow("projects", PROJECT_ORDER_SCOPE, "misc"),- "top",- ctx,- );- assert.deepEqual(otherFolder?.action, { kind: "move", projectId: "misc" });- assert.equal(otherFolder?.effects.unpinChat, "c3");+ const ownFolder = plannedDrop(+ planSidebarDrop(+ chat("c3", "pinned", PINNED_ORDER_SCOPE, "home"),+ folderRow("projects", PROJECT_ORDER_SCOPE, "home"),+ "top",+ ctx,+ ),+ );+ assert.deepEqual(ownFolder.action, { kind: "unpin" });+ assert.equal(ownFolder.effects.unpinChat, "c3");+ assert.equal(ownFolder.effects.moveChat, undefined);+ const otherFolder = plannedDrop(+ planSidebarDrop(+ chat("c3", "pinned", PINNED_ORDER_SCOPE, "home"),+ folderRow("projects", PROJECT_ORDER_SCOPE, "misc"),+ "top",+ ctx,+ ),+ );+ assert.deepEqual(otherFolder.action, { kind: "move", projectId: "misc" });+ assert.equal(otherFolder.effects.unpinChat, "c3");// In Pinned the folder row's upper half is a slot, so the file lands on its lower half.- const pinnedFolder = planSidebarDrop(- chat("c3", "pinned", PINNED_ORDER_SCOPE, "home"),- folderRow("pinned", PINNED_ORDER_SCOPE, "work"),- "bottom",- ctx,+ const pinnedFolder = plannedDrop(+ planSidebarDrop(+ chat("c3", "pinned", PINNED_ORDER_SCOPE, "home"),+ folderRow("pinned", PINNED_ORDER_SCOPE, "work"),+ "bottom",+ ctx,+ ),);- assert.deepEqual(pinnedFolder?.action, { kind: "move", projectId: "work" });- assert.equal(pinnedFolder?.effects.unpinChat, undefined);+ assert.deepEqual(pinnedFolder.action, { kind: "move", projectId: "work" });+ assert.equal(pinnedFolder.effects.unpinChat, undefined);});test("a folder reorders among its own list, and the block under it aims at it", () => {@@ -393,73 +455,92 @@ test("a folder reorders among its own list, and the block under it aims at it",orders: { ...context().orders, pinned: ["work", "p1", "play"] },});// Over the other folder's row.- const onRow = planSidebarDrop(- folder("play", "pinned", PINNED_ORDER_SCOPE),- folderRow("pinned", PINNED_ORDER_SCOPE, "work"),- "top",- ctx,+ const onRow = plannedDrop(+ planSidebarDrop(+ folder("play", "pinned", PINNED_ORDER_SCOPE),+ folderRow("pinned", PINNED_ORDER_SCOPE, "work"),+ "top",+ ctx,+ ),);- assert.deepEqual(onRow?.effects.orders, [+ assert.deepEqual(onRow.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["play", "work", "p1"] },]);// Over the chats under it: the top half of the block aims above the folder, the bottom half// below it, so the line flips once, in the middle. Below draws under the block's last row.- const upper = planSidebarDrop(- folder("play", "pinned", PINNED_ORDER_SCOPE),- chatRow("pinned", projectOrderScope("work"), "c1", "work", { index: 0, count: 2 }),- "top",- ctx,+ const upper = plannedDrop(+ planSidebarDrop(+ folder("play", "pinned", PINNED_ORDER_SCOPE),+ chatRow("pinned", projectOrderScope("work"), "c1", "work", {+ index: 0,+ count: 2,+ }),+ "top",+ ctx,+ ),);- assert.deepEqual(upper?.cue, {+ assert.deepEqual(upper.cue, {line: { rowKey: rowKey(PINNED_ORDER_SCOPE, "work"), edge: "top" },});- const lower = planSidebarDrop(- folder("play", "pinned", PINNED_ORDER_SCOPE),- {- ...chatRow("pinned", projectOrderScope("work"), "c2", "work", { index: 1, count: 2 }),- blockEnd: { scope: projectOrderScope("work"), id: "c2" },- },- "bottom",- ctx,+ const lower = plannedDrop(+ planSidebarDrop(+ folder("play", "pinned", PINNED_ORDER_SCOPE),+ {+ ...chatRow("pinned", projectOrderScope("work"), "c2", "work", {+ index: 1,+ count: 2,+ }),+ blockEnd: { scope: projectOrderScope("work"), id: "c2" },+ },+ "bottom",+ ctx,+ ),);- assert.deepEqual(lower?.cue, {+ assert.deepEqual(lower.cue, {line: { rowKey: rowKey(projectOrderScope("work"), "c2"), edge: "bottom" },});- assert.deepEqual(lower?.effects.orders, [+ assert.deepEqual(lower.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["work", "play", "p1"] },]);// Over a block's own rows, Show more or an empty folder, it lands below that folder.- const tail = planSidebarDrop(- folder("play", "pinned", PINNED_ORDER_SCOPE),- {- section: "pinned",- folderId: "work",- blockEnd: { scope: projectOrderScope("work"), id: "c2" },- },- "top",- ctx,+ const tail = plannedDrop(+ planSidebarDrop(+ folder("play", "pinned", PINNED_ORDER_SCOPE),+ {+ section: "pinned",+ folderId: "work",+ blockEnd: { scope: projectOrderScope("work"), id: "c2" },+ },+ "top",+ ctx,+ ),);- assert.deepEqual(tail?.cue, {+ assert.deepEqual(tail.cue, {line: { rowKey: rowKey(projectOrderScope("work"), "c2"), edge: "bottom" },});- assert.deepEqual(tail?.effects.orders, [+ assert.deepEqual(tail.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["work", "play", "p1"] },]);// A folder lands between pinned chats too: Pinned is one list.- const belowChat = planSidebarDrop(- folder("work", "pinned", PINNED_ORDER_SCOPE),- chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),- "bottom",- ctx,+ const belowChat = plannedDrop(+ planSidebarDrop(+ folder("work", "pinned", PINNED_ORDER_SCOPE),+ chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),+ "bottom",+ ctx,+ ),);- assert.deepEqual(belowChat?.effects.orders, [+ assert.deepEqual(belowChat.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["p1", "work", "play"] },]);// Its own block keeps it where it is, and Recents is no target at all.assert.equal(planSidebarDrop(folder("work", "pinned", PINNED_ORDER_SCOPE),- chatRow("pinned", projectOrderScope("work"), "c1", "work", { index: 0, count: 2 }),+ chatRow("pinned", projectOrderScope("work"), "c1", "work", {+ index: 0,+ count: 2,+ }),"top",ctx,),@@ -477,90 +558,116 @@ test("a folder reorders among its own list, and the block under it aims at it",});test("a folder dragged into Pinned is pinned where it lands, and back out is unpinned", () => {- const pin = planSidebarDrop(- folder("home", "projects", PROJECT_ORDER_SCOPE),- folderRow("pinned", PINNED_ORDER_SCOPE, "work"),- "top",- context(),+ const pin = plannedDrop(+ planSidebarDrop(+ folder("home", "projects", PROJECT_ORDER_SCOPE),+ folderRow("pinned", PINNED_ORDER_SCOPE, "work"),+ "top",+ context(),+ ),);- assert.deepEqual(pin?.action, { kind: "pin" });- assert.equal(pin?.effects.pinProject, "home");- assert.deepEqual(pin?.effects.orders, [+ assert.deepEqual(pin.action, { kind: "pin" });+ assert.equal(pin.effects.pinProject, "home");+ assert.deepEqual(pin.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["home", "work", "p1"] },]);// Over a pinned chat: the slot the line shows, since Pinned is one list.- const onChat = planSidebarDrop(- folder("home", "projects", PROJECT_ORDER_SCOPE),- chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),- "top",- context(),+ const onChat = plannedDrop(+ planSidebarDrop(+ folder("home", "projects", PROJECT_ORDER_SCOPE),+ chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),+ "top",+ context(),+ ),);- assert.deepEqual(onChat?.cue, {+ assert.deepEqual(onChat.cue, {line: { rowKey: rowKey(PINNED_ORDER_SCOPE, "p1"), edge: "top" },});- assert.deepEqual(onChat?.effects.orders, [+ assert.deepEqual(onChat.effects.orders, [{ scope: PINNED_ORDER_SCOPE, ids: ["work", "home", "p1"] },]);// Pinned sorted by a rule would move the row again, so the drop takes it to Manual.assert.equal(- planSidebarDrop(- folder("home", "projects", PROJECT_ORDER_SCOPE),- chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),- "top",- context({ pinnedSort: "updated" }),- )?.effects.switchSort,+ plannedDrop(+ planSidebarDrop(+ folder("home", "projects", PROJECT_ORDER_SCOPE),+ chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),+ "top",+ context({ pinnedSort: "updated" }),+ ),+ ).effects.switchSort,"pinned",);- const unpin = planSidebarDrop(- folder("work", "pinned", PINNED_ORDER_SCOPE),- folderRow("projects", PROJECT_ORDER_SCOPE, "misc"),- "bottom",- context(),+ const unpin = plannedDrop(+ planSidebarDrop(+ folder("work", "pinned", PINNED_ORDER_SCOPE),+ folderRow("projects", PROJECT_ORDER_SCOPE, "misc"),+ "bottom",+ context(),+ ),);- assert.deepEqual(unpin?.action, { kind: "unpin" });- assert.equal(unpin?.effects.unpinProject, "work");- assert.deepEqual(unpin?.effects.orders, [+ assert.deepEqual(unpin.action, { kind: "unpin" });+ assert.equal(unpin.effects.unpinProject, "work");+ assert.deepEqual(unpin.effects.orders, [{ scope: PROJECT_ORDER_SCOPE, ids: ["home", "misc", "work"] },]);- const unpinOnHeader = planSidebarDrop(- folder("work", "pinned", PINNED_ORDER_SCOPE),- { section: "projects", header: true },- "top",- context(),+ const unpinOnHeader = plannedDrop(+ planSidebarDrop(+ folder("work", "pinned", PINNED_ORDER_SCOPE),+ { section: "projects", header: true },+ "top",+ context(),+ ),);- assert.deepEqual(unpinOnHeader?.cue, { ring: sectionRingKey("projects") });+ assert.deepEqual(unpinOnHeader.cue, { ring: sectionRingKey("projects") });});// The gap between a header and its first row is where "above the first row" is aimed, so the// header stands for that edge for a drag of the same kind, and for the bare section otherwise.test("a section header stands for the top of its first row", () => {const ctx = context({ chatSort: "manual" });- const aboveFirstChat = planSidebarDrop(- chat("r2", "recents", RECENTS_ORDER_SCOPE, null),- { section: "recents", header: true, row: { id: "r1", kind: "chat", scope: RECENTS_ORDER_SCOPE } },- "bottom",- ctx,+ const aboveFirstChat = plannedDrop(+ planSidebarDrop(+ chat("r2", "recents", RECENTS_ORDER_SCOPE, null),+ {+ section: "recents",+ header: true,+ row: { id: "r1", kind: "chat", scope: RECENTS_ORDER_SCOPE },+ },+ "bottom",+ ctx,+ ),);- assert.deepEqual(aboveFirstChat?.cue, {+ assert.deepEqual(aboveFirstChat.cue, {line: { rowKey: rowKey(RECENTS_ORDER_SCOPE, "r1"), edge: "top" },});- assert.deepEqual(aboveFirstChat?.effects.orders, [+ assert.deepEqual(aboveFirstChat.effects.orders, [{ scope: RECENTS_ORDER_SCOPE, ids: ["r2", "r1"] },]);- const aboveFirstFolder = planSidebarDrop(- folder("misc", "projects", PROJECT_ORDER_SCOPE),- { section: "projects", header: true, row: { id: "home", kind: "project", scope: PROJECT_ORDER_SCOPE } },- "bottom",- ctx,+ const aboveFirstFolder = plannedDrop(+ planSidebarDrop(+ folder("misc", "projects", PROJECT_ORDER_SCOPE),+ {+ section: "projects",+ header: true,+ row: { id: "home", kind: "project", scope: PROJECT_ORDER_SCOPE },+ },+ "bottom",+ ctx,+ ),);- assert.deepEqual(aboveFirstFolder?.cue, {+ assert.deepEqual(aboveFirstFolder.cue, {line: { rowKey: rowKey(PROJECT_ORDER_SCOPE, "home"), edge: "top" },});// A chat over the Projects header does not file into the first folder.assert.equal(planSidebarDrop(chat("r1", "recents", RECENTS_ORDER_SCOPE, null),- { section: "projects", header: true, row: { id: "home", kind: "project", scope: PROJECT_ORDER_SCOPE } },+ {+ section: "projects",+ header: true,+ row: { id: "home", kind: "project", scope: PROJECT_ORDER_SCOPE },+ },"top",ctx,),@@ -575,17 +682,21 @@ test("a section header stands for the top of its first row", () => {// Equal plans must not re-render the sidebar.test("a plan's key changes exactly when what it paints or says does", () => {const ctx = context();- const a = planSidebarDrop(- chat("r1", "recents", RECENTS_ORDER_SCOPE, null),- chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),- "top",- ctx,- );- const b = planSidebarDrop(- chat("r1", "recents", RECENTS_ORDER_SCOPE, null),- chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),- "bottom",- ctx,+ const a = plannedDrop(+ planSidebarDrop(+ chat("r1", "recents", RECENTS_ORDER_SCOPE, null),+ chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),+ "top",+ ctx,+ ),+ );+ const b = plannedDrop(+ planSidebarDrop(+ chat("r1", "recents", RECENTS_ORDER_SCOPE, null),+ chatRow("pinned", PINNED_ORDER_SCOPE, "p1"),+ "bottom",+ ctx,+ ),);assert.equal(planKey(a), planKey({ ...a! }));assert.notEqual(planKey(a), planKey(b));@@ -639,11 +750,16 @@ test("every row and section is wired to the planner", () => {// A dragover can land in the same frame as its dragstart, before state commits.test("the dragged row is known before React re-renders", async () => {- const store = await readSrcAsync("features/chat/stores/sidebar-drag-source.ts");+ const store = await readSrcAsync(+ "features/chat/stores/sidebar-drag-source.ts",+ );assert.match(store, /let source: SidebarDragItem \| null = null;/);assert.match(HOOK, /setSidebarDragSource\(item\);\n\s*setDrag\(item\);/);// Every handler reads it from there; the state is only what paints.- assert.equal((HOOK.match(/const dragged = sidebarDragSource\(\);/g) ?? []).length, 2);+ assert.equal(+ (HOOK.match(/const dragged = sidebarDragSource\(\);/g) ?? []).length,+ 2,+ );assert.ok(!/const dragged = drag;/.test(HOOK));});@@ -652,11 +768,22 @@ test("a cue over nothing is cleared without trusting dragleave", () => {assert.ok(!HOOK.includes("onDragLeave"));assert.ok(!APP_SIDEBAR.includes("onDragLeave"));assert.match(HOOK, /lastHandledEvent = event\.nativeEvent;/);- assert.match(HOOK, /if \(lastHandledEvent !== event\) \{\n\s*cancelSpring\(\);\n\s*showPlan\(null\);/);+ assert.match(+ HOOK,+ /if \(lastHandledEvent !== event\) \{\n\s*cancelSpring\(\);\n\s*showPlan\(null\);/,+ );// No answer lets the outer zone answer; an answer marks the event rather than stopping it.- assert.match(HOOK, /if \(!next\) return;\n\s*event\.preventDefault\(\);\n\s*lastHandledEvent = event\.nativeEvent;/);- assert.ok(!HOOK.includes("event.stopPropagation();\n lastHandledEvent"));- assert.match(HOOK, /if \(!dragged \|\| lastHandledEvent === event\.nativeEvent\) return;/);+ assert.match(+ HOOK,+ /if \(!next\) return;\n\s*event\.preventDefault\(\);\n\s*lastHandledEvent = event\.nativeEvent;/,+ );+ assert.ok(+ !HOOK.includes("event.stopPropagation();\n lastHandledEvent"),+ );+ assert.match(+ HOOK,+ /if \(!dragged \|\| lastHandledEvent === event\.nativeEvent\) return;/,+ );});// Over its own row a lifted row is already home. The row claims the drag and paints nothing,@@ -666,7 +793,10 @@ test("a row over itself claims the drag and paints nothing", () => {HOOK,/if \(next === STAY\) \{\n\s*\/\/[^\n]*\n\s*cancelSpring\(\);\n\s*showPlan\(null\);\n\s*return;\n\s*\}/,);- assert.match(HOOK, /if \(next !== STAY\) optionsRef\.current\.onDrop\(next, dragged\);/);+ assert.match(+ HOOK,+ /if \(next !== STAY\) optionsRef\.current\.onDrop\(next, dragged\);/,+ );});// A chat's row stays on screen while its move is written, so it can be dropped again before the@@ -722,7 +852,10 @@ test("alt and an arrow reorder a row without a pointer", async () => {APP_SIDEBAR,/onKeyDown: \(event: React\.KeyboardEvent\) => \{\n\s*if \(\n\s*!event\.altKey \|\|\n\s*\(event\.key !== "ArrowUp" && event\.key !== "ArrowDown"\)\n\s*\)/,);- assert.match(APP_SIDEBAR, /reorderRowBy\(item, orderedIds, sort, event\.key === "ArrowDown" \? 1 : -1\);/);+ assert.match(+ APP_SIDEBAR,+ /reorderRowBy\(item, orderedIds, sort, event\.key === "ArrowDown" \? 1 : -1\);/,+ );// Same rule as a drop.assert.match(APP_SIDEBAR, /if \(resorts && !reorderSwitchesSort\) return;/);// A touch browser starts no drag, so its row menus keep Move up and Move down.@@ -742,12 +875,18 @@ test("alt and an arrow reorder a row without a pointer", async () => {assert.match(APP_SIDEBAR, /const coarsePointer = useIsCoarsePointer\(\);/);// Any touch pointer counts: a laptop with a touchscreen keeps the items too.const MOBILE = await readSrcAsync("hooks/use-mobile.ts");- assert.match(MOBILE, /const COARSE_POINTER_QUERY = "\(any-pointer: coarse\)";/);+ assert.match(+ MOBILE,+ /const COARSE_POINTER_QUERY = "\(any-pointer: coarse\)";/,+ );for (const key of ["moveUp", "moveDown"]) {assert.ok(EN.includes(`${key}:`), `${key} is missing from the en locale`);}// Both paths share the reorder, so both honour the sort rule.- assert.equal((APP_SIDEBAR.match(/reorderRowBy\(item, orderedIds, sort, /g) ?? []).length, 3);+ assert.equal(+ (APP_SIDEBAR.match(/reorderRowBy\(item, orderedIds, sort, /g) ?? []).length,+ 3,+ );});// The hint names every kind of drop.@@ -765,7 +904,10 @@ test("the hint beside the cursor names every kind of drop", () => {assert.ok(APP_SIDEBAR.includes(use), `${use} is never rendered`);}// In a portal, and only while the user wants it.- assert.match(APP_SIDEBAR, /draggingRow && dragHints && typeof document !== "undefined"\n\s*\? createPortal\(/);+ assert.match(+ APP_SIDEBAR,+ /draggingRow && dragHints && typeof document !== "undefined"\n\s*\? createPortal\(/,+ );assert.ok(APP_SIDEBAR.includes('data-testid="sidebar-drop-hint"'));});@@ -782,11 +924,22 @@ test("drag-and-drop preferences persist and show in the Organize menu", () => {assert.equal(next.dragHints, false);assert.equal(next.reorderSwitchesSort, false);assert.equal(next.dragOpensFolders, false);- for (const key of ["dragDrop", "dragHints", "reorderSwitchesSort", "dragOpensFolders"]) {+ for (const key of [+ "dragDrop",+ "dragHints",+ "reorderSwitchesSort",+ "dragOpensFolders",+ ]) {assert.ok(EN.includes(`${key}:`), `${key} is missing from the en locale`);- assert.ok(APP_SIDEBAR.includes(`shell.organize.${key}`), `${key} is never rendered`);+ assert.ok(+ APP_SIDEBAR.includes(`shell.organize.${key}`),+ `${key} is never rendered`,+ );}- assert.match(APP_SIDEBAR, /<DropdownMenuCheckboxItem\n\s*key=\{option\.key\}\n\s*checked=\{option\.get\(\)\}/);+ assert.match(+ APP_SIDEBAR,+ /<DropdownMenuCheckboxItem\n\s*key=\{option\.key\}\n\s*checked=\{option\.get\(\)\}/,+ );});// Resting on a closed folder or section opens it.@@ -796,7 +949,10 @@ test("a closed folder or section opens under a resting pointer", () => {APP_SIDEBAR,/onSpringOpen: \(zone\) => \{\n\s*if \(zone\.folderId\) \{\n\s*if \(collapsedProjectIds\.has\(zone\.folderId\)\) \{\n\s*toggleProjectCollapsed\(zone\.folderId\);/,);- assert.match(APP_SIDEBAR, /if \(zone\.section === "pinned"\) setPinnedOpen\(true\);/);+ assert.match(+ APP_SIDEBAR,+ /if \(zone\.section === "pinned"\) setPinnedOpen\(true\);/,+ );assert.match(APP_SIDEBAR, /springOpen: dragOpensFolders,/);});@@ -836,5 +992,8 @@ test("a drop that moves writes its slot and takes the pin off after the move", (APP_SIDEBAR,/if \(!order\.place \|\| !current \|\| current === before\) return order\.ids;\n\s*return placeIdAt\(current, order\.place\.id, order\.place\.targetId, order\.place\.edge\);/,);- assert.match(APP_SIDEBAR, /\): Promise<boolean> \{\n\s*if \(item\.projectId === projectId\) return true;/);+ assert.match(+ APP_SIDEBAR,+ /\): Promise<boolean> \{\n\s*if \(item\.projectId === projectId\) return true;/,+ );});