fix(workspace): permission enforcement, invite auto-create, switch clears stores
- DeleteAgent: require owner/admin role (was member-only check) - ListAgentTasks: add workspace membership verification (was unauthenticated) - CreateMember: auto-create user if email not found (enables invite flow) - Workspace switch: clear issue/inbox/agent stores before hydrating new data Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
2c02aa357d
commit
0ea9c38071
5 changed files with 45 additions and 21 deletions
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import { create } from "zustand";
|
||||
import type { Workspace, MemberWithUser, Agent } from "@multica/types";
|
||||
import { useIssueStore, useInboxStore, useAgentStore } from "@multica/store";
|
||||
import { api } from "@/shared/api";
|
||||
|
||||
interface WorkspaceState {
|
||||
|
|
@ -76,6 +77,11 @@ export const useWorkspaceStore = create<WorkspaceStore>((set, get) => ({
|
|||
const ws = workspaces.find((item) => item.id === workspaceId);
|
||||
if (!ws) return;
|
||||
|
||||
// Clear stale data from other stores before switching
|
||||
useIssueStore.getState().setIssues([]);
|
||||
useInboxStore.getState().setItems([]);
|
||||
useAgentStore.getState().setAgents([]);
|
||||
|
||||
await hydrateWorkspace(workspaces, ws.id);
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue