import 'package:flutter/widgets.dart'; import '../domain/run_decisions.dart'; /// The browser client's decision wording, kept verbatim. const decisionWaitingTitle = 'Waiting for your decision'; const decisionActionLabel = 'Decide'; const decisionFeedbackLabel = 'Feedback (optional)'; const decisionCancelLabel = 'Cancel'; const decisionConfirmLabel = 'Confirm decision'; const decisionSendingLabel = 'Sending…'; /// Stable test/semantics keys shared by the action and its prompt. const decisionActionKey = ValueKey('human-decision-action'); const decisionFeedbackKey = ValueKey('human-decision-feedback'); const decisionErrorKey = ValueKey('human-decision-error'); const decisionExhaustedKey = ValueKey('human-decision-exhausted'); /// `{stage} · run {id} · {label}`, as the web decision card shows it. String decisionMeta(PendingDecision decision) => '${decision.stageKey} · run ${decision.runId} · ${decision.runLabel}'; /// For a loop that exhausted its visits: `review used visit 3 of 3`, or the /// part the server recorded; "" for a declared human decision. String decisionExhaustedText(PendingDecision decision) { final loop = decision.exhausted; if (loop == null) return ''; final stage = loop.stage.isEmpty ? decision.stageKey : loop.stage; final visit = loop.visit; final max = loop.maxVisits; if (visit == null) return '$stage reached its visit limit'; return max == null ? '$stage reached its visit limit at visit $visit' : '$stage reached its visit limit: visit $visit of $max'; } /// The option's target line, `→ {target}`, or "" when no target was declared. String decisionTargetText(String target) => target.trim().isEmpty ? '' : '→ $target';