Commit graph

25 commits

Author SHA1 Message Date
Mario Zechner
4cb1a56b53 fix(tui,coding-agent): add OSC 133 user message markers support closes #1805 2026-03-04 18:33:22 +01:00
Zhou Rui
85d06052fb
fix(tui): stabilize regional indicator width to prevent streaming render drift (#1783) 2026-03-03 21:59:56 +01:00
Mario Zechner
07fad1362c feat(tui): hardware cursor positioning for IME support
- Add Focusable interface for components that need hardware cursor positioning
- Add CURSOR_MARKER (APC escape sequence) for marking cursor position in render output
- Editor and Input components implement Focusable and emit marker when focused
- TUI extracts cursor position from rendered output and positions hardware cursor
- Track hardwareCursorRow separately from cursorRow for differential rendering
- visibleWidth() and extractAnsiCode() now handle APC sequences
- Update overlay-test.ts example to demonstrate Focusable usage
- Add documentation for Focusable interface in docs/tui.md

Closes #719, closes #525
2026-01-16 04:30:07 +01:00
Nico Bailon
d29f268f46 feat(tui): add pad parameter to truncateToWidth, overlay QA tests 2026-01-12 10:01:53 -08:00
Mario Zechner
f9064c2f69 feat(tui): add overlay compositing for ctx.ui.custom() (#558)
Adds overlay rendering capability to the TUI, enabling floating modal
components that render on top of existing content without clearing the screen.

- Add showOverlay(), hideOverlay(), hasOverlay() methods to TUI
- Implement ANSI-aware line compositing via extractSegments()
- Support overlay stack (multiple overlays, later on top)
- Add { overlay: true } option to ctx.ui.custom()
- Add overlay-test.ts example extension

Also fixes pre-existing bug where bash tool output cached visual lines
at fixed terminal width, causing crashes on terminal resize.

Co-authored-by: Nico Bailon <nico.bailon@gmail.com>
2026-01-08 22:40:42 +01:00
robinwander
786a326a71 fix(tui): trim trailing whitespace in wrapped lines to prevent width overflow 2026-01-04 22:15:25 -06:00
cursive
d97a96493c
fix(tui): Strip OSC 8 hyperlink sequences in visibleWidth (#396) 2026-01-02 10:32:36 +01:00
nathyong
6e4270a286 tui: only check for emojis in visibleWidth when necessary
The initial render of a session, and any re-draws caused by terminal
resizing are noticeably slow, especially on conversations with 20+
turns and many tool calls.

From profiling with `bun --cpu-prof` (available since bun 1.3.2), the
majority of the rendering (90%) is spent on detection of emojis in the
string-width library, running the expensive `/\p{RGI_Emoji}$/v`
regular expression on every individual grapheme cluster in the entire
scrollback. I believe it essentially expands to a fixed search against
every possible emoji sequence, hence the amount of CPU time spent in it.

This change replaces the `stringWidth` from string-width with a
`graphemeWidth` function that performs a similar check, but avoids
running the `/\p{RGI_Emoji}$/v` regex for emoji detection unless it
contains codepoints that could be emojis.

The `visibleWidth` function also has two more optimisations:
- Short-circuits string length detection for strings that are entirely
  printable ASCII characters
- Adds a cache for non-ASCII segments to avoid recomputing string length
  when resizing
2026-01-02 01:56:11 +01:00
Mario Zechner
1d9fa13d58 Fix crash on Unicode format characters in visibleWidth
Strip all Unicode format characters (category Cf) before passing to
string-width. These are invisible control characters that crash
string-width but have no visible width anyway.

Closes #390
2026-01-01 22:33:09 +01:00
Mr. Rc
bbf23bd5f1
Fix characters (#372)
* Fix cat command

* Fix text rendering crash from undefined code points in bash output

* Revert unintentional model parameter changes from fix cat command commit
2026-01-01 02:16:29 +01:00
Ahmed Kamal
0427445242
Fix Ctrl+W to use standard readline word deletion behavior (#306)
- Skip trailing whitespace before deleting word (readline behavior)
- Make word navigation grapheme-aware using Intl.Segmenter
- Add Ctrl+Left/Right and Alt+Left/Right word navigation to Input
- Accept full Unicode input while rejecting control characters (C0/C1/DEL)
- Extract shared utilities to utils.ts (getSegmenter, isWhitespaceChar, isPunctuationChar)
- Fix unsafe cast in Editor.forceFileAutocomplete with runtime type check
- Add comprehensive tests for word deletion and navigation
2025-12-25 04:09:47 +01:00
Mario Zechner
d5fd685901 Enable more biome lints and fix things 2025-12-21 22:56:20 +01:00
Mario Zechner
ce9ffaff91 Fix ANSI styles not preserved across newlines in text wrapping
wrapTextWithAnsi() was processing each line independently after splitting
on newlines, losing ANSI state. When styled text contained embedded newlines
(e.g. from markdown paragraphs), subsequent lines would lose their styling.

Fixed by tracking ANSI state across lines and prepending active codes to
lines after the first.

Fixes #197
2025-12-15 23:00:25 +01:00
Mario Zechner
6ec1391ebb fix: escape codes not properly wrapped during line wrapping
- ANSI codes now attach to next visible content, not trailing whitespace
- Rewrote AnsiCodeTracker to track individual attributes
- Line-end resets only turn off underline, preserving background colors
- Added vitest config to exclude node:test files

fixes #109
2025-12-05 21:49:44 +01:00
Mario Zechner
240064eec3 fix: TUI crash with Unicode characters in branch selector
- Use truncateToWidth instead of substring in user-message-selector.ts
- Fix truncateToWidth to use Intl.Segmenter for proper grapheme handling
- Add tests for Unicode truncation behavior
2025-12-05 11:59:39 +01:00
Peter Steinberger
c43f1d307c Add CI workflow and fix workspace tests 2025-12-02 12:53:53 +00:00
Mario Zechner
e25420a4c8 Release v0.11.4 2025-12-01 13:05:12 +01:00
Mario Zechner
a59553a881 Fix edit diff line number alignment and whitespace preservation
- Fix line numbers showing incorrect values for edits far from file start
  (e.g., 1,2,3 instead of 336,337,338). Skip count was added after displaying
  lines instead of before.

- Rewrite splitIntoTokensWithAnsi in pi-tui to preserve whitespace as separate
  tokens instead of discarding it. Wrapped lines now maintain proper alignment
  and code indentation.

- Update mom README: rename title, remove em-dashes for cleaner prose
2025-11-27 11:53:00 +01:00
Mario Zechner
e7c48e33a2 fix: emoji text wrapping crash in pi-tui
Fixed crash when rendering text containing emojis followed by long content.
The breakLongWord function was iterating over UTF-16 code units instead of
grapheme clusters, causing emojis (surrogate pairs) to be miscounted during
line wrapping. Now uses Intl.Segmenter to properly handle multi-codepoint
characters.
2025-11-26 23:55:01 +01:00
Mario Zechner
85adcf22bf Release v0.8.0 2025-11-21 03:12:42 +01:00
Mario Zechner
1f68d6eb40 Release v0.7.22 2025-11-19 01:50:45 +01:00
Mario Zechner
1b28780155 Release v0.7.21 2025-11-19 00:56:16 +01:00
Mario Zechner
38ac29acfb Add ANSI-aware word wrapping to TUI components
- Created shared wrapTextWithAnsi() function in utils.ts
- Handles word-based wrapping while preserving ANSI escape codes
- Properly tracks active ANSI codes across wrapped lines
- Supports multi-byte characters (emoji, surrogate pairs)
- Updated Markdown and Text components to use shared wrapping
- Removed duplicate wrapping logic (158 lines total)
2025-11-18 22:26:24 +01:00
Mario Zechner
001beff394 Fix tab rendering in TUI components
Replace tabs with 3 spaces for consistent rendering and width calculation:
- Updated visibleWidth() to normalize tabs before measuring
- Updated Text and Markdown components to replace tabs when rendering
- Updated tool-execution display for read/write tools to replace tabs

This fixes background color rendering issues when displaying files with tab indentation.
2025-11-11 23:24:48 +01:00
Mario Zechner
c5083bb7cb Fix markdown streaming duplication by splitting newlines first
- Added string-width library for proper terminal column width calculation
- Fixed wrapLine() to split by newlines before wrapping (like Text component)
- Fixed Loader interval leak by stopping before container removal
- Changed loader message from 'Loading...' to 'Working...'
2025-11-11 19:27:58 +01:00