Skip to content

[codex] Fix long-line keyword highlight lockup#1864

Merged
binaricat merged 2 commits into
mainfrom
codex/fix-long-line-highlight-lock
Jul 1, 2026
Merged

[codex] Fix long-line keyword highlight lockup#1864
binaricat merged 2 commits into
mainfrom
codex/fix-long-line-highlight-lock

Conversation

@binaricat

Copy link
Copy Markdown
Owner

Summary

  • cap keyword-highlight wrapped-line lookups so oversized soft-wrapped output falls back to per-screen-line scanning
  • cache oversized wrapped-block misses during a refresh to avoid repeated failed scans
  • add a regression test for a near-2MB single-line terminal output case

Root cause

The terminal turns a huge single output line into thousands of soft-wrapped screen rows. After long-line pressure clears, keyword highlighting could repeatedly walk backward through the entire wrapped block while trying to build cross-line highlight context, which can lock the UI.

Addresses #1847.

Tests

  • node --test --import tsx components/terminal/keywordHighlight.test.ts components/terminal/keywordHighlightRegex.test.ts components/terminal/runtime/terminalOutputPressure.test.ts
  • npx eslint components/terminal/keywordHighlight.ts components/terminal/keywordHighlight.test.ts
  • npm run build

@binaricat binaricat marked this pull request as ready for review July 1, 2026 09:24

@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: 21373fc67f

ℹ️ 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
if (block) {
cache.set(startY, block);
}
if (startY < 0) return null;

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 Cache capped wrapped-start misses

When the viewport is in the middle of an oversized soft-wrapped block, findWrappedBlockStart returns -1 and this early return bypasses the per-refresh wrappedBlockCache, so every line in the viewport plus overscan repeats the full capped backward walk. In a narrow split pane the cap is still thousands of rows (TERMINAL_AUX_LONG_LINE_SCAN_LIMIT_CHARS / cols), which leaves the large-line lockup path doing O(renderedLines * maxRows) buffer reads on each refresh instead of caching the miss once.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Fixed by caching capped wrapped-block misses for the current refresh and tightening the regression test so repeated capped backward walks fail the check.

@binaricat

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

Reviewed commit: 3c72bbad39

ℹ️ 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".

@binaricat binaricat merged commit ab309c0 into main Jul 1, 2026
20 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.

1 participant