Skip to content

fix(website): correct block cursor rendering in browser terminal#192

Open
snvshal wants to merge 2 commits into
vercel-labs:mainfrom
snvshal:fix/website-terminal-block-cursor
Open

fix(website): correct block cursor rendering in browser terminal#192
snvshal wants to merge 2 commits into
vercel-labs:mainfrom
snvshal:fix/website-terminal-block-cursor

Conversation

@snvshal
Copy link
Copy Markdown

@snvshal snvshal commented Apr 16, 2026

Summary

Fix the custom browser terminal block cursor in examples/website so it behaves more like a real
terminal.

What changed

  • keep the block cursor on the current character cell instead of inserting extra space
  • preserve the character under the cursor
  • prevent characters to the right from disappearing while navigating
  • preserve the underlying glyph color during cursor blink
  • remove the vertical shift when the cursor moves over a character

Before

Before video:

website-terminal-block-cursor-before.mp4

After

After video:

website-terminal-block-cursor-after.mp4

Scope

This only changes the browser terminal UI in:

  • examples/website/app/components/lite-terminal/LiteTerminal.ts
  • examples/website/app/globals.css

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

@snvshal is attempting to deploy a commit to the Vercel Labs Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: 1d2c6b6ad9

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

}

this.cursorElement.textContent = text;
const resolvedColor = getComputedStyle(this.cursorElement).color;
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 Compute blink text color from underlying glyph style

In LiteTerminal.configureCursorElement, resolvedColor is captured from getComputedStyle(this.cursorElement) after applying the lite-terminal-cursor class, and that class now sets color: var(--cursor-block-fg, #000) in globals.css. For default (unstyled) text this resolves to the cursor block color instead of the line’s glyph color, so during the 50% blink phase (transparent background) the character under the cursor is drawn with the wrong color or effectively disappears on dark themes.

Useful? React with 👍 / 👎.

Comment on lines +576 to +577
const cursorChar = segment.text[offsetInSegment];
const afterCursor = segment.text.slice(offsetInSegment + 1);
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 Avoid slicing cursor glyph by UTF-16 code unit

renderLineContent now pulls the cursor cell with segment.text[offsetInSegment] and slice(offsetInSegment + 1), which split by UTF-16 code units rather than full grapheme clusters. If the cursor is on a multi-code-unit character (for example an emoji at the start of a line), this produces broken surrogate halves and corrupts what is rendered around the cursor, which is a regression introduced by the new cursor-char extraction path.

Useful? React with 👍 / 👎.

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