fix: vim cursor shape and mouse scroll in web terminal#20
Merged
Conversation
added 6 commits
March 27, 2026 16:13
…improve loadConfig/saveConfig documentation
Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
There was a problem hiding this comment.
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
termtoxterm-256colorand document the rationale (ADR 016). - Add
mouseScrollSpeedconfig, 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.
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cursor shape in Alacritty —
$TERMdefault changed fromprocess.env.TERM(inherited from the parent process) to a hardcodedxterm-256color. The parent terminal's identity is irrelevant to webtty's PTY children; inheritingTERM=alacrittycaused 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.handleWheelunconditionally sends arrow keys (\x1b[A/\x1b[B) on the alternate screen regardless of mouse tracking state. Added a custom wheel handler viaattachCustomWheelEventHandlerthat sends proper SGR scroll sequences (\x1b[<64/65;col;rowM) when the PTY app has enabled mouse tracking (e.g. vimset mouse=a), matching native terminal behaviour (ADR 017).mouseScrollSpeedconfig — new config key (default1) to scale SGR events per wheel tick. Values< 1reduce rate via accumulation (useful when scroll feels too fast); values> 1send multiple SGRs per tick. Takes effect on tab reload with no server restart required.