Skip to content

fix(terminal): defer keyword scroll refresh while Enter is pending - #2880

Merged
binaricat merged 4 commits into
mainfrom
cursor/issue-2879-31446551895
Aug 11, 2026
Merged

fix(terminal): defer keyword scroll refresh while Enter is pending#2880
binaricat merged 4 commits into
mainfrom
cursor/issue-2879-31446551895

Conversation

@netcatty-bot

Copy link
Copy Markdown
Collaborator

Summary

  • Restore Enter-pending protection so onScroll during the Ubuntu RTT gap (before onWriteParsed) no longer takes the immediate user-scroll keyword path.
  • While Enter output is pending, mark the viewport dirty instead of synchronously rescanning; cancel any queued scroll refresh when Enter is pressed.
  • When the Enter protection window clears, trigger a debounced write refresh so deferred viewport motion (including user scroll during the window) still catches up.
  • Add a regression test for idle Enter + scroll-before-writeParsed after a prior write cleared lastRenderRange.

Why

v1.1.77 claimed to fix keyword highlight flicker on Enter (#2805), but the persistence rewrite dropped the earlier enterInputPending scroll guard. After a normal write refresh, lastRenderRange is null and lastWriteAt goes stale at an idle prompt, so Ubuntu 24.04 echo that emits onScroll before onWriteParsed was again classified as user scroll and synchronously rescanned the viewport — flashing still-visible keyword decorations.

Changes

  • components/terminal/keywordHighlight.ts: restore Enter-time scroll deferral + idle-clear catch-up.
  • components/terminal/keywordHighlight.test.ts: cover the idle Enter / pre-writeParsed scroll race.

Testing

  • node --test --import tsx components/terminal/keywordHighlight.test.ts (47 passed)
  • Manual (unverified here): Settings → Terminal → Keyword Highlighting on; SSH to Ubuntu 24.04; press Enter at an idle prompt and confirm existing highlights do not flash.

Fixes #2879

Automation

  • Automated implement pass
  • Review gate: @codex review (own/bot PRs only)
  • Draft until Codex reports clean findings

@netcatty-bot netcatty-bot added automation:bot-pr PR created or owned by Cursor automation automation:codex-loop Own/bot PR waiting on Codex review↔fix loop triage Touched by Cursor automation labels Aug 11, 2026
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 315e596e08

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +727 to +728
this.markVisibleRangeDirty();
return;

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 Badge Bound Enter-pending scroll suppression without output

When the remote PTY produces no write after Enter—for example, with echo disabled or a stalled connection—onWriteParsed never runs. enterInputPending is set by onData, but its only clear timer is armed inside onWriteParsed, so this new early return suppresses every subsequent user-scroll refresh indefinitely. Newly revealed scrollback lines therefore remain unscanned and unhighlighted until unrelated output arrives; arm a fallback timer from onData or otherwise time-bound this guard.

Useful? React with 👍 / 👎.

@binaricat

Copy link
Copy Markdown
Owner

@codex review

Repository owner deleted a comment from binaricat Aug 11, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Another round soon, please!

Reviewed commit: 4935066e53

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@netcatty-bot
netcatty-bot marked this pull request as ready for review August 11, 2026 01:16
@netcatty-bot netcatty-bot added automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Aug 11, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator Author

Codex reported no major issues. This PR is marked ready for human review/merge.

@netcatty-bot
netcatty-bot marked this pull request as draft August 11, 2026 03:11
@netcatty-bot netcatty-bot removed the automation:codex-clean Last Codex review reported clean label Aug 11, 2026
@binaricat binaricat added the automation:codex-loop Own/bot PR waiting on Codex review↔fix loop label Aug 11, 2026
@binaricat

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6c4e27cb38

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread components/terminal/keywordHighlight.ts Outdated
// synchronously rescan the viewport and flash keywords still on screen.
// Keep real scrollback browsing synchronous; only defer the bottom-pinned
// viewport movement that can be caused by the pending Enter echo.
if (this.enterInputPending && !isBrowsingScrollback) {

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 Badge Preserve synchronous scans when scrolling back to bottom

When a user reaches the bottom while the Enter guard is active—for example, by pressing End after first scrolling upward—viewportY === baseY makes this branch classify the user action as Enter-driven output. It marks the viewport dirty and returns without scanning it; if no write follows, the newly revealed bottom viewport is not refreshed until the 600 ms guard timer plus the debounce delay expires. Distinguish an actual output-driven viewport change from a user scroll that happens to end at the bottom so the latter retains the synchronous scroll refresh path.

Useful? React with 👍 / 👎.

@binaricat

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: fbaa038b0d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@netcatty-bot
netcatty-bot marked this pull request as ready for review August 11, 2026 08:20
@netcatty-bot netcatty-bot added automation:codex-clean Last Codex review reported clean and removed automation:codex-loop Own/bot PR waiting on Codex review↔fix loop labels Aug 11, 2026
@netcatty-bot

Copy link
Copy Markdown
Collaborator Author

Codex reported no major issues. This PR is marked ready for human review/merge.

@binaricat
binaricat merged commit 518e4a1 into main Aug 11, 2026
18 checks passed

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fbaa038b0d

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

// Catch up any viewport motion deferred while Enter protection blocked
// scroll refresh (e.g. user scrolled during the post-Enter window).
this.markVisibleRangeDirty();
this.triggerRefresh("debounced", "write");

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 Badge Honor bulk-output pressure before Enter catch-up

When Enter launches output that trips large-output pressure while scrollback is saturated, the pressure state intentionally remains active for two largeOutputQuietMs windows (about 960 ms), and scheduleBulkPressureCatchUp() polls until pressure.largeOutput is false before scanning. This new Enter idle timer fires at 600 ms and schedules a normal write refresh anyway; under the configured large-output debounce that can execute at about 880 ms, reintroducing keyword scans/decoration work during the protected bulk window. Please route this catch-up through the bulk-pressure path or skip scheduling while output pressure is still active.

Useful? React with 👍 / 👎.

binaricat added a commit that referenced this pull request Aug 12, 2026
fix(terminal): stop idle-Enter keyword highlight flash after #2880 hole
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automation:bot-pr PR created or owned by Cursor automation automation:codex-clean Last Codex review reported clean triage Touched by Cursor automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] 连接Ubuntu24.04lts的情况下,回车之后高亮的关键字还是会闪

2 participants