## Why
In OpenCode's embedded terminal, Dvorak Ctrl+U and Ctrl+D can reach
Neovim as Ctrl+F and Ctrl+H when the child uses Kitty keyboard encoding.
Paging up instead pages down, and paging down moves the cursor left.
The incoming Kitty event correctly separates the active-layout character
from its base-layout alternative. `EmbeddedTerminalRenderable` currently
passes the alternative as the native encoder's unshifted character,
changing the key's identity.
## What Changes
Keep the active-layout character as the primary key, and use the
base-layout alternative only to infer the physical key when an explicit
physical code is unavailable.
| Incoming Dvorak input | Before | After |
| --- | --- | --- |
| Plain u, base-layout F | u (117), byte `75` hex | Unchanged |
| Ctrl+U, base-layout F | Ctrl+F | Ctrl+U |
| Ctrl+D, base-layout H | Ctrl+H | Ctrl+D |
| Ctrl+Shift+U, base-layout F | Ctrl+Shift+F | Ctrl+Shift+U |
If the child requests alternate-key reporting, the original base-layout
alternative remains available separately. Legacy control-byte output
stays unchanged.
This explains why ordinary typing can work while control shortcuts fail:
in the reproduced Kitty mode, plain letters use the translated text,
while control shortcuts use the incorrectly selected key codepoint.
Ctrl+U becomes `ESC[102;5u` instead of `ESC[117;5u`; Ctrl+D becomes
`ESC[104;5u` instead of `ESC[100;5u`.
Regression coverage parses real Kitty sequences and exercises the native
encoder. One table covers plain Dvorak u/d, control shortcuts, Shift,
Cyrillic input, a QWERTY control case, legacy child mode, and
alternate-key reporting. A focused-delivery test covers
press/repeat/release events.
## Demo
Real Neovim 0.12.4 running in the existing `embedded-terminal-demo.ts`
example with the production `EmbeddedTerminalRenderable`. The inspector
shows:
1. The received key, active-layout and base-layout codepoints, and raw
input sequence.
2. The actual `onData` output forwarded unchanged to the PTY, in escaped
and hexadecimal form. The inspector does not re-encode the key.
3. Neovim's independently observed key via `vim.on_key`, plus its
resulting cursor position.
Each case starts at line 80, column 8, with `scroll=8`. Plain u is typed
in Insert mode; Ctrl+D/U are pressed in Normal mode. The clean Neovim
fixture explicitly enables Kitty mode with `CSI > 1 u`; Dvorak Kitty
input sequences are injected at the outer terminal boundary rather than
generated by an OS keyboard layout.
Before uses the unchanged `EmbeddedTerminal.ts` from `fe547ebe`, loaded
through a test-only module override. After uses `03b84c9a`. The three
independent cases are reordered to show plain typing first, slowed to
0.1×, and held for four seconds each; setup and resets are omitted. Both
processes returned cleanly after the check.
**Before:** Plain u stays 117. Ctrl+D changes 100 → 104 and Neovim sees
`<C-H>`; Ctrl+U changes 117 → 102 and Neovim sees `<C-F>`.
https://github.com/user-attachments/assets/6e1b469f-e4d2-4298-a095-8f422e10a8d0
**After:** Plain u still works. Ctrl+D stays 100 and Neovim sees
`<C-D>`; Ctrl+U stays 117 and Neovim sees `<C-U>`.
https://github.com/user-attachments/assets/b825e1f0-b7e6-4f1b-a112-e780a9f34fe8
## Scope
This fixes OpenTUI's embedded-terminal key adapter, without
application-specific remapping or a public API change. OpenCode will
need to adopt an OpenTUI release containing the fix.
## Verification
```sh
cd packages/core
bun run test src/renderables/EmbeddedTerminal.test.ts
bun run typecheck
bun run test:js:node
bun run build:lib
bun run test
cd ../..
bun run fmt:check
bun run lint
```
- Focused suite: seven regressions fail with the baseline encoder, while
plain typing passes; all 31 tests pass afterward. Rechecked after
consolidating the repeated test setup.
- Full Bun suite after building the parser assets: 5,587 passed, 26
skipped, zero failures. The initial unbuilt-worktree run failed only
because `parser.worker.js` was absent.
- Node suite: 4,842 passed, seven skipped, zero failures.
- Typechecking, formatting, and lint pass.
- Real PTY before/after verification shown above.
Requiring a pinned footer forces scrollback images to fall back to
blocks during startup and after resize replay resets. Allow Kitty and
Sixel images before pinning when they fit above the pinned footer to
preserve image quality while the footer settles.
Reduce frame preparation and transport costs so local terminals can
consume image updates with less CPU work. Bound pending frames when
output stalls and fix per-frame GPU resource growth so sustained
rendering does not accumulate work or retain native handles.
Keep raw transport as the default and make file transport opt-in for
terminals that acknowledge image uploads.
#1328 partially superseded, but it has `NativeImage.adoptRgbaFile(path,
width, height)` that adopts an existing producer-created RGBA file
lazily. Eligible renders send that same path without reading, copying,
or rewriting its pixels.
Document the opt-in shared Zig local cache workflow for repeated native
builds across worktrees.
---------
Co-authored-by: Simon Klee <hello@simonklee.dk>
The native viewport lookup reports whether a view exists, but the FFI
binding discarded that result. Preserve the boolean so callers can
distinguish missing views from successful lookups.
A backpressured frame could schedule a retry after its callback paused
or
stopped the renderer, reviving a cancelled continuous loop.
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
## Summary
- recognize the selected Ghostty `std.log` scopes in OpenTUI's root
logger
- keep all standard-library logs silent by default
- read `OTUI_GHOSTTY_LOG_LEVEL` inside the native `logFn` and forward
enabled messages through the existing `logger.logMessage` path
- support `error`/`err`, `warn`/`warning`, `info`, and `debug`
thresholds
- document the environment variable
## Behavior
Unset or invalid `OTUI_GHOSTTY_LOG_LEVEL` values emit no `std.log`
messages. Recognized Ghostty scopes are forwarded up to the configured
severity. Logs from every other scope are discarded. Explicit OpenTUI
logger calls are unchanged.
## Testing
- release `bun run build` from `packages/core`
- `bun run test:native` from `packages/core` (2066 passed, 8 skipped)
- `zig fmt --check packages/native/src/lib.zig
packages/native/src/logger.zig`
- `oxfmt --check packages/web/src/content/docs/reference/env-vars.mdx`
## Summary
- install a root `std_options.logFn` that discards `std.log` output
- leave Zig's default compile-time log level unchanged
- keep explicit OpenTUI `logger.logMessage` output flowing through the
existing JavaScript callback
## Why
OpenTUI imports native dependencies such as Ghostty into its Zig root
module. Their `std.log` calls otherwise use Zig's default stderr logger,
bypass the renderer, and can corrupt the terminal display. OpenTUI
already has a separate explicit logger for messages intended for
JavaScript and file logging, so standard-library logs should not write
directly to the host terminal.
## Testing
- `zig fmt --check packages/native/src/lib.zig`
- release `bun run build` from `packages/core`
- `bun run test:native` from `packages/core` (2066 passed, 8 skipped)
## Summary
- reject parser escape codes such as `[A` and `[27u` as physical key
identifiers
- infer Web-style physical identities (`ArrowUp`, `KeyC`, `Digit1`,
`Escape`) before calling Ghostty
- derive the unshifted codepoint from that normalized physical identity
- cover raw arrow input and nested Kitty character/escape re-encoding
## Why this is needed
OpenTUI key events use `code` for two different kinds of values. Kitty
and raw escape parsing can produce parser codes such as `[A` for Up or
`[27u` for Kitty Escape, while other events provide Web-style physical
codes such as `KeyA`. Ghostty's key encoder accepts the latter physical
identities, not parser escape fragments. Passing `[A` through as the
physical key leaves Ghostty unable to encode an arrow key.
Embedded terminals also need to re-encode input when the program inside
them enables the Kitty keyboard protocol. In that mode, text alone is
insufficient for modified and disambiguated keys: Ghostty needs a
normalized physical identity and its unshifted codepoint. Raw character
events may not include `code`, so this change infers `KeyA`/`Digit1`;
Kitty escape events whose parser code is `[27u` fall back to `Escape`.
The regression verifies that Ctrl+C and Escape are re-emitted as Kitty
sequences for a nested terminal.
## Testing
- `bun test src/renderables/EmbeddedTerminal.test.ts` (16 passed)
- `oxlint packages/core/src/renderables/EmbeddedTerminal.ts
packages/core/src/renderables/EmbeddedTerminal.test.ts`
- `oxfmt --check packages/core/src/renderables/EmbeddedTerminal.ts
packages/core/src/renderables/EmbeddedTerminal.test.ts`
Ghostty 1.3 renders certain multi-code-point graphemes two columns wide.
Use its width profile for direct sessions so rendering, wrapping, and
cursor placement stay aligned with the terminal.
Fix#1401
Thai SARA AM occupies an additional cell within a grapheme. Count
positive-width spacing marks to keep output coordinates aligned with
terminals.
Fix#479
## Summary
- correlate cursor-position reports with the two emitted OSC 66 probes
- keep the startup cursor report out of capability detection
- require the exact expected columns instead of accepting larger echoed
payload widths
Terminals that echo an unsupported OSC 66 payload can leave the cursor
well past the expected probe column. Treating any row-1 report at or
beyond the expected column therefore enables capabilities the terminal
does not support. The probe state now consumes only the two ordered
responses emitted by `queryTerminalSend`, while an unrelated cursor
report cannot enable text scaling.
Closes#1383.
## Testing
- filtered Zig 0.16 native tests: 2 passed
- full Zig 0.16 native suite: 2,013 passed, 8 skipped
- native hello example
- `bun run build`
- `bun run fmt:check`
- `bun run lint`
- `zig fmt --check packages/native/src/terminal.zig
packages/native/src/tests/terminal_test.zig`
---------
Co-authored-by: Simon Klee <hello@simonklee.dk>
Model native flags as numeric bytes so Bun and Node share one FFI
contract. Keep split-footer commits within Darwin ARM64's eight argument
registers to prevent stack marshalling from losing frame-finalization
state.
Fix https://github.com/anomalyco/opentui/issues/74
Double-click selects a word. Triple-click selects the line. A first
click still selects nothing.
Renderer counts left presses. A second press on the same cell within 500
ms asks for a word. A third press asks for a line.
Drag after a word click keeps the spaces between words. Shift+arrow
after a multi-click extends by cell, not by word.
ASCII font and tables stay cell-only. The click interval and the
word-character set are hard-coded for now.
Replace Commit Mono with a project-owned Iosevka build so the site
typeface can evolve with OpenTUI's visual identity. Add a private font
lab to compare future builds before publishing them.