feat(FN-3845): suppress suspended-tab chat load failures and rewrite mailbo

Merges FN-3845 chat-first mailbox guidance and FN-3838 toast suppression for suspended tabs. Adds a new `visibilitySuspension` hook to suppress chat load failure toasts when browser tabs are hidden, rewrites the mailbox opt-in guidance to lead with chat-first messaging, and expands test coverage acr

Fusion-Task-Id: FN-3845
This commit is contained in:
Fusion
2026-05-09 09:23:22 -07:00
committed by gsxdsm
parent ed6d2e2423
commit fb486e0af9
4 changed files with 31 additions and 4 deletions

View File

@@ -1088,8 +1088,30 @@ describe("ChatManager.sendMessage", () => {
expect(mockAgentStore.init).toHaveBeenCalledTimes(1);
expect(mockAgentStore.getAgent).toHaveBeenCalledWith("agent-001");
expect(createOptions.systemPrompt).toContain("Be calm and precise.");
expect(createOptions.systemPrompt).toContain("type: \"agent-to-user\"");
expect(createOptions.systemPrompt).toContain("to_id: \"dashboard\"");
expect(createOptions.systemPrompt).toContain("Your chat reply is the primary response to the user.");
expect(createOptions.systemPrompt).toContain("Only use `fn_send_message` when the user explicitly asks");
});
it("includes guidance to avoid double-sending mailbox copies by default", async () => {
let createOptions: any;
__setCreateFnAgent(async (options: any) => {
createOptions = options;
return {
session: {
prompt: vi.fn().mockResolvedValue(undefined),
dispose: vi.fn(),
state: {
messages: [{ role: "assistant", content: "Done" }],
},
},
};
});
const chatManager = createChatManager();
await chatManager.sendMessage("chat-001", "Hello");
expect(createOptions.systemPrompt).toContain("Do not also call `fn_send_message` with the same content");
expect(createOptions.systemPrompt).toContain("Only use `fn_send_message` when the user explicitly asks for mailbox/inbox/notification delivery");
});
it("passes enriched system prompt with agent memory when agent context is available", async () => {