Skip to content

Keep the editor's code clear of Jim's stage - #791

Merged
jserv merged 1 commit into
sysprog21:mainfrom
EnjouWang:reserve-jim-stage-in-editor
Nov 21, 2026
Merged

jserv merged 1 commit into
sysprog21:mainfrom
EnjouWang:reserve-jim-stage-in-editor

Conversation

@EnjouWang

@EnjouWang EnjouWang commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Jim's stage floats over the editor, and the editor did not know it was there. At 1366x900 the end of a line longer than about 95 columns, and the caret typing there, scrolled to the textarea's right edge at x 1349, under the stage that starts at x 1174; at 1100x800 the last rows could not be scrolled out from under the compact card. As accepted in #512, this keeps the floating stage, the captions, the self-view and the shell layout as they are and changes only the editor's scroll range.

placeJimStageBelowToolbar() already observes the stage. It now also passes the stage, measured after .scrollable is settled, to reserveJimStageInEditor(), and observes the editor stack, since the test drawer's splitter moves the editor under the card without resizing the window or the stage. reserveJimStageInEditor() writes one of two reservations to the editor stack, whichever costs the editor less: --jim-stage-reserve-right, the width beside the stage plus a 6 px gap, or --jim-stage-reserve-bottom, the overlap of a compact card at the bottom.

Beside the stage the reservation is a transparent right border on #editor and #editor-highlight, not the right padding #512 proposed. Chromium leaves a textarea's right padding out of its scroll range: with 191 px of right padding the end of a long line still scrolled to x 1349.6. A narrower box would scroll correctly but leaves the strip beside the code outside the textarea, so a click there blurred the editor; a border still takes that click. In forced colors the border is Canvas: a transparent border is forced to CanvasText and painted the whole strip black, while a system color the author sets is kept, so the text and token colors stay forced. Under a compact card both text layers and the gutter pad their bottom instead, and scroll-padding-bottom keeps the caret above the card while typing, because the card grows with the captions and a border there would resize the text area while Jim speaks.

The bottom overlap is measured at rest, editor.bottom + window.scrollY + panel.scrollTop - stage.top, as the toolbar anchor is: scrolling only moves the editor up from under the fixed card, so the overlap at rest is the most it can be and the reserve does not depend on where the page or the panel is scrolled. The right reserve reads only horizontal positions. Comparing the two fractions keeps the cheap bottom reserve for the usual compact card (14 px of a 512 px editor at 1100x800, against 39% of its width) and takes the width when a long caption and the self-view grow the card down most of the editor (98% of its height at 1100x600). Below 1024 px the sidebar stacks above the editor and the page scrolls; the right reserve now covers those widths as well (1023x700, 1000x700, 900x800 and 800x900 all left the row beside the card under it before). A card over half the editor's width never takes the width. In the desktop shell, one window tall from 1024 px up, it always takes the bottom, as beside the widest sidebar (a 500 px editor at 1100x800 gets the same 14 px bottom reserve as the default one): with the width ruled out, the bottom is only room to scroll in a panel that scrolls itself, so it hides no row the card does not already cover, and no cost comparison is needed. Below 1024 px, where the page, not the editor, scrolls the code, it takes neither side.

There, as on a phone, the self-view alone made the compact card taller than the room the page had below the editor: at 480x800, 390x844, 360x640 and 412x915, with the page and the editor scrolled to their end, the last row stayed under the card, and so did the caret typed on it. A long caption can cover all of the editor's visible box (at 390x844 the editor spans y 408 to 650 and the card starts at y 383), so no reserve inside the editor can show those rows. Such a card therefore reserves nothing in the editor, and --jim-stage-reserve-page on the root, what the card covers of the window plus the gap, becomes the page's padding-bottom and scroll-padding-bottom, as the lobby's scroll-padding-bottom already keeps controls clear of its update notice. Across those four sizes, with the self-view on or off and no, a short, a medium or a full caption, no last row is under the card with the page scrolled to its end (24 of 32 were before), and the caret typed on the last row ends above the card in all 16 runs with the self-view. A stage that does not fit in the window where it floats is .scrollable and scrolls with the page under the toolbar, so it adds no room: its position in the window would make the page's length depend on where the page was scrolled. Only below 1024 px does a card get this room: from 1024 px up the page is one window tall and its panel scrolls the code, and with the room the widest sidebar at 1100x800 made the page 1000 px long and typing on the last rows scrolled the whole shell. Beside the widest sidebar, a card grown down most of the editor now takes the bottom too: at 1100x600 and 1024x768 with the self-view and a long caption the last row reserved nothing at 2557339 and 22e01d2 and ended under the card, and now ends above it with a 281 px reserve. Only where the card covers all but about a row of the editor (1024x600 with a longer caption, the card from y 115 and the editor from y 104) is there no room left to show it.

