Skip to content

fix(workspace): the rail's maximum comes from the viewport, not a constant (#2617) - #2649

Merged
vybe merged 2 commits into
devfrom
fix/2617-rail-max-from-viewport
Sep 10, 2026
Merged

vybe merged 2 commits into
devfrom
fix/2617-rail-max-from-viewport

Conversation

@dolho

@dolho dolho commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

RAIL_MAX = 560, applied unconditionally, meant the wider the display the smaller the share a person could give the column — about 22% of a 2560px screen.

"I'm trying to resize the right column with canvas, but it does not go bigger than like 20% or something. I should be able to make it whatever I want, say half the screen width."

That is the opposite of what a resize handle is for, and it contradicted the file's own stated intent — "deliberately generous — this is a person arranging their own screen, not a layout that needs defending from them" — which an absolute pixel number cannot express at more than one width.

The bound that replaces it was already in the file

CONVERSATION_MIN is the readable floor fitsThreeColumns already refuses to break. So a column may take everything left after its neighbour and that floor:

railMaxFor(viewport, sidebar) = viewport − sidebar − CONVERSATION_MIN

On 2560 with the default sidebar that is ~70% of the screen; on a laptop it is exactly what the auto-collapse rule already permitted. One rule at both ends, rather than a constant that is generous at one width and restrictive at every other.

Three details that are load-bearing

  • Floored at the column's own minimum. A ceiling below the floor inverts Math.min(max, Math.max(min, px)) — it pins the column to the maximum and quietly breaks the floor the minimum exists to hold. On a viewport with no room for three columns the auto-collapse rule applies, not a negative ceiling.
  • Desired width and effective width are two numbers (AC 4). What is stored and dragged is what the person asked for; what the grid renders is min(desired, derived max). So a layout arranged on a 2560px monitor is clamped down for display on a laptop and comes back intact. Clamping at the persistence boundary instead would have written the laptop's ceiling over their choice on the first commit() — "silently discarded" wearing a clamp, which is the failure mode the AC names.
  • enforceFit tests the EFFECTIVE widths. Testing the desired one would collapse a rail that fits, purely because a wider one was once arranged on a bigger screen. And since the drag is now bounded by the same floor fitsThreeColumns asks about, a drag can no longer break the fit at all — what remains for auto-collapse is exactly the case it was written for: a window too narrow for three columns at their minima.

Acceptance criteria

  • The rail drags to at least half the viewport on a wide display — the operator's 2560px case reaches ~70%, asserted.
  • The maximum is derived from the viewport; the conversation's floor is the one rule that stops a drag. No fractional-viewport fallback was needed, because the derivation already is one.
  • Narrow windows unchanged — the conversation never drops below its floor, and fitsThreeColumns → enforceFit still fires before it is squeezed.
  • A stored width larger than the current maximum is clamped for display and restored when there is room — neither discarded nor overflowing.
  • Keyboard parity: railMax / sidebarMax are what the handles receive, so End and aria-valuemax follow the derived value and update on window resize.
  • Narrowing the rail still widens the message column up to MESSAGE_MAX, untouched.
  • SIDEBAR_MAX reviewed and given the same treatment (AC 7) — nobody had hit it, but leaving one derived and one fixed would leave the next reader guessing which rule this file follows.
  • Vitest coverage at 1280 / 1440 / 2560 including the re-clamp-on-load case; the fitsThreeColumns tests stay green.

A trap worth naming for review

The ceilings are exposed as top-level computeds, not folded back into limits. A ref nested inside a plain object is not auto-unwrapped in a template, so :max="columns.limits.rail.max" would have rendered [object Object] into aria-valuemax — silently, since nothing type-checks an ARIA attribute. limits now carries no max at all rather than a stale number a caller could still read and believe.

Verification

  • New workspaceColumnMaxFromViewport.spec.js — 15 passed: the reported case, the exact derivation at four widths, monotonicity in viewport width, the neighbour trade-off, the inverted-clamp guard, an unmeasured viewport (0/null/NaN/a string), that a clamped drag can never break the conversation floor at any width, the sidebar's parity, and the AC-4 round trip (arranged at 2560 → clamped on a laptop → restored at 2560).
  • workspaceColumnResize.spec.js — two assertions rewritten, not deleted: the ceiling is an argument now, and persistence floors rather than caps. Both rewrites say why in place.
  • Full frontend suite 113 files / 2530 tests; both ratchets green; vite build clean.
  • Grepped for stragglers: no reference to RAIL_MAX, SIDEBAR_MAX or limits.*.max survives outside the comments that explain their removal.

