Skip to content

test: verify ghostty-web upstream fixes (coder/ghostty-web#147)#21

Closed
jesse23 wants to merge 2 commits intomainfrom
test/ghostty-web-upstream-fix
Closed

test: verify ghostty-web upstream fixes (coder/ghostty-web#147)#21
jesse23 wants to merge 2 commits intomainfrom
test/ghostty-web-upstream-fix

Conversation

@jesse23
Copy link
Copy Markdown
Owner

@jesse23 jesse23 commented Mar 28, 2026

Purpose

Verification branch for coder/ghostty-web#147 — the upstream PR that fixes three PTY input handling gaps directly in ghostty-web. This PR demonstrates that the webtty workarounds for Bug 2 and Bug 3 can be safely removed once the upstream fix lands.

Do not merge. This branch will be deleted after the upstream PR is reviewed and merged.


What changed

This branch Production (main)
ghostty-web file:../ghostty-web (local fork at fix/pty-input-handling-gaps) 0.4.0-next.14.g6a1a50d (npm)
Bug 2 — Ctrl+V workaround (paste capture listener) Removed Present
Bug 3 — mouse scroll workaround (attachCustomWheelEventHandler) Removed Present
Bug 1 — cursor shape workaround (cursor.ts) Kept Present

Bug 1 is kept because its upstream fix requires a WASM rebuild (new ghostty_render_state_get_cursor_style / _blinking exports). cursor.ts now has a comment listing exactly what to delete once the rebuilt WASM ships.


How to test locally

Setup

# 1. Clone the fork if you haven't already
git clone https://github.com/jesse23/ghostty-web ~/u/ex/ghostty-web

# 2. Check out the upstream fix branch
cd ~/u/ex/ghostty-web
git checkout fix/pty-input-handling-gaps

# 3. Copy the WASM from the installed npm package (no Zig needed)
cp ~/u/ex/webtty/node_modules/ghostty-web/ghostty-vt.wasm ghostty-vt.wasm
bun install && bun run build:lib && bun run build:wasm-copy

# 4. Switch webtty to this test branch
cd ~/u/ex/webtty
git checkout test/ghostty-web-upstream-fix
bun install

# 5. Build and restart
bun run build && bun run webtty stop
# then launch webtty from your terminal as usual

Test cases

Bug 2 — Ctrl+V forwards \x16 to PTY (no webtty paste listener)

  1. Open a session and run any tool that uses native clipboard read via \x16 (e.g. opencode image paste).
  2. Copy an image to clipboard, press Ctrl+V in the terminal.
  3. ✅ Expected: tool receives \x16 and triggers its OS clipboard read (osascript / wl-paste).
  4. ❌ Before fix: nothing happened — handleKeyDown swallowed the event.

Bug 3 — Mouse wheel scrolls vim buffer (no webtty custom handler)

  1. Open vim with set mouse=a in your vimrc (or run :set mouse=a after opening).
  2. Open a file with more lines than the window height.
  3. Scroll the mouse wheel.
  4. ✅ Expected: buffer scrolls up/down. Cursor does not move.
  5. ❌ Before fix: cursor moved on every wheel tick (arrow keys were sent instead of SGR sequences).

Bug 1 — Cursor shape (workaround still active, WASM not rebuilt)

Cursor shape changes (bar in insert mode, block in normal mode) still work via cursor.ts. This is unchanged from main. The upstream fix for Bug 1 will take effect after coder/ghostty-web#147 is merged and a new WASM binary is released.


Cleanup plan (after coder/ghostty-web#147 merges + new npm release)

  1. Bump ghostty-web version in package.json to the new release.
  2. Delete src/client/cursor.ts.
  3. Remove import { applyDecscusr } from './cursor' from index.ts.
  4. Remove applyDecscusr(term, event.data) call in ws.onmessage.
  5. Merge this PR's package.json diff (removing the file: path) alongside the above.

How to Manual Test This Change

To test locally, three steps:

  1. Build the ghostty-web fork (copies WASM from npm, compiles TS only — no Zig)
cd ~/work/ghostty-web
git checkout fix/pty-input-handling-gaps
cp ~/work/webtty/node_modules/ghostty-web/ghostty-vt.wasm ghostty-vt.wasm
bun install && bun run build:lib && bun run build:wasm-copy
  1. Switch webtty to the test branch and build
cd ~/work/webtty
git checkout test/ghostty-web-upstream-fix
bun install && bun run build && bun run webtty stop

Reference

coder/ghostty-web#147
coder/ghostty-web#145

jesse23 added 2 commits March 28, 2026 06:53
…rounds

Points ghostty-web to the local fork (jesse23/ghostty-web#fix/pty-input-handling-gaps).
Removes the webtty-level workarounds for Bug 2 (Ctrl+V paste listener) and
Bug 3 (attachCustomWheelEventHandler + mouseScrollSpeed) — the upstream fixes
in handleKeyDown and handleWheel are now sufficient.
Bug 1 (cursor shape) workaround kept since the WASM has not been rebuilt yet.
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