The three points raised in #512:

  1. The test drawer. Apart from the room a phone's page now gets, which lets the drawer scroll above the card there too, this change reserves space in the editor only; the right side of Add a case and Test results under the compact card at 1100 px is left for Jim's compact card covers the right side of Add a case and Test results #790.
  2. The right reservation is written once for the whole editor, so rows below the floating stage also end at the stage's column and leave an empty strip under it. "Placement and pose" in docs/avatar-contract.md now says so.
  3. The caret test. at <width>x<height> the caret at the end of a long line scrolls clear of Jim's stage runs at 1920x1080, 1366x900 and 1100x800, and at 1100x600 with a tall card, 1100x520 with a resize while the page is scrolled, 1000x700, and 1100x800 with the widest sidebar and a tall card. It types a 302-character line, presses Home to check that the line is longer than the editor, presses End so the browser scrolls to it, then checks that the last glyph painted on #editor-highlight does not overlap the stage, that #editor, which holds the caret, and #editor-lines scrolled exactly as far, and that the page adds no room past its end. At 1100 the stage is the compact card, so the row may end above it rather than left of it, which is what the bottom reservation provides. At 1000x700 the row is edited three rows above the end, where the browser has no reason to scroll the page; as the last row it would be scrolled into the 24 px below the card and pass without the change. With the reserveJimStageInEditor() call removed the test fails at all seven; at the three Jim's stage covers the editor, and Hide avatar does not free the space #512 asked for, the line ends at 1903.6 under the stage from 1728 at 1920, at 1349.6 under the stage from 1174 at 1366, and the last row ends at 658.2 under the card from 606.6 at 1100x800.

the strip beside Jim's floating stage takes a click and stays blank in forced colors pins the click and the forced-colors border. on a phone the card across the editor reserves neither its width nor its bottom (481x1400, where the bottom would be the cheaper side), on a phone the caret typing on the last row scrolls the page clear of the card (390x844 with the self-view) and a stage that scrolls with the page adds no room below it, wherever the page is pin the phone. The caret test also states which side each size reserves, requires more than 80% of the width where it is the bottom, and keeps the last glyph 3 px clear of the stage, half the gap: at 1920x1080 in headless Chromium on Linux the glyph ends 5.44 px clear, so a full 6 px would fail the unchanged code. Removing the border, the forced-colors rule, scroll-padding-bottom, the gutter's bottom padding, the editor-stack observer, the scroll offsets, the cost comparison, the gap, the root's padding or scroll padding, or the breakpoint, scrollable or half-width conditions each fails one of these tests. Reading the stage before .scrollable is settled fails none of them; the right reserve reads only stage.left, which .scrollable does not move.

Before and after at 1366x900 and 1100x800, on the test page with a long line as the caret's row:

before-w1366 after-w1366 before-w1100 after-w1100

