TheYuchen commited on
Commit
78949f0
·
1 Parent(s): cfc7fea

Layout: no horizontal page scroll at any width >= 768px (band overlay)

Browse files

At 864px CSS the app rendered wider than the viewport: persisted pane
widths from a wider monitor were only clamped on window-resize EVENTS
(never on mount), and even freshly clamped the 768-1200px range cannot
host both panes in flow at all -- LEFT_MIN + RIGHT_MIN + MIN_CANVAS_W +
two resizers = 808px, so the Evidence pane and toolbar cluster sat past
the right edge and the board grid computed auto-fill columns from a
container wider than the screen.

App.tsx now carries an explicit RESPONSIVE CONTRACT comment block and
implements it: 768-1199px is the compact-desktop "band", where the
Evidence pane never takes layout width -- it boots collapsed to its
32px strip and, when expanded (strip click, run-start auto-expand, the
hintExpandRightPane bridge), opens as a right-anchored overlay over the
center column (bandEvidenceOpen: session state, never persisted, so
band sessions cannot rewrite the >=1200px preference). The mount+resize
clamp is band-aware and runs once at mount. The center column keeps
owning remaining width via flex-1 + min-w-0.

MultiverseBoard: grid tracks become minmax(min(240px,100%),1fr) and the
scroll body gains overflow-x-hidden, so a narrow container shrinks the
column instead of minting a horizontal scrollbar (overflow-y:auto used
to force overflow-x:auto).

frontend/src/App.tsx CHANGED
@@ -6,7 +6,7 @@ import { api } from "./lib/api";
6
  import { getUserId } from "./lib/userId";
7
  import { useApp } from "./lib/store";
8
  import { ensureDemoArchive } from "./lib/demoArchive";
9
- import { useIsDesktop } from "./lib/useMediaQuery";
10
  import { TopBar } from "./components/TopBar";
11
  import { NodePalette } from "./components/NodePalette";
12
  import { FlowCanvas } from "./components/FlowCanvas";
@@ -18,6 +18,33 @@ import { MobileDrawer } from "./components/MobileDrawer";
18
  import { WelcomeTour, useFirstVisitTour } from "./components/WelcomeTour";
19
  import { activateScenario } from "./lib/scenarios";
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  // Default + clamp bounds for the two side panels. The middle canvas flexes.
22
  const LEFT_DEFAULT = 320;
23
  const LEFT_MIN = 220;
@@ -26,6 +53,8 @@ const RIGHT_DEFAULT = 400;
26
  const RIGHT_MIN = 300;
27
  const RIGHT_MAX = 720;
28
  const COLLAPSED_W = 32;
 
 
29
 
30
  // Minimum width we ever want to leave for the canvas (NodePalette + React
31
  // Flow). Below this, NodePalette tiles (each fixed at 108px and shrink-0)
