fix(agent-bridge-ui): remove double-write of risk-accepted localStorage (M5)

AgentCard.handleRiskAccept was calling markRiskAccepted() before opening the
RiskNoticeModal, which itself writes the same key via dontShowAgainKey on accept.
Remove the redundant markRiskAccepted call and delete the now-unused helper so
RiskNoticeModal (D16) is the sole canonical persistence owner. Add a spy-based
test asserting the key is written exactly once per accept.
This commit is contained in:
diegosouzapw
2026-05-28 16:24:09 -03:00
parent fa655ab4df
commit f0cdc3622e
2 changed files with 55 additions and 8 deletions

View File

@@ -21,13 +21,6 @@ function hasAcceptedRisk(agentId: string): boolean {
}
}
function markRiskAccepted(agentId: string): void {
try {
localStorage.setItem(RISK_STORAGE_KEY_PREFIX + agentId, "true");
} catch {
// ignore storage errors
}
}
interface AgentCardProps {
target: MitmTarget;
@@ -112,7 +105,6 @@ export function AgentCard({
};
const handleRiskAccept = async () => {
markRiskAccepted(target.id);
setRiskModalOpen(false);
await reallyToggleDns(true);
};