At this head ./scripts/test.sh rust passes, and node --test tests/browser/*.test.js passes 3630 of 3666 here. It fails a formatter that cannot load changes nothing, and the next press loads it in tests/browser/format-shortcut.test.js, which fails the same way with this change reverted and passes on main in CI. It also fails two tests in tests/browser/strict-selection.test.js that timed out under the full run's load and pass alone, twice each. Not run here: the other lanes of ./scripts/test.sh, which CI runs, and the Java, ffmpeg and desktop tests. Not checked: Firefox and Safari, whose caret reveal may ignore scroll-padding-bottom on the textarea or the root (the last rows stay reachable by scrolling either way), and a live interview on a real phone.

#713 also changes placeJimStageBelowToolbar(), returning place and changing its scrollable condition, so whichever of the two lands second rebases.

Close #512


Summary by cubic

Keeps the editor's scroll range clear of Jim's stage, so the caret and the end of a long line no longer scroll under it. This only changes the editor's scroll range; the floating stage, captions, self-view, and shell layout stay as accepted in #512.

  • Reserves whichever side costs the editor less: the width beside the floating stage, or the bottom rows under the compact card; a card grown down most of the editor takes the width instead.
  • Beside the stage, a transparent right border reserves the width with a 6 px gap; a textarea's right padding doesn't affect its scroll range, and a narrower box wouldn't take a click beside the code. In forced colors the border uses the Canvas system color so it doesn't paint as a solid bar.
  • Under the compact card, the text layers and gutter pad their bottom and scroll-padding-bottom keeps the caret above the card while it grows with the captions.
  • An editor-stack observer updates the reservation when the test drawer's splitter moves the editor. A card over half the editor's width, as on a phone, takes neither side: the page gets room past its end as tall as what the card covers of the window, so it scrolls the last rows and the caret above the card; a stage taller than the window scrolls with the page and adds no such room.
  • Caret tests run at 1920, 1366, 1100, 1000, and phone widths, covering a growing caption bar, a tall card, a resize while scrolled, and the stacked sidebar, plus click, forced-colors, and scrollable-stage tests.

Closes #512.

Written for commit ca7b8ec. Summary will update on new commits.

View guided diff

cubic-dev-ai[bot]

This comment was marked as resolved.

jserv

This comment was marked as resolved.

onepch

This comment was marked as resolved.

@EnjouWang
EnjouWang force-pushed the reserve-jim-stage-in-editor branch from 7d26ed9 to 7064858 Compare November 20, 2026 19:55
cubic-dev-ai[bot]

This comment was marked as resolved.

@EnjouWang
EnjouWang force-pushed the reserve-jim-stage-in-editor branch from 7064858 to 2557339 Compare November 20, 2026 20:23
jserv

This comment was marked as resolved.

@matthiola0 matthiola0 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.

Tested 25573393 on Windows 11 with Node.js v22.23.1 and Chromium.

node --test --test-name-pattern="clear of Jim's stage|reserves none of its width|strip beside Jim" tests/browser/interview-layout.test.js

All 8 tests passed at the PR head and after each change below. With the proposed assertions:

  • const bottom = false fails the two 1100 px cases that reserve space at the bottom.
  • JIM_STAGE_EDITOR_GAP_PX = 0 fails the four cases that reserve space beside the stage.

Comment thread tests/browser/interview-layout.test.js Resolved
Comment thread tests/browser/interview-layout.test.js Resolved
@EnjouWang
EnjouWang force-pushed the reserve-jim-stage-in-editor branch from 2557339 to 16165b3 Compare November 21, 2026 13:38
cubic-dev-ai[bot]

This comment was marked as resolved.

jserv

This comment was marked as resolved.

jserv

This comment was marked as resolved.

Jim's stage floats over the editor, and the editor did not know it was
there: at 1366 px the end of a long line, and the caret typing past
column 95, scrolled to the textarea's edge under the stage, and the last
rows could not be scrolled out from under the compact card. The stage's
placement now also tells the editor what it covers, and the editor keeps
the cheaper side out of its scroll range. Beside the stage that is a
transparent right border, since a textarea leaves its right padding out
of that range and a narrower box would not take a click beside the code;
in forced colors the border is Canvas, a system color they keep, so the
strip does not paint as a solid bar. Under a compact card it is the
bottom, measured with the page and the panel unscrolled so scrolling
never leaves it short, with scroll-padding keeping the caret above the
card. A card grown down most of the editor takes the width instead. One
over half the editor's width never takes the width. In the desktop
shell, one window tall from 1024 px up, it always takes the bottom, only
room to scroll in a panel that scrolls itself; below that, where the
page scrolls the editor, as on a phone, the self-view alone kept the
last row and the caret typing on it under the card with the page
scrolled to its end, so there it takes neither side and the page gets
room past its end as tall as what the card covers of the window, and
scroll padding as tall, so it scrolls them clear.

Close sysprog21#512

Change-Id: I1556b4a21ef34bf8b4f4a972531e0c635ae4b320
@EnjouWang
EnjouWang force-pushed the reserve-jim-stage-in-editor branch from 22e01d2 to ca7b8ec Compare November 21, 2026 15:03
@jserv
jserv merged commit 07b6758 into sysprog21:main Nov 21, 2026
18 of 20 checks passed
@jserv

jserv commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

Thank @EnjouWang for contributing!

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.

Jim's stage covers the editor, and Hide avatar does not free the space

4 participants