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.

Condense comments added since the last cleanup: Studio frontend and Tauri (#16109)

Daniel Han1641ea9b435e
diff --git a/studio/frontend/scripts/eslint-typescript6.cjs b/studio/frontend/scripts/eslint-typescript6.cjs
index 3b113bec255..0c4a3373824 100644
--- a/studio/frontend/scripts/eslint-typescript6.cjs
+++ b/studio/frontend/scripts/eslint-typescript6.cjs
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Imported first by eslint.config.js, so the CLI and editors both get it. typescript-eslint needs
-// the TypeScript JS API, which TypeScript 7 does not ship, so its require("typescript") goes to the
-// TypeScript 6 copy that @typescript/typescript6 brings. Drop this once typescript-eslint supports
-// TypeScript 7.
+// Imported first by eslint.config.js so CLI and editors both get it; typescript-eslint needs the
+// TypeScript JS API, which TypeScript 7 lacks, so require('typescript') gets the TypeScript 6 copy
+// from @typescript/typescript6. Drop once typescript-eslint supports TS 7.
const Module = require("node:module");
const path = require("node:path");
diff --git a/studio/frontend/src/app/provider.tsx b/studio/frontend/src/app/provider.tsx
index f5ebd0879d0..28bde8a2194 100644
--- a/studio/frontend/src/app/provider.tsx
+++ b/studio/frontend/src/app/provider.tsx
@@ -123,11 +123,9 @@ type TauriMonitor = NonNullable<
// Keep in step with MOBILE_BREAKPOINT in hooks/use-mobile.ts.
const MIN_DESKTOP_LAYOUT_WIDTH = 768;
-// Room the corner rail keeps around its cards so its overflow clip does not cut their shadows off (#9246).
-// Sized off the deepest card shadow, the dark-mode one: 0 8px 28px -6px reaches 22px to a card's left
-// and 14px above it, and a shorter gutter ends the halo on a hard line. Only those two edges show it:
-// the rail is flush with the bottom-right corner, so the clip there lands on the screen edge. Both
-// gutters come out of the cap, never out of the cards: 100dvh less 16 and 16 is the band they had.
+// Gutters keep the rail's overflow clip from cutting card shadows (#9246), sized to the dark-mode
+// shadow (22px left, 14px above); only the left and top edges show, and both come out of the cap,
+// never the cards.
const STACK_SHADOW_GUTTER_BOTTOM = 16;
const STACK_SHADOW_GUTTER_TOP = 16;
const STACK_SHADOW_GUTTER_LEFT = 28;
diff --git a/studio/frontend/src/app/window-layout-lifecycle.ts b/studio/frontend/src/app/window-layout-lifecycle.ts
index 51c179ba83e..279c145a413 100644
--- a/studio/frontend/src/app/window-layout-lifecycle.ts
+++ b/studio/frontend/src/app/window-layout-lifecycle.ts
@@ -70,11 +70,9 @@ type WindowMonitorReader<Monitor extends WorkAreaMonitor> = {
};
/**
- * Size bounds the window has to stay within on its current monitor.
- *
- * `logicalPerCssPx` reports the webview's zoom above a monitor's display scale,
- * keeping the resize floor a CSS-pixel floor under Windows text scaling. It
- * defaults to a no-op, which is every platform without it.
+ * Size bounds the window must stay within on its current monitor. logicalPerCssPx reports the
+ * webview's zoom above the monitor's display scale, keeping the resize floor in CSS pixels under
+ * Windows text scaling; the default no-op covers platforms without it.
*/
export async function measureWindowLayout<Monitor extends WorkAreaMonitor>(
reader: WindowMonitorReader<Monitor>,
@@ -222,10 +220,9 @@ export type MinimumSizeApplier = {
};
/**
- * tao applies a size floor by resizing the window to its own inner size, which drops
- * maximized first: a maximized window comes back unmaximized at full-screen size, its
- * bottom under the Windows taskbar (#13616). The floor only matters to a restored
- * window, so a call made while maximized, fullscreen or minimized waits for the restore.
+ * tao applies a size floor by resizing to its inner size, which drops maximized first, so a
+ * maximized window comes back at full-screen size, its bottom under the Windows taskbar (#13616); a
+ * call while maximized, fullscreen or minimized waits for restore.
*/
export function createMinimumSizeApplier(
win: MinimumSizeWindow,
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 30db94b2cd0..2a82273471f 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -421,12 +421,9 @@ const SELECT_WITH_META =
typeof navigator !== "undefined" &&
/mac/i.test(navigator.platform || navigator.userAgent);
-// Insertion line on the landing edge, drawn inside the row: a section's collapsible clips its
-// overflow, and the first and last rows are exactly where a row is dragged to. A border, not a
-// filled bar: border widths snap to whole device pixels, so the line keeps one thickness at any
-// zoom or UI scale instead of rounding differently per row.
-// DROP_CUE_CLASS: the carried row's copy covers the spot it is aimed at, so the drag draws each
-// cue's border again above it.
+// Insertion line drawn inside the row, since a collapsible's overflow clips it; a border, since
+// border widths snap to whole device pixels, keeps one thickness at any zoom. DROP_CUE_CLASS
+// redraws each cue's border above the carried row's copy, which covers the spot.
const DROP_CUE_BASE = `${DROP_CUE_CLASS} before:pointer-events-none before:absolute before:inset-x-2 before:z-10 before:h-0 before:border-t-[1.5px] before:border-foreground before:content-['']`;
const DROP_CUE_TOP = `${DROP_CUE_BASE} before:top-0`;
// bottom-px: on the last row, DROP_ROW_HIT's extra pixel is clipped by the list.
@@ -1331,8 +1328,7 @@ export function AppSidebar() {
select: (s) => ({
pathname: s.location.pathname,
search: s.location.search as Record<string, string | undefined>,
- // Pathname and search as one string, so a dep can follow it without a
- // fresh object every render.
+ // Pathname and search as one string: a dep follows it without a fresh object per render.
href: s.location.href,
}),
});
@@ -1393,9 +1389,8 @@ export function AppSidebar() {
const canRepair = repair !== null && !repair.isExternalServer;
const fullInstall = useFullInstallUpgrade();
const [fullInstallOpen, setFullInstallOpen] = useState(false);
- // Until /api/health answers, `chatOnly` is the browser-platform guess, so every Mac painted
- // Train and Video blacked out on load and only recovered once the backend reported. Gate the
- // rows on a measured verdict and let them spin until it lands.
+ // Until /api/health answers, chatOnly is only a browser-platform guess, so Macs blacked out Train
+ // and Video on load; gate the rows on a measured verdict and spin until it lands.
const capabilitiesUnknown = usePlatformStore((s) => s.capabilitiesUnknown());
const chatOnlyMeasured = chatOnly && !capabilitiesUnknown;
const trainBlocked = trainUnavailable && !capabilitiesUnknown;
@@ -1551,9 +1546,8 @@ export function AppSidebar() {
},
[syncFade],
);
- // Rail width: 0 where scrollbars overlay (macOS default) or the list fits, the platform's thin rail
- // where they are classic. Only rows inside the scroller lose it, so the rows outside pad by it to
- // keep one edge. Written to the DOM, and only on a change: state here would loop (React #185).
+ // Rail width is 0 where scrollbars overlay or the list fits, else the thin classic rail; outside
+ // rows pad by it. Written to the DOM only on change, since state would loop (React #185).
const railWidthRef = useRef<number | null>(null);
const measureScrollRail = useCallback((el: HTMLDivElement) => {
const rail = el.offsetWidth - el.clientWidth;
@@ -1562,9 +1556,8 @@ export function AppSidebar() {
el.parentElement?.style.setProperty("--sidebar-rail", `${rail}px`);
}, []);
- // A callback ref, not an effect: the mobile Sheet unmounts its subtree on close and the breakpoint
- // swaps it for the desktop one, so the scroller is a new node each time and an effect keyed on a
- // stable callback never re-runs. Still runs before paint.
+ // A callback ref, not an effect: the mobile Sheet unmounts it on close, and a breakpoint swap
+ // replaces it, so an effect on a stable callback never re-runs. Still before paint.
const railObserverRef = useRef<ResizeObserver | null>(null);
const sectionObserverRef = useRef<MutationObserver | null>(null);
const attachScroller = useCallback(
@@ -1574,15 +1567,13 @@ export function AppSidebar() {
sectionObserverRef.current?.disconnect();
sectionObserverRef.current = null;
scrollRef.current = el;
- // Per node: a new parent has no variable yet even at the same rail, and
- // the cache would otherwise skip the write.
+ // Per node: a new parent has no rail variable yet, and the cache would skip the write.
railWidthRef.current = null;
if (!el) return;
measureScrollRail(el);
syncFade(el);
- // Watch the box, not renders: the Images disclosure and the project toggles change the row count
- // without rendering this component, and a scrollbar appearing shrinks the content box. Safe where
- // the earlier observer was not: it writes the DOM, never state, so nothing feeds back.
+ // Watch the box, not renders: Images and project toggles change the row count without
+ // rendering, and a scrollbar shrinks the box. Safe here since it writes the DOM, never state.
const observer = new ResizeObserver(() => {
measureScrollRail(el);
syncFade(el);
@@ -1692,10 +1683,9 @@ export function AppSidebar() {
(projects.length > 0 || projectsLoaded);
const projectsSectionRendered =
!isStudioRoute && !showTrainingRecents && projectsSectionConfigured;
- // Deliberately not the rendered flag: Train and Recipes swap the section for their runs, and a
- // row reappearing there reads as a setting turning itself back on. The icon rail is the one
- // exception, since it hides the section in CSS without unmounting it and the row is then the
- // only way to reach projects.
+ // Not the rendered flag: Train and Recipes swap the section for their runs, and a row reappearing
+ // there reads as a setting turning itself back on. The icon rail is the exception: it hides the
+ // section in CSS, so the row is the only way to reach projects.
const projectsSectionShowing =
projectsSectionConfigured && (isMobile || sidebarState !== "collapsed");
const chatSort = useSidebarOrganizationStore((s) => s.chatSort);
@@ -1908,9 +1898,8 @@ export function AppSidebar() {
}
return map;
}, [allChatItems]);
- // With the Projects section on, a project chat lives in its folder and repeating it here would be
- // noise. With it off there are no folders, so Recents is where those chats go. Pinned chats are
- // held back either way: the Pinned section renders those, as a custom section does its own.
+ // Project chats are left out here when the Projects section is on, since they live in their
+ // folder; with it off, Recents takes them. Pinned chats are held back either way.
const recentChatItems = useMemo(
() =>
listedChatItems.filter(
@@ -2016,9 +2005,8 @@ export function AppSidebar() {
projectActivityAt,
projectSort,
]);
- // Memoised for its identity, not for the slice. It feeds the rendered-row set the selection guard
- // depends on, and that effect sets state: React re-renders once to find the bail-out, which would
- // rebuild this array and schedule the effect again, without end.
+ // Memoised for identity, not the slice: it feeds the selection guard's rendered-row set, and that
+ // effect sets state, so a rebuilt array would re-trigger it without end.
const [projectPageLimit, setProjectPageLimit] = useState(SIDEBAR_PAGE_SIZE);
const visibleProjectRecords = useMemo(
() =>
@@ -2112,11 +2100,9 @@ export function AppSidebar() {
? { id: pair.id, compare: true as const }
: { id, compare: false as const };
}, [runningByThreadId, approvalWaitingElsewhere, allChatItems]);
- // A chat started from a section's header joins it when its first send gives it an id, which
- // lands in the store while the address still names the new chat. Leaving that chat first lets
- // the mark go, so a chat opened afterwards is never filed by mistake. Turning it into a compare
- // chat before that first send is not leaving it: the compare chat takes the mark, and joins once
- // its pair is listed, under the id the address gives it.
+ // A chat started from a section header joins it once its first send gives it an id; leaving that
+ // chat first drops the mark, so no later chat is filed by mistake. Turning it into a compare chat
+ // before then is not leaving: the compare chat takes the mark and joins once its pair is listed.
useEffect(() => {
if (!pendingNewChatSection) return;
const { sectionId, nonce, compare } = pendingNewChatSection;
@@ -2197,8 +2183,7 @@ export function AppSidebar() {
mode: SidebarChatSort,
): SidebarItem[] => {
if (mode === "manual") {
- // Incoming order is the list's own rule, so undragged rows keep it:
- // newest first in Recents, pin order in Pinned.
+ // Undragged rows keep the list's order: newest first in Recents, pin order in Pinned.
return applyManualOrder(items, displayManualOrder[scope], (item) => item.id);
}
return [...items].sort((a, b) => b.updatedAt - a.updatedAt);
@@ -2226,9 +2211,8 @@ export function AppSidebar() {
end();
};
window.addEventListener("keyup", onKeyUp);
- // Losing the window ends it too: ⌘Tab away mid-walk and the release lands
- // elsewhere, leaving the walk frozen, so the next press carries on instead
- // of toggling back and the stack never takes the chat it landed on.
+ // Blur ends the walk too: ⌘Tab away mid-walk would leave it frozen, so the next press carries
+ // on instead of toggling back; the stack never takes the chat it landed on.
window.addEventListener("blur", end);
return () => {
window.removeEventListener("keyup", onKeyUp);
@@ -2252,8 +2236,7 @@ export function AppSidebar() {
}
return map;
}, [listedChatsByProjectId, sortChatItems, chatSort, pinnedIdSet, sectionByChatId]);
- // One id array per list, shared by every row in it. Built per row, these
- // would be N arrays of length N on each render.
+ // One id array per list shared by its rows; built per row, N arrays of length N each render.
const recentRowIds = useMemo(
() => sortedRecentChatItems.map((item) => item.id),
[sortedRecentChatItems],
@@ -2468,8 +2451,7 @@ 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.
+ // Not in one list: project chats are Recents rows, and a folder would list them twice.
if (!chatListsOnScreen || organizeBy !== "project" || !open) return [];
const out: SidebarItem[] = [];
for (const project of records) {
@@ -2499,8 +2481,7 @@ export function AppSidebar() {
() => (chatListsOnScreen && chatOpen ? sortedRecentChatItems : []),
[chatListsOnScreen, chatOpen, sortedRecentChatItems],
);
- // Pinned draws folders and chats in one order, so the section's chats read in that order,
- // each open folder's chats right under its row.
+ // Pinned draws folders and chats in one order; each open folder's chats sit under its row.
const pinnedSectionChatItems = useMemo(
() =>
chatListsOnScreen && pinnedOpen
@@ -2688,11 +2669,9 @@ export function AppSidebar() {
dropProjectSelection();
}, [dropChatSelection, dropProjectSelection]);
- // Emptying the published lists is not enough: Archive, Pin, Mark unread and Delete all prefer the
- // selection over the open chat, and a selection shows nowhere but the rows. Carried onto Train or
- // behind the icon rail it would be invisible and still be what the chords hit. Sections close one
- // at a time, though, and a "show less" takes back only its own overflow, so drop what went and keep
- // what stayed.
+ // Emptying the published lists is not enough: Archive, Pin, Mark unread and Delete prefer the
+ // selection over the open chat, and it shows only in the rows, so it is dropped when they leave.
+ // Show less takes back only its own overflow, so drop what went and keep what stayed.
useEffect(() => {
if (!chatRowsOnScreen) {
clearSelection();
@@ -4067,9 +4046,8 @@ export function AppSidebar() {
useEffect(() => {
openChatItemRef.current = openChatItem;
});
- // The sidebar is unmounted on the auth routes, so this is where a sign-out reaches: the store
- // outlives the component that filled it, and the unread set and the walk belong to the account
- // that just left.
+ // The sidebar unmounts on auth routes, so sign-out must reset here: the store outlives the
+ // component, and the unread set and walk belong to the account that left.
useEffect(
() => () => useChatNavigationStore.getState().resetAccountState(),
[],
@@ -4097,10 +4075,9 @@ export function AppSidebar() {
openChatItemById(item);
};
- // With rows selected these act on the selection, matching the context menu; otherwise on the open
- // chat. Acting on a selection clears it, so without this latch a second press would land on the
- // open chat, which the user never selected. Keyed by action: the press to hold back is a repeat of
- // the one that just took the selection, not a different command chosen deliberately.
+ // With rows selected these act on the selection, otherwise on the open chat. Acting clears the
+ // selection, so without this latch a second press would hit the open chat, which was never
+ // selected. Keyed by action, so only a repeat of the same press is held back.
const selectionActedRef = useRef<{ id: ShortcutId; at: number } | null>(null);
const actOnSelection = (id: ShortcutId, fn: () => void) => {
selectionActedRef.current = { id, at: Date.now() };
@@ -4121,9 +4098,8 @@ export function AppSidebar() {
// as covered would kill these chords on the mobile drawer, which unmounts.
const sidebarCovered = () => {
if (isSurfaceBackgrounded(SIDEBAR_SELECTOR)) return true;
- // With the mobile drawer closed the sidebar is unmounted, so the check above has nothing to read.
- // The app root is always mounted and Radix aria-hides it for a modal's life. A fallback only: an
- // open drawer is itself a dialog hiding the root, and the sidebar in it is the foreground.
+ // The mobile drawer unmounts the sidebar when closed, so this check reads the app root, which
+ // Radix aria-hides for a modal's life; an open drawer hides it and is the foreground.
return (
typeof document !== "undefined" &&
surfaceElements(SIDEBAR_SELECTOR).length === 0 &&
@@ -4185,9 +4161,8 @@ export function AppSidebar() {
},
{ claims: sidebarUncovered },
);
- // Through the dialog: the row's inline pill is rendered by the row, and the open chat may be behind
- // a collapsed section, past a folder's "show more", or on a route with no chat list at all, where
- // the chord would look dead and leave a rename waiting to appear when the row came back.
+ // Goes through the dialog: the open chat may be behind a collapsed section, past a folder's show
+ // more, or on a route with no chat list, where an inline row pill cannot show the rename.
useShortcut(
"renameChat",
() => withActiveChat((item) => openRenameChat(item)),
@@ -4424,9 +4399,8 @@ export function AppSidebar() {
);
}
- // The "..." on each list header, carrying only what that list is about, as ChatGPT does: Pinned
- // sorts its pins, Projects groups the sidebar and sorts its folders, and Recents adds which
- // sections show and a new one. A custom section's own "..." manages that section.
+ // The "..." menu on each list header carries only what that list is about, as ChatGPT does:
+ // Pinned sorts pins, Projects groups the sidebar, Recents adds which sections show.
function renderSidebarHeaderMenu(
options: { ariaLabel: string } & (
| { kind: "pinned" | "projects" | "recents" }
diff --git a/studio/frontend/src/components/assistant-ui/attachment-document-dialog.tsx b/studio/frontend/src/components/assistant-ui/attachment-document-dialog.tsx
index ffde50fa243..78e32a6b980 100644
--- a/studio/frontend/src/components/assistant-ui/attachment-document-dialog.tsx
+++ b/studio/frontend/src/components/assistant-ui/attachment-document-dialog.tsx
@@ -315,8 +315,7 @@ const SentOriginalDialog: FC<
);
};
-/** A file outside any message, such as a chat with files source, read on open: pages, markdown or
- * text (a text/* blob); a PDF opens at `page` (1-based). */
+/** Outside any message: pages, markdown or text read on open; a PDF opens at 1-based `page`. */
export const LocalFileDialog: FC<
PropsWithChildren<{ name: string; load: () => Promise<Blob>; page?: number }>
> = ({ children, name, load, page }) => (
diff --git a/studio/frontend/src/components/assistant-ui/attachment.tsx b/studio/frontend/src/components/assistant-ui/attachment.tsx
index c210cef7db7..0424a72434b 100644
--- a/studio/frontend/src/components/assistant-ui/attachment.tsx
+++ b/studio/frontend/src/components/assistant-ui/attachment.tsx
@@ -796,8 +796,7 @@ export const ComposerAttachments: FC<{
);
};
-// Not ComposerPrimitive.Attachments: its index keys remount every card after a removed one,
-// and each remount blanks its preview and decodes the image again.
+// Not ComposerPrimitive.Attachments: its index keys remount every card after a removal.
const ComposerAttachmentCardList: FC = () => {
const ids = useAuiState(
useShallow(({ composer }) =>
diff --git a/studio/frontend/src/components/assistant-ui/compaction-divider.tsx b/studio/frontend/src/components/assistant-ui/compaction-divider.tsx
index 0424b7b0a9e..242c65be8f5 100644
--- a/studio/frontend/src/components/assistant-ui/compaction-divider.tsx
+++ b/studio/frontend/src/components/assistant-ui/compaction-divider.tsx
@@ -96,8 +96,7 @@ const DividerRule: FC<{ children: ReactNode; className?: string }> = ({
<button
type="button"
data-slot="compaction-divider-label"
- // negative margins keep a large target from moving the rule.
- // positioning stops the reply above from covering the target.
+ // Negative margins keep the rule put; relative stops the reply covering the target.
className="relative -mx-2 -my-2.5 inline-flex shrink-0 cursor-default items-center gap-1.5 whitespace-nowrap rounded-full px-2 py-2.5 leading-none transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring"
>
<HugeiconsIcon icon={ArchiveIcon} className="size-3.5" aria-hidden={true} />
diff --git a/studio/frontend/src/components/assistant-ui/fence-highlight-queue.ts b/studio/frontend/src/components/assistant-ui/fence-highlight-queue.ts
index 552b236dcc5..cc7b3d4661a 100644
--- a/studio/frontend/src/components/assistant-ui/fence-highlight-queue.ts
+++ b/studio/frontend/src/components/assistant-ui/fence-highlight-queue.ts
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Highlighting swaps only a fence's own line nodes, so only a selection ending inside a fence
-// needs holding.
+// Highlight swaps only a fence's own lines, so only a selection ending in one needs holding.
export const selectionInFence = (
selection: Pick<Selection, "anchorNode" | "focusNode"> | null,
): boolean => {
diff --git a/studio/frontend/src/components/assistant-ui/markdown-table.tsx b/studio/frontend/src/components/assistant-ui/markdown-table.tsx
index ec949d5ffbc..453adffd4d1 100644
--- a/studio/frontend/src/components/assistant-ui/markdown-table.tsx
+++ b/studio/frontend/src/components/assistant-ui/markdown-table.tsx
@@ -29,9 +29,8 @@ import {
} from "streamdown";
import { ExpandArrowsIcon } from "@/lib/expand-icons";
-// Streamdown ships its own glyphs for the table controls; swap in ours so copy,
-// download and expand match the icons used everywhere else.
-// `strokeWidth` is dropped, not forwarded: SVG types it `string | number`, HugeiconsIcon wants a number.
+// Streamdown's table glyphs are swapped for ours so icons match elsewhere; `strokeWidth` is
+// dropped, as SVG types it string or number while HugeiconsIcon wants a number.
function streamdownIcon(icon: typeof Copy01Icon) {
return function StreamdownIcon({
size,
diff --git a/studio/frontend/src/components/assistant-ui/message-html-artifacts.tsx b/studio/frontend/src/components/assistant-ui/message-html-artifacts.tsx
index acd2d3fa560..97c91f7a6a8 100644
--- a/studio/frontend/src/components/assistant-ui/message-html-artifacts.tsx
+++ b/studio/frontend/src/components/assistant-ui/message-html-artifacts.tsx
@@ -3,12 +3,9 @@
"use client";
-// Once an assistant message finishes, append one browser card per fenced ```html
-// block in its text. No render_html tool call, no extra message. Defers to the
-// other paths to avoid duplicates: skips the message when a render_html tool
-// already rendered it, and skips full documents the in-place collapse handles.
-// React components (```jsx / ```tsx) get a card after the HTML ones; their code
-// stays in place, and nothing else renders them.
+// After an assistant message finishes, one browser card per fenced html block is appended, skipping
+// messages a render_html tool already rendered and full documents the in-place collapse handles;
+// React jsx and tsx blocks get a card after the HTML ones, code staying in place.
import {
memoOnArray,
@@ -49,9 +46,8 @@ export const MessageHtmlArtifacts: FC = () => {
const loadedIsDiffusion = useChatRuntimeStore(
(state) => state.loadedIsDiffusion,
);
- // Full docs already shown by the in-place collapse; excluded for diffusion,
- // which keeps its code inline instead. This picks which path renders a full
- // document, not whether fenced HTML renders at all.
+ // Full documents are already shown by the in-place collapse, except for diffusion (code stays
+ // inline there); this picks the path, not whether fenced HTML renders.
const collapsesFullDocs = collapseHtmlArtifacts && !loadedIsDiffusion;
const fences = useMemo(() => {
diff --git a/studio/frontend/src/components/assistant-ui/message-timing.tsx b/studio/frontend/src/components/assistant-ui/message-timing.tsx
index 4f971b4c691..33988b9d85f 100644
--- a/studio/frontend/src/components/assistant-ui/message-timing.tsx
+++ b/studio/frontend/src/components/assistant-ui/message-timing.tsx
@@ -83,8 +83,7 @@ export const MessageTiming: FC<{
draftN > 0 && typeof draftAccepted === "number" && Number.isFinite(draftAccepted)
? `${formatNumber(draftAccepted)} / ${formatNumber(draftN)} (${Math.round((draftAccepted / draftN) * 100)}%)`
: null;
- // `??` (not `||`) so an explicit cache_n=0 isn't replaced by a stale
- // contextUsage.cachedTokens from a prior turn.
+ // `??` not `||`: explicit cache_n=0 must not be replaced by stale contextUsage.cachedTokens.
const cacheHits =
st?.cache_n ?? custom?.contextUsage?.cachedTokens ?? 0;
const cacheWrites = custom?.contextUsage?.cacheWriteTokens ?? 0;
diff --git a/studio/frontend/src/components/assistant-ui/progressive-messages.tsx b/studio/frontend/src/components/assistant-ui/progressive-messages.tsx
index f2ebffb6516..5339af81449 100644
--- a/studio/frontend/src/components/assistant-ui/progressive-messages.tsx
+++ b/studio/frontend/src/components/assistant-ui/progressive-messages.tsx
@@ -123,15 +123,9 @@ function pickAnchorRow(viewport: HTMLElement): Element | null {
) {
return anchor;
}
- // Then descend to the fold. A row can be taller than the viewport (a long answer with images and code usually
- // is), so a reader partway through one has the row's top ABOVE them: a block earlier in that message growing
- // moves everything they see while the row's top stays put, and a whole-row anchor reports zero. The first
- // descendant reaching the fold does not. Bounded because that block is a few levels down, and this runs once
- // per re-pick, not per frame.
- // Known residual: if the fold lands inside a tall LEAF block (a paragraph with no element children) the descent
- // stops with its top above the reader, so lines reflowing inside it move what they see without moving the
- // block. Closing that needs a caret point at the fold, spelled differently on all three engines, costing a
- // Range and a rect every frame, and not itself stable across the reflow it would measure.
+ // Descends to the first descendant reaching the fold, since a whole-row anchor reports zero for a
+ // row taller than the viewport; capped at 8 levels, run once per re-pick. Residual: a tall leaf
+ // block can still reflow above the reader; a caret fix would cost a Range per frame.
for (let depth = 0; depth < 8; depth += 1) {
if (anchor.getBoundingClientRect().top >= fold) break;
let next: Element | null = null;
diff --git a/studio/frontend/src/components/assistant-ui/reasoning.tsx b/studio/frontend/src/components/assistant-ui/reasoning.tsx
index 96b96e73af1..f951934743e 100644
--- a/studio/frontend/src/components/assistant-ui/reasoning.tsx
+++ b/studio/frontend/src/components/assistant-ui/reasoning.tsx
@@ -728,8 +728,7 @@ const ReasoningGroupBlock = ({
if (!groupHasReasoning) {
return false;
}
- // The lead of a folded span keeps working through later thinking and blank text too,
- // until the answer.
+ // The lead of a folded span also takes later thinking and blank text until the answer.
for (let i = endIndex + 1; i < len; i += 1) {
const part = parts[i];
if (part?.type === "tool-call") continue;
diff --git a/studio/frontend/src/components/assistant-ui/row-notification-gate.ts b/studio/frontend/src/components/assistant-ui/row-notification-gate.ts
index c6784516ffa..6288f199c4a 100644
--- a/studio/frontend/src/components/assistant-ui/row-notification-gate.ts
+++ b/studio/frontend/src/components/assistant-ui/row-notification-gate.ts
@@ -93,8 +93,7 @@ function scopeState(client: AssistantClient, key: string): unknown {
return getState.call(methods);
}
-// Rebuilt on every repository write, hidden branches included, but not when only the store rebuilds
-// `thread.messages` (the first keystroke after a run does).
+// Per repository write, hidden branches too; not when only the store rebuilds thread.messages.
function repositoryRevision(client: AssistantClient): unknown {
const thread = (client as unknown as Record<string, unknown>).thread;
if (typeof thread !== "function") return UNKNOWN_REPOSITORY;
diff --git a/studio/frontend/src/components/assistant-ui/sandbox-files-view.tsx b/studio/frontend/src/components/assistant-ui/sandbox-files-view.tsx
index 89ac8e87c41..e25c02b4f6c 100644
--- a/studio/frontend/src/components/assistant-ui/sandbox-files-view.tsx
+++ b/studio/frontend/src/components/assistant-ui/sandbox-files-view.tsx
@@ -134,8 +134,7 @@ export function SandboxFiles({
}) {
if (!sessionId || files.length === 0) return null;
return (
- // No divider: the row sits outside the collapsible content, so on a collapsed card a rule
- // would separate the header from nothing.
+ // No divider: the row is outside the collapsible, so collapsed cards keep no stray rule.
<div className={cn("mt-2", className)}>
<SandboxFolderLabel
sessionId={sessionId}
diff --git a/studio/frontend/src/components/assistant-ui/stale-safe-scopes.tsx b/studio/frontend/src/components/assistant-ui/stale-safe-scopes.tsx
index 4fc316579c4..2e617eb6ca2 100644
--- a/studio/frontend/src/components/assistant-ui/stale-safe-scopes.tsx
+++ b/studio/frontend/src/components/assistant-ui/stale-safe-scopes.tsx
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// A thread switch swaps the store before React unmounts the outgoing rows, so a row re-rendering in
-// that window reads the incoming thread at its old index; assistant-ui 0.12 throws there (#10288).
-// Backports assistant-ui#5119, #5127 and #5948 for the scopes Studio renders.
+// Thread switches swap the store before React unmounts old rows, so a stale index throws in
+// assistant-ui 0.12 (#10288); backports assistant-ui#5119, #5127, #5948.
import type { MessageMethods, PartMethods } from "@assistant-ui/core/store";
import { AuiProvider, useAui, useAuiState } from "@assistant-ui/react";
diff --git a/studio/frontend/src/components/assistant-ui/thinking-fold.ts b/studio/frontend/src/components/assistant-ui/thinking-fold.ts
index d57dd557ef9..cad2bf64458 100644
--- a/studio/frontend/src/components/assistant-ui/thinking-fold.ts
+++ b/studio/frontend/src/components/assistant-ui/thinking-fold.ts
@@ -27,8 +27,7 @@ function belongsToRun(part: PartLike | undefined): boolean {
return type === "reasoning" || type === "tool-call" || isBlankTextPart(part);
}
-/** `[start, end)` of the run of thinking, tool calls and blank text around `index`, or null
- * when `index` is answer text. */
+/** `[start, end)` of the thinking, tool call or blank run around `index`; null on answer text. */
export function foldRun(
parts: readonly PartLike[],
index: number,
@@ -43,8 +42,7 @@ export function foldRun(
return { start, end };
}
-/** Last part of the first reasoning group in the run around `index`: the block that heads it.
- * Null when the run has no thinking, or `index` is not in a run. */
+/** Last part of the first reasoning group in the run around `index`; null when there is none. */
export function leadReasoningEnd(
parts: readonly PartLike[],
index: number,
diff --git a/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx b/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx
index 61e50041493..572226b4cbd 100644
--- a/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-confirmation-controls.tsx
@@ -154,9 +154,8 @@ export function ToolConfirmationControls({
showControls &&
pending === null &&
!((autoAllowed || chatFullAccess) && !failed);
- // The Chat route stays mounted under a dialog, so `keyboardReady` still says
- // yes while the request is hidden behind one. Answering a tool call the user
- // cannot see must not be reachable by accident, so both chords ask here, before the key is taken.
+ // keyboardReady stays true under a dialog, so the chords claim only while chat is uncovered;
+ // answering a tool call the user cannot see must never happen by accident.
const chatUncovered = () => !isSurfaceBackgrounded(COMPOSER_INPUT_SELECTOR);
useShortcut("approveToolRequest", () => void resolve("allow"), {
enabled: keyboardReady,
diff --git a/studio/frontend/src/components/assistant-ui/tool-group.tsx b/studio/frontend/src/components/assistant-ui/tool-group.tsx
index 35263a40965..b7037ef3572 100644
--- a/studio/frontend/src/components/assistant-ui/tool-group.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-group.tsx
@@ -168,8 +168,7 @@ function ToolGroupTrigger({
<CollapsibleTrigger
data-slot="tool-group-trigger"
className={cn(
- // Muted like the tool rows it summarises, so only the answer is at full foreground,
- // and it brightens on hover like the Thinking trigger above it.
+ // Muted like the tool rows it summarises, so only the answer is at full foreground.
"aui-tool-group-trigger group/trigger flex w-full cursor-pointer items-center gap-2 text-trace-foreground text-sm transition-colors hover:text-foreground",
"group-data-[variant=outline]/tool-group-root:px-4",
"group-data-[variant=muted]/tool-group-root:px-4",
@@ -308,8 +307,7 @@ const ToolGroupImpl: FC<
.some(
(part) =>
part.type === "tool-call" &&
- // Either scope: a first turn writes under the unresolved one for its whole
- // life, even after the autosave assigns the id (see useToolOutputFor).
+ // Either scope: a first turn writes under the unresolved scope for its whole life.
(Object.prototype.hasOwnProperty.call(
toolLiveOutput,
toolOutputKey(paneScope, part.toolCallId),
diff --git a/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx b/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx
index 612f7656aa7..912489aaa7e 100644
--- a/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx
+++ b/studio/frontend/src/components/assistant-ui/tool-ui-image-generation.tsx
@@ -315,8 +315,7 @@ const ImageGenerationToolUIImpl: ToolCallMessagePartComponent = ({
(name): name is string => typeof name === "string" && name.length > 0,
);
const errorText = toolErrorText(result);
- // Coerced for the same reason `prompt` is: these reach `.match`,
- // `.toLowerCase` and `Array.join`, all of which throw on a non-string.
+ // Coerced like `prompt`: .match, .toLowerCase and Array.join throw on a non-string.
const size = toolArgText(imageResult?.size);
const quality = toolArgText(imageResult?.quality);
const imageDimensions = parseImageSize(size);
diff --git a/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx b/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx
index 4530442b126..a8963b4b2fc 100644
--- a/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx
+++ b/studio/frontend/src/components/assistant-ui/use-intent-aware-autoscroll.tsx
@@ -47,12 +47,8 @@ type AutoScrollContextValue = {
/** Detach as if scrolled up: composer growth must not let observer pins shove the chat up. */
detachFromBottom: () => void;
/**
- * `deltaPx` of content was inserted ABOVE the viewport; shift by it so the
- * user keeps looking at the same thing. Progressive mounting (see
- * progressive-mount-controller) is the only caller and calls on EVERY
- * widening commit, zero included, since a zero correction still resyncs the
- * intent bookkeeping below. A method rather than a scrollTop write at the
- * inserting commit because this hook owns scrollTop.
+ * Called on every widening commit, zero included, since this hook owns scrollTop and resyncs
+ * intent.
*/
adjustForContentInsertedAbove: (deltaPx: number) => boolean;
notifyContentResized: () => void;
@@ -205,9 +201,8 @@ export function useIntentAwareAutoScroll(): {
el.toggleAttribute("data-aui-following", on);
};
- // Room to scroll upward. Guards wheel/touch detach: a gesture on a viewport with nothing
- // above can't express intent to leave the bottom and must not flip userDetachedRef, else
- // later streaming skips extendFollow and auto-follow stays dead for the session.
+ // Upward wheel/touch detaches only with room above, else auto-follow stays dead for the
+ // session.
const canScrollUp = (): boolean => el.scrollTop > 0;
// An inner scroller with room above consumes the upward delta, so it must not detach.
@@ -661,9 +656,8 @@ export function useIntentAwareAutoScroll(): {
el.addEventListener("pointerdown", onPointerDown, { passive: true });
el.ownerDocument.addEventListener("pointerup", onPointerUp, true);
el.ownerDocument.addEventListener("pointercancel", onPointerUp, true);
- // ResizeObserver covers window resizes. visualViewport.resize is the
- // only signal for iOS software-keyboard changes, where the visual
- // viewport shrinks without the element's clientHeight changing.
+ // visualViewport resize is the only signal for iOS keyboard changes, where clientHeight stays
+ // put.
window.visualViewport?.addEventListener("resize", onViewportResize);
const unsubscribePreferences = useChatPreferencesStore.subscribe(
diff --git a/studio/frontend/src/components/image-dropzone.tsx b/studio/frontend/src/components/image-dropzone.tsx
index 241baf539ba..c56947736b9 100644
--- a/studio/frontend/src/components/image-dropzone.tsx
+++ b/studio/frontend/src/components/image-dropzone.tsx
@@ -135,8 +135,7 @@ export function ImageDropzone({
[readFile],
);
- // Tauri suppresses the webview drop event, so desktop drops arrive as paths
- // that the native side registers and reads for this picker.
+ // Tauri suppresses the webview drop event, so desktop drops arrive as native paths.
const readNativePath = useCallback(
async (path: string | undefined) => {
const kind = classifyNativeImageDrop(path);
diff --git a/studio/frontend/src/components/load-anyway-dialog.tsx b/studio/frontend/src/components/load-anyway-dialog.tsx
index d8585dd1331..085745116b1 100644
--- a/studio/frontend/src/components/load-anyway-dialog.tsx
+++ b/studio/frontend/src/components/load-anyway-dialog.tsx
@@ -26,8 +26,7 @@ interface PendingRetry {
}
/**
- * Load anyway toast: the action only opens a confirmation; only Confirm retries the pick once with the
- * override. ``dismiss`` retires an open prompt when a newer pick or load begins.
+ * The toast action only opens a confirmation; only Confirm retries, and dismiss retires the prompt.
*/
export function useLoadAnywayPrompt(): {
offer: (message: string, retry: () => void) => void;
diff --git a/studio/frontend/src/components/nav-row-state.ts b/studio/frontend/src/components/nav-row-state.ts
index 0ac8331bfad..7d9bdd92c0d 100644
--- a/studio/frontend/src/components/nav-row-state.ts
+++ b/studio/frontend/src/components/nav-row-state.ts
@@ -11,10 +11,7 @@ export type NavRowState = {
pendingTooltip?: string;
};
-/**
- * A pending row stays enabled and spins rather than guessing a gray-out. Both render sites go
- * through here so they cannot drift.
- */
+/** A pending row stays enabled and spins rather than guessing a gray-out; both sites share it. */
export function resolveNavRowState(row: NavRowState): {
disabled?: boolean;
tooltip?: string;
diff --git a/studio/frontend/src/components/segmented-control.tsx b/studio/frontend/src/components/segmented-control.tsx
index 991032c5217..6df8d6c2b8f 100644
--- a/studio/frontend/src/components/segmented-control.tsx
+++ b/studio/frontend/src/components/segmented-control.tsx
@@ -18,8 +18,7 @@ interface SegmentedControlOption<T extends string> {
const HIDDEN = { display: "none" } as const;
-/** The pill's shadow, then the pill as a start cap, a middle strip and an
- * end cap, in the order segmented-pill-slide reads them. */
+/** Pieces in the order segmented-pill-slide reads them: shadow, start cap, strip, end cap. */
const SLIDE_PIECES = [
"left-0 origin-left rounded-full",
"left-0 rounded-l-full",
@@ -27,13 +26,10 @@ const SLIDE_PIECES = [
"right-0 rounded-r-full",
];
-/** The selected segment's pill. Render it inside the active (`relative`)
- * segment only, with a `group` id unique to the control: when the selection
- * moves, the new pill slides in from the old one's place on the compositor
- * (see segmented-pill-slide), or appears in place under reduced motion. It
- * sits at -z-10 in the track, so the track must isolate (`.hub-tab-toggle`
- * does) and the segments must not: a segment with its own stacking context
- * lets the sliding pill cover its neighbours' labels. */
+/**
+ * Render the pill only inside the active (relative) segment with a control-unique group id; the
+ * track must isolate (.hub-tab-toggle does) and segments must not, or the pill covers labels
+ */
export function SegmentedPill({
group,
className,
diff --git a/studio/frontend/src/components/segmented-pill-slide.ts b/studio/frontend/src/components/segmented-pill-slide.ts
index 872a88b6f9e..28424a5dae3 100644
--- a/studio/frontend/src/components/segmented-pill-slide.ts
+++ b/studio/frontend/src/components/segmented-pill-slide.ts
@@ -3,21 +3,9 @@
import { prefersReducedMotion } from "@/features/settings/stores/appearance-custom-store";
-// Slides a segmented control's selected pill from the old segment to the new one
-// without running script per frame or forcing layout during the click:
-// - geometry is read once per switch, in the first ResizeObserver callback for
-// the new pill's segment, after the browser has laid out the frame anyway.
-// Both the old and the new segment are measured then, so nothing is cached
-// that could go stale;
-// - the slide is transform-only Web Animations on both axes (tracks can wrap),
-// which every engine's compositor runs off the main thread. When the two
-// segments differ in width, the pill is drawn as two round caps and a middle
-// strip: the end cap moves and the strip stretches with scaleX, so the ends
-// stay round (a scaleX of the whole pill would squash them). The move and
-// the resize are then both transforms on one clock, so a busy main thread
-// (a list re-rendering after the click) cannot hold the width back while the
-// pill moves. A clip-path resize could: Chromium repaints it on the main thread.
-// At rest the pill paints itself and the caps, strip and shadow are hidden.
+// Transform-only Web Animations so the compositor runs the slide off the main thread (clip-path
+// resize would repaint there); geometry read once in the first ResizeObserver callback, with no
+// per-frame script or forced layout during the click
/** Spring the design system gives segmented controls (design.md, 2.5 Motion). */
const SPRING = { stiffness: 500, damping: 35, mass: 0.5 };
@@ -83,8 +71,7 @@ const EASING = HAS_LINEAR
).join(", ")}, 1)`
: `cubic-bezier(${FALLBACK.join(", ")})`;
-/** Progress of the curve the slide actually runs, so an interrupted slide
- * restarts from where its pill is drawn. */
+/** Progress of the curve the slide runs, so an interrupted slide restarts from its drawn pill. */
const CURVE = HAS_LINEAR ? SPRING_CURVE : bezierCurve();
function progressAt(ms: number): number {
@@ -151,15 +138,13 @@ function slide(
const [shadow, startCap, strip, endCap] = Array.from(
root.children,
) as HTMLElement[];
- // The caps are half circles. The strip runs between their flat sides and
- // tucks 1px under each, so no seam shows; any deeper and its square corners
- // would poke out past the curve. Every width involved must leave it room.
+ // The strip tucks 1px under each half-circle cap to hide the seam; any deeper and its square
+ // corners poke out, so every width involved must leave it room
const r = h / 2;
const inner = w - 2 * r + 2;
const resize =
endCap && Math.abs(dw) >= 0.5 && Math.min(w, w + dw) > 2 * r + 1;
- // Held until the cleanup below, so the pieces never show their rest state
- // between the end of the slide and the cleanup.
+ // Held until cleanup, so the pieces never show their rest state after the slide ends.
const timing = {
duration: SLIDE_MS,
easing: EASING,
@@ -172,11 +157,8 @@ function slide(
),
];
if (resize) {
- // The pill keeps its left end on the root's; the end cap moves by the
- // width change and the strip stretches to meet it. Only the strip scales,
- // and it has no round ends to squash. A shadow-only copy of the whole pill
- // stretches underneath, so the pieces need no shadow of their own; its
- // scale bends the shadow's ends a little, which the blur hides.
+ // Only the strip scales, the end cap moves, and a shadow-only copy underneath carries the
+ // shadow.
root.style.setProperty("background-color", "transparent", "important");
root.style.setProperty("box-shadow", "none", "important");
shadow.style.width = `${w}px`;
@@ -255,8 +237,7 @@ function place(group: string, root: HTMLElement, segment: HTMLElement) {
slide(root, to.w, to.h, dx, dy, dw);
}
-/** Track a mounted pill: once its segment has been laid out, slide it in from
- * the control's previous pill. Returns the cleanup. */
+/** Slide a mounted pill in from the previous one once laid out; returns the cleanup. */
export function watchSegmentedPill(group: string, root: HTMLElement) {
const segment = root.parentElement ?? root;
const observer = new ResizeObserver(() => {
diff --git a/studio/frontend/src/components/sidebar-edge-trigger.tsx b/studio/frontend/src/components/sidebar-edge-trigger.tsx
index 74bfe2332da..8e9492442f8 100644
--- a/studio/frontend/src/components/sidebar-edge-trigger.tsx
+++ b/studio/frontend/src/components/sidebar-edge-trigger.tsx
@@ -15,8 +15,7 @@ import { cn } from "@/lib/utils";
import { type ReactElement, useRef, useState } from "react";
/**
- * Draggable window edge for the zero-width desktop sidebar. On macOS a decorated window's resize
- * border takes presses in the first few pixels, so hover and keyboard are what work there.
+ * Sidebar drag edge; macOS's window resize border takes the presses, so only hover and keys work.
*/
export function SidebarEdgeTrigger({
className,
@@ -42,9 +41,8 @@ export function SidebarEdgeTrigger({
setWidth,
resetWidth,
} = useSidebarWidth();
- // A drag that reaches the minimum pins the sidebar part-way through, which
- // would unmount this: the handle would lose pointer capture and the width
- // would never commit. Hold on until the pointer is released.
+ // Holds the drag until release: reaching the minimum would pin the sidebar and unmount this
+ // handle.
const [holding, setHolding] = useState(false);
const release = () => setHolding(false);
diff --git a/studio/frontend/src/components/sidebar-navigation.ts b/studio/frontend/src/components/sidebar-navigation.ts
index 4e6297813c0..897887acc17 100644
--- a/studio/frontend/src/components/sidebar-navigation.ts
+++ b/studio/frontend/src/components/sidebar-navigation.ts
@@ -4,8 +4,7 @@
// Import-free so it is testable: app-sidebar.tsx pulls in the whole shell.
/**
- * Coalesces sidebar clicks: while the last pushed entry has not rendered, the next goes out as a
- * replace so a burst leaves one history entry.
+ * While the last push has not rendered, the next click replaces it, so a burst leaves one entry.
*/
export function createNavigationCoalescer<T>({
navigate,
diff --git a/studio/frontend/src/components/ui/button.tsx b/studio/frontend/src/components/ui/button.tsx
index d71ec36f9d2..42013446ec9 100644
--- a/studio/frontend/src/components/ui/button.tsx
+++ b/studio/frontend/src/components/ui/button.tsx
@@ -29,8 +29,7 @@ export const buttonVariants = cva(
"hover:bg-muted hover:text-foreground dark:hover:bg-muted/50 aria-expanded:bg-muted aria-expanded:text-foreground",
// Neutral grey at rest, unlike `secondary`, whose token carries a hue in some themes.
muted: "bg-muted text-foreground hover:bg-muted/80",
- // Rebinds --destructive on the button itself, so callers' own text-/bg-destructive
- // classes land on the same shade.
+ // Rebinds --destructive on the button so callers' destructive classes share its shade.
destructive:
"[--destructive:var(--destructive-button)] bg-destructive/10 hover:bg-destructive/15 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 text-destructive focus-visible:border-destructive/40",
link: "text-foreground underline-offset-4 hover:underline",
@@ -45,8 +44,7 @@ export const buttonVariants = cva(
"icon-xs": "size-6 [&_svg:not([class*='size-'])]:size-3",
"icon-sm": "size-8",
"icon-lg": "size-10",
- // Full-window screen actions (startup, update): taller than `lg`.
- // Height is left to the padding, so the label sets it.
+ // Screen actions (startup, update): taller than `lg`; height comes from the label.
hero: "h-auto rounded-full px-5 py-2.5",
},
},
diff --git a/studio/frontend/src/components/ui/popover.tsx b/studio/frontend/src/components/ui/popover.tsx
index 96d17db6d3b..55215259d8c 100644
--- a/studio/frontend/src/components/ui/popover.tsx
+++ b/studio/frontend/src/components/ui/popover.tsx
@@ -44,8 +44,7 @@ function PopoverContent({
}) {
const snappedRef = useSnappedPaddingRef(ref);
const inheritedGlow = useContext(DropdownGlowContext);
- // Inside a modal dialog the body scroll lock swallows wheel events on
- // body-portaled content; portal into the dialog instead (like Select).
+ // Modal body scroll lock swallows wheel on body-portaled content; portal into the dialog.
const dialogContainer = useDialogPortalContainer();
return (
<PopoverPrimitive.Portal
diff --git a/studio/frontend/src/components/ui/sonner.tsx b/studio/frontend/src/components/ui/sonner.tsx
index eb8bdc49147..146af9501b5 100644
--- a/studio/frontend/src/components/ui/sonner.tsx
+++ b/studio/frontend/src/components/ui/sonner.tsx
@@ -28,8 +28,7 @@ const handleToastPointerDownCapture = (
event.stopPropagation();
};
-// Sonner has no line count: tag toasts whose text runs past one line, so CSS can
-// centre a one-line toast's icon and top-align a longer one's.
+// Sonner has no line count, so multi-line toasts are tagged for CSS to place their icon.
function markMultilineToasts(scope: HTMLElement): () => void {
const sized = new ResizeObserver((entries) => {
for (const { target } of entries) {
@@ -132,9 +131,8 @@ const Toaster = ({ ...props }: ToasterProps) => {
"--normal-border": "transparent",
// Just above the compact-box tier; at --radius-xl a two-line toast reads as a capsule.
"--border-radius": "calc(var(--radius-lg) + 2px)",
- // Pin the close button inside the toast's top-right corner.
- // Sonner defaults to the left/outside edge, so keep the horizontal
- // override here and the top offset in index.css.
+ // Sonner defaults the close button to the outer edge; the horizontal override stays
+ // here.
"--toast-close-button-start": "auto",
"--toast-close-button-end": "12px",
"--toast-close-button-transform": "none",
diff --git a/studio/frontend/src/components/ui/tooltip-modal-layer.ts b/studio/frontend/src/components/ui/tooltip-modal-layer.ts
index 4e0214ef42a..edcf48c2ee9 100644
--- a/studio/frontend/src/components/ui/tooltip-modal-layer.ts
+++ b/studio/frontend/src/components/ui/tooltip-modal-layer.ts
@@ -2,8 +2,7 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
/**
- * Whether a tooltip trigger sits below the active modal. Radix writes inline pointer-events on
- * layers; the nearest ancestor with one owns the trigger. The trigger's own style is skipped.
+ * Whether a trigger sits below the active modal, judged by the nearest ancestor's pointer-events.
*/
export function isBlockedByActiveModal(element: HTMLElement): boolean {
for (let node = element.parentElement; node; node = node.parentElement) {
diff --git a/studio/frontend/src/components/ui/tooltip.tsx b/studio/frontend/src/components/ui/tooltip.tsx
index f5e5857125a..ce460570afe 100644
--- a/studio/frontend/src/components/ui/tooltip.tsx
+++ b/studio/frontend/src/components/ui/tooltip.tsx
@@ -133,10 +133,9 @@ function Tooltip({
setClickOpen((prev) => !prev);
}, []);
- // Drop what is open when a modal takes over, so closing the dialog does not
- // bring the tooltip back on its own. Owners of a controlled tooltip are told,
- // since their state (a `hovered` flag) never sees the pointerleave either.
- // Latch only a tooltip its owner held open: one already shut never sends another false.
+ // Closes an open tooltip when a modal takes over so it does not reappear on dialog close;
+ // controlled owners are told since they never see pointerleave, and only a tooltip its owner held
+ // open is latched, so a shut one never sends another false
const controlledOpenRef = useRef(controlledOpen);
controlledOpenRef.current = controlledOpen;
useEffect(() => {
diff --git a/studio/frontend/src/config/env.ts b/studio/frontend/src/config/env.ts
index d7487506c0a..e1c9a945158 100644
--- a/studio/frontend/src/config/env.ts
+++ b/studio/frontend/src/config/env.ts
@@ -337,9 +337,8 @@ async function readHealth(
? { chatOnly: previous.chatOnly, chatOnlyReason: null, chatOnlyDetail: null, chatOnlyHint: null }
: previous,
);
- // Cache only a server-reported platform. Unauthenticated responses fall
- // back to the browser platform, which can differ from the host (WSL,
- // SSH); keeping fetched=false retries once a token exists.
+ // Cache only server-reported platforms: browser fallbacks differ from the host, so retry
+ // until authed.
usePlatformStore.setState({
deviceType,
appleSilicon,
diff --git a/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx b/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx
index b092edbae95..2561e6bb207 100644
--- a/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx
+++ b/studio/frontend/src/features/api-monitor/components/api-model-load-controls.tsx
@@ -43,8 +43,7 @@ function loadErrorMessage(err: unknown, fallback: string): string | null {
return err instanceof Error ? err.message : fallback;
}
-// An uncached Hub pick downloads through the manager first, so the resident model keeps serving
-// the API until the download completes and the pick loads.
+// An uncached Hub pick downloads first, so the resident model keeps serving the API meanwhile.
async function startStagedDownload(
id: string,
meta: ModelSelectorChangeMeta | undefined,
diff --git a/studio/frontend/src/features/api-monitor/panel-placement.ts b/studio/frontend/src/features/api-monitor/panel-placement.ts
index 325c9b068da..d2c4693bbc4 100644
--- a/studio/frontend/src/features/api-monitor/panel-placement.ts
+++ b/studio/frontend/src/features/api-monitor/panel-placement.ts
@@ -35,8 +35,7 @@ export const PANEL_GAP = 8;
export const PANEL_TOP_MARGIN = 64;
/**
- * `clearRank` picks among free spots; `refugeRank` among covered ones, where right-hand corners
- * are worst because both panels keep their close button and resize grip there.
+ * clearRank orders free spots; refugeRank orders covered ones, where right-hand corners rank worst.
*/
interface Candidate {
anchor: PanelAnchor;
diff --git a/studio/frontend/src/features/api-monitor/reload-last-model.ts b/studio/frontend/src/features/api-monitor/reload-last-model.ts
index da8652a665c..26d9cb7a80a 100644
--- a/studio/frontend/src/features/api-monitor/reload-last-model.ts
+++ b/studio/frontend/src/features/api-monitor/reload-last-model.ts
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Reads the durable last-local-load record, not the monitor ring buffer: that one is bounded,
-// clearable and can be disabled.
+// Reads the durable last-local-load record, not the bounded, clearable monitor ring buffer.
export type LastLoadRecord = {
id: string;
diff --git a/studio/frontend/src/features/browser/agent/gate.ts b/studio/frontend/src/features/browser/agent/gate.ts
index 5e0b2c9563d..bc009496c55 100644
--- a/studio/frontend/src/features/browser/agent/gate.ts
+++ b/studio/frontend/src/features/browser/agent/gate.ts
@@ -217,9 +217,8 @@ export function gateElement(
// Enter in a field presses the form's default button: its words count as a click on it would.
const label = action === "submit" && info.submitter ? info.submitter : info.name;
const consequential = (info.role === "link" ? CONSEQUENTIAL_LINK : CONSEQUENTIAL).test(label) || LOCALIZED.test(label);
- // Selecting a checkbox, radio or switch is a click on it.
- // A select is a click: on a checkbox, its name; on a dropdown, the option chosen (the executor
- // passes it as the name), since a page can act on the change event.
+ // Selecting a checkbox, radio or switch is a click on it; a select is a click too: on a checkbox
+ // its name, on a dropdown the chosen option (passed as the name), since a page can act on change.
const clicks = action === "click" || submits || action === "select";
if (clicks && consequential) {
return { kind: "ask", ask: "click", host, name: clip(label), prompt: `Click “${clip(label)}” on ${host}?`, detail: describe(info) };
diff --git a/studio/frontend/src/features/browser/agent/page-agent.ts b/studio/frontend/src/features/browser/agent/page-agent.ts
index 6818c060689..fce7216f63e 100644
--- a/studio/frontend/src/features/browser/agent/page-agent.ts
+++ b/studio/frontend/src/features/browser/agent/page-agent.ts
@@ -586,9 +586,8 @@ export function installPageAgent(): PageAgent {
position: "absolute", left: "-14px", top: "-14px", width: "28px", height: "28px", "box-sizing": "border-box",
"border-radius": "50%", border: "2px solid", opacity: "0",
});
- // Hugeicons cursor-02, its corners rounded further by a round-joined stroke of the fill (white
- // outline drawn wider underneath), then scaled back to size about its tip at (3, 3). The rounded
- // tip ends up 1.25px short of (0, 0), hence the offset.
+ // Hugeicons cursor-02 with corners rounded by a round-joined fill stroke, scaled back about
+ // its tip at (3, 3); the rounded tip lands 1.25px short of (0, 0), hence the offset.
const arrow = styled(document.createElementNS(SVG, "svg"), {
position: "absolute", left: "-1.25px", top: "-1.25px", width: "24px", height: "24px", overflow: "visible",
});
@@ -727,9 +726,8 @@ export function installPageAgent(): PageAgent {
const describe = (ref: string, value?: unknown, point?: Point | null): Record<string, unknown> => {
const found = point ? elementAt(point) : ref ? lookup(ref) : (document.activeElement ?? document.body);
- // A click on text inside a button or label reaches that control (a label's being its field or
- // button), which may submit.
- // A point lands on whatever is drawn, often an icon inside a control: gate the control.
+ // A click on text inside a button or label reaches that control (a label being its field or
+ // button), which may submit; a point lands on whatever is drawn, so gate the control.
const control = point ? (lineage(found).find((node) => roleOf(node) !== null) ?? found) : found;
const holder = control.closest("button, label") ?? control;
const el = holder instanceof HTMLLabelElement && holder.control ? holder.control : holder;
@@ -1081,10 +1079,9 @@ export function installPageAgent(): PageAgent {
return down;
};
- // The agent works only in its own tab: a form or link aimed at a new tab (target, formtarget)
- // would be dropped by the panel, which opens tabs only on a real user click, while the model hears
- // it went. The target is read after the event, by the browser or by the proxy shell's deferred
- // setTimeout, so it points here for the action and is put back on a later timer.
+ // The agent works only in its own tab: a target or formtarget aimed at a new tab would be dropped
+ // by the panel (tabs open only on a real click); the target is read after the event, so it is
+ // repointed for the action and restored on a later timer.
const inOwnTab = <T>(act: () => T): T => {
const restore: Array<() => void> = [];
const point = (el: unknown, name: string) => {
diff --git a/studio/frontend/src/features/browser/native-view.ts b/studio/frontend/src/features/browser/native-view.ts
index 9cd996971e6..29b7ade88b0 100644
--- a/studio/frontend/src/features/browser/native-view.ts
+++ b/studio/frontend/src/features/browser/native-view.ts
@@ -570,10 +570,9 @@ let masked: HTMLElement[] = [];
let holeSignature = "";
let holeTab: string | null = null;
let holeBounds: Bounds | null = null;
-// The panel around the page. A split drag pins the page at its old width, so while the panel
-// shrinks the page view overflows the handle. Resizing the view every frame would relayout the page
-// every frame, which the pin is there to avoid; on a layered page the app draws over it instead,
-// by cutting the hole no wider than the panel.
+// A split drag pins the page at its old width, so as the panel shrinks the view overflows the
+// handle; resizing it every frame would relayout the page, so on a layered page the app draws over
+// it, cutting the hole no wider than the panel.
let holeClip: DOMRect | null = null;
function paints(computed: CSSStyleDeclaration): boolean {
@@ -593,10 +592,9 @@ function openHole(tabId: string, bounds: Bounds): void {
if (!markHole() && moved) placeHole();
}
-// Per holed node, not the root: the vars don't inherit, so a move restyles only those nodes.
-// Under the desktop app's interface zoom (the webview's page zoom), WebKit scales a fixed
-// background's lengths by the zoom once more than the layout they were read from: undone here, or
-// a zoomed-out app covers the right and bottom of the page.
+// Set per holed node, not the root, since the vars do not inherit; under the app's interface zoom
+// WebKit scales fixed-background lengths by that zoom again, so it is undone here or a zoomed-out
+// app covers the right and bottom of the page.
function placeHole(): void {
if (!holeBounds) return;
const zoom = getAppliedInterfaceZoom() || 1;
diff --git a/studio/frontend/src/features/chat/api/chat-adapter.ts b/studio/frontend/src/features/chat/api/chat-adapter.ts
index 9e5dced5e2c..d22fff1e0e1 100644
--- a/studio/frontend/src/features/chat/api/chat-adapter.ts
+++ b/studio/frontend/src/features/chat/api/chat-adapter.ts
@@ -2079,12 +2079,11 @@ export function findLatestUserVideoBase64(
return undefined;
}
-/** The MCP image bound applied to the run's own tool results, BEFORE they are
- * serialized. Bounding the OpenAI history afterwards meant every result's image
- * array was stringified into an envelope on the main thread and then parsed again
- * to be cut or dropped -- on every send, for pictures the request would not carry.
- * A result that keeps no picture becomes its plain text, which is what the
- * serializer emits for a stripped envelope. */
+/**
+ * MCP image bound applied to the run's tool results before serialization; bounding afterwards
+ * stringified and re-parsed every image array on each send, for pictures the request would not
+ * carry; a result with no picture becomes plain text.
+ */
function boundMcpImageResults(
messages: RunMessages,
{ readsImages, localMarkers }: { readsImages: boolean; localMarkers: boolean },
diff --git a/studio/frontend/src/features/chat/api/durable-gate.ts b/studio/frontend/src/features/chat/api/durable-gate.ts
index 47592b17e51..2ab08cc8340 100644
--- a/studio/frontend/src/features/chat/api/durable-gate.ts
+++ b/studio/frontend/src/features/chat/api/durable-gate.ts
@@ -2,14 +2,9 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
/**
- * Tools the BROWSER has to execute itself, so a turn that uses one genuinely cannot proceed once the tab is gone
- * and must stay on the subscriber-owned (cancel-on-disconnect) stream.
- *
- * Every other tool Studio runs for a local model - web_search, web_fetch, python, terminal, edit_file, render_html,
- * image_generation, MCP - is executed by the SERVER and streams as chunk events, so it is durable like plain text.
- * The browser tools are the exception: they drive this tab's browser panel. Add a name here only if a tool truly
- * needs a live tab. Spelled out rather than imported from features/browser/agent/tools.ts, which the barrel cycle
- * would leave uninitialized here; tests/browser-agent-gate.test.ts keeps the two lists equal.
+ * Browser-executed tools need this tab alive, so a turn using one stays on the subscriber-owned
+ * stream; server-run tools stream durably. Spelled out to avoid a barrel-cycle import of
+ * features/browser/agent/tools.ts; tests/browser-agent-gate.test.ts keeps them equal.
*/
export const BROWSER_EXECUTED_TOOLS: ReadonlySet<string> = new Set<string>([
"browser_navigate",
diff --git a/studio/frontend/src/features/chat/components/edit-project-dialog.tsx b/studio/frontend/src/features/chat/components/edit-project-dialog.tsx
index 1963913d46e..7ebb0a912a1 100644
--- a/studio/frontend/src/features/chat/components/edit-project-dialog.tsx
+++ b/studio/frontend/src/features/chat/components/edit-project-dialog.tsx
@@ -153,9 +153,8 @@ export function EditProjectDialog({
<DialogContent
className="corner-squircle dialog-soft-surface grid-cols-[minmax(0,1fr)] gap-5 sm:max-w-xl"
{...nameImeHandlers}
- // Enter saves from the name field, which a multi-line instructions box cannot do; the
- // chord saves from either. The menus and confirmations inside portal out of here, so
- // their own keys never reach this.
+ // Enter saves from the name field, which a multi-line instructions box cannot do, and the
+ // chord saves from either; portaled menus and confirmations keep their keys out of here.
onKeyDown={(e) => {
if (
imeOwnsInputKeydown(e, nameImeRef.current, {
diff --git a/studio/frontend/src/features/chat/lib/context-usage-bar-state.ts b/studio/frontend/src/features/chat/lib/context-usage-bar-state.ts
index a89227bdbd3..4148f52bb91 100644
--- a/studio/frontend/src/features/chat/lib/context-usage-bar-state.ts
+++ b/studio/frontend/src/features/chat/lib/context-usage-bar-state.ts
@@ -71,13 +71,9 @@ export function contextUsageRows(
}
/**
- * Which limit warning the tooltip carries, if any.
- *
- * llama.cpp stops generating at the window, so its advice is to raise the limit before
- * hitting it. MLX generates straight past instead, so the same wording would promise a
- * stop that never comes -- and once a conversation is over the window there is something
- * different to say about it. Read from the unclamped ratio: the reported percent caps at
- * 100%, which is exactly the state being reported on.
+ * Which limit warning the tooltip carries: llama.cpp stops at the window, so its advice is to raise
+ * the limit first; MLX runs past it, so no stop is promised, and an over-window conversation gets
+ * other wording; read the unclamped ratio, since the reported percent caps at 100%.
*/
export type ContextLimitAdvice =
| "none"
diff --git a/studio/frontend/src/features/chat/utils/auto-compaction.ts b/studio/frontend/src/features/chat/utils/auto-compaction.ts
index 2fc620dec0a..7793f2e53c7 100644
--- a/studio/frontend/src/features/chat/utils/auto-compaction.ts
+++ b/studio/frontend/src/features/chat/utils/auto-compaction.ts
@@ -1,12 +1,10 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-/** Local GGUF, MLX and managed engine auto-compaction. On or off; how it compacts is the server's call.
- *
- * Studio used to offer the policy as a setting, but the choice needed the reader to know what a
- * checkpoint epoch and a rolling window were before it meant anything, and both sides of it were
- * already the server's to configure. It now always follows the server, which is what the setting
- * shipped as anyway (UNSLOTH_CONTEXT_POLICY, default "checkpoint"). */
+/**
+ * Local GGUF, MLX and managed engine auto-compaction is on or off only; the server chooses how it
+ * compacts (UNSLOTH_CONTEXT_POLICY, default "checkpoint").
+ */
export const DEFAULT_AUTO_COMPACT_ENABLED = true;
diff --git a/studio/frontend/src/features/chat/utils/keep-running-when-tab-closed.ts b/studio/frontend/src/features/chat/utils/keep-running-when-tab-closed.ts
index ce58dc8b4ac..73249bc0903 100644
--- a/studio/frontend/src/features/chat/utils/keep-running-when-tab-closed.ts
+++ b/studio/frontend/src/features/chat/utils/keep-running-when-tab-closed.ts
@@ -5,11 +5,9 @@
export const DEFAULT_KEEP_RUNNING_WHEN_TAB_CLOSED = true;
/**
- * What a durable chat or Deep Research run is admitted with for "Keep running after the tab closes".
- *
- * Off asks the server to stop the run once no tab has followed it for a while (backend
- * state/unattended_runs.py), so a reload or a second tab still keeps it. On sends nothing, which
- * keeps admission exactly what it was before the setting existed.
+ * Run admission fields for the keep-running setting: off sets stopWhenUnattended so the server
+ * stops the run once no tab has followed it for a while; on sends nothing (backend
+ * state/unattended_runs.py).
*/
export function tabCloseRunFields(keepRunningWhenTabClosed: boolean): {
stopWhenUnattended?: true;
diff --git a/studio/frontend/src/features/chat/utils/studio-backup-import.ts b/studio/frontend/src/features/chat/utils/studio-backup-import.ts
index 09311849df6..6d59be151f3 100644
--- a/studio/frontend/src/features/chat/utils/studio-backup-import.ts
+++ b/studio/frontend/src/features/chat/utils/studio-backup-import.ts
@@ -27,17 +27,9 @@ const SERVER_MANAGED_LINK_KEYS = new Set<string>([
"generationSettled",
]);
-// A backup is a file that arrived from somewhere, so its settings snapshot is
-// untrusted input, not a saved preference. These are the only keys a restored chat
-// carries. Everything else in ThreadScopedSettings either turns a capability on
-// (toolsEnabled, codeToolsEnabled, mcpEnabledForChat, webFetchToolsEnabled,
-// deepResearchEnabled, the rag* group), silences the approval
-// prompt (permissionMode "off" sets confirm_tool_calls false and never pauses) or
-// injects text the sender chose (systemPrompt, systemVariables). Restoring those
-// together lets a sent backup arm a chat that runs tools unattended under the
-// importer's account on their first message.
-// An ALLOWLIST, so a setting added later is dropped until someone decides it is
-// safe to restore, rather than shipping restorable by default.
+// Backups are untrusted input, so only allowlisted keys are restored; capability toggles
+// (toolsEnabled, the rag group), approval silencing (permissionMode off) or sender-chosen prompts
+// would let a backup arm unattended tool runs. New keys stay dropped until vetted.
const RESTORABLE_SETTING_KEYS = new Set<string>([
"temperature",
"topP",
diff --git a/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx b/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx
index 19fddc2516b..347d401d9f9 100644
--- a/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx
+++ b/studio/frontend/src/features/hub/download-manager/download-manager-panel.tsx
@@ -99,10 +99,9 @@ function repoLabel(repoId: string): string {
function isRequiredAssetJob(job: RowSubject): boolean {
if (!job.variant?.startsWith("@")) return false;
- // The staging page tagged the entry it picked, which is the only reliable answer: a checkpoint
- // can be a curated single .safetensors and companion repos carry .safetensors too, so the
- // extension decides nothing. The old guess stays for jobs persisted before the flag existed,
- // which would otherwise change label mid-download after a restart.
+ // The staging page's checkpoint tag is the only reliable answer, since the extension decides
+ // nothing and companion repos carry .safetensors too; the old guess stays for jobs persisted
+ // before the flag, so labels do not change after a restart.
const isModelFile =
job.checkpoint ??
job.scopedFiles?.some((file) => file.toLowerCase().endsWith(".gguf"));
diff --git a/studio/frontend/src/features/igpu-carveout/igpu-carveout-toast.ts b/studio/frontend/src/features/igpu-carveout/igpu-carveout-toast.ts
index a61130b467d..3bc19c0c4d8 100644
--- a/studio/frontend/src/features/igpu-carveout/igpu-carveout-toast.ts
+++ b/studio/frontend/src/features/igpu-carveout/igpu-carveout-toast.ts
@@ -13,12 +13,11 @@ export const IGPU_CARVEOUT_NOTICE_DURATION_MS = 12000;
export const IGPU_CARVEOUT_NOTICE_TITLE = "This model could run faster";
-/** The action, a neutral wash and right-aligned rather than sonner's filled default.
- *
- * A solid button reads as the thing to do, and the thing to do here is nothing. And
- * the shared toast CSS puts an action at `justify-self: start`, which under six lines
- * of description floats it mid-toast, aligned to neither edge. Overridden here rather
- * than in that shared rule because every other toast's action IS the thing to do. */
+/**
+ * Neutral wash, right-aligned, not sonner's filled default: a solid button reads as the thing to
+ * do, and here that is nothing; shared toast CSS floats actions mid-toast, so it is overridden here
+ * rather than there, because other toasts' actions are the thing to do.
+ */
export const IGPU_CARVEOUT_ACTION_CLASS =
"!justify-self-end !h-[calc(26px*var(--ui-space-scale,1))] !border-0 !px-3 !font-medium !text-foreground " +
"!bg-[rgb(0_0_0_/_calc(0.06*var(--contrast-wash-gain,1)))] hover:!bg-[rgb(0_0_0_/_calc(0.09*var(--contrast-wash-gain,1)))] dark:!bg-[rgb(255_255_255_/_calc(0.06*var(--contrast-wash-gain,1)))] dark:hover:!bg-[rgb(255_255_255_/_calc(0.1*var(--contrast-wash-gain,1)))]";
diff --git a/studio/frontend/src/features/images/api.ts b/studio/frontend/src/features/images/api.ts
index d5d5065c29d..d816cc9f6bb 100644
--- a/studio/frontend/src/features/images/api.ts
+++ b/studio/frontend/src/features/images/api.ts
@@ -535,9 +535,8 @@ export async function generateDiffusionImage(
}
if (!response.ok && RESPONSE_LOST_STATUSES.has(response.status)) {
const detail = await readFastApiError(response);
- // A proxy answers with HTML (or nothing); the app answers with JSON. Only the former means the request may still
- // be running: settling an application error would poll for a generation that never started and hide the reason
- // the backend gave.
+ // Only a proxy's HTML or empty reply means the generation may still be running; a JSON
+ // application error is thrown with the backend's reason rather than polled for.
if ((response.headers.get("content-type") || "").toLowerCase().includes("application/json")) {
throw new Error(detail);
}
diff --git a/studio/frontend/src/features/images/compare/compare-values.ts b/studio/frontend/src/features/images/compare/compare-values.ts
index 621e04d1fa4..9b03a05ec4c 100644
--- a/studio/frontend/src/features/images/compare/compare-values.ts
+++ b/studio/frontend/src/features/images/compare/compare-values.ts
@@ -1,12 +1,11 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-/** Axis value syntax of AUTOMATIC1111's X/Y/Z plot (scripts/xyz_grid.py, process_axis):
- * - a comma (or newline) separated list, CSV quoting allowed: `euler, "a, b", dpmpp_2m`
- * - an integer or decimal range `1-5`, with a step `1-9 (+2)` or `10-1 (-3)`
- * - a range with a count `1-10 [4]`, evenly spaced (numpy.linspace), truncated for integer axes
- * Two deliberate differences: a descending range keeps its end (`5-1 (-1)` is 5..1, A1111 stops at 3), and a
- * decimal step may omit its sign (`0-1 (0.25)`). */
+/**
+ * A1111 X/Y/Z axis syntax: comma or newline lists with CSV quoting, ranges like 1-5, steps like 1-9
+ * (+2), counts like 1-10 [4] (evenly spaced, truncated for ints); a descending range keeps its end
+ * (5-1 (-1) is 5..1, A1111 stops at 3) and a decimal step may omit its sign.
+ */
export type AxisValueType = "int" | "float" | "str";
diff --git a/studio/frontend/src/features/loaded-models/eject-chat-model.ts b/studio/frontend/src/features/loaded-models/eject-chat-model.ts
index cdbfdc9803f..feb2a6d6dd7 100644
--- a/studio/frontend/src/features/loaded-models/eject-chat-model.ts
+++ b/studio/frontend/src/features/loaded-models/eject-chat-model.ts
@@ -55,9 +55,8 @@ export async function ejectChatModel(
// what the runtime really holds before calling the row somebody else's.
const holdsTarget = (names: string[] | undefined) =>
names?.some((name) => deps.matches(target, name)) ?? false;
- // Re-read even for a cached row: another tab may have evicted it since the card polled, and
- // unloading a name nobody holds would still stop the active model's queues. A failed read
- // keeps the row's own word, as before.
+ // Re-read even for a cached row, since another tab may have evicted it; unloading a name nobody
+ // holds would still stop the active model's queues; a failed read keeps the row's own word.
const cachedNow = await deps.readCached?.().catch(() => undefined);
if (cachedNow === undefined ? deps.cachedRow : holdsTarget(cachedNow)) {
// A cached row is never the active model, so the scoped read can never
diff --git a/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx b/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx
index eb92974b2c6..5e96091bcc6 100644
--- a/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx
+++ b/studio/frontend/src/features/loaded-models/loaded-models-indicator.tsx
@@ -249,11 +249,9 @@ export function LoadedModelsIndicator({
const dismissed = useLoadedModelsDismissed();
const reachable = canShowIndicator(pathname);
const enabled = showIndicator && !dismissed && reachable;
- // Dismissal is not part of this: a card the user closed must still hear the
- // load that brings it back. Reachability is, because it carries the auth gate
- // -- tracking on /login polls four protected endpoints every 5s, and each 401
- // runs authFetch's refresh-then-redirect ladder against a session that does
- // not exist yet.
+ // Dismissal is not part of this (a closed card must still hear the load that brings it back), but
+ // reachability is: tracking on /login polls four protected endpoints every 5s before any session
+ // exists, and each 401 runs authFetch's refresh-then-redirect ladder.
const { entries, polledEntries, ejecting, heldByOther, eject } =
useLoadedModels(enabled, showIndicator && reachable);
const [collapsed, setCollapsed] = usePersistedToggle(COLLAPSED_KEY);
diff --git a/studio/frontend/src/features/loaded-models/use-drag-position.ts b/studio/frontend/src/features/loaded-models/use-drag-position.ts
index 0665330c92b..571dc427546 100644
--- a/studio/frontend/src/features/loaded-models/use-drag-position.ts
+++ b/studio/frontend/src/features/loaded-models/use-drag-position.ts
@@ -154,10 +154,9 @@ export function useDragPosition(storageKey: string): UseDragPosition {
);
}, []);
- // A window that shrank, or a panel that grew when expanded, would otherwise strand it off screen
- // with nothing able to bring it back. Deliberately not keyed on `position`: it used to be, so
- // every frame of a drag tore the observer down and built a new one, and observing re-measures,
- // which forced a synchronous layout each time. reclamp returns the same object when unchanged.
+ // A shrunk window or a grown panel would strand it off screen; deliberately not keyed on
+ // position, since keying on it tore down and rebuilt the observer every drag frame; reclamp
+ // returns the same object when unchanged.
useEffect(() => {
if (!panelEl) return;
const measure = () => {
diff --git a/studio/frontend/src/features/model-picker/components/model-config-page.tsx b/studio/frontend/src/features/model-picker/components/model-config-page.tsx
index e0b8361da87..c0081fe697d 100644
--- a/studio/frontend/src/features/model-picker/components/model-config-page.tsx
+++ b/studio/frontend/src/features/model-picker/components/model-config-page.tsx
@@ -3336,10 +3336,9 @@ export function ModelConfigPage({
nBatch: runtimeConfig.nBatch,
nUbatch: runtimeConfig.nUbatch,
ctxCheckpoints: runtimeConfig.ctxCheckpoints ?? null,
- // The same substitution applyPerModelConfigToRuntime makes at load: a model with no per-model
- // override sends null, which the backend reads as Auto, while the selector has been showing
- // the global fallback. With the global Off and an 11 GB DSpark sidecar in the repo, the row
- // charged the sidecar for a load that disables it.
+ // Same substitution as applyPerModelConfigToRuntime: no per-model override sends null
+ // (read as Auto) while the selector shows the global fallback, so a global Off row
+ // charged an 11 GB DSpark sidecar.
speculativeType: resolveSpeculativeType(
runtimeConfig.speculativeType,
speculativeFallback,
@@ -3752,11 +3751,10 @@ export function ModelConfigPage({
: forgets
? deletePerModelConfig(configId, target.ggufVariant)
: true;
- // Mirror to the server so an API load gets these settings, not app defaults. Best-effort, and
- // skipped when the localStorage write failed or the two would permanently disagree. Gated on
- // auto-switch reach, not GGUF-ness: the resolver skips a materialized Ollama link, and a
- // native-path lease is the same.
- // A forget also drops the local records for every other spelling the server reports clearing.
+ // Best-effort mirror for API loads, skipped if the localStorage write failed (they would
+ // disagree); gated on auto-switch reach, not GGUF-ness, since the resolver skips materialized
+ // Ollama links and native-path leases; a forget also clears local records for every other
+ // spelling the server reports.
if (
saved &&
(keep || forgets) &&
diff --git a/studio/frontend/src/features/profile/api/profile-stats.ts b/studio/frontend/src/features/profile/api/profile-stats.ts
index 19dc7dfff37..e4cc2c22bf6 100644
--- a/studio/frontend/src/features/profile/api/profile-stats.ts
+++ b/studio/frontend/src/features/profile/api/profile-stats.ts
@@ -91,10 +91,9 @@ export type ProfileStats = {
};
};
-// Bucket days and hours in this browser's timezone, which is not the server's
-// when Unsloth is reached over the network. The IANA name is what gives each
-// historical date its own daylight-saving offset; the current offset only
-// covers callers whose host cannot resolve the name.
+// Bucket days and hours in this browser's timezone, not the server's when Unsloth is reached over
+// the network; the IANA name gives each historical date its own DST offset; the current offset only
+// covers hosts that cannot resolve the name.
function timezoneQuery(): URLSearchParams {
return new URLSearchParams({
tz_offset_minutes: String(new Date().getTimezoneOffset()),
diff --git a/studio/frontend/src/features/profile/utils/stats-format.ts b/studio/frontend/src/features/profile/utils/stats-format.ts
index 3102fd53940..9692f303926 100644
--- a/studio/frontend/src/features/profile/utils/stats-format.ts
+++ b/studio/frontend/src/features/profile/utils/stats-format.ts
@@ -44,11 +44,9 @@ function hasCompactUnit(locale: Locale, value: number): boolean {
/** One decimal below 100 of a unit; zero digits above it also avoids "1000K". */
export function formatCompactNumber(value: number, locale: Locale): string {
if (!Number.isFinite(value)) return "0";
- // Below the locale's first compact unit there is no unit to be a fraction OF, and these
- // are whole things: averageTokensPerChat is the one fractional caller, and "12.5 tokens"
- // reads as false precision where the pre-localization code said 13. Asked of Intl (is there
- // a `compact` part?) rather than a hardcoded 1000, because the first unit is per-locale:
- // en and hi compact at 1K, ja and de not until 万 and Mio.
+ // Below a locale's first compact unit values stay whole (12.5 tokens reads as false precision;
+ // averageTokensPerChat is the one fractional caller); compaction is asked of Intl, not hardcoded
+ // at 1000, since en and hi compact at 1K while ja and de wait for 万 and Mio.
if (!hasCompactUnit(locale, value))
return compactFormatter(locale, 0).format(value);
return compactInteger(locale, value) < 100
@@ -513,9 +511,8 @@ export function activitySummaryForMode(
export type WeekChartPoint = { week: string; tokens: number };
/**
- * One chart point per visible week, keyed by its first shown day. Weekly
- * series carry the week total on every day and cumulative ones only grow, so
- * the week's largest value is its total or its end-of-week running total.
+ * One point per visible week, keyed by its first shown day; the week's largest value is its total
+ * for weekly series or its end-of-week running total for cumulative ones.
*/
export function weekChartPoints(
grid: Array<Array<{ day: { date: string } | null; value: number }>>,
diff --git a/studio/frontend/src/features/rag/components/project-sources-panel.tsx b/studio/frontend/src/features/rag/components/project-sources-panel.tsx
index d2e8b1359fe..8a1c5c1c1ba 100644
--- a/studio/frontend/src/features/rag/components/project-sources-panel.tsx
+++ b/studio/frontend/src/features/rag/components/project-sources-panel.tsx
@@ -53,10 +53,9 @@ export function ProjectSourcesPanel({ projectId }: { projectId: string }) {
canRetry,
} = useRagDocuments({ type: "project", projectId }, lister);
- // Invalidate the sources probe before each mutation so a chat sent mid-upload
- // cannot cache "no sources" for the probe's TTL, and announce after it, which
- // is the half other instances and other tabs listen for. Announcing before
- // would refetch and resurrect the row this panel has already dropped.
+ // Invalidate the sources probe before each mutation so a mid-upload chat cannot cache no sources
+ // for its TTL; announce after, since other tabs listen and a refetch before would resurrect a
+ // dropped row.
const uploadNow = useCallback(
(items: RagUploadItem[]) => {
if (items.length === 0) return;
diff --git a/studio/frontend/src/features/recipe-studio/dialogs/seed/unstructured-drop-zone.tsx b/studio/frontend/src/features/recipe-studio/dialogs/seed/unstructured-drop-zone.tsx
index 20386c713df..9490aa341f3 100644
--- a/studio/frontend/src/features/recipe-studio/dialogs/seed/unstructured-drop-zone.tsx
+++ b/studio/frontend/src/features/recipe-studio/dialogs/seed/unstructured-drop-zone.tsx
@@ -239,9 +239,8 @@ export function UnstructuredDropZone({
return (
<div className="space-y-2">
<div
- // Stays hit-testable while disabled: pointer-events-none hides it from
- // elementFromPoint, so a native drop misses this target and falls
- // through to the window instead of saying the block is busy.
+ // Stays hit-testable while disabled: pointer-events-none would hide it from
+ // elementFromPoint, so a native drop falls through to the window instead of reporting busy.
className={`nodrag flex flex-col items-center justify-center rounded-xl border-2 border-dashed px-4 py-6 text-center transition-colors ${
isDragOver
? "border-ring-strong bg-wash-5"
diff --git a/studio/frontend/src/features/settings/api/coding-agents.ts b/studio/frontend/src/features/settings/api/coding-agents.ts
index 6a98dd039cb..d140093f2e5 100644
--- a/studio/frontend/src/features/settings/api/coding-agents.ts
+++ b/studio/frontend/src/features/settings/api/coding-agents.ts
@@ -14,10 +14,9 @@ type ApiCodingAgentsInfo = {
detected: string[];
};
-// Which CLIs are on PATH is environment state, not a persisted setting -- it can change any time
-// the user installs something new, so this only de-duplicates concurrent in-flight calls (e.g.
-// React strict-mode's double mount) rather than caching the result across the module's lifetime.
-// Every fresh call (each time a settings panel mounts) re-checks PATH for real.
+// Which CLIs are on PATH is environment state, so this only de-dupes concurrent in-flight calls
+// (e.g. the strict-mode double mount), never caching across the module lifetime; each fresh call
+// re-checks PATH.
let inFlightInfo: Promise<CodingAgentsInfo> | null = null;
function fromApi(info: ApiCodingAgentsInfo): CodingAgentsInfo {
diff --git a/studio/frontend/src/features/settings/api/debug-logs.ts b/studio/frontend/src/features/settings/api/debug-logs.ts
index cc3d167b609..6114a7d7eb1 100644
--- a/studio/frontend/src/features/settings/api/debug-logs.ts
+++ b/studio/frontend/src/features/settings/api/debug-logs.ts
@@ -200,10 +200,9 @@ export async function exportAllLogs(): Promise<string | null> {
try {
return await run(getAuthToken());
} catch (error) {
- // Rust uses the token once and as-is, so it cannot retry a 401 by
- // refreshing the way `authFetch` does; a desktop left idle past the
- // access-token lifetime would fail while holding a good refresh token.
- // Refresh only on a 401, so a spare refresh never rotates the pair for nothing.
+ // Rust uses the token once, so it cannot retry a 401 by refreshing as authFetch does and an
+ // idle desktop would fail holding a good refresh token; refresh only on a 401, so a spare
+ // refresh never rotates the pair for nothing.
if (desktopExportStatus(error) !== 401) throw desktopExportError(error);
try {
if (!(await refreshSession())) throw error;
diff --git a/studio/frontend/src/features/settings/components/training-api-snippets.ts b/studio/frontend/src/features/settings/components/training-api-snippets.ts
index 614a4a343d5..d09fd28037a 100644
--- a/studio/frontend/src/features/settings/components/training-api-snippets.ts
+++ b/studio/frontend/src/features/settings/components/training-api-snippets.ts
@@ -19,10 +19,9 @@ export interface TrainingApiSnippetInput {
const LORA = "LoRA/QLoRA";
/**
- * Where each field Start sends goes in the example. Exhaustive over the request type, so a new
- * field fails typecheck until it is placed: "openai" fields map to the OpenAI job fields, "extra"
- * ones are sent as Studio settings, "derived" ones follow from another field, and "host" ones
- * (secrets, this machine's paths and caches, offload, eval, logging, Hub / S3 data, resume) stay out.
+ * Route per request field, exhaustive so a new field fails typecheck until placed: openai maps to
+ * OpenAI job fields, extra to Studio settings, derived follows another field, host stays out
+ * (secrets, this machine's paths and caches, offload, eval, logging, Hub or S3 data, resume).
*/
export const TRAINING_FIELD_ROUTE: Record<keyof TrainingStartRequest, "openai" | "extra" | "derived" | "host"> = {
model_name: "openai",
diff --git a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts
index 243fc0c3144..02e003fe33a 100644
--- a/studio/frontend/src/features/settings/stores/appearance-custom-store.ts
+++ b/studio/frontend/src/features/settings/stores/appearance-custom-store.ts
@@ -849,10 +849,9 @@ const ACCENT_FG_VARS = [
let appliedTypography: string | null = null;
/**
- * Push the customization onto <html> as inline CSS variables, attributes, and
- * classes. Everything is keyed off explicit hooks (inline vars beat every
- * palette block; the classes/attributes gate rules in index.css), so the
- * default customization leaves the document byte-identical to stock.
+ * Applies the customization to html as inline CSS vars, attributes and classes; inline vars beat
+ * every palette block and classes gate index.css rules, so default leaves the document
+ * byte-identical to stock.
*/
export function applyCustomizationToDocument(
c: AppearanceCustomization,
diff --git a/studio/frontend/src/features/settings/tabs/voice-tab.tsx b/studio/frontend/src/features/settings/tabs/voice-tab.tsx
index 81fb911ef74..791cb54a6a5 100644
--- a/studio/frontend/src/features/settings/tabs/voice-tab.tsx
+++ b/studio/frontend/src/features/settings/tabs/voice-tab.tsx
@@ -148,10 +148,8 @@ function sttModelSource(model: SttModel): string {
}
/**
- * Model picker for local transcription. Lists the curated models and every
- * other ASR model the Transcribe page offers, and searches Hugging Face for
- * other Whisper repos (safetensors via Transformers). The trigger is a plain
- * button so the selection never renders inside a text input.
+ * Lists curated and other ASR models and searches Hugging Face for Whisper repos (safetensors via
+ * Transformers); a plain button trigger keeps the value out of text inputs.
*/
function SttModelPicker({
value,
diff --git a/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts b/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts
index 891bb1dbc24..8c4860c2975 100644
--- a/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts
+++ b/studio/frontend/src/features/transformers-upgrade/lib/upgrade-dialog-actions.ts
@@ -29,13 +29,11 @@ export function upgradeInstallVersion(
return null;
}
-/** Decide the dialog's actions from the check that raised it.
- *
- * The custom-code fallback used to appear only with nothing to install, or after an
- * install failed. It reads as a courtesy but is a correctness rule: the fallback loads
- * on the CURRENT transformers, the only path that still loads bnb 4-bit, since
- * installing activates the 16-bit sidecar. Hiding it behind Install leaves a QLoRA run
- * no way to start at its own precision. Whenever the fallback exists, it is offered. */
+/**
+ * Derives the dialog actions from the check that raised it; the custom-code fallback is always
+ * offered when it exists, as the only path loading bnb 4-bit (installing activates the 16-bit
+ * sidecar).
+ */
export function upgradeDialogActions({
upgrade,
phase,
diff --git a/studio/frontend/src/features/video/api.ts b/studio/frontend/src/features/video/api.ts
index 7722362b659..d3646ed2bd9 100644
--- a/studio/frontend/src/features/video/api.ts
+++ b/studio/frontend/src/features/video/api.ts
@@ -136,9 +136,8 @@ export interface VideoLoadRequest {
display_repo_id?: string;
// Required for gguf / single_file; omitted for a from_pretrained pipeline.
gguf_filename?: string;
- // How to load the model (omit to auto-detect from gguf_filename): "gguf", "single_file"
- // (safetensors transformer) or "pipeline". A single_file .safetensors loads from any repo;
- // pipeline loads are restricted to unsloth/* or family bases.
+ // Omit to auto-detect from gguf_filename: gguf, single_file (safetensors transformer, any repo)
+ // or pipeline (restricted to unsloth/ repos or family bases).
model_kind?: "gguf" | "single_file" | "pipeline";
base_repo?: string;
family_override?: string;
@@ -187,10 +186,9 @@ export interface VideoGenerateRequest {
// Omitted = the server default (on).
live_preview?: boolean;
negative_prompt?: string;
- // Width/height/num_frames/fps default per loaded family, so they are optional. When sent they
- // must match that family's rules -- a size near its presets, and num_frames on the
- // k*frame_step+1 lattice -- or the backend answers 422 with the supported shapes.
- // Width/height sit on resolution_multiple inside the custom_size_* bounds, or are a preset.
+ // Width, height, num_frames and fps default per family; when sent they must match its rules:
+ // num_frames on the k times frame_step plus 1 lattice, and width and height a preset or on
+ // resolution_multiple within the custom_size bounds, else 422.
width?: number;
height?: number;
num_frames?: number;
diff --git a/studio/frontend/src/features/video/video-page.tsx b/studio/frontend/src/features/video/video-page.tsx
index 123577f479c..6f5757886f0 100644
--- a/studio/frontend/src/features/video/video-page.tsx
+++ b/studio/frontend/src/features/video/video-page.tsx
@@ -341,12 +341,9 @@ function defaultsFor(repoId: string, family?: string): { steps: number; guidance
const id = fold(repoId);
// The Wan and FusionX rows count only in the model / file name, as on the backend.
const name = fold(repoId.replace(/[\\/]+$/, "").split(/[\\/]/).pop() ?? "");
- // LTX-2.5 (diffusers' pre-release "2.4" too) is decided on the two names the backend gets: the selected file and
- // the repo, read by their last segment. A local file's repo is the folder it sits in (the picker loads it from that
- // directory), a Hub file's is the repo segment after the owner. The version is ltx_name_version's ("ltx-2.5",
- // "LTX25", "ltx2.5", "LTX-Video-2.5"), or the explicit ltx-2.5 family. The variant is ltx25_is_dev's: the first
- // name naming one decides, "distill" before a dev / full / sft token (or transformer_full); a dev pick runs 30
- // steps at guidance 3, anything else the distilled 8 at guidance 1.
+ // LTX-2.5 (and pre-release 2.4) is read from the file and repo last path segments as the backend
+ // does; the first name naming a variant decides, distill before a dev, full or sft token (or
+ // transformer_full); dev runs 30 steps at guidance 3, else distilled 8 at guidance 1.
const segments = repoId.replace(/[\\/]+$/, "").split(/[\\/]/);
const local = /^([\\/~.]|[a-z]:)/i.test(repoId);
const fileLeaf = segments[segments.length - 1] ?? "";
diff --git a/studio/frontend/src/hooks/use-collapse-scroll-lock.ts b/studio/frontend/src/hooks/use-collapse-scroll-lock.ts
index 3941b8b157a..05f69a3c0a8 100644
--- a/studio/frontend/src/hooks/use-collapse-scroll-lock.ts
+++ b/studio/frontend/src/hooks/use-collapse-scroll-lock.ts
@@ -18,12 +18,9 @@ function findScrollContainer(element: HTMLElement): HTMLElement | null {
}
/**
- * Locks the nearest scrollable ancestor's scrollTop during a collapsible
- * animation so the page doesn't jump when content height changes.
- *
- * Unlike @assistant-ui/react's `useScrollLock`, this does NOT toggle
- * `scrollbar-width: none` on the container; hiding the scrollbar mid-animation
- * caused a visible flicker on tool-call collapsibles.
+ * Locks the nearest scrollable ancestor's scrollTop during a collapsible animation so the page does
+ * not jump; unlike assistant-ui's useScrollLock it does not set scrollbar-width none, since hiding
+ * the scrollbar flickered tool-call collapsibles.
*/
export function useCollapseScrollLock(
animatedElementRef: RefObject<HTMLElement | null>,
diff --git a/studio/frontend/src/hooks/use-composer-pill-fit.ts b/studio/frontend/src/hooks/use-composer-pill-fit.ts
index 16746dd227b..3ccecd96d1d 100644
--- a/studio/frontend/src/hooks/use-composer-pill-fit.ts
+++ b/studio/frontend/src/hooks/use-composer-pill-fit.ts
@@ -4,9 +4,8 @@
import { useCallback, useLayoutEffect, useState } from "react";
/**
- * - `undefined`: every pill keeps its label.
- * - `"first"`: only the leading permission pill drops to its icon.
- * - `"true"`: every pill drops to its icon.
+ * undefined keeps every pill label; first drops only the leading permission pill to its icon; true
+ * drops every pill to its icon.
*/
export type PillCompact = undefined | "first" | "true";
diff --git a/studio/frontend/src/hooks/use-llama-update-check.ts b/studio/frontend/src/hooks/use-llama-update-check.ts
index 481732f3fc4..5b49051156b 100644
--- a/studio/frontend/src/hooks/use-llama-update-check.ts
+++ b/studio/frontend/src/hooks/use-llama-update-check.ts
@@ -146,9 +146,8 @@ function parseStatus(value: unknown): LlamaUpdateStatus | null {
: "llama.cpp";
const whisper = nestedOffer(s.whisper);
const audio = nestedOffer(s.audio);
- // Legacy top-level version fields intentionally retain their llama meaning.
- // A whisper-only or audio-only update must display the nested release instead
- // of presenting equal llama tags as a new llama update.
+ // Legacy top-level version fields keep their llama meaning; a whisper-only or audio-only update
+ // must show the nested release, not equal llama tags as a new llama update.
const details =
component === "whisper.cpp" && whisper
? whisper
diff --git a/studio/frontend/src/hooks/use-notification-frequency.ts b/studio/frontend/src/hooks/use-notification-frequency.ts
index e6f8f9e971b..f9f7d0e103e 100644
--- a/studio/frontend/src/hooks/use-notification-frequency.ts
+++ b/studio/frontend/src/hooks/use-notification-frequency.ts
@@ -189,9 +189,8 @@ export function useDocumentVisible(): boolean {
}
/**
- * Whether a notification that `wanted` to show may show. Opening it in a visible tab
- * records the time, and it stays open until `wanted` drops (dismiss, snooze, update) or
- * the channel is off.
+ * Whether a notification that wanted to show may show; opening it in a visible tab records the
+ * time, and it stays open until wanted drops (dismiss, snooze, update) or the channel is off.
*/
export function useNotificationGate(
channel: NotificationChannel,
diff --git a/studio/frontend/src/hooks/use-single-line.ts b/studio/frontend/src/hooks/use-single-line.ts
index fc5014e7aa3..01eab7ea6e8 100644
--- a/studio/frontend/src/hooks/use-single-line.ts
+++ b/studio/frontend/src/hooks/use-single-line.ts
@@ -15,9 +15,8 @@ function fitsOneLine(el: HTMLElement): boolean {
}
/**
- * Whether the element's text currently fits on one line, tracked across resizes. A box that is
- * usually one line but can wrap (a command, a URL) is a pill on one line and a 16px box once
- * wrapped; CSS cannot tell the two apart.
+ * Whether the element's text fits on one line, tracked across resizes: a box that can wrap (a
+ * command, a URL) is a pill on one line and a 16px box once wrapped; CSS cannot tell.
*/
export function useSingleLine<T extends HTMLElement>(): [
(node: T | null) => void,
diff --git a/studio/frontend/src/lib/gguf-fit.ts b/studio/frontend/src/lib/gguf-fit.ts
index 398bdd5b626..ea9a3810509 100644
--- a/studio/frontend/src/lib/gguf-fit.ts
+++ b/studio/frontend/src/lib/gguf-fit.ts
@@ -89,10 +89,8 @@ export function classifyGgufFit(
? "marginal"
: "fits";
}
- // Raw card, deliberately. This band means "over your budget, still card-sized", which is the only
- // thing that distinguishes it from `fits`: scoring it against `budget` too would make it
- // unreachable, since `required <= budget` has already returned above. It is a warning tier, not a
- // claim that the load will be admitted.
+ // Raw card size on purpose: this marginal band is over budget yet card-sized, and budget scoring
+ // would make it unreachable; a warning tier, not a claim the load will be admitted.
if (required <= gpuGb) return "marginal";
// Once layers spill, the GPU contributes only its budget; the reserve is off-limits
// (vram_budget_settings.py).
diff --git a/studio/frontend/src/lib/latex.ts b/studio/frontend/src/lib/latex.ts
index 02ed129bd28..9c9e13f48f6 100644
--- a/studio/frontend/src/lib/latex.ts
+++ b/studio/frontend/src/lib/latex.ts
@@ -1,8 +1,5 @@
-// Adapted from LibreChat's latex.ts
-// https://github.com/danny-avila/LibreChat/blob/main/client/src/utils/latex.ts
-//
-// Converts `\[...\]` / `\(...\)` to the dollar forms remark-math tokenizes, then escapes currency
-// dollars so singleDollarTextMath does not read them as math.
+// Adapted from LibreChat's latex.ts; converts TeX bracket delimiters to the dollar forms
+// remark-math tokenizes, then escapes currency dollars so singleDollarTextMath skips them.
import { parseMarkdownIntoBlocks } from "./parse-markdown-blocks.ts";
import {
diff --git a/studio/frontend/src/lib/model-lifecycle-events.ts b/studio/frontend/src/lib/model-lifecycle-events.ts
index 6138b95c1b1..42bb16fa14a 100644
--- a/studio/frontend/src/lib/model-lifecycle-events.ts
+++ b/studio/frontend/src/lib/model-lifecycle-events.ts
@@ -79,9 +79,8 @@ export function subscribeModelDeleted(
}
/**
- * Announce a load around `run`, so the indicator shows it for the whole time
- * the toast does. Settles on failure too, or a failed load would leave the row
- * spinning until the next poll disagreed.
+ * Announces a load around run so the indicator lasts as long as the toast; settles on failure too,
+ * or the row would spin until a poll disagreed.
*/
export async function withModelLoadNotice<T>(
runtime: ModelRuntime,
@@ -97,12 +96,9 @@ export async function withModelLoadNotice<T>(
}
/**
- * What a `load-progress` endpoint reports. `null` is terminal once a load has
- * started: all three engines return it only for "nothing loading and nothing
- * loaded", and `begin_load` records its loading state before the POST answers,
- * so a read before the first byte moves says `downloading`. It is what a
- * cancelled or evicted load leaves behind -- the Images page's own poll treats
- * it the same way, and must, "else this loop spins forever".
+ * null is terminal once a load starts: all three engines return it only when nothing is loading or
+ * loaded; begin_load records loading before the POST answers, so an early read says downloading; a
+ * cancelled or evicted load leaves null, which pollers must treat as the end or spin forever.
*/
export type LoadPhase =
| "downloading"
diff --git a/studio/frontend/src/lib/schedule-idle-task.ts b/studio/frontend/src/lib/schedule-idle-task.ts
index 80c7196ec53..62399ebbb9e 100644
--- a/studio/frontend/src/lib/schedule-idle-task.ts
+++ b/studio/frontend/src/lib/schedule-idle-task.ts
@@ -38,9 +38,8 @@ export const nonScrollInputQuietIn = (): number => {
};
/**
- * Run `callback` once the main thread is idle, or after `timeout` at the latest; returns a
- * canceller. Falls back to setTimeout without requestIdleCallback (Safari, the WebKitGTK webview
- * the desktop app embeds on Linux), and runs synchronously with no window.
+ * Runs callback when the main thread is idle or after timeout, returning a canceller; falls back to
+ * setTimeout without requestIdleCallback (Safari, WebKitGTK) and runs synchronously with no window.
*/
export function scheduleIdleTask(
callback: () => void,
diff --git a/studio/frontend/src/lib/shield-cog-icon.ts b/studio/frontend/src/lib/shield-cog-icon.ts
index dad6c56f59f..ee4fe7a8750 100644
--- a/studio/frontend/src/lib/shield-cog-icon.ts
+++ b/studio/frontend/src/lib/shield-cog-icon.ts
@@ -3,8 +3,7 @@
import type { IconSvgElement } from "@hugeicons/react";
-// Hugeicons "Shield Cog" (stroke-rounded, MIT). Not in the pinned free-icons package.
-// https://hugeicons.com/icon/shield-cog
+// Hugeicons Shield Cog (stroke-rounded, MIT); it is not in the pinned free-icons package.
export const ShieldCogIcon: IconSvgElement = [
[
"path",
diff --git a/studio/frontend/src/lib/speculative-modes.ts b/studio/frontend/src/lib/speculative-modes.ts
index 958f0c65706..32dfa11af43 100644
--- a/studio/frontend/src/lib/speculative-modes.ts
+++ b/studio/frontend/src/lib/speculative-modes.ts
@@ -56,10 +56,8 @@ export function mlxSpeculativeMode(mode: string): string {
}
/**
- * The modes that consume spec_draft_n_max, i.e. the ones that launch a drafter
- * with a configurable depth. Named for the setting rather than for MTP: DSpark
- * and DFlash are in here too. Mirrors DRAFT_N_MAX_SPEC_TYPES in
- * studio/backend/utils/openai_auto_switch_settings.py.
+ * Modes that read spec_draft_n_max, named for the setting rather than MTP so DSpark and DFlash
+ * count too; mirrors DRAFT_N_MAX_SPEC_TYPES in studio/backend/utils/openai_auto_switch_settings.py.
*/
export const DRAFT_N_MAX_SPEC_TYPES: ReadonlySet<string> = new Set([
"mtp",
@@ -85,14 +83,9 @@ export function resolveSpeculativeType(
}
/**
- * The modes that always launch a SEPARATE draft model, and so a second context
- * with its own KV cache for the draft cache dtype to apply to.
- *
- * MTP is left out: whether it loads a drafter file (Gemma) or reads baked-in
- * heads out of the target GGUF (Qwen) is a property of the model, known only once
- * the loader has read its metadata. The backend emits the draft cache flags
- * wherever it emits --model-draft, so a stored setting still reaches an MTP load
- * that does attach one.
+ * Modes that always launch a separate draft model with its own KV cache; MTP is left out since a
+ * drafter file or baked-in heads is known only after metadata loads, but draft cache flags go
+ * wherever --model-draft does, so a stored setting still reaches MTP loads that attach a drafter.
*/
export const SEPARATE_DRAFT_MODEL_SPEC_TYPES: ReadonlySet<string> = new Set([
"dspark",
diff --git a/studio/frontend/src/lib/swap-save-phase.ts b/studio/frontend/src/lib/swap-save-phase.ts
index 72dda68253b..df41b326538 100644
--- a/studio/frontend/src/lib/swap-save-phase.ts
+++ b/studio/frontend/src/lib/swap-save-phase.ts
@@ -1,10 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// While an Images or Video load POST is pending, the backend may first save the chat model's
-// context so chat can resume after the swap. That save is the only thing load-progress says
-// about THIS load before the POST answers: every other phase still describes the previous
-// model, so reading "ready" or null here as the end of the load would be wrong.
+// While an Images or Video load POST is pending, load-progress says only that the chat context is
+// saving for this load; other phases describe the previous model, so ready or null is not the end.
export const SAVING_CHAT_CONTEXT = "saving_chat_context";
diff --git a/studio/frontend/tests/amd-driver-idle-evict-notice.test.ts b/studio/frontend/tests/amd-driver-idle-evict-notice.test.ts
index 0c933cb132a..f6564c86ef5 100644
--- a/studio/frontend/tests/amd-driver-idle-evict-notice.test.ts
+++ b/studio/frontend/tests/amd-driver-idle-evict-notice.test.ts
@@ -1,9 +1,8 @@
// 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 System tab's notice for a Windows AMD driver with the idle-eviction bug
-// (ROCm/TheRock#7221), from /api/system's gpu.driver_warning. Lifted by regex like
-// gpu-torch-mismatch.test.ts, since the tab pulls in the whole app.
+// Tests the System tab notice for a Windows AMD driver with the idle-eviction bug (ROCm/TheRock
+// issue 7221), read from gpu.driver_warning; lifted by regex since the tab pulls in the whole app.
import assert from "node:assert/strict";
import test from "node:test";
diff --git a/studio/frontend/tests/approval-waiting.test.ts b/studio/frontend/tests/approval-waiting.test.ts
index 0ef624f935b..9d6cbbb68a0 100644
--- a/studio/frontend/tests/approval-waiting.test.ts
+++ b/studio/frontend/tests/approval-waiting.test.ts
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// A chat waiting on an Allow / Deny prompt is marked in the sidebar, and on Desktop the window asks
-// for attention. app-sidebar.tsx is .tsx, which node's type stripping cannot import, so its wiring
-// is pinned from source.
+// A chat awaiting Allow or Deny is marked in the sidebar and on Desktop asks for window attention;
+// app-sidebar.tsx cannot be imported by node type stripping, so it is checked from source.
import assert from "node:assert/strict";
import { register } from "node:module";
@@ -53,9 +52,8 @@ function parked(entries: Record<string, string>) {
// Loaded once up front, so the module's own dynamic import is a cache hit in every case.
await import("@tauri-apps/api/window");
-// The attention request is a dynamic import, so wait on the calls rather than a turn count. A case
-// expecting none still waits a while, so a call that should not happen has time to land. Real
-// time, since setTimeout and Date are mocked.
+// Waits on the attention calls rather than a turn count, since the request is a dynamic import; a
+// case expecting none waits real time, as setTimeout and Date are mocked.
async function attention(
expected: number,
): Promise<(number | null | undefined)[]> {
diff --git a/studio/frontend/tests/browser-native-view-layered.test.ts b/studio/frontend/tests/browser-native-view-layered.test.ts
index 230c537fc9f..53b61430ddf 100644
--- a/studio/frontend/tests/browser-native-view-layered.test.ts
+++ b/studio/frontend/tests/browser-native-view-layered.test.ts
@@ -170,9 +170,8 @@ test("a menu over a layered page neither captures nor hides it, and owns its inp
await frame();
assert.equal(section.vars.get("--native-hole-bg"), "oklch(0.2 0 0)");
- // a split drag pins the page at its old width while the panel shrinks past it: the app covers
- // the overflow by cutting the hole no wider than the panel, and the page view isn't resized,
- // which would relayout the page every frame
+ // A split drag pins the page at its old width while the panel shrinks past it; the hole is cut
+ // no wider than the panel and the page view is not resized, which would relayout every frame.
let panelLeft = 650;
const panelBody = { getBoundingClientRect: () => rect(panelLeft, 0, 1000 - panelLeft, 800), closest: () => null };
// the pinned outer page box keeps its old rect, the page's own
diff --git a/studio/frontend/tests/browser-submenu-surface.test.ts b/studio/frontend/tests/browser-submenu-surface.test.ts
index c470b028ea8..c3ce0bdfc8c 100644
--- a/studio/frontend/tests/browser-submenu-surface.test.ts
+++ b/studio/frontend/tests/browser-submenu-surface.test.ts
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Dark submenus no longer copy their parent's fill, so each one carries its
-// parent's surface class.
+// Dark submenus carry their parent's surface class themselves rather than copying its fill.
import assert from "node:assert/strict";
import test from "node:test";
diff --git a/studio/frontend/tests/chat-remembers-its-model.test.ts b/studio/frontend/tests/chat-remembers-its-model.test.ts
index f78ad52aed3..9353dad5d7e 100644
--- a/studio/frontend/tests/chat-remembers-its-model.test.ts
+++ b/studio/frontend/tests/chat-remembers-its-model.test.ts
@@ -1,11 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Every thread row has carried modelId since long before this notice, and each send now
-// moves it to the model that send ran on, so a chat knows the model it last used. What was
-// missing was offering it back. The rules below are the ones that keep the offer from becoming a
-// nuisance: it never loads anything on its own, it stays quiet whenever it could not be
-// honoured, and a model still loaded alongside is switched to without asking.
+// Each send moves a thread's modelId to the model it ran on; the offer never loads a model on its
+// own, stays quiet when it cannot be honoured, and switches without asking to one still loaded
+// alongside.
import assert from "node:assert/strict";
import test from "node:test";
@@ -222,9 +220,8 @@ test("the automatic switch runs once per chat open", () => {
// Any loaded slot counts, Keep models loaded on or off: the switch only ever adopts it.
assert.match(body, /createdModel && !resident\s*\?\s*chatModelLoadedTarget/);
assert.doesNotMatch(body, /keepModelsLoaded/);
- // A cross-tab revision carries no thread, so the saved model is read again rather than kept stale.
- // Only the plain cross-tab Event re-reads (streamed chunks are CustomEvents), and a slower read
- // never lands over a newer answer.
+ // A cross-tab revision carries no thread, so the saved model is re-read; only plain Events
+ // re-read (streamed chunks are CustomEvents), and a slower read never lands over a newer one.
assert.match(notice, /if \(event instanceof CustomEvent\) return;\s*reader\.invalidate\(\);\s*const generation = \+\+readGeneration;/);
assert.match(notice, /if \(updatedThread\.id === threadId\) readGeneration \+= 1;/);
assert.match(
diff --git a/studio/frontend/tests/code-fence-mode.test.ts b/studio/frontend/tests/code-fence-mode.test.ts
index 0eb6619834e..2bca8972b90 100644
--- a/studio/frontend/tests/code-fence-mode.test.ts
+++ b/studio/frontend/tests/code-fence-mode.test.ts
@@ -12,12 +12,9 @@ import {
import { readSrc } from "./helpers/kit.ts";
/**
- * The fence mode decision table, RUN rather than described.
- *
- * The other tests around this change are regexes over source, because what they protect is a React
- * hook over IntersectionObserver and would need a DOM. This is a pure function of two values, and
- * the point of the default moving from "off" to "defer" is that every existing override keeps
- * working in BOTH directions. A truth table nobody executes is not evidence of that.
+ * Runs the fence mode decision table rather than describing it: the default moved from off to defer
+ * and every existing override must keep working in both directions; other tests are source regexes
+ * because the hook needs a DOM.
*/
test("the default defers highlighting without moving line windows during scroll", () => {
diff --git a/studio/frontend/tests/code-tool-placement.test.ts b/studio/frontend/tests/code-tool-placement.test.ts
index def2c4e4e4c..7218b5b3686 100644
--- a/studio/frontend/tests/code-tool-placement.test.ts
+++ b/studio/frontend/tests/code-tool-placement.test.ts
@@ -156,11 +156,8 @@ test("response details record Code from the placement, local or hosted", () => {
// ── Whether the pill is offered at all ─────────────────────────────
-// Until Unsloth's loop reached the general external providers, the composer
-// keyed the Tools pill on the hosted flag alone, so a model without the hosted
-// sandbox simply did not offer it. Keying it on the Unsloth-tools flag instead
-// offered it everywhere, including where the rule above deliberately runs
-// nothing, and the user got a lit toggle that sent enable_tools: false.
+// Keying the Tools pill on the Unsloth-tools flag offered it everywhere, even where nothing runs,
+// so the user got a lit toggle that sent enable_tools: false.
test("a model with its provider's sandbox can run code", () => {
assert.equal(
diff --git a/studio/frontend/tests/debug-log-export.test.ts b/studio/frontend/tests/debug-log-export.test.ts
index 16f7bf533e6..02359429cde 100644
--- a/studio/frontend/tests/debug-log-export.test.ts
+++ b/studio/frontend/tests/debug-log-export.test.ts
@@ -312,9 +312,8 @@ test("openLogsFolder preserves the selected path with an older backend", async (
});
test("an export that works does not touch the session", async () => {
- // refreshSession rotates the stored pair, so refreshing before every export
- // would spend a refresh token, and risk a sign-out, just for clicking
- // Download all logs.
+ // refreshSession rotates the stored pair, so refreshing before every export would spend a refresh
+ // token and risk a sign-out just to click Download all logs.
const world = makeWorld({
isTauri: true,
invoke: async () => SAVED_PATH,
diff --git a/studio/frontend/tests/hosted-image-tool-with-studio-tools.test.ts b/studio/frontend/tests/hosted-image-tool-with-studio-tools.test.ts
index 1ecffc2a247..631caadb0b1 100644
--- a/studio/frontend/tests/hosted-image-tool-with-studio-tools.test.ts
+++ b/studio/frontend/tests/hosted-image-tool-with-studio-tools.test.ts
@@ -17,11 +17,9 @@ function studioToolsBranch(): string {
return SOURCE.slice(start, end);
}
-// Images and Fetch have their own toggles and no local implementation. Before
-// this PR an OpenAI or Gemini connection never took the Unsloth branch, so the
-// hosted branch below always carried them; now that Search, Tools, MCP or a
-// project's automatic RAG selects the Unsloth branch instead, a list of purely
-// local names would leave a lit Images pill out of the request entirely.
+// Images and Fetch have their own toggles and no local implementation, so the Unsloth-tools branch
+// must still ask for them: Search, Tools, MCP or project RAG can now pick that branch, and a purely
+// local list would drop a lit Images pill.
test("the Unsloth-tools branch still asks for the hosted tools Unsloth cannot run", () => {
const branch = studioToolsBranch();
diff --git a/studio/frontend/tests/image-a1111-infotext-keys.test.ts b/studio/frontend/tests/image-a1111-infotext-keys.test.ts
index d9bb65bcc5a..b38e6c2c62b 100644
--- a/studio/frontend/tests/image-a1111-infotext-keys.test.ts
+++ b/studio/frontend/tests/image-a1111-infotext-keys.test.ts
@@ -13,9 +13,8 @@ import {
type Handling = "applied" | "reported" | "ignored";
-// Every key AUTOMATIC1111 (create_infotext, extra_generation_params, the `infotext=` options) and Forge
-// write, with a value that changes the image where one exists. "ignored" is only for keys that set
-// nothing: hashes, the writer, the version. Anything not handled falls through to "reported".
+// Lists every infotext key AUTOMATIC1111 and Forge write; applied keys change the image, ignored
+// keys (hashes, writer, version) set nothing, and unhandled keys fall through to reported.
const KEYS: Array<[string, string, Handling]> = [
// create_infotext
["Steps", "30", "applied"],
diff --git a/studio/frontend/tests/keyboard-shortcuts.test.ts b/studio/frontend/tests/keyboard-shortcuts.test.ts
index fb928ccf54d..ddcb715860d 100644
--- a/studio/frontend/tests/keyboard-shortcuts.test.ts
+++ b/studio/frontend/tests/keyboard-shortcuts.test.ts
@@ -370,10 +370,8 @@ test("the workspace chords land where the guard lets them", async () => {
}
});
-// A chord behind a hidden developer menu is not one the browser took from the
-// user, and these sets drive a warning the user reads. Safari has ⌥⌘E (and
-// ⌥⌘R, which Firefox's Reader View flags anyway) only once the Develop menu is
-// switched on, so reserving it would tell every macOS user something untrue.
+// Safari has ⌥⌘E and ⌥⌘R only once its Develop menu is switched on (Firefox's Reader View flags ⌥⌘R
+// anyway), so reserving them would falsely warn every macOS user.
test("an opt-in developer chord is not treated as taken", () => {
for (const value of ["Mod+Alt+KeyE"]) {
for (const mac of [true, false]) {
@@ -1679,9 +1677,8 @@ test("a selection chord does not fall through to the open chat", async () => {
assert.match(APP_SIDEBAR, /const SELECTION_ACTION_GRACE_MS = \d+;/);
for (const id of ["archiveChat", "markChatUnread", "togglePinChat"]) {
const body = sidebarShortcut(id);
- // Both halves name the action. A shared latch would hold back Archive
- // after Pin took the selection, and that is a different command the user
- // chose, not the repeat this guard exists for.
+ // Each action stamps the latch under its own name, since a shared latch would hold back Archive
+ // after Pin took the selection, a different command, not a repeat.
assert.match(
body,
new RegExp(`actOnSelection\\("${id}",`),
diff --git a/studio/frontend/tests/latex-code-regions.test.ts b/studio/frontend/tests/latex-code-regions.test.ts
index c8a31899299..1e5f59e4eee 100644
--- a/studio/frontend/tests/latex-code-regions.test.ts
+++ b/studio/frontend/tests/latex-code-regions.test.ts
@@ -133,10 +133,9 @@ test("same-line nested items set the continuation content column", () => {
});
test("a fence's backticks do not stand in for an inline span", () => {
- // findInlineCodeRegions returns early when no backtick sits outside a block
- // region, because the mask it would build turns every backtick inside one
- // into a space and can only yield no spans. The early return has to agree
- // with the scan it replaces in both directions, so pin both.
+ // findInlineCodeRegions returns early when no backtick lies outside a block region, since its
+ // mask would turn every backtick inside one into a space and yield no spans; the early return
+ // must agree with the scan it replaces in both directions.
const fence = "```python\ndef step(lr):\n return lr\n```";
assert.equal(
diff --git a/studio/frontend/tests/llama-job-lifecycle.test.ts b/studio/frontend/tests/llama-job-lifecycle.test.ts
index 0178db46729..0ee14d367af 100644
--- a/studio/frontend/tests/llama-job-lifecycle.test.ts
+++ b/studio/frontend/tests/llama-job-lifecycle.test.ts
@@ -214,9 +214,8 @@ test("a bundle with nothing from the job names no single release", () => {
);
});
-// The card is muted per component, and a chained apply drops llama.cpp from the
-// status when its phase lands and the whisper.cpp phase starts. Reading the live
-// switch there hid a running update for the whole second phase.
+// The card's muting is per component, and a chained apply drops llama.cpp from status once its
+// phase lands; reading the live switch then hid a running update for the whole second phase.
test("the switch a running card started under is held until the job is over", () => {
let held = heldUpdateBannerPref(null, true, true);
assert.equal(held, true);
diff --git a/studio/frontend/tests/loaded-models-drag-restore.test.ts b/studio/frontend/tests/loaded-models-drag-restore.test.ts
index 77e22a28eb6..ee61ec7a40c 100644
--- a/studio/frontend/tests/loaded-models-drag-restore.test.ts
+++ b/studio/frontend/tests/loaded-models-drag-restore.test.ts
@@ -70,9 +70,8 @@ test("clamping is idempotent, so the observer cannot feed itself", () => {
// ── The wiring the geometry depends on ──────────────────────────────────
test("the stored position is clamped before the first measurement", () => {
- // Without this the card paints once at the stored coordinates. On a smaller
- // screen that single frame is off screen, and if the observer ever fails to
- // attach it stays there.
+ // Without the clamp the card paints once at stored coordinates, a frame that is off screen on a
+ // smaller display and stays there if the observer never attaches.
assert.match(
SOURCE,
/readStored\(storageKey\)[\s\S]{0,600}?width: 0,\s*height: 0,/,
diff --git a/studio/frontend/tests/model-catalog-fetched-from.test.ts b/studio/frontend/tests/model-catalog-fetched-from.test.ts
index f7ce3391d31..fe5d73b98c3 100644
--- a/studio/frontend/tests/model-catalog-fetched-from.test.ts
+++ b/studio/frontend/tests/model-catalog-fetched-from.test.ts
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// A catalog row on a gated vendor id is still a one-click download when the backend fetches it from an
-// open unsloth mirror, so it carries `fetchedFrom` and no `gated: true` (which would make the router skip
-// it). The nightly network check then judges the mirror. That is only true while the backend really
-// does redirect the id, so every `fetchedFrom` must be one of diffusion_families' gated mirror pairs.
+// A gated vendor id stays a one-click download via fetchedFrom, not gated: true (the router would
+// skip it); the nightly check judges the mirror, which holds only while the backend redirects that
+// id, so each fetchedFrom must be a diffusion_families gated mirror pair.
import assert from "node:assert/strict";
import test from "node:test";
diff --git a/studio/frontend/tests/model-load-native-notifications.test.ts b/studio/frontend/tests/model-load-native-notifications.test.ts
index 136cc86b09c..2368545b6ac 100644
--- a/studio/frontend/tests/model-load-native-notifications.test.ts
+++ b/studio/frontend/tests/model-load-native-notifications.test.ts
@@ -245,13 +245,9 @@ test("a denied grant sends nothing and does not reject", async () => {
assert.deepEqual(mod.control.sent, [], "sent a notification after a denial");
});
-// tauri_plugin_notification replaces window.Notification with its own shim, so
-// these are the shim's states, not hypothetical browser ones: Linux and macOS
-// report "granted" with no prompt (desktop request_permission is hardcoded to
-// Granted), Windows reports "denied" because the shim short-circuits its own
-// bootstrap (tauri-apps/plugins-workspace#3512) while the backend still grants,
-// so the backend's answer wins. Moving the prime off the chat path must not
-// change what training does.
+// tauri_plugin_notification's shim reports granted with no prompt on Linux and macOS, but denied on
+// Windows because it short-circuits its own bootstrap (tauri-apps/plugins-workspace issue 3512);
+// the backend still grants, so its answer wins, and moving the chat prime must not change training.
test("each desktop platform's shim state behaves the same with and without a chat prime", async () => {
const platforms = [
{ name: "linux/macOS", webview: "granted" as const, expected: ["Training finished"] },
diff --git a/studio/frontend/tests/personalization-locale-hydration.test.ts b/studio/frontend/tests/personalization-locale-hydration.test.ts
index f02ef6639a2..0202f067427 100644
--- a/studio/frontend/tests/personalization-locale-hydration.test.ts
+++ b/studio/frontend/tests/personalization-locale-hydration.test.ts
@@ -271,9 +271,8 @@ function setup(
isLocalePreference: (value: unknown) => typeof value === "string",
setLocale: async (value: unknown, options?: { timeoutMs?: number }) => {
localeCalls.push(value);
- // A catalog request the network accepted and never completed. It
- // rejects nothing, so the only thing that can end this wait is the
- // caller asking the store to bound it.
+ // A catalog request the network accepted but never completed; it rejects nothing, so only
+ // the caller asking the store to bound it can end the wait.
if (localeResult === "stalled") {
if (typeof options?.timeoutMs !== "number") {
return new Promise<string>(() => {});
diff --git a/studio/frontend/tests/pinned-models-reorder.test.ts b/studio/frontend/tests/pinned-models-reorder.test.ts
index e7d70d175f5..7bf89b04a14 100644
--- a/studio/frontend/tests/pinned-models-reorder.test.ts
+++ b/studio/frontend/tests/pinned-models-reorder.test.ts
@@ -77,12 +77,9 @@ test("movePinned ignores unknown keys and self-moves", () => {
});
test("movePinned keeps keys not shown in the current view in relative order", () => {
- // The pinned list is one global order shared by the hub's On Device list and
- // the model selector's Pinned section, and the hub only ever shows the repo
- // keys. A quant pin the hub cannot show ("hidden") therefore has to survive a
- // hub reorder. It keeps its position relative to every pin the drag did not
- // touch, which is not the same as keeping its index: one key moving past it
- // necessarily shifts it by one slot.
+ // The pinned list is one global order shared by the hub and the model selector; the hub shows
+ // only repo keys, so a hidden quant pin must survive a reorder by keeping its position relative
+ // to untouched pins, not its index.
setPinned(["m1", "hidden", "m2", "m3"]);
usePinnedModelsStore.getState().movePinned("m3", "m1");
assert.deepEqual(usePinnedModelsStore.getState().pinned, [
diff --git a/studio/frontend/tests/preset-model-memory.test.ts b/studio/frontend/tests/preset-model-memory.test.ts
index 6d91e0b5257..bc2fcfade20 100644
--- a/studio/frontend/tests/preset-model-memory.test.ts
+++ b/studio/frontend/tests/preset-model-memory.test.ts
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Picking a preset is not a per-model edit (#14068). Default fell back to fixed sampling for every
-// model, and a custom preset's values came back on the next load after switching to Default. These
-// drive the real store the way the settings sheet, a model load and a status poll do.
+// Picking a preset is not a per-model edit (issue 14068): switching to Default must not fall back
+// to fixed sampling for every model or revive a custom preset's values on the next load.
import assert from "node:assert/strict";
import { register } from "node:module";
diff --git a/studio/frontend/tests/progressive-mount-glue.test.ts b/studio/frontend/tests/progressive-mount-glue.test.ts
index ab75b835180..78b1c197061 100644
--- a/studio/frontend/tests/progressive-mount-glue.test.ts
+++ b/studio/frontend/tests/progressive-mount-glue.test.ts
@@ -38,9 +38,8 @@ const GLUE_WINDOW = () =>
);
test("the thread renders rows through MessageByIndex, never ThreadPrimitive.Messages", () => {
- // Upstream renders MessageByIndexProvider -> RenderChildrenWithAccessor -> children; this row map
- // renders MessageByIndexProvider -> children. Switching between the two on convergence would
- // change the element type at that position, so React would unmount and rebuild every message.
+ // Upstream renders MessageByIndexProvider, RenderChildrenWithAccessor, then children, while this
+ // row map skips the accessor; switching between them on convergence would remount every message.
assert.match(
GLUE,
/<AuiProvider key=\{index\} value=\{gate\.row\(index\)\}>\s*<MessageByIndexProvider index=\{index\}>/,
diff --git a/studio/frontend/tests/read-aloud-studio-voice.test.ts b/studio/frontend/tests/read-aloud-studio-voice.test.ts
index 1238222d647..d2e02ca8424 100644
--- a/studio/frontend/tests/read-aloud-studio-voice.test.ts
+++ b/studio/frontend/tests/read-aloud-studio-voice.test.ts
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Read aloud on the "Unsloth model" engine speaks with the loaded speech model (named, so
-// one kept beside the chat model answers), in a saved Audio voice, and keeps its clips out of
-// Speak's history.
+// Read aloud on the Unsloth model engine speaks with the loaded speech model (named, so one kept
+// beside the chat model answers), in a saved Audio voice, and keeps clips out of Speak's history.
import assert from "node:assert/strict";
import { readdirSync } from "node:fs";
diff --git a/studio/frontend/tests/reasoning-source-render.test.ts b/studio/frontend/tests/reasoning-source-render.test.ts
index 7ee507d7c13..1206675761a 100644
--- a/studio/frontend/tests/reasoning-source-render.test.ts
+++ b/studio/frontend/tests/reasoning-source-render.test.ts
@@ -8,15 +8,12 @@ import { promisify } from "node:util";
const execFileAsync = promisify(execFile);
-// Each render cold-starts Vite and transforms the Markdown component graph with no
-// prebundle: about 9 s on an idle Linux box. The Windows frontend job runs it beside
-// thousands of other tests and went past a 30 s cap, failing PRs that never touched
-// the renderer. The cap only stops a hung child; the assertions are what is tested.
+// Each render cold-starts Vite with no prebundle and runs beside thousands of tests on Windows, so
+// a 30 s cap failed unrelated PRs; the cap only stops a hung child.
const RENDER_TIMEOUT_MS = 120_000;
-// Vite's Markdown plugin graph retains close hooks after SSR. Run the real
-// renderer in an isolated process so the assertion owns its complete lifetime
-// and can terminate those hooks after the markup has been produced.
+// Vite's Markdown plugin graph retains close hooks after SSR, so the real renderer runs in an
+// isolated process that can terminate them once the markup is produced.
const RENDER_SOURCE_WITHOUT_PART_SCOPE = String.raw`
import { createElement } from "react";
import { renderToStaticMarkup } from "react-dom/server";
diff --git a/studio/frontend/tests/sidebar-spinner-column.test.ts b/studio/frontend/tests/sidebar-spinner-column.test.ts
index 38ca585c135..f2c68c2968d 100644
--- a/studio/frontend/tests/sidebar-spinner-column.test.ts
+++ b/studio/frontend/tests/sidebar-spinner-column.test.ts
@@ -56,9 +56,8 @@ test("nav and Recents spinners land on one trailing column", async () => {
);
});
-// The kebab overlays the row's right edge, so a spinner row must pad past it.
-// The spinner, the waiting-for-approval dot and the unread dot take turns in one slot; a dot off
-// that centre reads as misaligned next to a spinner or a dot in the row above.
+// The kebab overlays the row's right edge, so a spinner row must pad past it; the spinner, approval
+// dot and unread dot share one slot, and a dot off that centre reads as misaligned.
test("the Recents spinner, the approval mark and the unread dot share one centre", () => {
const centre = (anchor: string, box: string) => inset(anchor, "right") + inset(box, "size") / 2;
const spinnerAnchor = grab(
diff --git a/studio/frontend/tests/thread-ancestor-has-scope.test.ts b/studio/frontend/tests/thread-ancestor-has-scope.test.ts
index ed9c29d1729..4ba66eb79aa 100644
--- a/studio/frontend/tests/thread-ancestor-has-scope.test.ts
+++ b/studio/frontend/tests/thread-ancestor-has-scope.test.ts
@@ -2,9 +2,8 @@
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
/*
- * No descendant-argument `:has()` on an ancestor of the thread: Chromium re-walks the whole
- * thread on every insertion (measured as the entire per-append cost). Child form `has-[>...]`
- * is cheap. Source test only; other ancestors are guarded by the perf ladder.
+ * No descendant-argument :has() on an ancestor of the thread (Chromium re-walks the whole thread
+ * per insertion); child has-[>...] is cheap; other ancestors are guarded by the perf ladder.
*/
import assert from "node:assert/strict";
diff --git a/studio/frontend/tests/thread-scoped-default-export.test.ts b/studio/frontend/tests/thread-scoped-default-export.test.ts
index db18689b900..1355958958d 100644
--- a/studio/frontend/tests/thread-scoped-default-export.test.ts
+++ b/studio/frontend/tests/thread-scoped-default-export.test.ts
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Chat exports read threadScopedDefault for a chat whose snapshot omits the system prompt. While
-// the first chat's read is out, an edit to its prompt is held in the live store, and that edit
-// must not become the default every other snapshot-less chat exports.
+// Chat exports read threadScopedDefault when a snapshot omits the system prompt; an edit held in
+// the live store during that read must not become the default for other snapshot-less chats.
import assert from "node:assert/strict";
import { register } from "node:module";
diff --git a/studio/frontend/tests/training-start-payload-offload.test.ts b/studio/frontend/tests/training-start-payload-offload.test.ts
index e3111052cd4..dee598af1f1 100644
--- a/studio/frontend/tests/training-start-payload-offload.test.ts
+++ b/studio/frontend/tests/training-start-payload-offload.test.ts
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Offload layers in the start payload: off by default, a full finetune always sends it off,
-// and the VRAM budget goes out only with "auto", the one mode that sizes to it, per card when
-// training sees several GPUs.
+// Offload layers are off by default and always off for a full finetune; the VRAM budget is sent
+// only with "auto", the one mode that sizes to it, per card on multi-GPU runs.
import assert from "node:assert/strict";
import test from "node:test";
diff --git a/studio/frontend/tests/video-model-defaults.test.ts b/studio/frontend/tests/video-model-defaults.test.ts
index ae73a177c6e..4b6f4392645 100644
--- a/studio/frontend/tests/video-model-defaults.test.ts
+++ b/studio/frontend/tests/video-model-defaults.test.ts
@@ -1,10 +1,9 @@
// 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 Video page seeds steps and guidance from a repo-id substring table before the backend status
-// answers. The table and its matcher live inside the page component, so this lifts both out of the
-// source and runs them on real checkpoint names, including separator spellings the backend's family
-// matcher already folds together.
+// The Video page seeds steps and guidance from a repo-id substring table before backend status
+// answers; the test lifts the table and matcher out of the page and runs them on real checkpoint
+// names, including separator spellings the backend family matcher already folds.
import assert from "node:assert/strict";
import test from "node:test";
diff --git a/studio/frontend/tests/windows-path-portability.test.ts b/studio/frontend/tests/windows-path-portability.test.ts
index 202df384fe1..13fe0b3ddcf 100644
--- a/studio/frontend/tests/windows-path-portability.test.ts
+++ b/studio/frontend/tests/windows-path-portability.test.ts
@@ -1,10 +1,9 @@
// SPDX-License-Identifier: AGPL-3.0-only
// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0
-// Frontend CI is ubuntu-only, so two Windows-only breakages are caught from source:
-// 1. a fileURLToPath result as an import() specifier (ERR_UNSUPPORTED_ESM_URL_SCHEME);
-// 2. a file: URL's pathname as an fs path ("/D:/..." opens as "D:\D:\...").
-// Both APIs accept a URL directly. fileURLToPath into existsSync is fine.
+// Frontend CI is ubuntu-only, so Windows breakages are caught from source: fileURLToPath passed to
+// import() fails (ERR_UNSUPPORTED_ESM_URL_SCHEME), and a file: URL pathname as an fs path opens a
+// doubled drive path; both APIs take a URL, and fileURLToPath into existsSync is fine.
import assert from "node:assert/strict";
import { readFileSync, readdirSync } from "node:fs";
diff --git a/studio/src-tauri/Cargo.toml b/studio/src-tauri/Cargo.toml
index 84a268e4c84..2845df7cbae 100644
--- a/studio/src-tauri/Cargo.toml
+++ b/studio/src-tauri/Cargo.toml
@@ -88,9 +88,8 @@ windows = { version = "0.62.2", features = ["Win32_System_Threading"] }
windows-core = "0.62.2"
windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Globalization", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_Console", "Win32_System_Diagnostics_ToolHelp", "Win32_System_JobObjects", "Win32_System_Registry", "Win32_System_SystemInformation", "Win32_System_Threading", "Win32_UI_Input_KeyboardAndMouse", "Win32_UI_Shell", "Win32_Networking_WinHttp"] }
-# Whole-program LTO: a 25% smaller Linux binary (53.8 -> 40.4 MB) for a longer final link.
-# panic and strip stay at their defaults: catch_unwind guards cleanup, and the panic hook
-# symbolizes backtraces.
+# Whole-program LTO shrinks the Linux binary at the cost of a longer final link; panic and strip
+# stay at defaults since catch_unwind guards cleanup and the panic hook symbolizes backtraces.
[profile.release]
lto = true
codegen-units = 1
diff --git a/studio/src-tauri/src/install.rs b/studio/src-tauri/src/install.rs
index 8b2498ddb74..01deff417e3 100644
--- a/studio/src-tauri/src/install.rs
+++ b/studio/src-tauri/src/install.rs
@@ -646,11 +646,10 @@ fn spawn_script(
#[cfg(target_os = "linux")]
crate::process::scrub_appimage_python_env(&mut cmd);
- // install.sh / install.ps1 reject inherited custom roots under --tauri, so
- // scrub them and pass only the desktop's chosen root, with its flag.
- // Applied by hand here, the one managed spawn outside
- // apply_managed_cli_context: the Python setup.sh starts reads whatever is
- // exported, even though setup.sh assigns UNSLOTH_HOME itself.
+ // install.sh and install.ps1 reject inherited custom roots under --tauri, so scrub them and
+ // pass only the chosen root with its flag; this hand-applied spawn sits outside
+ // apply_managed_cli_context, and setup.sh reads whatever is exported even though it assigns
+ // UNSLOTH_HOME.
for name in crate::process::MANAGED_CHILD_SCRUBBED_ENV {
cmd.env_remove(name);
}
@@ -1305,9 +1304,8 @@ pub fn install_system_packages(
}
}
- // install.sh reports Debian package names. Do not pass them to dnf,
- // zypper, or pacman where names differ; show an explicit support boundary
- // instead of offering an elevation flow that is likely to fail.
+ // install.sh reports Debian package names, so do not pass them to dnf, zypper or pacman where
+ // names differ; show a support boundary instead of an elevation flow likely to fail.
if !Path::new(APT_GET).exists() {
let msg = "Automatic system package installation is supported on apt-based Linux distributions (Ubuntu/Debian) only. Install the missing dependencies with your package manager and retry."
.to_string();