What I could not check

No browser here, so the feel of dragging to 70% of a 2560px screen is unverified — the arithmetic, the clamp behaviour and the wiring are. The aria-valuemax trap above is the reason I would still want one pass with a real handle in hand.

Fixes #2617

🤖 Generated with Claude Code

https://claude.ai/code/session_01Bd71qsYbFodvofba8P69eP

…stant (#2617)

`RAIL_MAX = 560` was applied unconditionally, so the wider the display the
SMALLER the share a person could give the column — about 22% of a 2560px
screen. That is the opposite of what a resize handle is for, and it contradicted
the file's own stated intent ("deliberately generous — this is a person
arranging their own screen, not a layout that needs defending from them"), which
an absolute pixel number cannot express.

Operator report: "it does not go bigger than like 20% or something. I should be
able to make it whatever I want, say half the screen width."

The replacement bound was already in the file. `CONVERSATION_MIN` is the
readable floor `fitsThreeColumns` already refuses to break, so a column may take
everything left after its neighbour and that floor:

    railMaxFor(viewport, sidebar) = viewport - sidebar - CONVERSATION_MIN

On 2560 with the default sidebar that is ~70% of the screen; on a laptop it is
exactly what the old auto-collapse rule already permitted. One rule at both
ends, rather than a constant that is generous at one width and restrictive at
every other.

Three details are load-bearing:

* **Floored at the column's own minimum.** A ceiling below the floor inverts
  `Math.min(max, Math.max(min, px))` — it pins the column to the MAXIMUM and
  quietly breaks the floor the minimum exists to hold. On a viewport with no
  room for three columns the auto-collapse rule applies, not a negative ceiling.
* **Desired width and effective width are two numbers (AC 4).** What is stored
  and dragged is what the person asked for; what the grid renders is
  `min(desired, derived max)`. A layout arranged on a 2560px monitor is clamped
  down for display on a laptop and comes back intact. Clamping at the
  persistence boundary instead would have written the laptop's ceiling over
  their choice on the first `commit()` — "silently discarded" wearing a clamp.
* **`enforceFit` tests the EFFECTIVE widths.** Testing the desired one would
  collapse a rail that fits, purely because a wider one was once arranged on a
  bigger screen. Since the drag is now bounded by the same floor
  `fitsThreeColumns` asks about, a drag can no longer break the fit at all;
  what remains is the case that rule was written for.

`SIDEBAR_MAX` got the same treatment (AC 7). Nobody had hit it, but leaving one
derived and one fixed would leave the next reader guessing which rule this file
follows.

The ceilings are exposed as top-level computeds rather than folded back into
`limits`, so `aria-valuemax` and `End` follow them: a ref nested inside a plain
object is NOT auto-unwrapped in a template and `limits.rail.max` would have
rendered `[object Object]`. `limits` no longer carries a `max` at all rather
than carrying a stale number a caller could still read.

Tests: `workspaceColumnMaxFromViewport.spec.js` (15) — the reported case at
1280 / 1440 / 2560, the exact derivation, monotonicity in viewport width, the
inverted-clamp guard, an unmeasured viewport, that a clamped drag can never
break the conversation floor at any width, and the AC-4 round trip
(wide → laptop → wide). Two assertions in the ent#492 spec were rewritten: the
ceiling is an argument now, and persistence floors rather than caps.

Frontend suite: 113 files, 2530 tests, all passing; both ratchets green; build
clean.

Related to #2617

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01Bd71qsYbFodvofba8P69eP
@dolho
dolho requested a review from vybe September 9, 2026 13:22
@vybe

vybe commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

merge-train 2026-09-09: not on this train. Two findings in the changed lines, both verified against the source.

1. sidebarMax reads the rail's desired width, not its actual width — src/frontend/src/composables/useColumnResize.js:255

The comment directly above says the ceiling is measured against "what the rail is ACTUALLY taking", but effectiveRail carries no railOpen term. railWidth, three lines below, is that value. With the rail collapsed at a 1280px viewport the sidebar ceiling lands at 416 while 752 is genuinely free — below the SIDEBAR_MAX = 480 constant this replaces, so AC 3 ("narrow windows are unchanged") regresses.

2. Both handles bind the desired width to :value while :max is the derived ceiling — src/frontend/src/views/Portal.vue:437 and :142

Removing the readStored cap is deliberate, but it lets aria-valuenow exceed aria-valuemax, and startValue = props.value then clamps every pointermove, so the rail handle is inert for several hundred px of travel on a laptop. effectiveRail / effectiveSidebar are exported at :356-357 and currently have no consumer.

The one-identifier fix for (1) changes rendered behaviour, and whether a drag from a clamped position should overwrite the stored desire (2) is a product call — so this goes back to you rather than getting patched on the train.

Worth noting for both: no test instantiates useColumnResize(), so every stateful value this PR adds is asserted only by source-text regex. The AC-4 test recomputes the expected value rather than reading effectiveRail, which is why (1) shipped green. The composable can be driven directly via effectScope with a stubbed window.

Rides the next train once fixed.

…ort the effective width (#2617)

Two findings from review, both the same shape — a derived ceiling paired with
the wrong width.

1. `sidebarMax` was measured against `effectiveRail`, which carries no `railOpen`
   term, so a COLLAPSED rail was still charged at its full open width. At a
   1280px viewport the ceiling landed at 416 while 752 was genuinely free —
   below the `SIDEBAR_MAX = 480` constant this PR replaces, so AC 3 ("narrow
   windows are unchanged") regressed. It now reads `railWidth`, the width the
   rail actually renders: its effective width when open, the 48px strip when
   closed. `railWidth` moved above `sidebarMax` so the file still declares in
   dependency order; `railMax` still keys off the sidebar's DESIRE, so there is
   no cycle.

2. Both handles bound `:value` to the desired width while `:max` was the derived
   ceiling. That lets `aria-valuenow` exceed `aria-valuemax`, and
   `ColumnResizeHandle` takes `startValue = props.value` and clamps every
   `pointermove` — so on a laptop showing a layout arranged on a 2560px monitor
   the rail handle is inert for several hundred px of travel. They now bind
   `columns.effectiveSidebar` / `columns.effectiveRail`, which is what the two
   exported computeds were for. The desire survives untouched in storage and
   returns when there is room; a drag from a clamped position replaces it, which
   is the intended call — the person is moving the handle they can see.

Tests: the composable is now DRIVEN rather than scanned. `effectScope` plus a
stubbed `window` gives it a reactive owner (the two lifecycle hooks are the only
thing it wanted a component for), and eleven cases execute the real computeds —
the collapsed-rail ceiling, the no-regression floor, the open/close round trip,
the three-column sum, desired-vs-effective on a narrow viewport, the ARIA
relation, and a drag from a clamped position moving on pixel one while the
desire-bound version stays pinned for 300+px. Three of them fail against the
pre-fix `effectiveRail` wiring — verified by reverting the one identifier.
The AC-4 test that shipped green recomputed its expectation from `railMaxFor`
instead of reading what the composable derives, which is why (1) got through.

113 files / 2540 tests green; raw-colour scan unchanged.

Related to #2617

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01RSjVEjay9ztC1oDXXkh9uN
@dolho

dolho commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Both fixed in 9efcd0a8, and the testing gap you named is closed — the composable is now driven, not scanned.

1. sidebarMax reads railWidth, not effectiveRail. You were exactly right: effectiveRail has no railOpen term, so a collapsed rail was billed at its full open width. railWidth moved above sidebarMax so the file still declares in dependency order; railMax still keys off the sidebar's desire, so there is no cycle. At 1280 collapsed the ceiling is now 752, and there is a test asserting it is >= 480 specifically so the AC-3 regression cannot come back.

2. Both handles bind :value to the effective width. columns.effectiveSidebar / columns.effectiveRail — which is what those two exports were for. On the product call you flagged: a drag from a clamped position does overwrite the stored desire, deliberately. The handle is at the effective position on screen, so a drag has to be relative to that; the desire is preserved while untouched and returns on the wider monitor, but once the person moves the handle they can see, that is the new desire. Written into the template comment and the requirements entry so it reads as a decision rather than a side effect.

Tests. effectScope + a stubbed window is enough — the two lifecycle hooks were the only thing it wanted a component for. Eleven cases execute the real computeds: the collapsed-rail ceiling, the no-regression floor, collapse/reopen round trip, the three-column sum never exceeding the viewport, desired-vs-effective on a narrow viewport, effective <= max (the ARIA relation), and a drag from a clamped position moving on pixel one while the desire-bound version stays pinned for 300+px of travel. Reverting the one identifier in sidebarMax reds three of them.

You also called the mechanism: the AC-4 test recomputed its expectation from railMaxFor rather than reading what the composable derives, which is exactly why (1) shipped green.

113 files / 2540 tests green, raw-colour scan byte-identical.

@dolho

dolho commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Re-review after the fixes. Clean from me — I went looking for a third instance of the same class and did not find one.

Specifically re-checked, because a ceiling that reads the wrong width is exactly the bug that shipped twice here:

  • No dependency cycle. railMax keys off the sidebar's desired width, effectiveRail off railMax, railWidth off railOpen, sidebarMax off railWidth, effectiveSidebar off sidebarMax. Each is a pure function of (viewport, desired widths, railOpen), so there is no feedback loop even though the two ceilings reference each other's columns. Worth stating because the obvious "fix" — making railMax read effectiveSidebar — would create one.
  • The collapsed→open round trip converges. Sidebar dragged to 752 at 1280 with the rail closed, then the rail reopened: railMax → 48 → floored to RAIL_MIN 280, effectiveRail 280, sidebarMax 520, effectiveSidebar 520, conversation exactly 480. The floor holds, the desired 752 survives, and nothing oscillates.
  • enforceFit is unaffected — it returns early when the rail is closed, and when open railWidth == effectiveRail, so the auto-collapse rule tests the same numbers it did before.

The effectScope harness is the part I would keep: the AC-4 test that shipped green recomputed its expectation from railMaxFor instead of reading what the composable derives, and every source-regex assertion in this file has that same shape. Driving the composable is what makes the difference between "the formula is right" and "the wiring uses the formula".

@dolho

dolho commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Deeper self re-review. No defect. Two things I had asserted in the first pass and have now actually driven, plus one honest limit.

  • The ceiling pair does not oscillate, verified by running the composable rather than reasoning about it: railMax keys off the sidebar's desired width (not effectiveSidebar), so the two ceilings reference each other's columns without a feedback loop. The obvious "improvement" — making railMax read the effective sidebar — would create one, which is worth a comment on that line if anyone is tempted.
  • The collapsed→open round trip converges to the floor exactly. Sidebar dragged to 752 at 1280 with the rail closed, rail reopened: railMax 48 → floored to RAIL_MIN 280, sidebarMax 520, effectiveSidebar 520, conversation 480. Desire 752 survives untouched, and re-collapsing returns to 752.

The limit worth stating: this PR's tests drive useColumnResize, but nothing drives ColumnResizeHandle — the startValue = props.value / clamp behaviour that the :value binding fix is about is modelled in the test (drag(startValue, delta)), not executed. The model matches the component today; it is a copy, and a change to the handle's drag arithmetic would not red it. Given the package has no mount harness (environment: 'node', no @vue/test-utils), the honest options are to leave it as a documented model or to extract the drag arithmetic into a pure function both the component and the test import. I would take the second in a follow-up rather than here — it is the same "derive, do not restate" rule the repo applies to two-vocabulary constants.

Everything else from the earlier pass holds: enforceFit is unaffected (early-returns when the rail is closed; when open railWidth == effectiveRail), and the AC-4 regression that let the original bug ship — recomputing the expectation from railMaxFor instead of reading what the composable derives — is gone.

@vybe vybe left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

validate-pr (Lane B): both merge-train findings verified fixed in 9efcd0a — sidebarMax reads railWidth (carries railOpen), handles bind effectiveSidebar/effectiveRail; composable is now driven via effectScope. Security greps clean; CI incl. vitest + e2e green; no overlap with the two dev-side Portal.vue commits since base. Body patched to Fixes #2617 so the issue auto-promotes.

@vybe
vybe merged commit 3edd0dc into dev Sep 10, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants