fix(team): target correct team in Allow all and Settings panel
Allow all button and ToolApprovalSettingsPanel now use current approval's teamName instead of selectedTeamName. Prevents applying settings to wrong team when approval comes from a different team than the one currently viewed.
This commit is contained in:
parent
58bd7cc507
commit
228572a1f8
3 changed files with 21 additions and 9 deletions
|
|
@ -408,7 +408,9 @@ export const ToolApprovalSheet: React.FC = () => {
|
|||
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => void updateToolApprovalSettings({ autoAllowAll: true })}
|
||||
onClick={() =>
|
||||
void updateToolApprovalSettings({ autoAllowAll: true }, current.teamName)
|
||||
}
|
||||
className="rounded-md border px-3.5 py-1.5 text-xs font-medium transition-colors"
|
||||
style={{
|
||||
color: 'var(--color-text-muted)',
|
||||
|
|
@ -444,7 +446,7 @@ export const ToolApprovalSheet: React.FC = () => {
|
|||
</div>
|
||||
|
||||
{/* Settings expanded content — below actions row */}
|
||||
<ToolApprovalSettingsContent expanded={settingsExpanded} />
|
||||
<ToolApprovalSettingsContent expanded={settingsExpanded} teamName={current.teamName} />
|
||||
|
||||
{/* Timeout progress bar */}
|
||||
<TimeoutProgress receivedAt={current.receivedAt} />
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import React, { useState } from 'react';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
|
||||
import { Checkbox } from '@renderer/components/ui/checkbox';
|
||||
import {
|
||||
|
|
@ -11,7 +11,7 @@ import {
|
|||
import { useStore } from '@renderer/store';
|
||||
import { ChevronDown, ChevronRight, Settings } from 'lucide-react';
|
||||
|
||||
import type { ToolApprovalTimeoutAction } from '@shared/types';
|
||||
import type { ToolApprovalSettings, ToolApprovalTimeoutAction } from '@shared/types';
|
||||
|
||||
export const ToolApprovalSettingsToggle: React.FC<{ expanded: boolean; onToggle: () => void }> = ({
|
||||
expanded,
|
||||
|
|
@ -37,10 +37,17 @@ export const ToolApprovalSettingsToggle: React.FC<{ expanded: boolean; onToggle:
|
|||
</button>
|
||||
);
|
||||
|
||||
export const ToolApprovalSettingsContent: React.FC<{ expanded: boolean }> = ({ expanded }) => {
|
||||
export const ToolApprovalSettingsContent: React.FC<{
|
||||
expanded: boolean;
|
||||
teamName?: string;
|
||||
}> = ({ expanded, teamName }) => {
|
||||
const [localSeconds, setLocalSeconds] = useState<string>('');
|
||||
const settings = useStore((s) => s.toolApprovalSettings);
|
||||
const updateSettings = useStore((s) => s.updateToolApprovalSettings);
|
||||
const rawUpdateSettings = useStore((s) => s.updateToolApprovalSettings);
|
||||
const updateSettings = useCallback(
|
||||
(patch: Partial<ToolApprovalSettings>) => rawUpdateSettings(patch, teamName),
|
||||
[rawUpdateSettings, teamName]
|
||||
);
|
||||
|
||||
if (!expanded) return null;
|
||||
|
||||
|
|
|
|||
|
|
@ -696,7 +696,10 @@ export interface TeamSlice {
|
|||
/** Resolved permission approvals: request_id → allowed (true/false). Used for noise row icons. */
|
||||
resolvedApprovals: Map<string, boolean>;
|
||||
toolApprovalSettings: ToolApprovalSettings;
|
||||
updateToolApprovalSettings: (patch: Partial<ToolApprovalSettings>) => Promise<void>;
|
||||
updateToolApprovalSettings: (
|
||||
patch: Partial<ToolApprovalSettings>,
|
||||
forTeam?: string
|
||||
) => Promise<void>;
|
||||
respondToToolApproval: (
|
||||
teamName: string,
|
||||
runId: string,
|
||||
|
|
@ -2347,8 +2350,8 @@ export const createTeamSlice: StateCreator<AppState, [], [], TeamSlice> = (set,
|
|||
set({ provisioningProgressUnsubscribe: unsubscribe });
|
||||
},
|
||||
|
||||
updateToolApprovalSettings: async (patch) => {
|
||||
const teamName = get().selectedTeamName;
|
||||
updateToolApprovalSettings: async (patch, forTeam) => {
|
||||
const teamName = forTeam ?? get().selectedTeamName;
|
||||
const current = get().toolApprovalSettings;
|
||||
const merged = { ...current, ...patch };
|
||||
set({ toolApprovalSettings: merged });
|
||||
|
|
|
|||
Loading…
Reference in a new issue