mirror of
https://github.com/davidkaya/aryx.git
synced 2026-07-25 05:58:39 +02:00
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:
@@ -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}
|
||||
/>
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user