Commit graph

2099 commits

Author SHA1 Message Date
Mario Zechner
458702b3a7 Add --resume flag with session selector
- New SessionSelectorComponent to browse and select sessions
- Lists sessions sorted by last modified date
- Shows first message, created/modified dates, message count
- Automatically truncates long messages and formats dates
- Adds --resume/-r flag to CLI
- Session selector integrates with main flow
2025-11-12 09:17:04 +01:00
Mario Zechner
7813e14492 Add model name to footer stats line (right-aligned) 2025-11-12 09:10:41 +01:00
Mario Zechner
95d040195c Add model selector TUI and update session management 2025-11-12 01:01:23 +01:00
Mario Zechner
bf5f4b17c0 Add custom session events for thinking level and model changes
Session manager changes:
- Add ThinkingLevelChangeEntry and ModelChangeEntry types
- Add saveThinkingLevelChange() and saveModelChange() methods
- Update loadThinkingLevel() to also check for thinking_level_change events
  (not just session headers)

TUI changes:
- Pass SessionManager to TuiRenderer constructor
- Call saveThinkingLevelChange() when user changes thinking level via /thinking
- Store session manager as instance variable for future use

This ensures thinking level changes during a session are persisted
and correctly restored on --continue.
2025-11-11 23:56:08 +01:00
Mario Zechner
02a21dd936 Fix viewport width issues in thinking selector and text rendering
Thinking selector fix:
- Replace hardcoded 50-character borders with DynamicBorder component
  that adjusts to viewport width
- Prevents crash when terminal is resized narrow

Text/Markdown rendering fixes:
- Fix Markdown wrapSingleLine to check if adding next character would
  exceed width BEFORE adding it (was checking AFTER, causing lines to
  be 1 character too long)
- Add word truncation in Text component for words longer than
  contentWidth (prevents long unbreakable words from exceeding width)

These fixes prevent "Rendered line exceeds terminal width" errors.
2025-11-11 23:52:18 +01:00
Mario Zechner
a3b3849188 Fix SelectList crash on narrow terminal and thinking level restoration
SelectList fixes:
- Use hardcoded visual width for arrow prefix instead of string length
  which includes ANSI codes
- Truncate scroll indicator text to prevent exceeding terminal width
- Fixes crash when terminal is resized narrow and arrow keys are pressed

Thinking level fix:
- Restore thinking level even if it's "off" (removed !== "off" check)
- This ensures the thinking level selector shows the correct state on continue
2025-11-11 23:47:59 +01:00
Mario Zechner
cef526ce4d Add padding to Aborted text for consistent spacing 2025-11-11 23:42:42 +01:00
Mario Zechner
dbee5b69ec Show "Aborted" text when aborting text generation during streaming
Update streaming component with final message in message_end event.
The final message includes the stopReason, which allows the component
to render "Aborted" text for aborted text generation.

Now behavior is consistent:
- Abort during text generation (no tool calls) → shows red "Aborted"
- Abort during tool call streaming → tool components turn red
2025-11-11 23:41:05 +01:00
Mario Zechner
1e857e0a6a Fix aborted tool display when continuing sessions
Two fixes for rendering aborted tools in --continue mode:

1. In renderInitialMessages: Check if assistant message was aborted/errored
   and immediately mark tool execution components as failed instead of
   leaving them in pending state.

2. In AssistantMessageComponent: Don't show "Aborted" text when there are
   tool calls in the message, since the tool execution components will
   show the error state themselves. This prevents duplicate error messages.

Now aborted tools show properly as red with "Operation aborted" message,
without the duplicate "Aborted" text above them.
2025-11-11 23:39:00 +01:00
Mario Zechner
2fdd304fbf Mark pending tool components as aborted when streaming is interrupted
When user presses Esc during tool argument streaming, the assistant
message ends with stopReason="aborted" but tool execution never starts.
Now we check for aborted/error stopReasons in message_end and update
all pending tool execution components to show red error state with
"Operation aborted" message.

This fixes the issue where tool components stayed stuck in blue/pending
state after aborting during JSON streaming.
2025-11-11 23:37:05 +01:00
Mario Zechner
594edec31b Make file operations properly abortable with async operations
Replace synchronous file operations with async Promise-based operations
that listen to abort signals during execution:
- read, write, edit now use fs/promises async APIs
- Add abort event listeners that reject immediately on abort
- Check abort status before and after each async operation
- Clean up event listeners properly

