feat(workspace): 1/5 Foundation - API client and session manager#8181
feat(workspace): 1/5 Foundation - API client and session manager#8181
Conversation
- Add workspaceApi.ts with all workspace endpoint methods - Add sessionManager.ts for workspace token storage - Update workspaceConstants.ts with storage keys - Add INVITE namespace to preservedQueryNamespaces
📝 WalkthroughWalkthroughAdds workspace constants for persistent storage tracking, expands navigation namespaces for invite handling, introduces a comprehensive Workspace API client with authentication wrappers and type definitions, and adds a session manager service for managing workspace-related storage and page reloads. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Client
participant sessionManager
participant workspaceApi
participant Firebase
participant Backend
User->>Client: Switch to workspace
Client->>sessionManager: switchWorkspaceAndReload(workspaceId)
sessionManager->>sessionManager: clearWorkspaceToken()
sessionManager->>sessionManager: setCurrentWorkspaceId(workspaceId)
sessionManager->>sessionManager: setLastWorkspaceId(workspaceId)
sessionManager->>Client: Trigger page reload
Client->>Client: Page reloads
Client->>workspaceApi: exchangeToken({workspace_id})
workspaceApi->>Firebase: Get ID token
Firebase-->>workspaceApi: ID token
workspaceApi->>Backend: POST /auth/token with Firebase token + workspace_id
Backend-->>workspaceApi: ExchangeTokenResponse (token, expires_at)
workspaceApi-->>Client: Token received
Client->>sessionManager: setWorkspaceToken(token, expiresAt)
sessionManager->>sessionManager: Store in localStorage
Possibly related PRs
Suggested reviewers
✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🎭 Playwright Tests:
|
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 01/20/2026, 08:19:02 PM UTC 🔗 Links🎉 Your Storybook is ready for review! |
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 22.4 kB (baseline 22.4 kB) • ⚪ 0 BMain entry bundles and manifests
Status: 1 added / 1 removed Graph Workspace — 1.02 MB (baseline 1.02 MB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Status: 1 added / 1 removed Views & Navigation — 80.7 kB (baseline 80.7 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Status: 9 added / 9 removed Panels & Settings — 430 kB (baseline 430 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
Status: 8 added / 8 removed User & Accounts — 3.94 kB (baseline 3.94 kB) • ⚪ 0 BAuthentication, profile, and account management bundles
Status: 3 added / 3 removed Editors & Dialogs — 2.8 kB (baseline 2.8 kB) • ⚪ 0 BModals, dialogs, drawers, and in-app editors
Status: 2 added / 2 removed UI Components — 32.8 kB (baseline 32.8 kB) • ⚪ 0 BReusable component library chunks
Status: 5 added / 5 removed Data & Services — 3.04 MB (baseline 3.04 MB) • 🔴 +56 BStores, services, APIs, and repositories
Status: 7 added / 7 removed Utilities & Hooks — 18.7 kB (baseline 18.7 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Status: 4 added / 4 removed Vendor & Third-Party — 10.4 MB (baseline 10.4 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 6.25 MB (baseline 6.25 MB) • 🔴 +23 BBundles that do not match a named category
Status: 26 added / 26 removed |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/platform/workspace/services/sessionManager.ts`:
- Around line 143-147: The clearAndReload() method currently calls
clearWorkspaceToken() and clearCurrentWorkspaceId() but does not remove the
persisted LAST_WORKSPACE_ID key, so a deleted workspace can be rehydrated on
next boot; update clearAndReload() in sessionManager.ts to also remove the
LAST_WORKSPACE_ID entry from localStorage (or call the existing helper that
clears that key) before calling window.location.reload() so the app falls back
to the personal workspace on next start.
| clearAndReload(): void { | ||
| this.clearWorkspaceToken() | ||
| this.clearCurrentWorkspaceId() | ||
| window.location.reload() | ||
| } |
There was a problem hiding this comment.
Clear LAST_WORKSPACE_ID when resetting context.
clearAndReload() is documented to fall back to personal workspace, but it leaves LAST_WORKSPACE_ID in localStorage, which can rehydrate a deleted workspace on next boot. Clear it before reload.
🛠️ Proposed fix
clearAndReload(): void {
this.clearWorkspaceToken()
this.clearCurrentWorkspaceId()
+ this.clearLastWorkspaceId()
window.location.reload()
}🤖 Prompt for AI Agents
In `@src/platform/workspace/services/sessionManager.ts` around lines 143 - 147,
The clearAndReload() method currently calls clearWorkspaceToken() and
clearCurrentWorkspaceId() but does not remove the persisted LAST_WORKSPACE_ID
key, so a deleted workspace can be rehydrated on next boot; update
clearAndReload() in sessionManager.ts to also remove the LAST_WORKSPACE_ID entry
from localStorage (or call the existing helper that clears that key) before
calling window.location.reload() so the app falls back to the personal workspace
on next start.
Stack: 1/5 | Part of workspace feature (see full branch)
Adds workspace API client and session storage manager. Pure infrastructure—no UI, no integrations. Safe to merge as dead code until subsequent PRs land. All code gated by
isCloud && teamWorkspacesEnabled.Files:
workspaceApi.ts,sessionManager.ts,workspaceConstants.ts┆Issue is synchronized with this Notion page by Unito