Multi-Agent Collaboration for Team and Friends
TypeScript agent-automationagent-orchestrationagent-workflowai-agentsai-collaborationai-memoryai-workforceautonomous-agentsclaude-codeclaude-code-skillscodexcoding-agentmulti-agentmultiple-agentone-person-businessone-person-companyone-person-teamopencodesolopreneur
fix(web): refresh email list when switching mailbox address
Gener25ae604aa5fd
diff --git a/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx b/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsxindex c97949c50..251a8c8df 100644--- a/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx+++ b/src/web/src/app/(app)/w/[slug]/agents/[id]/email/page.tsx@@ -78,10 +78,10 @@ export default function AgentEmailPage() {const selected = emails.find((e) => e.id === selectedId) ?? null;- const loadEmails = useCallback(async (dir: string) => {+ const loadEmails = useCallback(async (dir: string, address?: string) => {setLoading(true);try {- const data = await listEmails(agentId, workspaceId, dir);+ const data = await listEmails(agentId, workspaceId, dir, address);setEmails(data);} catch {toast.error("Failed to load emails");@@ -98,16 +98,16 @@ export default function AgentEmailPage() {setSelectedId(null);setBody(null);setComposing(false);- loadEmails(folder);- }, [folder, loadEmails]);+ loadEmails(folder, activeAddress);+ }, [folder, activeAddress, loadEmails]);useEffect(() => {return subscribeWs((msg) => {if (msg.type === "email.received" && msg.agentId === agentId) {- loadEmails(folder);+ loadEmails(folder, activeAddress);}});- }, [subscribeWs, agentId, folder, loadEmails]);+ }, [subscribeWs, agentId, folder, activeAddress, loadEmails]);const handleSelect = async (emailId: string) => {setComposing(false);diff --git a/src/web/src/app/api/email/route.ts b/src/web/src/app/api/email/route.tsindex efec6908e..a289d8044 100644--- a/src/web/src/app/api/email/route.ts+++ b/src/web/src/app/api/email/route.ts@@ -27,7 +27,8 @@ export const GET = withAuth(async (req: NextRequest, ctx) => {}const folder = req.nextUrl.searchParams.get("folder");- const agentEmail = agent.emailHandle ? `${agent.emailHandle}@alook.ai` : "";+ const address = req.nextUrl.searchParams.get("address");+ const agentEmail = address || (agent.emailHandle ? `${agent.emailHandle}@alook.ai` : "");let emailList;if (folder === "inbox" && agentEmail) {diff --git a/src/web/src/lib/api.ts b/src/web/src/lib/api.tsindex 3f986099d..96eafb841 100644--- a/src/web/src/lib/api.ts+++ b/src/web/src/lib/api.ts@@ -263,8 +263,8 @@ export const getTaskMessages = (id: string, workspaceId: string, since?: number));// Emails-export const listEmails = (agentId: string, workspaceId: string, folder?: string) =>- apiFetch<Email[]>(`/api/email${wsQuery(workspaceId, { agentId, ...(folder ? { folder } : {}) })}`);+export const listEmails = (agentId: string, workspaceId: string, folder?: string, address?: string) =>+ apiFetch<Email[]>(`/api/email${wsQuery(workspaceId, { agentId, ...(folder ? { folder } : {}), ...(address ? { address } : {}) })}`);export const getEmail = (id: string, workspaceId: string) =>apiFetch<Email>(`/api/email/${id}${wsQuery(workspaceId)}`);