@@ -73,6 +102,9 @@ export default function App() {
73
  const theaterOpen = useApp((s) => s.theaterOpen);
74
  const [ready, setReady] = useState(false);
75
  const isDesktop = useIsDesktop();
 
 
 
76
 
77
  // Welcome tour: auto-opens on the first visit (skipped under
78
  // ?scenario= boots), re-openable from the TopBar Tour button.
@@ -102,6 +134,14 @@ export default function App() {
102
  const [leftDrawerOpen, setLeftDrawerOpen] = useState(false);
103
  const [rightDrawerOpen, setRightDrawerOpen] = useState(false);
104
 
 
 
 
 
 
 
 
 
105
  // FlowCanvas can ask us to surface the CircuitPicker when the user
106
  // tries to run without a circuit selected.
107
  const hintExpandLeftPane = useApp((s) => s.hintExpandLeftPane);
@@ -117,9 +157,10 @@ export default function App() {
117
  const hintExpandRightPane = useApp((s) => s.hintExpandRightPane);
118
  useEffect(() => {
119
  if (hintExpandRightPane === 0) return;
120
- if (isDesktop) setRightCollapsed(false);
121
- else setRightDrawerOpen(true);
122
- }, [hintExpandRightPane, isDesktop]);
 
123
 
124
  // True while a PaneResizer drag is in flight. We use it to suppress the
125
  // CSS `transition-[width]` during dragging: setRightW / setLeftW fire on
@@ -170,14 +211,18 @@ export default function App() {
170
  const prevRunningRef = useRef(running);
171
  useEffect(() => {
172
  if (running && !prevRunningRef.current) {
173
- if (isDesktop) {
174
- if (rightCollapsed) setRightCollapsed(false);
175
- } else {
176
  setRightDrawerOpen(true);
 
 
 
 
 
 
177
  }
178
  }
179
  prevRunningRef.current = running;
180
- }, [running, rightCollapsed, isDesktop]);
181
 
182
  // Close any open drawer as soon as we leave mobile layout, so switching
183
  // from portrait to landscape doesn't leave a floating panel hanging.
@@ -188,33 +233,38 @@ export default function App() {
188
  }
189
  }, [isDesktop]);
190
 
191
- // Window resize → shrink oversized panes back into the safe zone.
192
- // The drag-time clamp keeps users from making things too wide; this
193
- // covers the case where the user shrinks the window after panes were
194
- // already wide. Without it, current widths could exceed the dynamic
195
- // max for the new viewport, and NodePalette tiles would overflow into
196
- // the side panes again.
197
  useEffect(() => {
198
  if (!isDesktop) return;
199
- const onResize = () => {
200
  const ww = window.innerWidth;
201
- const leftFoot = leftCollapsed ? COLLAPSED_W : 0; // pane footprint computed below
202
- const rightFoot = rightCollapsed ? COLLAPSED_W : 0;
203
- // Headroom each pane has, given the *other* pane and resizers.
 
 
 
 
204
  const maxLeft = Math.min(
205
  LEFT_MAX,
206
- ww - (rightCollapsed ? rightFoot : rightW + RESIZER_W) - RESIZER_W - MIN_CANVAS_W,
207
  );
208
  const maxRight = Math.min(
209
  RIGHT_MAX,
210
- ww - (leftCollapsed ? leftFoot : leftW + RESIZER_W) - RESIZER_W - MIN_CANVAS_W,
211
  );
212
  setLeftW((w) => Math.max(LEFT_MIN, Math.min(w, Math.max(LEFT_MIN, maxLeft))));
213
  setRightW((w) => Math.max(RIGHT_MIN, Math.min(w, Math.max(RIGHT_MIN, maxRight))));
214
  };
215
- window.addEventListener("resize", onResize);
216
- return () => window.removeEventListener("resize", onResize);
217
- }, [isDesktop, leftCollapsed, rightCollapsed, leftW, rightW]);
 
218
 
219
  const setPlugins = useApp((s) => s.setPlugins);
220
  useEffect(() => {
@@ -269,7 +319,10 @@ export default function App() {
269
  }, []);
270
 
271
  const leftWidth = leftCollapsed ? COLLAPSED_W : leftW;
272
- const rightWidth = rightCollapsed ? COLLAPSED_W : rightW;
 
 
 
273
 
274
  return (
275
  // h-[100dvh] uses the dynamic viewport height — iOS Safari shrinks
@@ -288,7 +341,7 @@ export default function App() {
288
  />
289
  {isDesktop ? (
290
  /* ===================== Desktop ===================== */
291
- <div className="flex-1 flex min-h-0">
292
  <aside
293
  style={{ width: leftWidth }}
294
  className={`shrink-0 border-r border-edge flex flex-col min-h-0 ${
@@ -313,7 +366,7 @@ export default function App() {
313
  // the canvas falls below MIN_CANVAS_W. Account for the
314
  // right pane's current footprint (collapsed strip when
315
  // collapsed, full width otherwise) and both resizers.
316
- const rightFoot = rightCollapsed ? COLLAPSED_W : rightW + RESIZER_W;
317
  const dynamicMax = Math.min(
318
  LEFT_MAX,
319
  window.innerWidth - rightFoot - RESIZER_W - MIN_CANVAS_W,
@@ -354,7 +407,7 @@ export default function App() {
354
  </div>
355
  )}
356
  </main>
357
- {!rightCollapsed && (
358
  <PaneResizer
359
  onResize={(dx) =>
360
  setRightW((w) => {
@@ -381,18 +434,38 @@ export default function App() {
381
  style={{ width: rightWidth }}
382
  className={`shrink-0 border-l border-edge flex flex-col min-h-0 overflow-x-hidden ${
383
  isResizing ? "" : "transition-[width] duration-150"
384
- } ${rightCollapsed ? "overflow-hidden" : ""}`}
385
  >
386
- {rightCollapsed ? (
387
  <CollapsedStrip
388
  label="Evidence"
389
  side="right"
390
- onExpand={() => setRightCollapsed(false)}
 
 
391
  />
392
  ) : (
393
  <ResultsPane onCollapse={() => setRightCollapsed(true)} />
394
  )}
395
  </aside>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
396
  </div>
397
  ) : (
398
  /* ===================== Mobile ====================== */
 
6
  import { getUserId } from "./lib/userId";
7
  import { useApp } from "./lib/store";
8
  import { ensureDemoArchive } from "./lib/demoArchive";
9
+ import { useIsDesktop, useMediaQuery } from "./lib/useMediaQuery";
10
  import { TopBar } from "./components/TopBar";
11
  import { NodePalette } from "./components/NodePalette";
12
  import { FlowCanvas } from "./components/FlowCanvas";
 
18
  import { WelcomeTour, useFirstVisitTour } from "./components/WelcomeTour";
19
  import { activateScenario } from "./lib/scenarios";
20
 
21
+ // ---------------------------------------------------------------------------
22
+ // RESPONSIVE CONTRACT (no horizontal page scroll at ANY width ≥ 768px)
23
+ //
24
+ // <768px mobile: both side panes become MobileDrawers; the Run
25
+ // FAB replaces the toolbar Run button.
26
+ // 768–1199px compact desktop ("the band"): the left pane stays in
27
+ // flow (its clamps account for the strip), but the
28
+ // Evidence pane NEVER takes layout width — it boots
29
+ // collapsed to its 32px strip and, when expanded, opens
30
+ // as a right-anchored OVERLAY over the center column
31
+ // (bandEvidenceOpen: session state, never persisted).
32
+ // Rationale: LEFT_MIN + RIGHT_MIN + MIN_CANVAS_W + two
33
+ // resizers = 808px, so hosting both panes in flow is
34
+ // impossible at 768px and cramped through ~1200px.
35
+ // ≥1200px full desktop: three columns, both panes resizable,
36
+ // widths + collapsed preferences persisted.
37
+ //
38
+ // Two width guards keep the columns inside the viewport: the drag-time
39
+ // clamp in each PaneResizer, and the mount+resize clamp effect below —
40
+ // it MUST run on mount, not just on resize events, because persisted
41
+ // widths from a wider monitor would otherwise overflow the first paint
42
+ // into horizontal scroll. The center column owns all remaining width
43
+ // (flex-1 + min-w-0 down to the board grid, whose auto-fill tracks are
44
+ // minmax(min(240px,100%),1fr)); the board/theater overlays are
45
+ // absolutely positioned inside it, so nothing can widen the page.
46
+ // ---------------------------------------------------------------------------
47
+
48
  // Default + clamp bounds for the two side panels. The middle canvas flexes.
49
  const LEFT_DEFAULT = 320;
50
  const LEFT_MIN = 220;
 
53
  const RIGHT_MIN = 300;
54
  const RIGHT_MAX = 720;
55
  const COLLAPSED_W = 32;
56
+ // Full-desktop threshold — below this (and ≥768px) is "the band".
57
+ const WIDE_QUERY = "(min-width: 1200px)";
58
 
59
  // Minimum width we ever want to leave for the canvas (NodePalette + React
60
  // Flow). Below this, NodePalette tiles (each fixed at 108px and shrink-0)
 
102
  const theaterOpen = useApp((s) => s.theaterOpen);
103
  const [ready, setReady] = useState(false);
104
  const isDesktop = useIsDesktop();
105
+ const isWide = useMediaQuery(WIDE_QUERY);
106
+ // 768–1199px compact-desktop band (see RESPONSIVE CONTRACT above).
107
+ const band = isDesktop && !isWide;
108
 
109
  // Welcome tour: auto-opens on the first visit (skipped under
110
  // ?scenario= boots), re-openable from the TopBar Tour button.
 
134
  const [leftDrawerOpen, setLeftDrawerOpen] = useState(false);
135
  const [rightDrawerOpen, setRightDrawerOpen] = useState(false);
136
 
137
+ // Band (768–1199px) Evidence overlay — session-only, never
138
+ // persisted: the band boots collapsed-by-default regardless of the
139
+ // ≥1200px preference, and expanding here must not rewrite it.
140
+ const [bandEvidenceOpen, setBandEvidenceOpen] = useState(false);
141
+ useEffect(() => {
142
+ if (!band) setBandEvidenceOpen(false);
143
+ }, [band]);
144
+
145
  // FlowCanvas can ask us to surface the CircuitPicker when the user
146
  // tries to run without a circuit selected.
147
  const hintExpandLeftPane = useApp((s) => s.hintExpandLeftPane);
 
157
  const hintExpandRightPane = useApp((s) => s.hintExpandRightPane);
158
  useEffect(() => {
159
  if (hintExpandRightPane === 0) return;
160
+ if (!isDesktop) setRightDrawerOpen(true);
161
+ else if (band) setBandEvidenceOpen(true);
162
+ else setRightCollapsed(false);
163
+ }, [hintExpandRightPane, isDesktop, band]);
164
 
165
  // True while a PaneResizer drag is in flight. We use it to suppress the
166
  // CSS `transition-[width]` during dragging: setRightW / setLeftW fire on
 
211
  const prevRunningRef = useRef(running);
212
  useEffect(() => {
213
  if (running && !prevRunningRef.current) {
214
+ if (!isDesktop) {
 
 
215
  setRightDrawerOpen(true);
216
+ } else if (band) {
217
+ // Band: surface progress as the overlay — the in-flow pane
218
+ // must not take layout width here (RESPONSIVE CONTRACT).
219
+ setBandEvidenceOpen(true);
220
+ } else if (rightCollapsed) {
221
+ setRightCollapsed(false);
222
  }
223
  }
224
  prevRunningRef.current = running;
225
+ }, [running, rightCollapsed, isDesktop, band]);
226
 
227
  // Close any open drawer as soon as we leave mobile layout, so switching
228
  // from portrait to landscape doesn't leave a floating panel hanging.
 
233
  }
234
  }, [isDesktop]);
235
 
236
+ // Mount + window-resize clamp → shrink oversized panes back into
237
+ // the safe zone (RESPONSIVE CONTRACT). The drag-time clamp keeps
238
+ // users from making things too wide while dragging; this covers (a)
239
+ // the user shrinking the window afterwards and (b) BOOTING at a
240
+ // narrower viewport than the persisted widths came from — (b) is why
241
+ // it runs once immediately, not only on resize events.
242
  useEffect(() => {
243
  if (!isDesktop) return;
244
+ const clamp = () => {
245
  const ww = window.innerWidth;
246
+ // In the band the right pane is always its strip in flow (the
247
+ // expanded pane is an overlay, costing no layout width).
248
+ const rightInFlow =
249
+ band || rightCollapsed ? COLLAPSED_W : rightW + RESIZER_W;
250
+ const leftInFlow = leftCollapsed ? COLLAPSED_W : leftW + RESIZER_W;
251
+ // Headroom each pane has, given the *other* pane's in-flow
252
+ // footprint, its own resizer and the canvas floor.
253
  const maxLeft = Math.min(
254
  LEFT_MAX,
255
+ ww - rightInFlow - RESIZER_W - MIN_CANVAS_W,
256
  );
257
  const maxRight = Math.min(
258
  RIGHT_MAX,
259
+ ww - leftInFlow - RESIZER_W - MIN_CANVAS_W,
260
  );
261
  setLeftW((w) => Math.max(LEFT_MIN, Math.min(w, Math.max(LEFT_MIN, maxLeft))));
262
  setRightW((w) => Math.max(RIGHT_MIN, Math.min(w, Math.max(RIGHT_MIN, maxRight))));
263
  };
264
+ clamp();
265
+ window.addEventListener("resize", clamp);
266
+ return () => window.removeEventListener("resize", clamp);
267
+ }, [isDesktop, band, leftCollapsed, rightCollapsed, leftW, rightW]);
268
 
269
  const setPlugins = useApp((s) => s.setPlugins);
270
  useEffect(() => {
 
319
  }, []);
320
 
321
  const leftWidth = leftCollapsed ? COLLAPSED_W : leftW;
322
+ // In the band the Evidence pane's in-flow footprint is ALWAYS the
323
+ // strip; the expanded pane is an overlay (RESPONSIVE CONTRACT).
324
+ const rightStrip = band || rightCollapsed;
325
+ const rightWidth = rightStrip ? COLLAPSED_W : rightW;
326
 
327
  return (
328
  // h-[100dvh] uses the dynamic viewport height — iOS Safari shrinks
 
341
  />
342
  {isDesktop ? (
343
  /* ===================== Desktop ===================== */
344
+ <div className="relative flex-1 flex min-h-0">
345
  <aside
346
  style={{ width: leftWidth }}
347
  className={`shrink-0 border-r border-edge flex flex-col min-h-0 ${
 
366
  // the canvas falls below MIN_CANVAS_W. Account for the
367
  // right pane's current footprint (collapsed strip when
368
  // collapsed, full width otherwise) and both resizers.
369
+ const rightFoot = rightStrip ? COLLAPSED_W : rightW + RESIZER_W;
370
  const dynamicMax = Math.min(
371
  LEFT_MAX,
372
  window.innerWidth - rightFoot - RESIZER_W - MIN_CANVAS_W,
 
407
  </div>
408
  )}
409
  </main>
410
+ {!rightStrip && (
411
  <PaneResizer
412
  onResize={(dx) =>
413
  setRightW((w) => {
 
434
  style={{ width: rightWidth }}
435
  className={`shrink-0 border-l border-edge flex flex-col min-h-0 overflow-x-hidden ${
436
  isResizing ? "" : "transition-[width] duration-150"
437
+ } ${rightStrip ? "overflow-hidden" : ""}`}
438
  >
439
+ {rightStrip ? (
440
  <CollapsedStrip
441
  label="Evidence"
442
  side="right"
443
+ onExpand={() =>
444
+ band ? setBandEvidenceOpen(true) : setRightCollapsed(false)
445
+ }
446
  />
447
  ) : (
448
  <ResultsPane onCollapse={() => setRightCollapsed(true)} />
449
  )}
450
  </aside>
451
+ {/* Band Evidence overlay (RESPONSIVE CONTRACT): expanded
452
+ Evidence floats over the center column instead of taking
453
+ layout width, so the canvas/board keep computing layout
454
+ from real viewport space and the page can never scroll
455
+ horizontally. Width: the persisted pane width, capped so
456
+ a sliver of the center column stays visible. */}
457
+ {band && bandEvidenceOpen && (
458
+ <div
459
+ role="complementary"
460
+ aria-label="Evidence pane (overlay)"
461
+ className="absolute inset-y-0 right-0 z-30 flex flex-col min-h-0 bg-canvas border-l border-edge shadow-xl overflow-x-hidden"
462
+ style={{
463
+ width: `min(${rightW}px, calc(100vw - ${COLLAPSED_W + 48}px))`,
464
+ }}
465
+ >
466
+ <ResultsPane onCollapse={() => setBandEvidenceOpen(false)} />
467
+ </div>
468
+ )}
469
  </div>
470
  ) : (
471
  /* ===================== Mobile ====================== */
frontend/src/components/MultiverseBoard.tsx CHANGED
@@ -848,7 +848,7 @@ export function MultiverseBoard() {
848
  </div>
849
  )}
850
 
851
- <div className="flex-1 min-h-0 overflow-y-auto">
852
  {runs == null ? (
853
  <div className="p-6 text-sm text-mute">Loading archive…</div>
854
  ) : groups.length === 0 ? (
@@ -881,7 +881,13 @@ export function MultiverseBoard() {
881
  ref={gridRef}
882
  className="grid gap-3 p-3"
883
  style={{
884
- gridTemplateColumns: "repeat(auto-fill, minmax(240px, 1fr))",
 
 
 
 
 
 
885
  }}
886
  >
887
  {groups.map((g) => {
 
848
  </div>
849
  )}
850
 
851
+ <div className="flex-1 min-h-0 overflow-y-auto overflow-x-hidden">
852
  {runs == null ? (
853
  <div className="p-6 text-sm text-mute">Loading archive…</div>
854
  ) : groups.length === 0 ? (
 
881
  ref={gridRef}
882
  className="grid gap-3 p-3"
883
  style={{
884
+ // min(240px, 100%): in a container narrower than one
885
+ // 240px track the column shrinks to the container
886
+ // instead of forcing horizontal overflow (the scroll
887
+ // body's overflow-y:auto would otherwise mint an x
888
+ // scrollbar — see the RESPONSIVE CONTRACT in App.tsx).
889
+ gridTemplateColumns:
890
+ "repeat(auto-fill, minmax(min(240px, 100%), 1fr))",
891
  }}
892
  >
893
  {groups.map((g) => {