[GH-ISSUE #2794] [Issue]: Mobile: Display Size scales chrome too — topbar nav buttons overflow off-screen at Large/Huge; preset marker-row name squeezed #1418

Closed
opened 2026-10-21 05:33:28 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @kolacheee on GitHub (Jun 22, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2794

Summary

On mobile (~360-390px viewports), the Settings → Display Size control is the single most disruptive layout lever in the app. It is wired to one thing only — the root font-size on <html> — and because essentially the entire UI is sized in rem/em, that one value scales text AND every padding, gap, icon, button, and container uniformly. There is no chrome-vs-prose decoupling. The result:

  • At larger sizes (Large=19px / Huge=22px): the topbar's two control groups (left + right nav) both grow with the font size. Both are shrink-0 and the bar does not wrap or scroll, so the combined width exceeds the viewport, the middle flex-1 region collapses to 0, and buttons get pushed off-screen / clipped at the edge (or trigger horizontal scroll). This is the umbrella cause of the separately-reported "top nav overflows at Huge."
  • At all sizes (already tight at Default=17px): dense control strips that were never robust to narrow widths get amplified. Preset marker-section rows squeeze the section name very short, and a non-shrink-0 group chip can steal space from it; lorebook tag chips can shrink and wrap raggedly.

The underlying mechanism is real and confirmed in code. Several originally-reported symptoms are overstated (see Root cause); the honest framing is: control strips aren't robust to narrow widths, and the one font lever scales chrome too, so larger Display Sizes compound pre-existing tightness.

Note: the Display Size select actually exposes six sizes (Tiny=12 / Small=14 / Medium=16 / Default=17 / Large=19 / Huge=22), not three. Default 17px is only ~6% above the 16px browser baseline, so layouts that look tight "at Default" are tight regardless of this setting — the setting amplifies, it is not the sole cause.

Symptom & UX impact (mobile)

  • Topbar (Large/Huge): panel-toggle buttons grow and the right <nav> / left controls run off the screen edge or clip; some buttons become unreachable. High-impact because the topbar is primary navigation.
  • Preset editor marker rows: the section name (min-w-0 flex-1 truncate) gets squeezed to an ellipsis or near-zero width when the MARKER badge + group chip are present; the group chip can shrink/wrap and steal width from the name. Names ellipsize (they do not fully vanish — truncate guarantees at least an ellipsis), but readability is degraded.
  • Lorebook tag filters: user-defined tag chips can shrink (no flex-shrink:0) and long multi-word tags wrap internally, producing ragged chip heights. (Built-in single-word category chips do not overlap — they're in flex flex-wrap gap-1, which prevents overlap by design.)

Steps to reproduce

  1. Open the app in a mobile viewport (360-390px wide), e.g. iPhone SE / small Android.
  2. Go to Settings → Display Size. Default is "Default" (17px).
  3. Preset rows: open a preset that has marker sections and grouped sections. Observe the section name squeezed to an ellipsis while the MARKER badge + group chip crowd it.
  4. Lorebook tags: open Lorebooks, expand Tags, with several long/multi-word user tags present. Observe ragged chip heights / mid-word wrapping.
  5. Topbar: set Display Size to Large, then Huge. Observe the topbar buttons grow until the right nav / left controls overflow past the px-3 bar and get clipped or pushed off-screen (not colliding — pushed out). Reproduces every time.

Root cause (exact file:line trace)

One lever drives the root font size:

  • packages/client/src/components/panels/SettingsPanel.tsx:2197-2208 — the Display Size <select> calls setFontSize(Number(...)) with one of 12 | 14 | 16 | 17 | 19 | 22.
  • packages/client/src/stores/ui.store.ts:1034 — fontSize default 17.
  • packages/client/src/App.tsx:406-408 — document.documentElement.style.fontSize = ${fontSize}px on every change.
  • packages/client/src/styles/globals.css:4183-4186 — section "22. DISPLAY SIZE SCALING" is comment-only ("All sizes now use rem so they scale with the root font-size set by App.tsx"). There is no --scale, no data-* attribute, no html rule — confirming there is no chrome-vs-prose decoupling. Text and all rem chrome scale together.

Topbar overflow (the real Large/Huge failure):

  • packages/client/src/components/layout/TopBar.tsx:205 — header is flex h-12 flex-shrink-0 items-center justify-between ... px-3.
  • :212 — left controls group flex shrink-0 items-center gap-2.
  • :279-283 — right <nav> is flex shrink-0 items-center justify-end gap-0.5 ... max-sm:gap-0 max-sm:p-0.5. No flex-wrap, no overflow-x-auto, no collapse. (rightNavRef at :280 is used only for Spotify-fit measurement at lines 155-176, not for nav overflow relief.)
  • :62 — TOPBAR_PANEL_BUTTON_CLASS = "relative rounded-lg p-2 transition-all duration-200 max-sm:p-1.5" — rem padding, no fixed dimensions.
  • Icons are size="0.9375rem" (lines 301, 322, 346, 378). At 17px root each button is ~29px; at 22px root ~37px.
  • Mechanism: both control groups are shrink-0 and the bar is justify-between with the middle flex-1 collapsing to 0. As font size grows, the two groups' combined width exceeds the viewport, so buttons are pushed past px-3 and clipped/scrolled off-screen. They keep their per-button spacing — they do not collide. The right nav has 8 buttons (Browser :286 + Characters :307 + 5 RIGHT_PANEL_BUTTONS + Settings :363); the left chat/home buttons live in the separate :212 group. (Original "11 buttons squish/overlap" was wrong on both count and failure mode.)

Preset marker row (name squeeze):

  • packages/client/src/components/presets/PresetEditor.tsx:1282-1386 — dense row: grip + 2 arrows (1283), chevron (1324), role icon (1332), 3 right buttons (1350) are all shrink-0, around a min-w-0 flex-1 truncate name (1333-1338).
  • :1341 — MARKER badge is already shrink-0 (fine).
  • :1345 — {group && <span className="mari-editor-chip px-1.5 py-0.5 text-[0.5625rem]">{group.name}</span>} — the group chip lacks shrink-0 and whitespace-nowrap, so it can shrink/wrap and steal width from the flex-1 name. This is the genuinely fixable defect here. Note this chip uses mari-editor-chip (globals.css:1600, no flex-shrink) — not mari-chrome-control — so a CSS fix on .mari-chrome-control will NOT cover it; it needs an inline class change.
  • :1346 — the role label is hidden ... sm:inline, so it's absent on mobile (not a contributor). The name still truncates under pressure, which is acceptable; it does not become "invisible."

Lorebook tag chips (ragged wrap):

  • packages/client/src/components/panels/LorebooksPanel.tsx:771 and :802 — both chip groups are flex flex-wrap gap-1 → overlap is impossible by design.
  • :779, :790 — PRIMARY category chips already have whitespace-nowrap.
  • :822 — TAGGED-category chips use mari-chrome-control mari-chrome-control--compact and lack whitespace-nowrap. But all built-in category labels are single words (CATEGORIES are All/Active/World/Character/NPC/Spellbook/Other), so the missing whitespace-nowrap here is effectively a no-op — single words don't wrap.
  • :842-845 — user-defined tag chips use mari-chrome-control mari-chrome-control--compact and also lack whitespace-nowrap; these can be multi-word, so they wrap mid-tag.
  • globals.css:619-636 .mari-chrome-control and :661-666 --compact define no flex-shrink and no min-width, so chips can shrink in the wrap container, producing ragged heights. This (not "overlap") is the real defect.

Suggested fix (concrete)

Targeted bugfix (recommended scope for this PR):

1. Pin topbar buttons + icons to fixed px (cures Large/Huge overflow). This stops the nav from growing with Display Size — the actual cure. Apply to BOTH the right nav and the left controls group (line 212) so the left group doesn't re-create overflow.

// TopBar.tsx:62 — fixed hit-target, responsive smaller on mobile
const TOPBAR_PANEL_BUTTON_CLASS =
  "relative flex h-8 w-8 items-center justify-center rounded-lg p-0 transition-all duration-200 max-sm:h-7 max-sm:w-7";
// All panel-button icons: swap rem for fixed px (lines 301, 322, 346, 378)
<Bot size={15} className={TOPBAR_ACCENT_ICON_CLASS} />

Apply the same fixed-px sizing to the left-controls buttons/icons under :212. Math: 8 right buttons × ~30px + 2 left buttons + px-3 fits ~360px even at Huge, so no overflow-x-auto is needed — and adding it to a 48px bar is poor UX. Drop the originally-proposed overflow-x-auto (keep only as a defensive fallback if desired).

2. Keep lorebook chips from shrinking + wrapping.

/* globals.css:619 — add to .mari-chrome-control */
.mari-chrome-control { flex-shrink: 0; }
// LorebooksPanel.tsx:842 — add whitespace-nowrap to the TAG chip className
"mari-chrome-control mari-chrome-control--compact group/tag cursor-pointer whitespace-nowrap"

(Adding whitespace-nowrap to the category chips at :822 is a no-op for shipped single-word labels — harmless but don't bill it as the fix. Bumping gap-1→gap-1.5 at :802 is cosmetic, not a fix for "overlap," which doesn't occur.)

3. Protect the preset section name. Add shrink-0 whitespace-nowrap to the group chip so the flex-1 name keeps priority; also pin the row's control icons to px so they don't bloat at Huge.

// PresetEditor.tsx:1345
{group && (
  <span className="mari-editor-chip shrink-0 whitespace-nowrap px-1.5 py-0.5 text-[0.5625rem]">
    {group.name}
  </span>
)}

The name will still truncate — that is acceptable. Prefer this pin-and-shrink-0 approach over restructuring the header to flex-wrap (which changes the single-row design and may look worse); flex-wrap is an alternative only if the pinned approach proves insufficient.

Alternatives / long-term (file as follow-up, not required here): introduce a --ui-control-scale (or px/clamp() hit-targets) so Display Size scales prose only while chrome stays fixed. That is the correct architecture but larger than this bugfix needs.

Affected files

  • packages/client/src/App.tsx (mechanism reference: :406-408)
  • packages/client/src/stores/ui.store.ts (mechanism reference: :1034)
  • packages/client/src/components/panels/SettingsPanel.tsx (mechanism reference: :2197-2208)
  • packages/client/src/components/layout/TopBar.tsx (fix: :62, :212, :279-283, icon sizes :301/322/346/378)
  • packages/client/src/components/presets/PresetEditor.tsx (fix: :1345, row icons :1282-1386)
  • packages/client/src/components/panels/LorebooksPanel.tsx (fix: :842)
  • packages/client/src/styles/globals.css (fix: .mari-chrome-control :619; refs :1600 .mari-editor-chip, :4183-4186 comment-only section)

Validation

  • pnpm check passes (TypeScript + ESLint).
  • Topbar fits without horizontal overflow at 360px at every Display Size: Tiny / Small / Medium / Default / Large / Huge (test the extremes especially).
  • No topbar buttons clipped or pushed off-screen at Large and Huge; all panel toggles remain tappable.
  • Left controls group (chat/home) also stays within bounds at Huge (not just the right nav).
  • Preset marker-section rows at 360px: section name stays readable (truncates with ellipsis, not squeezed to ~0) when MARKER badge + group chip are present, at Default and Huge.
  • Preset group chip no longer shrinks/wraps to steal name width.
  • Lorebook Tags expanded at 360px: long/multi-word user tags do not wrap mid-tag; chip heights are even, at Default and Huge.
  • Lorebook category chips and primary filters unchanged (no regression).
  • Verify no overflow-x-auto scrollbar was introduced in the 48px topbar.
  • Manually verify each Display Size on a real small device or device emulation (DevTools), not just desktop narrow-resize.

AI-investigated against released 2.0.0; verify before fixing.

Originally created by @kolacheee on GitHub (Jun 22, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/2794 ## Summary On mobile (~360-390px viewports), the **Settings → Display Size** control is the single most disruptive layout lever in the app. It is wired to one thing only — the root `font-size` on `<html>` — and because essentially the entire UI is sized in `rem`/`em`, that one value scales **text AND every padding, gap, icon, button, and container uniformly**. There is no chrome-vs-prose decoupling. The result: - **At larger sizes (Large=19px / Huge=22px):** the topbar's two control groups (left + right nav) both grow with the font size. Both are `shrink-0` and the bar does not wrap or scroll, so the combined width exceeds the viewport, the middle `flex-1` region collapses to 0, and buttons get pushed off-screen / clipped at the edge (or trigger horizontal scroll). This is the umbrella cause of the separately-reported "top nav overflows at Huge." - **At all sizes (already tight at Default=17px):** dense control strips that were never robust to narrow widths get amplified. Preset marker-section rows squeeze the section name very short, and a non-`shrink-0` group chip can steal space from it; lorebook tag chips can shrink and wrap raggedly. The underlying mechanism is real and confirmed in code. Several originally-reported symptoms are overstated (see Root cause); the honest framing is: **control strips aren't robust to narrow widths, and the one font lever scales chrome too, so larger Display Sizes compound pre-existing tightness.** > Note: the Display Size select actually exposes **six** sizes (Tiny=12 / Small=14 / Medium=16 / Default=17 / Large=19 / Huge=22), not three. Default 17px is only ~6% above the 16px browser baseline, so layouts that look tight "at Default" are tight regardless of this setting — the setting amplifies, it is not the sole cause. ## Symptom & UX impact (mobile) - **Topbar (Large/Huge):** panel-toggle buttons grow and the right `<nav>` / left controls run off the screen edge or clip; some buttons become unreachable. High-impact because the topbar is primary navigation. - **Preset editor marker rows:** the section name (`min-w-0 flex-1 truncate`) gets squeezed to an ellipsis or near-zero width when the `MARKER` badge + group chip are present; the group chip can shrink/wrap and steal width from the name. Names ellipsize (they do **not** fully vanish — `truncate` guarantees at least an ellipsis), but readability is degraded. - **Lorebook tag filters:** user-defined tag chips can shrink (no `flex-shrink:0`) and long multi-word tags wrap internally, producing ragged chip heights. (Built-in single-word category chips do **not** overlap — they're in `flex flex-wrap gap-1`, which prevents overlap by design.) ## Steps to reproduce 1. Open the app in a mobile viewport (360-390px wide), e.g. iPhone SE / small Android. 2. Go to **Settings → Display Size**. Default is "Default" (17px). 3. **Preset rows:** open a preset that has marker sections and grouped sections. Observe the section name squeezed to an ellipsis while the `MARKER` badge + group chip crowd it. 4. **Lorebook tags:** open Lorebooks, expand **Tags**, with several long/multi-word user tags present. Observe ragged chip heights / mid-word wrapping. 5. **Topbar:** set Display Size to **Large**, then **Huge**. Observe the topbar buttons grow until the right nav / left controls overflow past the `px-3` bar and get clipped or pushed off-screen (not colliding — pushed out). Reproduces every time. ## Root cause (exact file:line trace) **One lever drives the root font size:** - `packages/client/src/components/panels/SettingsPanel.tsx:2197-2208` — the Display Size `<select>` calls `setFontSize(Number(...))` with one of `12 | 14 | 16 | 17 | 19 | 22`. - `packages/client/src/stores/ui.store.ts:1034` — `fontSize` default `17`. - `packages/client/src/App.tsx:406-408` — `document.documentElement.style.fontSize = ${fontSize}px` on every change. - `packages/client/src/styles/globals.css:4183-4186` — section "22. DISPLAY SIZE SCALING" is **comment-only** ("All sizes now use rem so they scale with the root font-size set by App.tsx"). There is no `--scale`, no `data-*` attribute, no `html` rule — confirming there is **no** chrome-vs-prose decoupling. Text and all `rem` chrome scale together. **Topbar overflow (the real Large/Huge failure):** - `packages/client/src/components/layout/TopBar.tsx:205` — header is `flex h-12 flex-shrink-0 items-center justify-between ... px-3`. - `:212` — left controls group `flex shrink-0 items-center gap-2`. - `:279-283` — right `<nav>` is `flex shrink-0 items-center justify-end gap-0.5 ... max-sm:gap-0 max-sm:p-0.5`. No `flex-wrap`, no `overflow-x-auto`, no collapse. (`rightNavRef` at `:280` is used only for Spotify-fit measurement at lines 155-176, not for nav overflow relief.) - `:62` — `TOPBAR_PANEL_BUTTON_CLASS = "relative rounded-lg p-2 transition-all duration-200 max-sm:p-1.5"` — `rem` padding, no fixed dimensions. - Icons are `size="0.9375rem"` (lines 301, 322, 346, 378). At 17px root each button is ~29px; at 22px root ~37px. - **Mechanism:** both control groups are `shrink-0` and the bar is `justify-between` with the middle `flex-1` collapsing to 0. As font size grows, the two groups' combined width exceeds the viewport, so buttons are pushed past `px-3` and clipped/scrolled off-screen. They keep their per-button spacing — they do **not** collide. The right nav has **8** buttons (Browser `:286` + Characters `:307` + 5 `RIGHT_PANEL_BUTTONS` + Settings `:363`); the left chat/home buttons live in the separate `:212` group. (Original "11 buttons squish/overlap" was wrong on both count and failure mode.) **Preset marker row (name squeeze):** - `packages/client/src/components/presets/PresetEditor.tsx:1282-1386` — dense row: grip + 2 arrows (`1283`), chevron (`1324`), role icon (`1332`), 3 right buttons (`1350`) are all `shrink-0`, around a `min-w-0 flex-1 truncate` name (`1333-1338`). - `:1341` — `MARKER` badge is already `shrink-0` (fine). - `:1345` — `{group && <span className="mari-editor-chip px-1.5 py-0.5 text-[0.5625rem]">{group.name}</span>}` — **the group chip lacks `shrink-0` and `whitespace-nowrap`**, so it can shrink/wrap and steal width from the `flex-1` name. This is the genuinely fixable defect here. Note this chip uses `mari-editor-chip` (globals.css:1600, no flex-shrink) — **not** `mari-chrome-control` — so a CSS fix on `.mari-chrome-control` will NOT cover it; it needs an inline class change. - `:1346` — the role label is `hidden ... sm:inline`, so it's absent on mobile (not a contributor). The name still `truncate`s under pressure, which is acceptable; it does not become "invisible." **Lorebook tag chips (ragged wrap):** - `packages/client/src/components/panels/LorebooksPanel.tsx:771` and `:802` — both chip groups are `flex flex-wrap gap-1` → overlap is impossible by design. - `:779`, `:790` — PRIMARY category chips **already** have `whitespace-nowrap`. - `:822` — TAGGED-category chips use `mari-chrome-control mari-chrome-control--compact` and lack `whitespace-nowrap`. **But all built-in category labels are single words** (`CATEGORIES` are All/Active/World/Character/NPC/Spellbook/Other), so the missing `whitespace-nowrap` here is effectively a **no-op** — single words don't wrap. - `:842-845` — user-defined **tag** chips use `mari-chrome-control mari-chrome-control--compact` and also lack `whitespace-nowrap`; these can be multi-word, so they wrap mid-tag. - `globals.css:619-636` `.mari-chrome-control` and `:661-666` `--compact` define **no `flex-shrink` and no `min-width`**, so chips can shrink in the wrap container, producing ragged heights. This (not "overlap") is the real defect. ## Suggested fix (concrete) Targeted bugfix (recommended scope for this PR): **1. Pin topbar buttons + icons to fixed px (cures Large/Huge overflow).** This stops the nav from growing with Display Size — the actual cure. Apply to BOTH the right nav and the left controls group (line 212) so the left group doesn't re-create overflow. ```ts // TopBar.tsx:62 — fixed hit-target, responsive smaller on mobile const TOPBAR_PANEL_BUTTON_CLASS = "relative flex h-8 w-8 items-center justify-center rounded-lg p-0 transition-all duration-200 max-sm:h-7 max-sm:w-7"; ``` ```tsx // All panel-button icons: swap rem for fixed px (lines 301, 322, 346, 378) <Bot size={15} className={TOPBAR_ACCENT_ICON_CLASS} /> ``` Apply the same fixed-px sizing to the left-controls buttons/icons under `:212`. Math: 8 right buttons × ~30px + 2 left buttons + `px-3` fits ~360px even at Huge, so **no `overflow-x-auto` is needed** — and adding it to a 48px bar is poor UX. Drop the originally-proposed `overflow-x-auto` (keep only as a defensive fallback if desired). **2. Keep lorebook chips from shrinking + wrapping.** ```css /* globals.css:619 — add to .mari-chrome-control */ .mari-chrome-control { flex-shrink: 0; } ``` ```tsx // LorebooksPanel.tsx:842 — add whitespace-nowrap to the TAG chip className "mari-chrome-control mari-chrome-control--compact group/tag cursor-pointer whitespace-nowrap" ``` (Adding `whitespace-nowrap` to the category chips at `:822` is a no-op for shipped single-word labels — harmless but don't bill it as the fix. Bumping `gap-1`→`gap-1.5` at `:802` is cosmetic, not a fix for "overlap," which doesn't occur.) **3. Protect the preset section name.** Add `shrink-0 whitespace-nowrap` to the group chip so the `flex-1` name keeps priority; also pin the row's control icons to px so they don't bloat at Huge. ```tsx // PresetEditor.tsx:1345 {group && ( <span className="mari-editor-chip shrink-0 whitespace-nowrap px-1.5 py-0.5 text-[0.5625rem]"> {group.name} </span> )} ``` The name will still `truncate` — that is acceptable. Prefer this pin-and-`shrink-0` approach over restructuring the header to `flex-wrap` (which changes the single-row design and may look worse); flex-wrap is an alternative only if the pinned approach proves insufficient. **Alternatives / long-term (file as follow-up, not required here):** introduce a `--ui-control-scale` (or px/`clamp()` hit-targets) so Display Size scales **prose only** while chrome stays fixed. That is the correct architecture but larger than this bugfix needs. ## Affected files - `packages/client/src/App.tsx` (mechanism reference: `:406-408`) - `packages/client/src/stores/ui.store.ts` (mechanism reference: `:1034`) - `packages/client/src/components/panels/SettingsPanel.tsx` (mechanism reference: `:2197-2208`) - `packages/client/src/components/layout/TopBar.tsx` (fix: `:62`, `:212`, `:279-283`, icon sizes `:301/322/346/378`) - `packages/client/src/components/presets/PresetEditor.tsx` (fix: `:1345`, row icons `:1282-1386`) - `packages/client/src/components/panels/LorebooksPanel.tsx` (fix: `:842`) - `packages/client/src/styles/globals.css` (fix: `.mari-chrome-control` `:619`; refs `:1600 .mari-editor-chip`, `:4183-4186` comment-only section) ## Validation - [ ] `pnpm check` passes (TypeScript + ESLint). - [ ] Topbar fits without horizontal overflow at **360px** at every Display Size: Tiny / Small / Medium / Default / Large / **Huge** (test the extremes especially). - [ ] No topbar buttons clipped or pushed off-screen at Large and Huge; all panel toggles remain tappable. - [ ] Left controls group (chat/home) also stays within bounds at Huge (not just the right nav). - [ ] Preset marker-section rows at 360px: section name stays readable (truncates with ellipsis, not squeezed to ~0) when `MARKER` badge + group chip are present, at Default and Huge. - [ ] Preset group chip no longer shrinks/wraps to steal name width. - [ ] Lorebook **Tags** expanded at 360px: long/multi-word user tags do not wrap mid-tag; chip heights are even, at Default and Huge. - [ ] Lorebook category chips and primary filters unchanged (no regression). - [ ] Verify no `overflow-x-auto` scrollbar was introduced in the 48px topbar. - [ ] Manually verify each Display Size on a real small device or device emulation (DevTools), not just desktop narrow-resize. --- _AI-investigated against released 2.0.0; verify before fixing._
Author
Owner

@SpicyMarinara commented on GitHub (Jun 22, 2026):

Addressed in PR #2790 / commit acab1fba: topbar controls now keep fixed responsive dimensions, chrome controls stop shrinking, and lorebook/preset chips avoid wrapping or squeezing into adjacent controls at large display sizes.

<!-- gh-comment-id:4772440982 --> @SpicyMarinara commented on GitHub (Jun 22, 2026): Addressed in PR #2790 / commit acab1fba: topbar controls now keep fixed responsive dimensions, chrome controls stop shrinking, and lorebook/preset chips avoid wrapping or squeezing into adjacent controls at large display sizes.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#1418
No description provided.