Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: Library chat, project and section cards keep one size (#15471)

Michael Han9e09d192835d
diff --git a/studio/frontend/src/features/library/chats/chats-items.tsx b/studio/frontend/src/features/library/chats/chats-items.tsx
index 79904510e4b..a482a6ea9b6 100644
--- a/studio/frontend/src/features/library/chats/chats-items.tsx
+++ b/studio/frontend/src/features/library/chats/chats-items.tsx
@@ -81,9 +81,13 @@ import { CARD_SHADOW, OVERLAY_CONTROL, RAISED_SURFACE } from "../surface";
const CARD = cn(
RAISED_SURFACE,
CARD_SHADOW,
- // min-w-0: a grid item's automatic minimum is its content, so a long project line widened the card past its column.
- "group/chat relative flex aspect-[8/7] min-w-0 cursor-pointer flex-col gap-2.5 self-stretch rounded-2xl px-5 py-5 transition hover:bg-neutral-100 hover:shadow-none dark:hover:bg-accent/60",
+ // min-h-0 min-w-0: content must not size the card, or one long card grows its whole tab.
+ "group/chat relative flex min-h-0 min-w-0 cursor-pointer flex-col gap-2.5 self-stretch rounded-2xl px-5 py-5 transition hover:bg-neutral-100 hover:shadow-none dark:hover:bg-accent/60",
);
+
+/** Fits the fullest card: tile, two-line title, two-line footer (+1 unit for its icon). */
+export const CHAT_CARD_ROW_MIN =
+ "calc(var(--spacing) * 26 + 2.75 * var(--text-ui-14) + 3 * var(--text-ui-12))";
import {
type ChatContents,
type ChatSort,
diff --git a/studio/frontend/src/features/library/chats/chats-library.tsx b/studio/frontend/src/features/library/chats/chats-library.tsx
index 2bcfb8fe09f..eacec7d7532 100644
--- a/studio/frontend/src/features/library/chats/chats-library.tsx
+++ b/studio/frontend/src/features/library/chats/chats-library.tsx
@@ -92,6 +92,7 @@ import { CardGrid } from "../components/library-cards";
import { LIST_ROW_GAP } from "../components/library-list";
import type { LibraryView } from "../settings-store";
import {
+ CHAT_CARD_ROW_MIN,
ChatCard,
ChatListHeader,
type ChatDestination,
@@ -1109,7 +1110,7 @@ export function ChatsLibrary({
list ? (
<div className={cn("mt-1 flex flex-col", LIST_ROW_GAP)}>{shownEntries.map(entryRow)}</div>
) : (
- <CardGrid equalRows>{shownEntries.map(entryRow)}</CardGrid>
+ <CardGrid minRowHeight={CHAT_CARD_ROW_MIN}>{shownEntries.map(entryRow)}</CardGrid>
)
) : (
groups.map((group) => (
@@ -1124,7 +1125,7 @@ export function ChatsLibrary({
{group.items.map((chat) => chatRow(chat, group.bucket?.kind))}
</div>
) : (
- <CardGrid equalRows>{group.items.map((chat) => chatRow(chat, group.bucket?.kind))}</CardGrid>
+ <CardGrid minRowHeight={CHAT_CARD_ROW_MIN}>{group.items.map((chat) => chatRow(chat, group.bucket?.kind))}</CardGrid>
)}
</section>
))
@@ -1187,11 +1188,11 @@ export function ChatsLibrary({
);
}
return (
- <CardGrid equalRows>
+ <CardGrid minRowHeight={CHAT_CARD_ROW_MIN}>
<button
type="button"
onClick={() => setMovingIntoNew({ kind: "section", chats: [] })}
- className="flex aspect-[8/7] flex-col self-stretch items-center justify-center gap-2 rounded-2xl border border-dashed border-border text-ui-14 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground"
+ className="flex min-h-0 flex-col self-stretch items-center justify-center gap-2 rounded-2xl border border-dashed border-border text-ui-14 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground"
>
<HugeiconsIcon icon={PlusSignIcon} strokeWidth={1.5} className="size-6" />
{t("shell.sections.newSection")}
@@ -1233,7 +1234,7 @@ export function ChatsLibrary({
))}
</div>
) : (
- <CardGrid equalRows>
+ <CardGrid minRowHeight={CHAT_CARD_ROW_MIN}>
{sectionProjects.map((project) => (
<ProjectCard key={project.id} project={project} stats={stats.get(project.id)} showTile={false} />
))}
@@ -1282,12 +1283,12 @@ export function ChatsLibrary({
);
}
return (
- <CardGrid equalRows>
+ <CardGrid minRowHeight={CHAT_CARD_ROW_MIN}>
{!embedded && (
<button
type="button"
onClick={() => setCreatingProject(true)}
- className="flex aspect-[8/7] flex-col self-stretch items-center justify-center gap-2 rounded-2xl border border-dashed border-border text-ui-14 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground"
+ className="flex min-h-0 flex-col self-stretch items-center justify-center gap-2 rounded-2xl border border-dashed border-border text-ui-14 text-muted-foreground transition-colors hover:bg-muted/60 hover:text-foreground"
>
<HugeiconsIcon icon={FolderAddIcon} strokeWidth={1.5} className="size-6" />
{t("library.chats.toolbar.newProject")}
diff --git a/studio/frontend/src/features/library/components/library-cards.tsx b/studio/frontend/src/features/library/components/library-cards.tsx
index 608f9fbe180..eb00050abfe 100644
--- a/studio/frontend/src/features/library/components/library-cards.tsx
+++ b/studio/frontend/src/features/library/components/library-cards.tsx
@@ -355,25 +355,30 @@ export function Masonry<T>({
export function CardGrid({
children,
- equalRows = false,
+ minRowHeight,
}: {
children: ReactNode;
- equalRows?: boolean;
+ /** Rows are max(this, the column's 8:7 height). */
+ minRowHeight?: string;
}) {
const container = useRef<HTMLDivElement>(null);
const columns = useCardColumns(container);
- return (
+ const grid = (
<div
ref={container}
className={cn("grid gap-x-5", CARD_ROW_GAP)}
style={{
gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`,
- gridAutoRows: equalRows ? "1fr" : undefined,
+ gridAutoRows: minRowHeight
+ ? `max(${minRowHeight}, calc((100cqw - ${columns - 1} * var(--spacing) * 5) / ${columns} * 7 / 8))`
+ : undefined,
}}
>
{children}
</div>
);
+ // cqw resolves against an ancestor container, never the grid itself.
+ return minRowHeight ? <div className="@container">{grid}</div> : grid;
}
export function FolderGrid({
diff --git a/studio/frontend/tests/library-chats.test.ts b/studio/frontend/tests/library-chats.test.ts
index e40164d98cf..da036f1039e 100644
--- a/studio/frontend/tests/library-chats.test.ts
+++ b/studio/frontend/tests/library-chats.test.ts
@@ -414,7 +414,15 @@ test("sections have created and last modified dates, and Last modified is the de
test("chat, project and section cards are a little shorter than square, dated bottom left", () => {
const items = readSrc("features/library/chats/chats-items.tsx");
const card = items.slice(items.indexOf("const CARD = cn("), items.indexOf("const ICON ="));
- assert.match(card, /aspect-\[8\/7\]/);
+ assert.doesNotMatch(card, /aspect-\[/);
+ assert.match(card, /min-h-0 min-w-0/);
+ assert.match(card, /CHAT_CARD_ROW_MIN =\s*"calc\(var\(--spacing\) \* 26 \+ 2\.75 \* var\(--text-ui-14\) \+ 3 \* var\(--text-ui-12\)\)"/);
+ const grid = readSrc("features/library/components/library-cards.tsx");
+ assert.match(grid, /max\(\$\{minRowHeight\}, calc\(\(100cqw - \$\{columns - 1\} \* var\(--spacing\) \* 5\) \/ \$\{columns\} \* 7 \/ 8\)\)/);
+ assert.match(grid, /<div className="@container">\{grid\}<\/div>/);
+ const library = readSrc("features/library/chats/chats-library.tsx");
+ assert.doesNotMatch(library, /<CardGrid(?! minRowHeight=\{CHAT_CARD_ROW_MIN\})/);
+ assert.doesNotMatch(library, /aspect-\[8\/7\]/);
assert.doesNotMatch(card, /overflow-hidden/);
assert.match(card, /self-stretch/);
assert.doesNotMatch(items, /cn\(CARD, "min-h-/);