Commit graph

23 commits

Author SHA1 Message Date
Sviatoslav Abakumov
c5d16fe456
feat(tui): add character jump navigation (Ctrl+], Ctrl+Alt+]) (#1074)
Add Bash/Readline-style character search:

- Ctrl+] enters forward jump mode, awaits next character, jumps to it
- Ctrl+Alt+] does the same but searches backward
- Multi-line search
- Case-sensitive matching
- Pressing the hotkey again cancels; control chars cancel and fall
  through
2026-01-30 01:42:14 +01:00
Mario Zechner
a6f9c3cf0d fix(tui): fix scrollback overwrite when appending lines past viewport
Appended lines were not committed to terminal scrollback because the
renderer used cursor movement (CSI B) and carriage return without
linefeed. This caused earlier content to be overwritten when the
viewport filled up.

Changes:
- For appended lines, emit \r\n to create real scrollback lines
- When target row is below viewport, scroll with \r\n before positioning
- Add PI_TUI_WRITE_LOG env var for debugging raw ANSI output
- Add fullRedraws readonly property to TUI class
- Add viewport-overwrite-repro.ts test script

fixes #954
2026-01-26 16:51:28 +01:00
Mario Zechner
ad337e30be docs: document Focusable interface propagation pattern for IME support
Container components with embedded Input/Editor children must implement
Focusable and propagate focus state to enable correct IME candidate
window positioning.

Related to #827
2026-01-18 17:27:16 +01:00
Mario Zechner
5c938e08d0 docs: document EditorOptions paddingX and editorPaddingX setting 2026-01-16 23:57:35 +01:00
Mario Zechner
356a482527 fix(tui): add vertical scrolling to Editor when content exceeds terminal height
The Editor component now accepts TUI as the first constructor parameter,
enabling it to query terminal dimensions. When content exceeds available
height, the editor scrolls vertically keeping the cursor visible.

Features:
- Max editor height is 30% of terminal rows (minimum 5 lines)
- Page Up/Down keys scroll by page size
- Scroll indicators show lines above/below: ─── ↑ 5 more ───

Breaking change: Editor constructor signature changed from
  new Editor(theme)
to
  new Editor(tui, theme)

fixes #732
2026-01-16 04:12:21 +01:00
Mario Zechner
7d45e434de Merge branch 'main' into feat/tui-overlay-options 2026-01-13 22:06:02 +01:00
Nico Bailon
0c0aac6599 feat(tui): add OverlayOptions API and fix width overflow crash
Adds positioning/sizing options for overlays and fixes crash when compositing
lines with complex ANSI sequences exceed terminal width.
2026-01-12 10:01:34 -08:00
Mario Zechner
6d495348c5 fix(tui): reset styles per line 2026-01-11 18:36:48 +01:00
Mario Zechner
6af7c97154 Update tui README.md: replace isXxx() with matchesKey() and Key helper 2026-01-03 23:11:11 +01:00
Mario Zechner
6f7c10e323 Add setEditorText/getEditorText to hook UI context, improve custom() API
- Add setEditorText() and getEditorText() to HookUIContext for prompt generator pattern
- custom() now accepts async factories for fire-and-forget work
- Add CancellableLoader component to tui package
- Add BorderedLoader component for hooks with cancel UI
- Export HookAPI, HookContext, HookFactory from main package
- Update all examples to import from packages instead of relative paths
- Update hooks.md and custom-tools.md documentation

fixes #350
2026-01-01 00:04:56 +01:00
Mario Zechner
71cbae6371 Export wrapTextWithAnsi utility and add handleInput docs
- Export wrapTextWithAnsi from tui package
- Add 'Handling Input' section to README with key detection example
- Document wrapTextWithAnsi in utilities section
2025-12-30 23:28:38 +01:00
Mario Zechner
1d3203fd3d Expand tui README: Component interface docs and custom component guide
- Document render/handleInput/invalidate methods in Component interface
- Add 'Creating Custom Components' section with:
  - Width constraint warning (lines must not exceed width)
  - Examples using truncateToWidth and visibleWidth
  - ANSI code handling explanation
  - Caching pattern for performance
2025-12-30 23:26:21 +01:00
Mario Zechner
adbe0c9b4f Update tui CHANGELOG and README
- Add changelog entries for new key detection functions and TUI.onDebug
- Completely rewrite README with accurate documentation:
  - All components documented (added TruncatedText, SettingsList)
  - All theme interfaces documented (EditorTheme, MarkdownTheme, SelectListTheme, SettingsListTheme, ImageTheme)
  - Fixed incorrect constructor signatures
  - Added key detection utilities section
  - Added utilities section