This ensures pressing Esc during file operations shows red error state.
2025-11-11 23:33:16 +01:00
Mario Zechner
e6b47799a4 Add abort signal handling to read, write, and edit tools
All tools now check the abort signal before executing and throw
"Operation aborted" error if the signal is already aborted.
This ensures consistent abort behavior across all tools.
2025-11-11 23:28:39 +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
7beb354337 Add thinking level persistence and fix UI issues
- Save and restore thinking level when continuing sessions
- Fix thinking level confirmation message spacing and styling
- Fix thinking text wrapping to preserve ANSI formatting across lines
2025-11-11 23:18:40 +01:00
Mario Zechner
159075cad7 Improve tool execution rendering and error handling
- Show tool execution components immediately when tool calls appear in streaming
- Update components with streaming arguments as they come in
- Handle incomplete/partial arguments gracefully with optional chaining
- Fix error handling: tools now throw exceptions instead of returning error messages
- Fix bash abort handling to properly reject on abort/timeout
- Clean up error display
2025-11-11 23:05:58 +01:00
Mario Zechner
2d43b2f2e3 Don't show stats for assistant messages with only tool calls 2025-11-11 22:13:00 +01:00
Mario Zechner
ea8b8b7f54 Fix thinking trace styling when text wraps 2025-11-11 22:08:20 +01:00
Mario Zechner
3fcae75e93 Remove StreamingMessageComponent - just use AssistantMessageComponent
- StreamingMessageComponent was just a wrapper around AssistantMessageComponent
- AssistantMessageComponent now handles its own stats rendering
- Made AssistantMessageComponent updatable with updateContent()
- Removed duplicate stats handling code from tui-renderer
- All stats are now managed by the component itself
2025-11-11 22:04:42 +01:00
Mario Zechner
741add4411 Refactor TUI into proper components
- Create UserMessageComponent - handles user messages with spacing
- Create AssistantMessageComponent - handles complete assistant messages
- Create ThinkingSelectorComponent - wraps selector with borders
- Add setSelectedIndex to SelectList for preselecting current level
- Simplify tui-renderer by using dedicated components
- Much cleaner architecture - each message type is now a component
2025-11-11 21:55:29 +01:00
Mario Zechner
e2649341f0 Simplify assistant message spacing - just add spacer to components 2025-11-11 21:51:12 +01:00
Mario Zechner
f5176bb173 Fix double spacing before tool executions by removing bottom padding from assistant Markdown 2025-11-11 21:43:53 +01:00
Mario Zechner
f63ec78524 Add spacer above user messages (except first one) 2025-11-11 21:39:42 +01:00
Mario Zechner
0cceb346be Use Spacer component for blank line before tool execution 2025-11-11 21:37:11 +01:00
Mario Zechner
c061b4fba9 Simplify tool execution component structure with proper padding
- Use single Text component with paddingY=1 for green background box
- Add spacer line with transparent background at top
- Header and content in same component with blank line separator
- Move error markers to header line instead of after content
2025-11-11 21:35:11 +01:00
Mario Zechner
ba5299a39e Fix tool execution formatting and colors
- Add blank spacer line with no background before tool execution
- Apply colored background to header (read/write/edit line)
- Apply same colored background to content
- Use lighter gray (chalk.dim) for file content
- Show first 10 lines of content for write operations
- Use cyan color for file paths (matching markdown code color)
2025-11-11 21:32:00 +01:00
Mario Zechner
5d7bc60cff Replace Markdown with Text component for tool execution
- Add background color support to Text component
- Replace Markdown component with Text in ToolExecutionComponent
- Use chalk.bold for formatting instead of markdown syntax
- Remove unnecessary markdown parsing overhead
2025-11-11 21:27:23 +01:00
Mario Zechner
10520a8c41 Fix read/write tool output formatting
- Remove code fences (```) from read output - show raw content
- Show first 10 lines instead of 5 for read
- Only show line count for write if > 10 lines
- Remove indentation from read output
- Cleaner, more minimal tool output display
2025-11-11 21:22:08 +01:00
Mario Zechner
4fa09814bd Refactor TUI components into separate files
- Move TUI components into src/tui/ folder
- Split out CustomEditor, StreamingMessageComponent, ToolExecutionComponent, FooterComponent
- Trim assistant message text content
- Add newline after per-message token/cost stats
- Improve code organization and maintainability
2025-11-11 21:16:31 +01:00
Mario Zechner
fe5706885d Clean up bash output formatting
- Remove "Command aborted by user" message (Aborted already shown separately)
- Remove STDOUT/STDERR labels - just show output cleanly
- Stderr is now separated by newline without labels
- Timeout and error messages moved to end of output
2025-11-11 21:09:50 +01:00
Mario Zechner
6e9fa8dde1 Fix bash abort to kill entire process tree immediately
- Switch from exec() to spawn() with detached: true
- Create new process group for spawned commands
- Kill entire process group with process.kill(-pid) on abort
- This ensures commands like "sleep 4 && echo hello" abort immediately
- Previous implementation only killed parent shell, leaving subprocesses running
2025-11-11 21:07:39 +01:00
Mario Zechner
ea5097e13e Add thinking trace support and improve bash output formatting
- Render thinking traces in dark gray italic in final messages
- Show thinking as italic markdown in streaming view
- Remove code fences from bash output for cleaner minimal display
- Remove superfluous empty line after tool executions
- Thinking blocks now render inline in proper order with text
2025-11-11 21:01:42 +01:00
Mario Zechner
8fa780e052 Improve TUI instructions and thinking selector styling
- Add ctrl+k to delete line instruction
- Change all "set x to y" confirmation messages to blue with padding
- Add blue top and bottom borders around thinking selector dialog
2025-11-11 20:53:27 +01:00
Mario Zechner
ba8d802999 Add interactive UI selector for /thinking command
- /thinking now opens a SelectList UI component to choose thinking level
- Temporarily replaces the editor with the selector
- Shows 5 levels (off, minimal, low, medium, high) with descriptions
- Supports keyboard navigation (arrows, enter, escape)
- Shows confirmation message after selection
- Maintains backward compatibility with /thinking <level> direct syntax
2025-11-11 20:49:20 +01:00
Mario Zechner
71fb1b9173 Put each instruction on its own line and add file drop hint 2025-11-11 20:43:17 +01:00
Mario Zechner
9b20b91a99 Make stats darker gray and remove extra newline after header 2025-11-11 20:40:35 +01:00
Mario Zechner
9f0242d477 Replace logo with 'pi' + version from package.json 2025-11-11 20:38:56 +01:00
Mario Zechner
5627b3054a Improve logo design with decorative brackets 2025-11-11 20:35:50 +01:00
Mario Zechner
95d71920f3 Update welcome banner with minimal pi logo and improved instructions 2025-11-11 20:34:52 +01:00
Mario Zechner
ea01a758e0 Suppress punycode deprecation warning from dependencies 2025-11-11 20:32:49 +01:00
Mario Zechner
97e00fc45d Fix Escape key to cancel autocomplete before interrupting agent 2025-11-11 20:29:38 +01:00
Mario Zechner
dc1e2f928b Add /thinking command and improve TUI UX
- Add /thinking slash command with autocomplete for setting reasoning levels (off, minimal, low, medium, high)
- Fix Ctrl+C behavior: remove hardcoded exit in TUI, let focused component handle it
- Add empty lines before and after tool execution components for better visual separation
- Fix stats rendering: display stats AFTER tool executions complete (matches web-ui behavior)
- Remove "Press Ctrl+C again to exit" message, show "(esc to interrupt)" in loader instead
- Add bash tool abort signal support with immediate SIGKILL on interrupt
- Make Text and Markdown components return empty arrays when no actual text content
- Add setCustomBgRgb() method to Markdown for dynamic background colors
2025-11-11 20:28:10 +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
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
ec50ede6c2 Release 0.5.48 2025-10-26 21:23:06 +01:00
Mario Zechner
23be934a9a Relesae 0.5.47 2025-10-26 00:45:52 +02:00
Mario Zechner
ef09efaac9 Fix XLSX dependency 2025-10-22 13:09:18 +02:00
Mario Zechner
a94b19e1df Fix dependencies 2025-10-22 13:05:24 +02:00
Mario Zechner
2a7ccf0fcb Updates to prompts 2025-10-17 22:44:03 +02:00
Mario Zechner
ffc9be8867 Agent package + coding agent WIP, refactored web-ui prompts 2025-10-17 11:47:01 +02:00