Skip to content

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

Open
EnjouWang wants to merge 1 commit into
sysprog21:mainfrom
EnjouWang:reserve-jim-stage-in-editor
Open

EnjouWang wants to merge 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 calls reserveJimStageInEditor(), which writes what the stage covers to the editor stack: --jim-stage-reserve-right beside the floating stage, plus a 6 px gap, or --jim-stage-reserve-bottom under the compact card. It also observes the editor stack, because the test drawer's splitter moves the editor's bottom under the card without resizing the window or the stage.

Beside the floating 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 work for scrolling but leaves the strip beside the code outside the textarea, so a click there blurred the editor; a border still takes that click. Under the 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. An editor that runs past the window, as under the stacked sidebar on a narrow screen, reserves nothing: the fixed card's overlap there depends on the page's scroll, and the page already scrolls any row out from under it.

The three points raised in #512:

  1. The test drawer. This change reserves space in the editor only; the right side of Add a case and Test results under the compact card 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>px the caret at the end of a long line scrolls clear of Jim's stage runs at 1920, 1366 and 1100. 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 where the last glyph is painted on #editor-highlight and that #editor, which holds the caret, and #editor-lines scrolled exactly as far. At 1100 the stage is the compact card, so the check there is that the row ends above the card rather than left of it, which is what the bottom reservation provides; the test shrinks the drawer first, because on the test page the card otherwise covers only 13 px of the editor, less than its own bottom padding. With the reserveJimStageInEditor(stage) call removed it fails at all three widths: 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 1100.

a click beside the code below Jim's floating stage stays in the editor pins the click. Removing the border, scroll-padding-bottom, the gutter's bottom padding or the editor-stack observer each fails one of the new tests. Removing the guard for an editor that runs past the window fails only the existing a stacked expanded drawing keeps the panel's available width, which then times out on an unstable Expand drawing button; there is no direct test of that guard.

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

./scripts/test.sh at this head, with Git 2.56.1: every gate passes except two that fail on this machine for reasons outside the change. git-hooks fails 2 of 482 checks because shfmt, commentflow and ruff are not installed; browser-tests fails only 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. Not run here: Java, ffmpeg and desktop tests, and the formatters and linters listed above. Not checked: Firefox and Safari, whose caret reveal may ignore scroll-padding-bottom (the last rows stay reachable by scrolling either way), and a live interview with captions growing the card.

#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 changes only the editor's scroll range; the floating stage, captions, self-view, and shell layout stay as accepted in #512.

  • Beside the floating stage a transparent border reserves the width, with a 6 px gap; right padding doesn't scroll in a textarea, and a narrower box wouldn't take a click beside the code.
  • 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; a border there would resize the text area.
  • An editor-stack observer updates the reservation when the test drawer's splitter moves the editor; an editor running past the window reserves nothing, since the page scrolls rows out from under the fixed card.

The three points from #512 are covered: the test drawer's right side stays for #790, the uniform right strip is documented in docs/avatar-contract.md, and caret tests run at 1920, 1366, and 1100 px plus a click test.

Closes #512.

Written for commit 7d26ed9. Summary will update on new commits.

View guided diff

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 measures how much of the editor it covers.
Beside the floating stage a transparent border keeps that width out of
the text layers' scroll range, since a textarea leaves its right
padding out of it and a narrower box would not take a click beside the
code. Under the compact card they pad their bottom instead, with
scroll-padding keeping the caret above it, because the card grows with
the captions and a shorter text area would resize while Jim speaks. An
editor that runs past the window reserves nothing, as the page itself
scrolls any row out from under the fixed card.

Close sysprog21#512

Change-Id: I2f74b83f4191e33b46b50f51ec0f27dea4b24407

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="web/interview.js">

<violation number="1" location="web/interview.js:5863">
P2: The reservation uses a stale stage rectangle after `.scrollable` can reposition the stage. Re-read `getBoundingClientRect()` after toggling `.scrollable`, otherwise an oversized compact card can reserve the fixed-bottom position while it is actually rendered at the toolbar anchor.</violation>

<violation number="2" location="web/interview.js:5883">
P2: The reservation is computed from viewport positions, but it only refreshes on resize, not on scroll. When the editor panel or page scrolls, `covers` can flip while `--jim-stage-reserve-right` and `--jim-stage-reserve-bottom` keep their old values, so the caret can sit under the stage. Re-run the reservation on scroll of the editor panel, or compute it without depending on the viewport position.</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread web/interview.js
const stack = nodes.editorStack;
if (!stack.isConnected) return;
const editor = stack.getBoundingClientRect();
const covers =

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The reservation is computed from viewport positions, but it only refreshes on resize, not on scroll. When the editor panel or page scrolls, covers can flip while --jim-stage-reserve-right and --jim-stage-reserve-bottom keep their old values, so the caret can sit under the stage. Re-run the reservation on scroll of the editor panel, or compute it without depending on the viewport position.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At web/interview.js, line 5883:

<comment>The reservation is computed from viewport positions, but it only refreshes on resize, not on scroll. When the editor panel or page scrolls, `covers` can flip while `--jim-stage-reserve-right` and `--jim-stage-reserve-bottom` keep their old values, so the caret can sit under the stage. Re-run the reservation on scroll of the editor panel, or compute it without depending on the viewport position.</comment>

<file context>
@@ -5857,14 +5860,44 @@ function placeJimStageBelowToolbar(toolbar) {
+  const stack = nodes.editorStack;
+  if (!stack.isConnected) return;
+  const editor = stack.getBoundingClientRect();
+  const covers =
+    editor.top >= 0 &&
+    editor.bottom <= window.innerHeight &&
</file context>

Comment thread web/interview.js
"scrollable",
stage.top < 0 || stage.bottom > window.innerHeight,
);
reserveJimStageInEditor(stage);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2: The reservation uses a stale stage rectangle after .scrollable can reposition the stage. Re-read getBoundingClientRect() after toggling .scrollable, otherwise an oversized compact card can reserve the fixed-bottom position while it is actually rendered at the toolbar anchor.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At web/interview.js, line 5863:

<comment>The reservation uses a stale stage rectangle after `.scrollable` can reposition the stage. Re-read `getBoundingClientRect()` after toggling `.scrollable`, otherwise an oversized compact card can reserve the fixed-bottom position while it is actually rendered at the toolbar anchor.</comment>

<file context>
@@ -5857,14 +5860,44 @@ function placeJimStageBelowToolbar(toolbar) {
       "scrollable",
       stage.top < 0 || stage.bottom > window.innerHeight,
     );
+    reserveJimStageInEditor(stage);
   };
   const observer = new window.ResizeObserver(place);
</file context>
Suggested change
reserveJimStageInEditor(stage);
reserveJimStageInEditor(nodes.jimStage.getBoundingClientRect());

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

1 participant