Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(auth): wire onLogout callback to auth store and let guard handle redirect

Naiyuan Qing715f19643447
diff --git a/packages/core/platform/core-provider.tsx b/packages/core/platform/core-provider.tsx
index a66eac62ca..6d0ca57942 100644
--- a/packages/core/platform/core-provider.tsx
+++ b/packages/core/platform/core-provider.tsx
@@ -18,7 +18,12 @@ import type { StorageAdapter } from "../types/storage";
let initialized = false;
let authStore: ReturnType<typeof createAuthStore>;
let workspaceStore: ReturnType<typeof createWorkspaceStore>;
-function initCore(apiBaseUrl: string, storage: StorageAdapter) {
+function initCore(
+ apiBaseUrl: string,
+ storage: StorageAdapter,
+ onLogin?: () => void,
+ onLogout?: () => void,
+) {
if (initialized) return;
const api = new ApiClient(apiBaseUrl, {
@@ -36,7 +41,7 @@ function initCore(apiBaseUrl: string, storage: StorageAdapter) {
const wsId = storage.getItem("multica_workspace_id");
if (wsId) api.setWorkspaceId(wsId);
- authStore = createAuthStore({ api, storage });
+ authStore = createAuthStore({ api, storage, onLogin, onLogout });
registerAuthStore(authStore);
workspaceStore = createWorkspaceStore(api, { storage });
@@ -54,9 +59,9 @@ export function CoreProvider({
onLogout,
}: CoreProviderProps) {
// Initialize singletons on first render only. Dependencies are read-once:
- // apiBaseUrl and storage are set at app boot and never change at runtime.
+ // apiBaseUrl, storage, and callbacks are set at app boot and never change at runtime.
// eslint-disable-next-line react-hooks/exhaustive-deps
- useMemo(() => initCore(apiBaseUrl, storage), []);
+ useMemo(() => initCore(apiBaseUrl, storage, onLogin, onLogout), []);
return (
<QueryProvider>
diff --git a/packages/views/layout/app-sidebar.tsx b/packages/views/layout/app-sidebar.tsx
index 21bbbb1e3d..3500038191 100644
--- a/packages/views/layout/app-sidebar.tsx
+++ b/packages/views/layout/app-sidebar.tsx
@@ -105,10 +105,9 @@ export function AppSidebar({ topSlot, searchSlot, headerClassName, headerStyle }
() => deduplicateInboxItems(inboxItems).filter((i) => !i.read).length,
[inboxItems],
);
- const hasRuntimeUpdates = useMyRuntimesNeedUpdate();
+ const hasRuntimeUpdates = useMyRuntimesNeedUpdate(wsId);
const logout = () => {
- push("/");
authLogout();
useWorkspaceStore.getState().clearWorkspace();
};