at ─────► User sees 'a'
- │ grid pos immediately
- │
- │ (meanwhile, 200ms later...)
- │
- ▼
- PTY echo 'a' ─────► xterm.js canvas ─────► Canvas shows 'a'
- (overlay still on top,
- cleared on next clear())
-```
-
-### DOM Overlay Positioning
-
-The overlay is a `` inserted into xterm.js's `.xterm-screen` element:
+### DOM Structure
```
div.xterm-screen (position: relative)
- ├── div.xterm-helpers (z-index: 5)
- ├── div.xterm-rows (z-index: auto)
+ ├── div.xterm-rows (z-index: auto) ← terminal owns this
├── div.xterm-selection (z-index: 1)
+ ├── div.xterm-helpers (z-index: 5)
├── div.xterm-decoration-container (z-index: 6-7)
- └── div[zerolag overlay] (z-index: 7) ← our overlay
+ └── div[zerolag overlay] (z-index: 7) ← our overlay (invisible to Ink)
```
-Each character is rendered as an absolutely-positioned `` on the terminal's cell grid:
+### Per-Character Grid Alignment
+
+Each character is an absolutely-positioned ``:
```
-left = charIndex * cellWidth (CSS pixels)
-top = lineIndex * cellHeight (CSS pixels)
-width = cellWidth (one cell per character)
+left = charIndex * cellWidth (CSS pixels)
+top = lineIndex * cellHeight (CSS pixels)
+width = cellWidth (exact cell width)
```
-Cell dimensions are read from xterm.js:
-- **v5.x**: `terminal._core._renderService.dimensions.css.cell` (private API)
-- **v7+**: `terminal.dimensions.css.cell` (public API, auto-detected)
+This avoids sub-pixel drift from normal DOM text flow.
### Font Matching
-The overlay matches the terminal's font rendering by:
-1. Caching `fontFamily`, `fontSize`, `fontWeight` from `terminal.options`
-2. Reading `letterSpacing` from the computed style of `.xterm-rows`
-3. Applying `-webkit-font-smoothing: antialiased` (matches canvas grayscale rendering)
-4. Disabling ligatures via `font-feature-settings: 'liga' 0, 'calt' 0`
-5. Using `text-rendering: geometricPrecision` for consistent glyph sizing
+1. `fontFamily`, `fontSize`, `fontWeight` from `terminal.options`
+2. `letterSpacing` from computed style of `.xterm-rows`
+3. `-webkit-font-smoothing: antialiased` (matches canvas grayscale)
+4. `font-feature-settings: 'liga' 0, 'calt' 0` (no ligatures)
+5. `text-rendering: geometricPrecision`
-### Render Cache
+### Cell Dimensions
-A render key based on `displayText:startCol:row:col:totalCols:flushedOffset` prevents redundant DOM rebuilds. The cache is cleared by `rerender()`, `refreshFont()`, and internally on state changes that affect the display.
-
-### Scroll Awareness
-
-The overlay hides when the user scrolls away from the bottom of the terminal (where the prompt lives). A scroll listener on `.xterm-viewport` detects `viewportY !== baseY` and hides the overlay. When the user scrolls back to the bottom, a debounced re-render (50ms default) repositions the overlay.
+- **xterm.js v5.x**: `terminal._core._renderService.dimensions.css.cell` (private API)
+- **xterm.js v7+**: `terminal.dimensions.css.cell` (public API, auto-detected)
### Prompt Column Locking
-When flushed text exists, the prompt column is locked to prevent visual jitter from full-screen redraws that temporarily shift the prompt marker. The row is allowed to change (output scrolls the prompt down), but the column stays fixed until the flushed state is cleared.
+When flushed text exists, the prompt column is locked to prevent jitter from full-screen redraws. Row changes are allowed (output can scroll the prompt).
-### Text Wrapping
+### Scroll Awareness
-Long input that exceeds the terminal width is wrapped at column boundaries:
-- Line 0: `(totalCols - startCol)` characters (starts after prompt)
-- Line 1+: `totalCols` characters (starts at column 0)
+Overlay hides when scrolled up (`viewportY !== baseY`). Debounced re-render when scrolling back to bottom.
-This matches xterm.js's character-level wrapping behavior.
-
-## Compatibility
-
-- **xterm.js v5.x**: Uses private API `terminal._core._renderService.dimensions` for cell sizing. Fully supported.
-- **xterm.js v7+** (future): Will automatically use public `terminal.dimensions` API when available.
-- **Renderers**: Best results with the canvas/WebGL renderer. DOM renderer works but the overlay is redundant since DOM text is already positioned identically.
+---
## Known Limitations
-- **Canvas/WebGL font mismatch**: Minor sub-pixel differences between DOM overlay text and canvas-rendered text are possible. The per-character absolute positioning minimizes this, but it's not pixel-identical on all platforms.
-- **Unicode/emoji**: Multi-byte characters (emoji, CJK) are not reliably echoed — they occupy variable cell widths that can't be predicted client-side. The overlay renders them at single-cell width, causing misalignment.
-- **Misprediction**: If the server processes input differently than expected (e.g., password prompts that suppress echo), the overlay shows characters that aren't actually displayed. Call `clear()` when you detect such cases.
-- **Prompt character in output**: If the prompt character appears in command output (e.g., `$` in a log message), the overlay may position at the wrong location. Use a more specific regex or custom finder to avoid this.
+- **Canvas/WebGL font mismatch**: Minor sub-pixel differences possible. Per-character absolute positioning minimizes this.
+- **Unicode/emoji**: Multi-byte characters occupy variable cell widths — rendered at single-cell width, causing misalignment.
+- **Password prompts**: Overlay shows characters that aren't echoed. Call `clear()` when you detect no-echo mode.
+- **Prompt in output**: If `$` appears in command output, prompt detection may find the wrong position. Use regex or custom finder.
+
+---
## License
-MIT
+MIT — [Claudeman](https://github.com/Ark0N/Claudeman) Contributors
diff --git a/packages/xterm-zerolag-input/package.json b/packages/xterm-zerolag-input/package.json
index e3564fcc..65284329 100644
--- a/packages/xterm-zerolag-input/package.json
+++ b/packages/xterm-zerolag-input/package.json
@@ -1,6 +1,6 @@
{
"name": "xterm-zerolag-input",
- "version": "0.1.1",
+ "version": "0.1.2",
"description": "Instant keystroke feedback overlay for xterm.js — eliminates perceived input latency over high-RTT connections",
"type": "module",
"main": "dist/index.cjs",
@@ -32,10 +32,10 @@
"addon"
],
"license": "MIT",
- "homepage": "https://github.com/nicobailon/claudeman/tree/master/packages/xterm-zerolag-input#readme",
+ "homepage": "https://github.com/Ark0N/Claudeman/tree/master/packages/xterm-zerolag-input#readme",
"repository": {
"type": "git",
- "url": "git+https://github.com/nicobailon/claudeman.git",
+ "url": "git+https://github.com/Ark0N/Claudeman.git",
"directory": "packages/xterm-zerolag-input"
},
"devDependencies": {