Permission requests queue up instead of pushing each other away (upstream #563)
ApprovalQueue (upstream e391a14, after #157 by @Mydao57): up to 5 requests wait in line, the card shows the oldest with «1/N» and the project of the asking session; a click answers the request that was on screen and is ignored if the card moved on. Each request keeps its own hang-up monitor and 115 s timeout and is settled by its own session's events; a sibling session's events are no longer dropped while one waits. BroV keeps its DangerCheck warning per request and the iPhone relay answers the request it was shown. Upstream tests pass: bash scripts/test-approval-queue.sh. Co-Authored-By: Mydao57 <150259698+Mydao57@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -298,12 +298,32 @@ struct ApprovalView: View {
|
||||
|
||||
var approval: ApprovalInfo? { state.pendingApproval }
|
||||
|
||||
/// The pill, named after the session that asks (several sessions can share a pill).
|
||||
private var asker: AgentTask? {
|
||||
guard var task = state.focusTask else { return nil }
|
||||
if let project = approval?.projectName, !project.isEmpty { task.name = project }
|
||||
return task
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
let danger = approval?.danger ?? []
|
||||
// Captured when the card is drawn: a click answers the request that was on screen,
|
||||
// and is ignored if the card has moved on to the next one since.
|
||||
let shownId = approval?.id
|
||||
ZStack {
|
||||
CardBackground(wash: danger.isEmpty ? .amber : .red)
|
||||
VStack(alignment: .leading, spacing: 5) {
|
||||
AgentWho(task: state.focusTask, label: "просит разрешение")
|
||||
HStack(spacing: 7) {
|
||||
AgentWho(task: asker, label: "просит разрешение")
|
||||
// Other requests waiting behind this one: "1/3".
|
||||
if let count = approval?.queueCount, count > 1 {
|
||||
Text(verbatim: "1/\(count)")
|
||||
.font(.system(size: 12, weight: .semibold))
|
||||
.foregroundColor(Color(hex: "#8E939C"))
|
||||
.monospacedDigit()
|
||||
.help("Ещё \(count - 1) ждут в очереди")
|
||||
}
|
||||
}
|
||||
CodeBlock(text: approval?.command ?? approval?.tool ?? "…")
|
||||
if !danger.isEmpty {
|
||||
HStack(alignment: .top, spacing: 5) {
|
||||
@@ -320,16 +340,16 @@ struct ApprovalView: View {
|
||||
}
|
||||
HStack(spacing: 8) {
|
||||
SecondaryButton("Запретить") {
|
||||
HookServer.shared.sendApprovalDecision("deny")
|
||||
HookServer.shared.sendApprovalDecision("deny", for: shownId)
|
||||
}
|
||||
PrimaryButton("Разрешить") {
|
||||
HookServer.shared.sendApprovalDecision("allow")
|
||||
HookServer.shared.sendApprovalDecision("allow", for: shownId)
|
||||
}
|
||||
// Codex rejects updatedPermissions, so "Always" is not offered.
|
||||
// Never for a dangerous command: one click must not save a destructive rule.
|
||||
if approval?.pillId != "agent_codex" && danger.isEmpty {
|
||||
SecondaryButton("Всегда") {
|
||||
HookServer.shared.sendApprovalDecision("always")
|
||||
HookServer.shared.sendApprovalDecision("always", for: shownId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user