fix: clamp auto-approval pill count to known tools

The auto-approval pill displayed effectiveAutoApproved.size as the
numerator, which could include tool names not present in the approval
tool list (e.g. names added via 'Always approve' for tools that aren't
in runtimeTools yet). This caused impossible counts like '17/14'.

Compute the count by intersecting effectiveAutoApproved with the actual
approvalTools list, so the numerator never exceeds the denominator.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
David Kaya
2026-03-27 20:40:30 +01:00
co-authored by Copilot
parent c02589f4c0
commit cf41279ff5
2 changed files with 10 additions and 2 deletions
+6
View File
@@ -120,6 +120,10 @@ export function ChatPane({
),
[isApprovalOverridden, session.approvalSettings, pattern.approvalPolicy],
);
const effectiveAutoApprovedCount = useMemo(
() => approvalTools.filter((t) => effectiveAutoApproved.has(t.id)).length,
[approvalTools, effectiveAutoApproved],
);
useEffect(() => {
transcriptRef.current?.scrollTo({
@@ -443,6 +447,7 @@ export function ChatPane({
approvalTools={approvalTools}
disabled={isComposerDisabled}
effectiveAutoApproved={effectiveAutoApproved}
effectiveAutoApprovedCount={effectiveAutoApprovedCount}
isOverridden={isApprovalOverridden}
onUpdate={onUpdateSessionApprovalSettings}
/>
@@ -497,6 +502,7 @@ export function ChatPane({
approvalTools={approvalTools}
disabled={isComposerDisabled}
effectiveAutoApproved={effectiveAutoApproved}
effectiveAutoApprovedCount={effectiveAutoApprovedCount}
isOverridden={isApprovalOverridden}
onUpdate={onUpdateSessionApprovalSettings}
/>
+4 -2
View File
@@ -348,16 +348,18 @@ const approvalKindLabels: Record<ApprovalToolKind, string> = {
export function InlineApprovalPill({
approvalTools,
effectiveAutoApproved,
effectiveAutoApprovedCount,
isOverridden,
disabled,
onUpdate,
}: {
approvalTools: ApprovalToolDefinition[];
effectiveAutoApproved: Set<string>;
effectiveAutoApprovedCount: number;
isOverridden: boolean;
disabled: boolean;
onUpdate: (settings: { autoApprovedToolNames?: string[] }) => void;
}) {
}){
const [open, setOpen] = useState(false);
const ref = useClickOutside<HTMLDivElement>(() => setOpen(false), open);
@@ -393,7 +395,7 @@ export function InlineApprovalPill({
type="button"
>
<ShieldCheck className="size-2.5" />
<span>{effectiveAutoApproved.size}/{approvalTools.length} auto-approved</span>
<span>{effectiveAutoApprovedCount}/{approvalTools.length} auto-approved</span>
<ChevronDown className={`size-2.5 transition ${open ? 'rotate-180' : ''}`} />
</button>