Skip to content

fix: waiting for approval when creating rules#260

Merged
virattt merged 6 commits into
virattt:mainfrom
swrzalek:fix-waiting-for-approval-when-creating-rules
May 12, 2026
Merged

fix: waiting for approval when creating rules#260
virattt merged 6 commits into
virattt:mainfrom
swrzalek:fix-waiting-for-approval-when-creating-rules

Conversation

@swrzalek
Copy link
Copy Markdown
Contributor

@swrzalek swrzalek commented May 11, 2026

Fix approval prompt not rendering when creating rules

Problem

When the agent requested approval for file-modifying tools (e.g., write_file to create .dexter/RULES.md), the CLI showed "Waiting for approval..." but never rendered the actual approval overlay with selectable options. Pressing Enter had no effect because the approval prompt was never displayed.

Root Cause

renderSelectionOverlay() was only called from the model selection callback and startup — never from the agent runner's onChange. When the agent entered approval state, the working indicator updated but the overlay wasn't triggered.

Fix

Added lastPendingApproval state tracking in the onChange callback (src/cli.ts). When pendingApproval transitions (enters or exits), renderSelectionOverlay() is now called to properly show/hide the approval overlay.

Tests

Added 12 unit tests in src/controllers/agent-runner.test.ts covering:

  • Approval state transitions (enter/exit)
  • onChange firing during approval state changes
  • cancelExecution behavior
  • Edge cases (no-op when no approval pending)

Files Changed

  • src/cli.ts - Track pendingApproval changes and trigger overlay rendering
  • src/controllers/agent-runner.test.ts - 12 new tests for approval state management

Resolves: #245

@swrzalek
Copy link
Copy Markdown
Contributor Author

@virattt ready for review :)

/**
* Helper to create an AgentRunnerController with a change counter
*/
function createController(onChange?: () => void) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we can also create test-utils. I am open.

@virattt
Copy link
Copy Markdown
Owner

virattt commented May 12, 2026

Also fixes: #266

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Owner

@virattt virattt left a comment

Choose a reason for hiding this comment

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

🚀

@virattt virattt merged commit 19f9b45 into virattt:main May 12, 2026
2 checks passed
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.

Approval prompt hangs / does not respond when creating .dexter/RULES.md

2 participants