Skip to content

fix: vim cursor shape and mouse scroll in web terminal#20

Merged
jesse23 merged 8 commits intomainfrom
jesse_fix2
Mar 28, 2026
Merged

fix: vim cursor shape and mouse scroll in web terminal#20
jesse23 merged 8 commits intomainfrom
jesse_fix2

Conversation

@jesse23
Copy link
Copy Markdown
Owner

@jesse23 jesse23 commented Mar 28, 2026

Summary

  • Cursor shape in Alacritty$TERM default changed from process.env.TERM (inherited from the parent process) to a hardcoded xterm-256color. The parent terminal's identity is irrelevant to webtty's PTY children; inheriting TERM=alacritty caused vim to not emit DECSCUSR sequences, leaving the cursor permanently stuck at the startup shape (ADR 016).

  • Mouse scroll moves cursor instead of scrolling — ghostty-web's Terminal.handleWheel unconditionally sends arrow keys (\x1b[A/\x1b[B) on the alternate screen regardless of mouse tracking state. Added a custom wheel handler via attachCustomWheelEventHandler that sends proper SGR scroll sequences (\x1b[<64/65;col;rowM) when the PTY app has enabled mouse tracking (e.g. vim set mouse=a), matching native terminal behaviour (ADR 017).

  • mouseScrollSpeed config — new config key (default 1) to scale SGR events per wheel tick. Values < 1 reduce rate via accumulation (useful when scroll feels too fast); values > 1 send multiple SGRs per tick. Takes effect on tab reload with no server restart required.

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adjusts webtty’s default terminal identity and wheel-event behavior so vim gets the expected cursor-shape sequences and mouse-scrolling works correctly when apps enable mouse tracking.

Changes:

  • Hardcode default term to xterm-256color and document the rationale (ADR 016).
  • Add mouseScrollSpeed config, expose it via /api/config, and use it in the client’s custom wheel handler to emit SGR scroll sequences (ADR 017).
  • Update config/client specs and tests to reflect the new config flow and keys.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/server/routes.ts Exposes mouseScrollSpeed to the browser via /api/config.
src/config.ts Adds mouseScrollSpeed, hardcodes default term, and replaces saveConfig with initConfig (stub write).
src/config.test.ts Updates tests for initConfig and adds coverage around the new term default.
src/client/index.ts Adds custom wheel handler to send SGR mouse scroll sequences when mouse tracking is enabled.
docs/specs/config.md Documents new defaults and mouseScrollSpeed behavior/hot-reload semantics.
docs/specs/client.md Documents client config payload / mouse scroll behavior.
docs/adrs/017.client.mouse-scroll.md ADR for custom wheel handler + SGR scroll forwarding.
docs/adrs/016.config.term-default.md ADR for fixing term default to xterm-256color.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread docs/specs/client.md
Comment thread docs/specs/client.md
Comment thread src/config.test.ts Outdated
Comment thread src/config.test.ts Outdated
Comment thread src/server/routes.ts
- Clarify mouseScrollSpeed is used by wheel handler, not Terminal constructor
- Simplify DEFAULT_CONFIG.term test (term is now a static string, no env mutation needed)
- Rename describe('saveConfig') to describe('initConfig')
- Add mouseScrollSpeed assertion to GET /api/config route test

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
@jesse23 jesse23 merged commit 208094f into main Mar 28, 2026
3 checks passed
@jesse23 jesse23 deleted the jesse_fix2 branch March 28, 2026 02:56
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.

2 participants