fix(assistant): dedupe missing approval storage warnings

This commit is contained in:
2026-03-30 11:49:05 +02:00
parent 978cd9184d
commit 4c542d0015
2 changed files with 16 additions and 0 deletions
@@ -10,9 +10,11 @@ import {
getAvailableAssistantTools,
listPendingAssistantApprovals,
peekPendingAssistantApproval,
resetAssistantApprovalStorageWarningStateForTests,
selectAssistantToolsForRequest,
} from "../router/assistant.js";
import { TOOL_DEFINITIONS } from "../router/assistant-tools.js";
import { logger } from "../lib/logger.js";
function getToolNames(
permissions: PermissionKeyValue[],
@@ -205,6 +207,7 @@ describe("assistant router tool gating", () => {
beforeEach(() => {
approvalStore = createApprovalStoreMock();
apiRateLimiter.reset();
resetAssistantApprovalStorageWarningStateForTests();
});
it("hides advanced tools unless the dedicated assistant permission is granted", () => {
@@ -863,6 +866,7 @@ describe("assistant router tool gating", () => {
});
it("degrades approval reads gracefully when approval storage is missing", async () => {
const warnSpy = vi.spyOn(logger, "warn").mockImplementation(() => logger);
const missingTableError = createMissingApprovalTableError();
const missingStore = {
assistantApproval: {
@@ -885,9 +889,11 @@ describe("assistant router tool gating", () => {
await expect(peekPendingAssistantApproval(missingStore, TEST_USER_ID, TEST_CONVERSATION_ID)).resolves.toBeNull();
await expect(consumePendingAssistantApproval(missingStore, TEST_USER_ID, TEST_CONVERSATION_ID)).resolves.toBeNull();
await expect(clearPendingAssistantApproval(missingStore, TEST_USER_ID, TEST_CONVERSATION_ID)).resolves.toBeUndefined();
expect(warnSpy).toHaveBeenCalledTimes(1);
});
it("returns an explicit error when approval storage is missing for mutation confirmation", async () => {
const warnSpy = vi.spyOn(logger, "warn").mockImplementation(() => logger);
const missingTableError = createMissingApprovalTableError();
const missingStore = {
assistantApproval: {
@@ -913,6 +919,7 @@ describe("assistant router tool gating", () => {
"create_project",
JSON.stringify({ name: "Apollo" }),
)).rejects.toThrow("Assistant approval storage is unavailable");
expect(warnSpy).toHaveBeenCalledTimes(1);
});
it("does not require confirmation for read-only assistant tools", () => {