Skip to content

Conversation

@edenreich
Copy link
Contributor

Summary

This PR implements a comprehensive tool approval workflow that allows users to review and approve or reject tool executions before they run in chat mode. This enhances security and user control over potentially sensitive operations.

Key Features

  • Interactive Approval Modal: Beautiful centered modal with tool name, arguments display, and approve/reject options
  • Event-Driven Architecture: Clean event flow using ToolApprovalRequestedEvent with channel-based communication
  • Smart Execution Separation: Tools requiring approval execute sequentially; others maintain parallel execution
  • Keyboard Navigation: Intuitive controls (←/→ navigate, Enter/y approve, n/Esc reject)
  • Mode-Aware: Only prompts for approval in chat mode, not in autonomous agent mode

Technical Changes

  • Added new ViewStateToolApproval view state and ApprovalComponent UI component
  • Extended StateManager interface with approval state management methods:
    • SetupApprovalUIState()
    • GetApprovalUIState()
    • SetApprovalSelectedIndex()
    • ClearApprovalUIState()
  • Added IsChatMode flag to AgentRequest to differentiate chat vs agent execution contexts
  • Implemented new events: ToolApprovalRequestedEvent, ToolApprovedEvent, ToolRejectedEvent
  • Added approval-specific keybindings in the keybinding registry
  • Refactored tool execution in AgentService to separate approval and parallel paths

Files Changed

  • internal/ui/components/approval_component.go (new): Approval modal renderer
  • internal/domain/state.go: Approval state types and view state
  • internal/domain/events.go: Approval event types
  • internal/domain/interfaces.go: StateManager approval methods
  • internal/services/agent.go: Approval logic and execution separation
  • internal/handlers/chat_handler.go: Approval event handling
  • internal/app/chat.go: Approval view rendering and message handling
  • internal/ui/keybinding/actions.go & registry.go: Approval keybindings
  • Mock files regenerated for new interfaces

Test Plan

  • Start chat mode and verify approval modal appears for configured tools
  • Test keyboard navigation (←/→, h/l) between approve and reject options
  • Test approval with Enter and 'y' keys
  • Test rejection with 'n' and Esc keys
  • Verify approved tools execute normally
  • Verify rejected tools fail with "rejected by user" error
  • Verify agent mode (non-chat) does not prompt for approval
  • Test with multiple tool calls (approval tools sequential, others parallel)
  • Verify approval modal displays tool arguments correctly
  • Test timeout behavior (5 minute timeout)

🤖 Generated with Claude Code

edenreich and others added 13 commits November 18, 2025 15:14
Implement a comprehensive tool approval workflow that allows users to review and approve/reject tool executions before they run in chat mode. This enhances security and user control over potentially sensitive operations.

Key changes:
- Add new ViewStateToolApproval view state and ApprovalComponent UI
- Implement approval request/response event flow with channel-based communication
- Separate tool execution into approval-required and parallel-execution paths
- Add approval-specific keybindings (←/→ navigate, Enter/y approve, n/Esc reject)
- Extend StateManager with approval state management methods
- Add IsChatMode flag to AgentRequest to differentiate chat vs agent modes
- Tools requiring approval execute sequentially; others maintain parallel execution

The approval modal displays tool name, arguments, and interactive approve/reject options with keyboard navigation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: Eden Reich <eden.reich@gmail.com>
- Add Context domain model with approval tracking
- Implement tool approval validation in agent service
- Update bash tool to use context-based approval system
- Add approval status tracking for pending/rejected tools
- Update chat command handler to support tool approval workflows
- Add comprehensive test coverage for chat command functionality
- Improve chat handler integration with approval system
- Refactor autocomplete rendering to use stable table format with aligned columns
- Calculate column width across all filtered items to prevent jumping during navigation
- Add vertical separator (│) for clearer visual distinction between columns
- Update theme integration across selection views and UI components
- Enhance grep tool with improved formatting
- Expand theme mock with GetDimColor support

The autocomplete now displays commands and tools in a clean, stable table
layout that doesn't shift as users navigate through options.

Signed-off-by: Eden Reich <eden.reich@gmail.com>
- Replace string concatenation with proper lipgloss styling
- Remove redundant ID display in parentheses after agent name
- Fix hex color codes appearing as literal text
- Improve visual consistency across all render methods

Signed-off-by: Eden Reich <eden.reich@gmail.com>
Improvements to project initialization and agent command:
- Add configurable timeout flag for init command AI analysis
- Implement comprehensive gateway health checks before agent/init execution
- Add signal handling and graceful cleanup for init command
- Increase tool execution concurrency from 3 to 10 for faster analysis
- Improve analysis prompts with chunked reading strategy for efficiency
- Add support for overwriting existing AGENTS.md via --overwrite flag
- Simplify AGENTS.md documentation structure
- Add agent container naming constant and improved logging
- Enhance gateway startup with timeout and user-friendly error messages

Signed-off-by: Eden Reich <eden.reich@gmail.com>
…selection view

- Replace direct ANSI escape sequences with Lipgloss styles for better maintainability
- Use lipgloss.NewStyle().Foreground() for consistent color handling
- Improve code readability by separating color definitions from rendering logic
- Maintain same visual appearance while using modern styling approach
- Add approval workflow for tool execution requests
- Implement diff visualization component for code changes
- Add real-time status updates for pending approvals
- Enhance UI with approval/rejection controls and feedback
- Update chat interface to handle approval states
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.

2 participants