Skip to content

Commit a333811

Browse files
lidge-junjunhajune
authored
fix(models): normalize mobile tab spacing and stabilize Combos layout (#3386)
Carried from #3333 onto current dev. Independent of the other carried fixes, so it ships as its own PR rather than a stack layer. The Models page keeps its panels mounted and toggles hidden, so width rules written against panel CONTENTS behaved differently depending on what had loaded and what had been visited: the catalog column gated on .models-workspace-shell, which is absent during the loading skeleton and after a cold failure, so the tab rendered at 980px and snapped to 1200px once data arrived. Routing had no rule at all and fell back to 980px. Scoping to the visible panel id fixes both and cannot leak to another tab. Combos separately renders its loading and error states without the workspace shell, so full-bleed styling stretched a lone notice edge to edge. That is now limited to the actual workspace. The dashboard page-tabs guard located its target with a bare indexOf(".page-tabs {"), which matches any rule whose selector merely ENDS in that string — including the scoped Combos rule this adds above it. Anchoring the search to a line-start rule fixes the guard without weakening it. Rebuilt from the PR's own diff rather than its files: the first attempt copied gui/src/styles.css wholesale and silently reverted both the Logs clipping fix (#3367) and the sidebar footer rework (#3382). Co-authored-by: jun <[email protected]> Co-authored-by: hajune <[email protected]>
1 parent cfa0383 commit a333811

5 files changed

Lines changed: 156 additions & 8 deletions

File tree

75.5 KB
Loading

‎gui/src/styles-compatibility-matrix.css‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,16 @@
33
Namespace: lab-matrix-
44
============================================================================ */
55

6-
.main-inner:has(.lab-page) {
6+
/*
7+
Scoped to the VISIBLE compatibility panel by id, not to `.lab-page`: the lab renders no
8+
`.lab-page` while it is loading (skeleton), so a `:has(.lab-page)` test dropped the width
9+
to 980px during load and snapped to 1200px afterwards — the tab's size was not fixed. It
10+
also matched from any tab once the lab had been opened (panels stay mounted), leaking the
11+
width across tabs. `#models-panel-compatibility:not([hidden])` is true only while this is
12+
the active tab, so the width is held steady across load/error and never leaks. Matches the
13+
catalog and routing rules in styles-models-workspace.css.
14+
*/
15+
.main-inner:has(#models-panel-compatibility:not([hidden])) {
716
max-width: 1200px;
817
box-sizing: border-box;
918
}

‎gui/src/styles-models-workspace.css‎

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,29 @@
88
/*
99
The catalog wants a wider column than the 980px default.
1010
11-
Scoped to a VISIBLE catalog panel, not merely a present one: panels mount lazily and
12-
then stay mounted so drafts survive a tab hop, so a bare `:has(.models-workspace-shell)`
13-
keeps matching after the catalog has been opened once. Routing would then render at
14-
980px on a direct visit and 1200px afterwards — a width that depends on browsing
15-
history. No surface renders the shell outside a tabpanel any more, so the old
16-
direct-child arm is gone with the standalone pages it served.
11+
Scoped to the VISIBLE catalog panel by its id: `#models-panel-catalog:not([hidden])` is
12+
true only while catalog is the active tab (an inactive panel carries `hidden`), so this
13+
never leaks onto another tab even though panels stay mounted after their first visit.
14+
15+
It deliberately does NOT also require `.models-workspace-shell`: the shell is absent
16+
while the catalog is loading (skeleton) or after a cold failure (error notice), so gating
17+
on it dropped the width back to 980px in those states and snapped it to 1200px only once
18+
data arrived — the catalog tab's size was not fixed. The panel-id test alone holds the
19+
width steady across load, empty, and error, matching the routing rule below.
1720
*/
18-
.main-inner:has(#models-panel-catalog:not([hidden]) .models-workspace-shell) {
21+
.main-inner:has(#models-panel-catalog:not([hidden])) {
22+
max-width: 1200px;
23+
}
24+
25+
/*
26+
Routing shares the catalog/compatibility 1200px column so hopping between the Models
27+
tabs never resizes the page. Scoped to the VISIBLE routing panel for the same reason
28+
the catalog rule is: panels stay mounted after their first visit, so an unscoped `:has`
29+
would leak this width onto whatever tab is open. Without this rule routing fell back to
30+
the 980px `.main-inner` default — a visible width jump on every hop to it, and one that
31+
only appeared once the compatibility tab's own `:has(.lab-page)` had leaked 1200px in.
32+
*/
33+
.main-inner:has(#models-panel-routing:not([hidden])) {
1934
max-width: 1200px;
2035
}
2136

‎gui/src/styles.css‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,46 @@ input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
436436
}
437437
.main-inner.main-inner--combos > .page-sub { margin-bottom: 10px; }
438438

439+
/* Keep the Models tab strip border aligned with its tab buttons in the full-bleed layout. */
440+
.main-inner.main-inner--combos > .page-tabs {
441+
margin-inline: 36px;
442+
padding-inline: 0;
443+
}
444+
445+
/*
446+
Full-bleed is for the combos WORKSPACE grid only. Its loading and error fallbacks render
447+
no `.combos-workspace-shell` (Combos.tsx returns a bare skeleton or an error notice), yet
448+
`main-inner--combos` is applied on tab selection alone — so with no workspace to fill, the
449+
lone subtitle/notice/retry stretched edge to edge (padding:0, max-width:none, flex column)
450+
while every sibling Models tab stayed boxed. That is the "콤보만 영역이 이상해짐" report.
451+
452+
When no workspace shell is present, drop the full-bleed and box the page like the other
453+
tabs: reset the container, its chrome inset, and the fill panel back to normal flow.
454+
*/
455+
/*
456+
Each rule below is a SINGLE selector on purpose. Vite's Rolldown CSS minifier corrupts a
457+
comma-separated selector list whose selectors carry `:not(:has(...))` — it emits a stray
458+
`)` before the block and the browser then drops the whole rule. A single `:not(:has())`
459+
selector minifies correctly, so the chrome inset is handled without a list: the container
460+
drops its own horizontal padding and the page chrome keeps the 36px inline padding it
461+
already gets above (`.main-inner--combos > .page-head` etc.), which the panel matches.
462+
*/
463+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) {
464+
max-width: 1200px;
465+
margin: 0 auto;
466+
padding: 32px 0 64px;
467+
min-height: 0;
468+
height: auto;
469+
overflow: visible;
470+
display: block;
471+
}
472+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) > .models-tab-panel--fill:not([hidden]) {
473+
flex: 0 1 auto;
474+
height: auto;
475+
display: block;
476+
padding-inline: 36px;
477+
}
478+
439479
/* ---- page header ---- */
440480
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
441481
.page-head h2 { font-size: var(--text-title); }
@@ -2347,6 +2387,28 @@ button.prov-account-row.active { cursor: default; }
23472387
.main-inner.main-inner--combos > .page-head,
23482388
.main-inner.main-inner--combos > .page-tabs,
23492389
.main-inner.main-inner--combos > .page-sub { padding-inline: 18px; }
2390+
.main-inner.main-inner--combos > .page-tabs {
2391+
margin-inline: 18px;
2392+
padding-inline: 0;
2393+
}
2394+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) > .models-tab-panel--fill:not([hidden]) {
2395+
padding-inline: 0;
2396+
}
2397+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) {
2398+
padding: 22px 18px 48px;
2399+
}
2400+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) > .page-head {
2401+
padding-inline: 0;
2402+
}
2403+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) > .page-tabs {
2404+
padding-inline: 0;
2405+
}
2406+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) > .page-sub {
2407+
padding-inline: 0;
2408+
}
2409+
.main-inner.main-inner--combos:not(:has(.combos-workspace-shell)) > .page-tabs {
2410+
margin-inline: 0;
2411+
}
23502412
/* settings rows: copy takes the full width, controls drop underneath */
23512413
.setting-row { flex-wrap: wrap; }
23522414
.setting-row .setting-copy { flex: 1 1 100% !important; }
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import { expect, test } from "bun:test";
2+
import { effectiveDeclaration, ruleBodies, withoutComments } from "./helpers/css-declarations";
3+
4+
async function readStylesheet(path: string): Promise<string> {
5+
return withoutComments(await Bun.file(new URL(path, import.meta.url)).text());
6+
}
7+
8+
test("Models tab strips keep their full-bleed container borders aligned", async () => {
9+
const baseStyles = await readStylesheet("../src/styles.css");
10+
const workspaceStyles = await readStylesheet("../src/styles-models-workspace.css");
11+
const compatibilityStyles = await readStylesheet("../src/styles-compatibility-matrix.css");
12+
13+
// The Combos workspace removes the outer container padding. Replacing the tab strip's
14+
// padding with an equal inline margin keeps its border aligned with the tab buttons.
15+
const tabStripSelector = ".main-inner.main-inner--combos > .page-tabs";
16+
const tabStripBodies = ruleBodies(baseStyles, tabStripSelector);
17+
expect(tabStripBodies[0]).toMatch(/margin-inline:\s*36px/);
18+
expect(effectiveDeclaration(baseStyles, tabStripSelector, "margin-inline")).toBe("18px");
19+
expect(effectiveDeclaration(
20+
baseStyles,
21+
tabStripSelector,
22+
"padding-inline",
23+
)).toBe("0");
24+
expect(tabStripBodies.at(-1)).toMatch(/padding-inline:\s*0/);
25+
26+
// Loading, empty, and error fallbacks do not render the workspace shell. Keep those
27+
// shell-free states boxed instead of allowing the full-bleed Combos container to stretch
28+
// their notice and retry controls edge to edge.
29+
const shellFreeContainer = ".main-inner.main-inner--combos:not(:has(.combos-workspace-shell))";
30+
expect(effectiveDeclaration(baseStyles, shellFreeContainer, "max-width")).toBe("1200px");
31+
expect(effectiveDeclaration(baseStyles, shellFreeContainer, "margin")).toBe("0 auto");
32+
expect(ruleBodies(baseStyles, shellFreeContainer)[0]).toMatch(/padding:\s*32px 0 64px/);
33+
expect(effectiveDeclaration(baseStyles, shellFreeContainer, "padding")).toBe("22px 18px 48px");
34+
35+
const shellFreePanel = `${shellFreeContainer} > .models-tab-panel--fill:not([hidden])`;
36+
expect(effectiveDeclaration(baseStyles, shellFreePanel, "display")).toBe("block");
37+
expect(ruleBodies(baseStyles, shellFreePanel)[0]).toMatch(/padding-inline:\s*36px/);
38+
expect(effectiveDeclaration(baseStyles, shellFreePanel, "padding-inline")).toBe("0");
39+
40+
for (const selector of [
41+
`${shellFreeContainer} > .page-head`,
42+
`${shellFreeContainer} > .page-tabs`,
43+
`${shellFreeContainer} > .page-sub`,
44+
]) {
45+
expect(effectiveDeclaration(baseStyles, selector, "padding-inline")).toBe("0");
46+
}
47+
expect(effectiveDeclaration(baseStyles, `${shellFreeContainer} > .page-tabs`, "margin-inline")).toBe("0");
48+
49+
// Every Models workspace tab uses the same column width, including loading/error states
50+
// where the panel content itself may not have mounted yet.
51+
for (const selector of [
52+
".main-inner:has(#models-panel-catalog:not([hidden]))",
53+
".main-inner:has(#models-panel-routing:not([hidden]))",
54+
]) {
55+
expect(effectiveDeclaration(workspaceStyles, selector, "max-width")).toBe("1200px");
56+
}
57+
expect(effectiveDeclaration(
58+
compatibilityStyles,
59+
".main-inner:has(#models-panel-compatibility:not([hidden]))",
60+
"max-width",
61+
)).toBe("1200px");
62+
});

0 commit comments

Comments
 (0)