feat(tui): inline tool approval UI in input zone#119
Open
Conversation
Replace modal-based tool approval with inline UI in the input zone (similar to settings). Features: - Tool approval now displays in the input area instead of a modal - Three action options: [n] Reject, [y] Accept Once, [a] Accept & Set Risk - Risk level submenu with [1] Low, [2] Medium, [3] High options - Keyboard navigation with arrow keys and Enter to confirm - ESC cancels or goes back from submenu to main options - Automatic permission mode update when setting risk level UI Layout: ╭─ Tool Approval ─────────────────────────────────────────╮ │ ⚠ Execute: tool_name │ │ args summary (truncated)... │ │ [n] Reject [y] Accept Once [a] Accept & Set Risk │ ╰─────────────────────────────────────────────────────────╯
Greptile OverviewGreptile SummaryThis PR replaces the modal-based tool approval UI with an inline approval interface displayed in the input zone. The new design provides a more integrated experience similar to the settings interface. Key Changes:
Implementation Quality:
Confidence Score: 2/5
|
| Filename | Overview |
|---|---|
| src/cortex-tui/src/runner/event_loop/input.rs | Added handle_inline_approval_key and handle_approve_with_risk_level methods; integrated inline approval into key handling flow |
| src/cortex-tui/src/views/minimal_session/rendering.rs | Added render_inline_approval function to render approval UI with custom border drawing and helper functions |
| src/cortex-tui/src/views/minimal_session/view.rs | Modified render_input to display inline approval UI when pending_approval exists, replacing normal input area |
Sequence Diagram
sequenceDiagram
participant User
participant EventLoop
participant AppState
participant Renderer
participant ActionHandler
Note over User,ActionHandler: Tool Approval Flow
AppState->>AppState: request_tool_approval()
AppState->>AppState: Set pending_approval with default selection
AppState->>AppState: Set view to AppView::Approval
EventLoop->>Renderer: render()
Renderer->>Renderer: Check pending_approval exists
Renderer->>Renderer: render_inline_approval() in input area
Note right of Renderer: Shows: [n] Reject, [y] Accept Once, [a] Accept & Set Risk
User->>EventLoop: Press key ('y', 'n', 'a', arrows, Enter)
EventLoop->>EventLoop: handle_inline_approval_key()
alt User presses 'a' (Accept & Set Risk)
EventLoop->>AppState: Set show_risk_submenu = true
EventLoop->>Renderer: render()
Renderer->>Renderer: render_inline_approval() with submenu
Note right of Renderer: Shows: [1] Low, [2] Medium, [3] High, [Esc] Cancel
User->>EventLoop: Press '1', '2', or '3'
EventLoop->>EventLoop: handle_approve_with_risk_level()
EventLoop->>AppState: Update permission_mode
EventLoop->>ActionHandler: handle_approve()
ActionHandler->>AppState: approve() - takes pending_approval
ActionHandler->>ActionHandler: Execute tool or send to bridge
else User presses 'y' (Accept Once)
EventLoop->>ActionHandler: handle_approve()
ActionHandler->>AppState: approve() - takes pending_approval
ActionHandler->>ActionHandler: Execute tool or send to bridge
else User presses 'n' or Esc (Reject)
EventLoop->>ActionHandler: handle_reject()
ActionHandler->>AppState: reject() - takes pending_approval
ActionHandler->>AppState: Update tool status to failed
else User presses arrows
EventLoop->>AppState: Update selected_action or selected_risk_level
EventLoop->>Renderer: render()
else User presses Enter
EventLoop->>EventLoop: Execute action based on selected_action
end
AppState->>AppState: Clear pending_approval
AppState->>AppState: Return to Session view
Additional Comments (1)
Since the PR description states the goal is to "replace modal-based tool approval with inline UI", this rendering path should be removed or the view should be changed to Prompt To Fix With AIThis is a comment left during a code review.
Path: src/cortex-tui/src/runner/event_loop/rendering.rs
Line: 44:48
Comment:
The old modal-based `ApprovalView` is still being rendered when `AppView::Approval` is active, which will overlay on top of the new inline approval UI. This creates a confusing double-approval interface.
Since the PR description states the goal is to "replace modal-based tool approval with inline UI", this rendering path should be removed or the view should be changed to `AppView::Session` to only show the inline approval.
```suggestion
AppView::Approval => {
// Inline approval is now rendered within the session view
let session_view = crate::views::MinimalSessionView::new(&self.app_state);
frame.render_widget(session_view, area);
}
```
How can I resolve this? If you propose a fix, please make it concise. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace modal-based tool approval with inline UI in the input zone (similar to settings).
Features
UI Layout
Main Approval
Risk Level Submenu (when 'a' is pressed)
Changes
src/cortex-tui/src/app/approval.rs: AddedInlineApprovalSelection,RiskLevelSelectionenums and related state fieldssrc/cortex-tui/src/runner/event_loop/input.rs: Addedhandle_inline_approval_keyandhandle_approve_with_risk_levelmethodssrc/cortex-tui/src/views/minimal_session/rendering.rs: Addedrender_inline_approvalfunction for UI renderingsrc/cortex-tui/src/views/minimal_session/view.rs: Integrated inline approval UI in input area