Skip to content

Fix terminal sticky scroll showing output instead of the executed command - #332438

Draft
Anthony Kim (anthonykim1) with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-terminal-sticky-scroll
Draft

Fix terminal sticky scroll showing output instead of the executed command#332438
Anthony Kim (anthonykim1) with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-terminal-sticky-scroll

Conversation

Copilot AI commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Description

Sticky scroll could pin rows of unrelated output (e.g. the tail of a previous npm install) instead of the command line that produced the output currently in view.

The overlay built its render window starting at the prompt start and capped it at maxLineCount rows from the top:

const stickyScrollLineStart = startMarker.line - (promptRowCount - 1);
const stickyScrollLineCount = Math.min(promptRowCount + commandRowCount - 1, maxLineCount) - rowOffset;

When promptRowCount > maxLineCount, that window ends above the command line, so only rows preceding the command are rendered. promptRowCount inflates easily: handlePromptStart clones the previous command's end marker as the prompt start, so anything printed between a command finishing and the next prompt being drawn (background/late process output, job control notices, shell chatter) counts as prompt rows. maxLineCount is min(terminal.integrated.stickyScroll.maxLineCount, floor(rows * 0.4)), so a short panel (≈11 rows → 4) makes this easy to hit.

Changes

  • terminalStickyScrollOverlay.ts — row math extracted into an exported pure getStickyScrollLayout() that prioritizes the command line: prompt rows are included only when prompt + command fit within maxLineCount, otherwise the window starts at the command start row (which still carries the prompt terminator, e.g. $ ). Unchanged in the common case where the prompt fits.
  • isTruncated — the trailing is now appended only when content is genuinely cut off at the bottom, rather than whenever the prompt didn't fit.
  • Empty overlay — hide when rowOffset clips every row, instead of resizing to a zero/negative row count and serializing a stray output row.
  • Tests — new stickyScroll/test/browser/terminalStickyScrollOverlay.test.ts covering the layout function, plus a case driven by the real CommandDetectionCapability that reproduces the reported scenario (output printed after the previous command finished ⇒ promptRowCount: 6 vs maxLineCount: 5).
const { lineStart: stickyScrollLineStart, lineCount: stickyScrollLineCount, isTruncated } =
    getStickyScrollLayout(startMarker.line, promptRowCount, commandRowCount, maxLineCount, rowOffset);

Note the hide check buffer.viewportY <= stickyScrollLineStart now compares against the command start row when the prompt is dropped, so the overlay disappears exactly when the command line itself scrolls into view.

An alternative to dropping the prompt entirely would be trimming prompt rows from the top to fill the available space — that keeps the overlay full height but still shows the unrelated output the issue complains about, so this takes the simpler route. Happy to switch if preferred.

Copilot AI balanced review requested due to automatic review settings August 24, 2026 22:25

Copilot AI 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.

Copilot wasn't able to review any files in this pull request.

Copilot AI and others added 3 commits August 24, 2026 22:42
…not fit

Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
Co-authored-by: anthonykim1 <62267334+anthonykim1@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix terminal sticky scroll to show correct command Fix terminal sticky scroll showing output instead of the executed command Aug 24, 2026
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.

Terminal sticky scroll shows wrong command

3 participants