2025-12-30 23:22:41 +01:00
Mario Zechner
e7097d911a Custom tools with session lifecycle, examples for hooks and tools
- Custom tools: TypeScript modules that extend pi with new tools
  - Custom TUI rendering via renderCall/renderResult
  - User interaction via pi.ui (select, confirm, input, notify)
  - Session lifecycle via onSession callback for state reconstruction
  - Examples: todo.ts, question.ts, hello.ts

- Hook examples: permission-gate, git-checkpoint, protected-paths

- Session lifecycle centralized in AgentSession
  - Works across all modes (interactive, print, RPC)
  - Unified session event for hooks (replaces session_start/session_switch)

- Box component added to pi-tui

- Examples bundled in npm and binary releases

Fixes #190
2025-12-17 16:03:23 +01:00
Mario Zechner
b8a0465e30 Update docs for inline images, remove PI_NO_IMAGES env var
- Add CHANGELOG entry for inline image rendering feature
- Add /show-images to slash commands table in README
- Expand Image Support section with inline rendering info
- Add terminal.showImages to settings documentation
- Remove PI_NO_IMAGES environment variable feature
2025-12-13 23:21:18 +01:00
Nico Bailon
fcad447f32 add image component docs to readme 2025-12-12 19:38:36 -08:00
Markus Ylisiurunen
ff047e5ee1
Implement fuzzy search for model/session selector and improve Input multi-key sequence handling (#122)
* implement fuzzy search and filtering for tui selectors

* update changelog and readme

* add correct pr to changelog
2025-12-05 20:33:04 +01:00
Mario Rodler
c8dcf1cdae feat(tui): Editor now handles extended character input (e.g., umlauts) and updates key binding documentation 2025-11-16 18:09:17 +01:00
Mario Zechner
985f955ea0 Clean up TUI package and refactor component structure
- Remove old TUI implementation and components (LoadingAnimation, MarkdownComponent, TextComponent, TextEditor, WhitespaceComponent)
- Rename components-new to components with new API (Loader, Markdown, Text, Editor, Spacer)
- Move Text and Input components to separate files in src/components/
- Add render caching to Text component (similar to Markdown)
- Add proper ANSI code handling in Text component using stripVTControlCharacters
- Update coding-agent to use new TUI API (requires ProcessTerminal, uses custom Editor subclass for key handling)
- Remove old test files, keep only chat-simple.ts and virtual-terminal.ts
- Update README.md with new minimal API documentation
- Switch from tsc to tsgo for type checking
- Update package dependencies across monorepo
2025-11-11 10:32:18 +01:00
Mario Zechner
192d8d2600 fix(tui): Container change detection for proper differential rendering
Fixed rendering artifact where duplicate bottom borders appeared when components
dynamically shifted positions (e.g., Ctrl+C in agent clearing status container).

Root cause: Container wasn't reporting as "changed" when cleared (0 children),
causing differential renderer to skip re-rendering that area.

Solution: Container now tracks previousChildCount and reports changed when
child count changes, ensuring proper re-rendering when containers are cleared.

- Added comprehensive test reproducing the layout shift artifact
- Fixed Container to track and report child count changes
- All tests pass including new layout shift artifact test
2025-08-11 02:31:49 +02:00
Mario Zechner
838fde47ba refactor(tui): Move examples from README to test directory
- Move chat application example to test/chat-app.ts
- Move multi-component layout example to test/multi-layout.ts
- Update README to reference example files instead of inline code
- Add proper exit handlers (Ctrl+C) to all examples
- Simplify README by reducing inline code examples
2025-08-11 01:29:43 +02:00
Mario Zechner
12dfcfad23 docs(tui): Update README with surgical differential rendering documentation
- Add surgical differential rendering as the main feature
- Document the three rendering strategies (surgical, partial, full)
- Add performance metrics documentation
- Simplify component examples to be more concise
- Add comprehensive testing section with VirtualTerminal API
- Include testing best practices and performance testing guidance
- Remove duplicate TextEditor documentation section
2025-08-11 01:22:45 +02:00
Mario Zechner
a74c5da112 Initial monorepo setup with npm workspaces and dual TypeScript configuration
- Set up npm workspaces for three packages: pi-tui, pi-agent, and pi (pods)
- Implemented dual TypeScript configuration:
  - Root tsconfig.json with path mappings for development and type checking
  - Package-specific tsconfig.build.json for clean production builds
- Configured lockstep versioning with sync script for inter-package dependencies
- Added comprehensive documentation for development and publishing workflows
- All packages at version 0.5.0 ready for npm publishing
2025-08-09 17:18:38 +02:00