Repository navigation
refactor(tui): approvals as source-agnostic UI state carrying the risk tier - #554
Merged
Merged
Conversation
…k tier (#526) ApprovalRequest (sanitized line plus Risk, can_allow_always false for Destructive) and a Pending with a one-shot reply closure replace the Sender-based Pending. Prompter::ask blocks as before; Prompter::post lets a remote source feed the same UI. The verdict is delivered once and a Pending dropped unanswered denies through its Drop.
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Third part of #526 (UI epic #523): a pending approval is modelled as source-agnostic UI state.
ApprovalRequest(what the UI shows and decides on, with theRisktier) and aPendingwhose reply is a one-shot closure replace theSender-basedPending { text, destructive, reply }. Refs #526.Why
Today the only approval source is the in-process turn thread:
Pendingheld aSender<Verdict>, and "fail closed" was an accident of dropping that sender. A remote UI (the server's/approvalsqueue, #200) needs the same UI state with a different way to answer, and the rule that aDestructivecall is never offered "allow always" must not be re-implemented in each UI. This is item 4 of the #526 plan.Changes
ApprovalRequest { text, risk }:newreduces the text to one safe line (control characters escaped, asPrompter::askdid),risk()is the realtole_core::tool::Risk, andcan_allow_always()is false only forDestructive(the approver never allowlists it): the rule lives in one place for every UI.Pending { request, reply }: the reply is aFnOnce(Verdict) + Send. The verdict is delivered exactly once, andDropdeliversDenyif it was never answered, so "dropped unanswered denies" is now structural (a cancelled turn, a newer request replacing an unanswered one, the UI going away with requests still queued) instead of relying on a dropped channel sender.Prompter::ask(request)blocks for an in-process turn as before. NewPrompter::post(request, reply)does not block: a remote source calls it andreplyis where the verdict goes (for example the decisionPOST); it returnsfalseand has already denied if the UI is gone.tole-cliTuiPromptbuilds anApprovalRequestfrom the tool request (same text, same risk). The transcript still tags? destructive:/? write:.Prompter::ask(text, destructive)is nowask(ApprovalRequest)andPending's fields are private; new public itemsApprovalRequestandPrompter::post),docs/tui.md(Architecture: approvals) anddocs/epics.mdupdated in the same PR (AGENTS.md §7); README unaffected.No behavior change for users: same keys (y / n / Esc), same texts, same fail-closed outcome.
Testing
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings,cargo check -p tole-cli --no-default-features,cargo test --workspace(1209 passed: the previous 1203 plus 6)cora review --staged: not run (cora is not installed in this environment); the CI Cora Review job is the verdict.Deny, exactly once.Prompter::askreturnsDenyeither way. Everything else in the 63 priortole-tuitests and thetui_e2epty suite passes unchanged.ReadOnly/Writeand never forDestructive; a remote-style source (postwith a closure, never blocking) gets the user's verdict exactly once for y and n and nothing before the answer, with later keys changing nothing; Esc denies and cancels for a remote source too; a destructive request is shown as destructive; and an approval that never gets an answer is denied once whatever ended it (the turn ends, a newer request replaces it, the UI goes away with requests queued, posting to a UI that is already gone).Pendingno longer denies, allow-always offered forDestructive, andpostreporting success with the UI gone.Next in #526
The issue's item 2: move
drawand its helpers into a rendering module that only readsAppstate (a mechanical move; no state changes there). With it the acceptance criteria are covered; I will post the status on the issue.Related Issues
Refs #526, part of #523. Related: #464, #463, #200.
Generated by Claude Code