Commit Graph
11 Commits
Author SHA1 Message Date
can1357 705c937c56 fix(tui): fixed visibleWidth parity and OSC66 width metadata behavior
- Fixed `visibleWidth` parity with native width using `Bun.stringWidth` ANSI stripping.
- Fixed tab and OSC66 width parsing with `s=`/`w=` metadata handling.
- Added ASCII and long-string fast paths in `visibleWidth` for faster width checks.
- Consolidated visible-width regression coverage by replacing removed IME/Arabic/Jamo tests with `visible-width.test.ts`.
2026-06-07 06:24:07 +02:00
can1357 53aaced81f feat: enabled text-sizing and fixed OSC66 and DECCARA rendering behavior
- Added `textSizing` terminal capability and `tui.textSizing` setting for Kitty OSC66 scaling.
- Updated OSC66 range and visible-width handling to preserve grapheme slice behavior.
- Updated markdown rendering to apply heading text sizing only when enabled.
- Fixed DECCARA trailing-background fill tracking and DECRPM status 3/4 recognition.
2026-06-04 01:33:48 +02:00
can1357 fe6a94cb2a feat(packages/tui): added OSC 66 text sizing for markdown headings
- Added OSC 66 text-sizing utilities and `encodeTextSized` for safe, width-aware span emission.
- Enabled scale-2 OSC 66 output for H1 headings when text sizing is enabled and width permits.
- Handled OSC 66 heading rows as raw output, skipping wrap/background and preserving the reserved blank row.
- Mapped inline heading tokens to plain text to gate OSC 66 heading rendering by measured width.
2026-06-04 00:50:46 +02:00
can1357 86c56d6472 feat(tui): added DECCARA fill optimizer with OSC 66 and DEC 2026/2048
- Added a Kitty-only DECCARA optimizer painting solid bg panels as rectangles, with `PI_NO_DECCARA` kill switch.
- Added OSC 66 text-sizing width handling to slicing, truncation, and wrapping.
- Added DECRQM probes for DEC 2026 sync output and 2048 in-band resize.
- Added structured OSC 99 notification formatting.
2026-06-04 00:27:20 +02:00
can1357 4399e4b822 fix(tui): deferred ED3 scrollback erases on risky terminals
- Moved `eagerEraseScrollbackRisk` detection into `TerminalInfo` and `terminal-capabilities.ts`, removing the duplicate from `terminal.ts`.
- Added iTerm2 and Apple Terminal to risk detection; required double at-bottom probe before trusting live rebuilds.
- Fixed overlay hide in multiplexer sessions triggering a viewport repaint instead of a stale diff.
- Fixed width-shrink rebuilds leaving old-width fragments in native history before subsequent appends.
2026-06-03 00:02:06 +02:00
can1357 b82d29c6ff fix: fixed VS16 emoji width handling on macOS
- Switched `grapheme_width_str` to compute multi-character widths from `UnicodeWidthStr::width` and then apply the macOS Hangul Compatibility Jamo correction on top of that result.
- Added regression tests in native and TUI text-width tests for VS16 emoji-presentation symbols, keycaps, and related bare-symbol cases.
- Adjusted the AuthStorage codex ranking timeout test fallback to 2s with a 1s elapsed assertion so slow aborted requests cannot mask the fast timeout path.
2026-06-02 23:06:35 +02:00
can1357 55e146fa3c fix: synchronized snapshot-tag checks and fixed ANSI width emoji handling
- Introduced a shared missingSnapshotTagMessage helper and reused it from both hashline patcher and preview validation.
- Required snapshot tags in preview hashline sections for all edits, including head/tail inserts, so preview failures now match apply-time rejections.
- Updated TUI width calculation to strip ANSI escapes before grapheme splitting, preserving styled ZWJ emoji width behavior.
2026-05-30 15:59:58 +02:00
changhee.an b9437a4276 Use native width for non-ASCII TUI text
Keep the printable ASCII fast path, but send tabs, ANSI/control sequences, combining marks, and CJK through the same native width engine used by slicing and wrapping. This fixes Bun.stringWidth overcounting Arabic non-spacing marks and the old pure-ASCII tab double count.\n\nConstraint: Bun.stringWidth still reports Arabic combining marks as visible cells on Bun 1.3.14.\nRejected: Strip \p{Mn} in TypeScript | It would still leave tabs and future Unicode width mismatches divergent from native truncation.\nConfidence: high\nScope-risk: narrow\nDirective: Keep visibleWidth, sliceWithWidth, truncateToWidth, and wrapTextWithAnsi on one Unicode width model.\nTested: bun test packages/tui/test/text-utils.test.ts packages/tui/test/visible-width-jamo.test.ts packages/tui/test/wrap-ansi.test.ts packages/tui/test/truncate-to-width.test.ts packages/tui/test/render-regressions.test.ts; bun test packages/tui/test/*.test.ts; bun run check in packages/tui.\nNot-tested: Interactive terminal repaint with a live Arabic transcript.
2026-05-29 16:44:31 +09:00
can1357 e1bcf492a1 refactor: restructured text module and simplified NAPI API surface
- Renamed `EllipsisKind` enum to `Ellipsis` across all packages for clearer API naming.
- Refactored Rust text module from 356 to 155 lines with simplified state tracking using u32 ColorVal instead of enum ColorCode and named attribute constants.
- Removed `Env` parameter from public NAPI functions `truncate_to_width` and `extract_segments` to simplify API surface.
- Changed return type of `truncate_to_width` from `JsString` to `Either<JsString, Utf16String>` to support zero-copy returns.
- Removed early return optimization in `truncateToWidth()` function.
- Reordered native module search paths to prioritize repository build artifacts over system paths.
2026-02-01 10:23:41 +01:00
can1357 09225bc491 feat: refactored text truncation API to use string type and hardcoded ellipsis
- Changed TextInput type parameter to string in truncateToWidth(), visibleWidth(), sliceWithWidth(), and extractSegments() functions in native bindings.
- Removed TextInput type export from public API of pi-natives package.
- Removed format.ellipsis symbol from theme configuration, replacing all theme-based ellipsis references with hardcoded Unicode ellipsis character (...).
- Removed ellipsis property from SymbolTheme interface in pi-tui package.
- Removed truncateToWidth, sliceWithWidth, and extractSegments wrapper functions from pi-tui public API, now re-exporting directly from pi-natives.
- Added early return optimizations in truncateToWidth() and sliceWithWidth() native functions to skip native calls when possible.
2026-02-01 10:01:56 +01:00
can1357 8ef11355e7 perf(tui,natives): added native text utilities with JS fast path for short strings
- Added native text utilities in pi-natives (visible width, truncation, slicing, segment extraction)
- Wired pi-tui to use native implementations with short-string JS fast path
- Optimized key matching via cached parsed key ids
- Refactored visual truncation to reuse Text instances
- Reduced theme color lookups by switching from Map to plain records
- Regenerated WASM artifacts

Benchmarks (after vs before, lower is better):
- truncateToWidth/ansi: 20.37ms vs 38.13ms (2000 iters)
- sliceWithWidth/ansi: 5.12ms vs 20.39ms
- extractSegments/ansi: 8.92ms vs 27.60ms
- truncateToVisualLines: 3.51ms vs 411.55ms (500 iters)
- visibleWidth/ansi: 0.24ms vs 0.31ms
2026-01-29 10:47:55 +01:00