supermemory/apps/web/lib
MaheshtheDev db7f5c3f64 fix(web): select the correct Company Brain workspace (#1372)
## What changed

- Make `/brain` reuse the active Company Brain, switch to a single existing Company Brain, show a picker for multiple choices, or create one only when none exists.
- Wait for active-organization restoration before making that decision.
- Make Company Brain onboarding match organizations by the confirmed company domain and never offer unrelated-domain workspaces.
- Create a new Company Brain when no matching workspace exists and show an actionable workspace-limit toast when creation is blocked.
- Improve the organization picker, loading, and error states.

## Why

The previous flows could use or mutate the currently active normal organization, start research against stale Company Brain metadata, or offer unrelated Company Brain workspaces after a quota failure.

## Impact

Normal organizations are no longer silently converted. Research is scoped to the Company Brain for the confirmed domain, and users receive a clear recovery path when they reach their workspace limit.

This keeps the existing `{ domain }` research API contract; no organization-reconfiguration API is required.

## Validation

- Biome checks passed for all five changed web files
- Targeted web TypeScript diagnostics reported no errors for the changed files
- React Doctor against `origin/main`: no issues found
- `git diff --check`

No test files were added.
2026-07-28 06:14:22 +00:00
..
agent-space.test.ts feat(web): add Cursor to Agents (#1361) 2026-07-25 22:09:28 +00:00
agent-space.ts feat(web): add Cursor to Agents (#1361) 2026-07-25 22:09:28 +00:00
analytics.ts feat(web): surface Company Brain to personal-brain users (#1370) 2026-07-28 04:25:04 +00:00
billing-utils.ts docs(brain): note trial attach after Slack OAuth (#1313) 2026-07-21 21:34:25 +00:00
chat-auto-space.ts Update chat empty state and Auto space mode (#954) 2026-05-16 23:55:34 -07:00
chat-highlight-documents.ts Draft: Add chat source annotations (#1165) 2026-06-26 20:51:40 -07:00
chat-memory-tools.test.ts Draft: Add chat source annotations (#1165) 2026-06-26 20:51:40 -07:00
chat-memory-tools.ts Draft: Add chat source annotations (#1165) 2026-06-26 20:51:40 -07:00
chat-search-memory-results.ts feat: web search and improve chat with tools (#810) 2026-03-27 01:57:13 +00:00
chat-space-label.ts fix: space selector dropdown (#898) 2026-05-04 17:15:10 +00:00
chat-stream-error.ts chat: fix tool-output validation, bump ai sdk, update model labels (#887) 2026-04-26 04:25:09 +00:00
chat-web-search-tools.ts feat: web search and improve chat with tools (#810) 2026-03-27 01:57:13 +00:00
company-brain-entry.ts fix(web): select the correct Company Brain workspace (#1372) 2026-07-28 06:14:22 +00:00
constants.ts fix: redirect new users to onboarding from plugin connect page (#908) 2026-05-11 10:57:43 -07:00
extract-urls.test.ts fix(web): stop extractUrls treating email addresses as URLs (#1187) 2026-07-10 19:14:57 -07:00
file-cache.ts implement Nova chat attachments on the web side (#1004) 2026-06-08 06:18:28 +00:00
fonts.ts feat: deep-research on user profile and tiptap integration (#672) 2026-01-15 21:53:53 +00:00
ingest-auto-space.ts Brand own space as Nova chats (#957) 2026-05-17 00:25:22 -07:00
integration-routes.ts feat(web): make /integrations a real route with connect deeplinks (#1155) 2026-06-23 20:42:29 +00:00
mcp-client-setup.ts docs: restructure documentation site and update integration UI (#1331) 2026-07-21 20:19:30 -07:00
mcp-manual-instructions.ts Add Antigravity MCP setup (#1119) 2026-06-16 12:10:36 +05:30
models.tsx Grok 4.3, web sources UX, and mobile polish (#1064) 2026-06-08 12:34:15 +05:30
oauth-plugins.ts feat(web): MCP OAuth consent page (#1118) 2026-06-16 17:33:09 +00:00
plugin-catalog.ts docs: restructure documentation site and update integration UI (#1331) 2026-07-21 20:19:30 -07:00
plugin-document.test.ts feat(web): add Cursor to Agents (#1361) 2026-07-25 22:09:28 +00:00
plugin-document.ts feat(web): add Cursor to Agents (#1361) 2026-07-25 22:09:28 +00:00
plugin-space.ts feat(web): add Cursor to Agents (#1361) 2026-07-25 22:09:28 +00:00
search-params.ts feat(web): add Cursor to Agents (#1361) 2026-07-25 22:09:28 +00:00
source-annotations.test.ts Draft: Add chat source annotations (#1165) 2026-06-26 20:51:40 -07:00
source-annotations.ts Draft: Add chat source annotations (#1165) 2026-06-26 20:51:40 -07:00
theme-provider.tsx feat: layout design with theme improvements (#443) 2025-10-01 21:59:54 +00:00
url-helpers.test.ts fix(web): match YouTube URLs by hostname instead of substring (#1182) 2026-07-10 16:20:18 -07:00
url-helpers.ts fix(web): use backend URL fallback for direct fetches (#1212) 2026-07-10 20:02:24 -07:00
variants.ts chore: delete document, document ui (#673) 2026-01-16 21:44:26 +00:00
view-mode-context.tsx feat(web): make /integrations a real route with connect deeplinks (#1155) 2026-06-23 20:42:29 +00:00