Skip to content

feat: high-visibility approval banner for pending tool calls#6

Merged
saucam merged 4 commits into
mainfrom
feat/approval-banner
Jun 23, 2026
Merged

feat: high-visibility approval banner for pending tool calls#6
saucam merged 4 commits into
mainfrom
feat/approval-banner

Conversation

@saucam

@saucam saucam commented Jun 23, 2026

Copy link
Copy Markdown
Owner

Makes tool-approval requests impossible to miss.

Problem

A pending approval surfaced only in low-key places: a one-line worker row (same weight as the idle/thinking indicator), an inline tool card that scrolls away, a footer hint, and a ! on the tab. There's a modal system, but it was only used for destroy confirmation — tool approvals got no prominent treatment, so in a busy autonomous session the request was easy to overlook.

Change

A dedicated high-contrast approval banner rendered above the prompt, but only while the focused session has a tool awaiting confirmation:

┌ ⚠ APPROVAL NEEDED ──────────────────────────────┐
│ Edit  edit src/main.rs                           │
│  Y  approve    D  deny    Esc  cancel            │
└──────────────────────────────────────────────────┘
  • Bold yellow border + inverted title chip; Y/D/Esc as green/red/grey background chips so the action reads at a glance.
  • Inserted as a conditional layout zone — zero footprint when there's nothing to approve.
  • The worker row no longer duplicates the approval text.

Tests

pending_tool (the focused-session lookup) is pure + unit-tested (finds a waiting tool, ignores completed ones, ellipsis truncation). Full codeoid-tui suite: 159 passed, clippy clean.

Independent of #5 (scroll perf) — different files, no conflict.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added a dedicated, high-visibility approval banner for tools awaiting confirmation, showing the tool name, a truncated description, and action keys to approve, deny, or cancel.
  • Improvements
    • Moved approval prompts out of the worker status line and into the banner.
    • Updated the main TUI layout to automatically show/hide the banner while maintaining correct spacing.
  • Tests
    • Added unit tests covering pending detection, banner contents, truncation behavior, and layout insertion when approvals are needed.

A pending tool approval only surfaced as a one-line worker row — same
visual weight as the idle/thinking indicator — plus an inline tool card
that scrolls away. Easy to miss in a busy autonomous session.

Add a dedicated, high-contrast banner above the prompt that appears only
while the focused session has a tool awaiting confirmation: a bold-bordered
"⚠ APPROVAL NEEDED" block showing the tool + what it wants to do, with
[Y] approve / [D] deny / [Esc] cancel as colored chips. The worker row no
longer duplicates the approval text. The banner only occupies layout space
when there's something to approve.

`pending_tool` is a pure, unit-tested lookup.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 73111554-5912-4f3b-8ac1-a74979e68491

📥 Commits

Reviewing files that changed from the base of the PR and between 940dd47 and d952299.

📒 Files selected for processing (1)
  • crates/codeoid-tui/src/ui/approval.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • crates/codeoid-tui/src/ui/approval.rs

📝 Walkthrough

Walkthrough

Adds a dedicated TUI approval banner for pending tool confirmations, conditionally inserts it into the main layout, and removes the older inline approval warning from the worker status line.

Changes

Approval banner flow

Layer / File(s) Summary
Pending approval detection
crates/codeoid-tui/src/ui/approval.rs
Module setup, styling constants, and public API functions that scan focused-session messages for waiting-confirmation tools and export a predicate to check whether approval is pending.
Banner rendering and helper utilities
crates/codeoid-tui/src/ui/approval.rs
Implements render entry point, renders the approval banner with bordered block containing tool name and truncated description, displays approve/deny/cancel key chips, includes a text truncation helper with edge-case handling, and validates rendering and truncation via unit tests.
Layout integration and worker cleanup
crates/codeoid-tui/src/ui/mod.rs, crates/codeoid-tui/src/ui/worker.rs, crates/codeoid-tui/src/ui/approval.rs
Adds approval module to UI entrypoint, dynamically builds layout constraints to conditionally include the approval banner row between transcript and worker rows, updates widget placement logic to advance indices when the banner is present, removes the previous inline waiting-for-approval message from the worker status line, and validates the complete integration with a full-layout test.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: adding a high-visibility approval banner for pending tool calls, which aligns with the primary objective and all file modifications.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/approval-banner

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.44%. Comparing base (d7dea06) to head (d952299).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff             @@
##             main       #6       +/-   ##
===========================================
+ Coverage   36.79%   49.44%   +12.64%     
===========================================
  Files          30       31        +1     
  Lines        5156     5362      +206     
===========================================
+ Hits         1897     2651      +754     
+ Misses       3259     2711      -548     
Flag Coverage Δ
tui 49.44% <100.00%> (+12.64%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
crates/codeoid-tui/src/ui/approval.rs 100.00% <100.00%> (ø)
crates/codeoid-tui/src/ui/mod.rs 100.00% <100.00%> (+100.00%) ⬆️
crates/codeoid-tui/src/ui/worker.rs 21.31% <ø> (+21.31%) ⬆️

... and 10 files with indirect coverage changes

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/codeoid-tui/src/ui/approval.rs`:
- Around line 70-82: The truncation budget for the description in the action
Line construction does not account for the width of the tool name prefix that
appears before it. Currently, only 2 is subtracted from inner.width in the
truncate call, but this ignores the actual rendered width of the tool label
itself plus the surrounding spaces. Calculate the total width of the prefix (the
space, the tool name, and the two spaces) and subtract that complete width from
inner.width to determine the proper truncation budget for the description text,
ensuring the full line does not exceed the available width.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7f959bd7-89ab-4682-89b9-908facd3a366

📥 Commits

Reviewing files that changed from the base of the PR and between d7dea06 and 9f59ca1.

📒 Files selected for processing (3)
  • crates/codeoid-tui/src/ui/approval.rs
  • crates/codeoid-tui/src/ui/mod.rs
  • crates/codeoid-tui/src/ui/worker.rs

Comment thread crates/codeoid-tui/src/ui/approval.rs Outdated
saucam and others added 3 commits June 23, 2026 22:32
Extract render_banner so the drawing is exercised without an AppState, and
assert the rendered buffer carries the title, tool, description, and the
approve/deny key prompts. Lifts patch coverage on the new render code.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Drive the full ui::render with a session whose tool is awaiting
confirmation and assert the banner appears — covering the conditional
layout zone in ui::mod plus pending/is_pending/render.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…abbit)

truncate() was given inner.width - 2, ignoring the rendered ' <tool>  '
prefix, so a long tool+description could overflow and wrap the banner.
Subtract the prefix columns so the line stays single-row.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@saucam

saucam commented Jun 23, 2026

Copy link
Copy Markdown
Owner Author

Good catch @coderabbitai — fixed in d952299: the description budget now subtracts the <tool> prefix width so the banner can't overflow into a second row.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Tip

For best results, initiate chat on the files or code changes.

@saucam: Thanks for the quick fix! Subtracting the prefix width from the description budget is the right approach — it ensures the content stays within the allocated HEIGHT regardless of tool name length.

@saucam saucam merged commit 95c70a4 into main Jun 23, 2026
4 checks passed
This was referenced Jun 23, 2026
@saucam saucam mentioned this pull request Jul 2, 2026
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