Skip to content

Conversation

@shuv1337
Copy link
Contributor

@shuv1337 shuv1337 commented Jan 8, 2026

Summary

This PR adds a comprehensive set of TUI enhancements and new features to opencode-ralph, organized into 7 atomic commits for easier review.

Features

Theme System (29 themes)

  • Full theme support with catppuccin, dracula, nord, tokyo-night, gruvbox, monokai, and 23 more
  • Theme resolver that loads from opencode config
  • ThemeContext for reactive theme switching

UI Infrastructure

  • Dialog System: Stack-based dialogs with Alert, Confirm, Prompt, and Select variants
  • Toast Notifications: Auto-dismiss toasts with fade animation
  • Command Palette: VS Code-style Ctrl+P palette with fuzzy search (fuzzysort)

Terminal & Clipboard

  • Cross-platform terminal detection (Kitty, Alacritty, WezTerm, iTerm2, etc.)
  • Terminal launcher with T key to open terminal with attach command
  • Cross-platform clipboard support (pbcopy, xclip, xsel, wl-copy)

Loop Enhancements

  • External Server: --server and --server-timeout options to connect to existing opencode servers
  • Custom Prompts: --prompt-file option with placeholder replacement
  • Error Retry: Exponential backoff with jitter for transient errors
  • Session Steering: Send messages to active sessions via : key

Debug Mode

  • --debug / -d flag for manual session control
  • Skip automatic loop start
  • N key for new session, P key for prompt input

Tasks Panel

  • Shift+T to toggle tasks panel showing plan.md checklist items
  • Token usage tracking with footer display

Testing

  • 252 tests passing
  • New unit tests for theme resolver, clipboard, terminal launcher, toast, command palette, session stats
  • New integration tests for debug mode, terminal detection, ralph flow

Commits

  1. feat: add theme system with 29 color themes
  2. feat: add dialog and toast notification systems
  3. feat: add command palette with fuzzy search
  4. feat: add terminal launcher and clipboard support
  5. feat: add loop enhancements, state hooks, and event types
  6. feat: integrate features into app, components, and CLI
  7. docs: update documentation and configuration

Add comprehensive theming support with theme files for popular color schemes:
- Theme JSON files: catppuccin, dracula, nord, tokyo-night, gruvbox, monokai, etc.
- Theme resolver for loading themes from opencode config
- ThemeContext provider for reactive theme access
- Theme color accessor functions with fallbacks

Themes are compatible with opencode's theme format and support
dynamic switching based on user preferences.
Add reusable UI infrastructure for user interaction:

Dialog System:
- DialogContext with stack-based dialog management
- Dialog base component with overlay and Escape handling
- DialogAlert for message notifications
- DialogConfirm with Y/N keyboard shortcuts
- DialogPrompt with text input field
- DialogSelect for selection with fuzzy search support

Toast System:
- ToastContext with ToastProvider for global notifications
- ToastStack component for displaying stacked notifications
- Auto-dismiss with fade-out animation
- Support for info/success/error toast types
Add VS Code-style command palette for quick action access:

- CommandContext for registering and executing commands
- Centralized keymap with keybind definitions
- Fuzzy search via fuzzysort for filtering commands
- Ctrl+P keyboard shortcut to open palette
- Support for command categories and shortcuts display

Commands can be registered dynamically and include actions like:
- Pause/Resume loop execution
- Copy attach command
- Toggle tasks panel
- Choose default terminal
Add cross-platform utilities for terminal and clipboard operations:

Terminal Launcher:
- Detect installed terminals on macOS, Linux, and Windows
- Support for popular terminals: Kitty, Alacritty, WezTerm, iTerm2, etc.
- Terminal selection dialog for choosing preferred terminal
- Launch terminal with opencode attach command

Clipboard:
- Cross-platform clipboard detection (pbcopy, xclip, xsel, wl-copy)
- Async copy function with fallback handling
- Integration with toast notifications for feedback

Config:
- Persistent config module for user preferences
- Terminal preference storage in .ralph-config.json
Major enhancements to the core loop functionality:

External Server Support:
- --server and --server-timeout CLI options
- Server URL validation and health checking
- Connect to existing opencode servers

Custom Prompt Files:
- --prompt-file option with .ralph-prompt.md.example template
- buildPrompt() with precedence: CLI > file > default
- Placeholder replacement for task description

Error Retry:
- Exponential backoff with jitter for transient errors
- Retry countdown display in TUI
- Configurable retry behavior

Session Steering:
- Session lifecycle callbacks (onSessionCreated, onSessionEnded)
- sendMessage() for sending messages to active sessions
- Session guard to prevent sending to inactive sessions

State Management Hooks:
- useLoopState: Reducer pattern for loop state
- useLoopStats: Iteration timing and ETA tracking
- useActivityLog: Session activity logging
- useSessionStats: Token usage tracking

Event Types:
- Centralized event types with icons and colors
- Verbose event marking for dim styling
- Detail field for tool arguments
- parsePlanTasks() for tasks panel
Wire up all new features into the main application:

App Integration:
- Wrap app with ThemeProvider, DialogProvider, ToastProvider, CommandProvider
- Add keyboard handlers: Ctrl+P (palette), T (terminal), Shift+T (tasks)
- Add colon key detection for steering mode
- Register commands: pause/resume, copy attach, tasks, terminal

Component Updates:
- Header: Add [DEBUG] badge, use theme colors
- Footer: Add token display, steering hint, theme colors
- Log: Use theme colors, render event details, dim verbose events
- Paused: Use theme colors

New Components:
- Steering overlay for live session interaction
- Tasks panel with plan task display

CLI Enhancements:
- --debug / -d flag for manual session control
- --agent / -a flag for agent selection
- Build-time version injection
- Improved TUI render options

Debug Mode:
- Skip automatic loop start
- N key for new session
- P key for prompt input
README Updates:
- Document --server and --server-timeout options
- Document --prompt-file option
- Document --debug and --agent flags

AGENTS.md Updates:
- Add local build and install instructions
- Document version handling (build-time injection)
- Add version bumping workflow
- Document OpenTUI configuration

Configuration:
- Add CONTEXT/ and bin/ to .gitignore
- Add .ignore for ripgrep exclusions
- Add docs for OpenTUI theme colors fix
- Add docs for command palette fix
- Update plan.md as minimal test plan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant