Skip to content

refactor(tabs): live Zero-synced tabs with workspace limits and UI polish#1609

Open
AnishSarkar22 wants to merge 28 commits into
MODSetter:devfrom
AnishSarkar22:fix/tabs
Open

refactor(tabs): live Zero-synced tabs with workspace limits and UI polish#1609
AnishSarkar22 wants to merge 28 commits into
MODSetter:devfrom
AnishSarkar22:fix/tabs

Conversation

@AnishSarkar22

@AnishSarkar22 AnishSarkar22 commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Reworked the tab system so tabs store only lightweight pointers (id, type, entity id, workspace id) instead of persisting full server-owned snapshots, cutting over to a new v2 storage key.
  • Added a resolver hook that joins tab pointers against Zero and derives titles/existence live, pruning a tab only when its row is absent and the query has confirmed completeness.
  • Extended the Zero thread schema with title, visibility, and created-by, and added by-ids queries for threads (with per-thread authz: own thread or workspace-shared) and documents.
  • Published the new thread metadata columns to the Zero publication via a new migration so titles and access filtering sync in real time.
  • Removed the legacy tab migration and its test now that tabs use the pointer-only v2 shape.
  • Rewired all tab consumers to resolved tabs: the tab bar renders from resolved data, the layout shell splits tabbed/untabbed panels behind a show-tabs flag and resolves document tabs via entity id plus live title, and the free layout renders untabbed.
  • Reworked fallback navigation for pointer tabs, deriving URLs from entity/workspace ids and letting title and visibility resolve asynchronously.
  • Dropped the title/visibility/has-comments snapshot arguments from tab sync in the activate-thread hook and the new-chat page effect.
  • Added a configurable per-user workspace creation limit enforced on the backend with unit tests, and surfaced that limit to the frontend through types, API service, query atoms, cache keys, and limit-aware "add workspace" affordances across the create dialog, icon rail, and sidebars.
  • Added a threads loading skeleton and relative timestamp formatting in the All Chats sidebar, backed by a shared date helper.
  • Added a chats-click handler across sidebar components for improved navigation.
  • Added cookie persistence for the playground sidebar collapsed state.
  • Improved chat message loading-state handling and introduced a can-submit interface/logic to gate chat submission.
  • Polished panel headers and controls across the citation, report, and artifacts panels, refined inline citations, and clarified the connect-agent dialog title.
  • Refined the chat header's responsive styling and updated the automations loading skeleton.
  • Swapped the document mention picker icon for better visual consistency.

Motivation and Context

FIX #

Screenshots

API Changes

  • This PR includes API changes

Change Type

  • Bug fix
  • New feature
  • Performance improvement
  • Refactoring
  • Documentation
  • Dependency/Build system
  • Breaking change
  • Other (specify):

Testing Performed

  • Tested locally
  • Manual/QA verification

Checklist

  • Follows project coding standards and conventions
  • Documentation updated as needed
  • Dependencies updated as needed
  • No lint/build errors or new warnings
  • All relevant tests are passing

High-level PR Summary

This PR refactors the tab management system to rely on real-time Zero synchronization for chat thread metadata instead of persisting full metadata in local storage. The tabs now store only lightweight pointers (entityId and workspaceId) that are resolved against Zero queries at runtime. Additionally, backend workspace creation limits are enforced with a new configurable MAX_WORKSPACES_PER_USER setting, and various UI improvements include better loading states, refined panel headers, improved date formatting, and visual polish across chat and sidebar components.

⏱️ Estimated Review Time: 1-3 hours

💡 Review Order Suggestion
Order File Path
1 surfsense_web/atoms/tabs/migrate-tabs.test.ts
2 surfsense_web/atoms/tabs/migrate-tabs.ts
3 surfsense_web/atoms/tabs/tabs.atom.ts
4 surfsense_web/hooks/use-resolved-tabs.test.ts
5 surfsense_web/hooks/use-resolved-tabs.ts
6 surfsense_web/zero/schema/chat.ts
7 surfsense_web/zero/queries/chat.ts
8 surfsense_web/zero/queries/documents.ts
9 surfsense_web/zero/queries/index.ts
10 surfsense_backend/app/zero_publication.py
11 surfsense_backend/alembic/versions/175_publish_thread_metadata_to_zero.py
12 surfsense_web/components/layout/ui/tabs/TabBar.tsx
13 surfsense_web/components/layout/ui/shell/LayoutShell.tsx
14 surfsense_web/app/dashboard/[workspace_id]/new-chat/[[...chat_id]]/page.tsx
15 surfsense_web/hooks/use-activate-chat-thread.ts
16 surfsense_web/components/layout/providers/LayoutDataProvider.tsx
17 surfsense_web/components/layout/ui/sidebar/AllChatsSidebar.tsx
18 surfsense_web/components/assistant-ui/thread.tsx
19 surfsense_web/lib/chat/can-submit-chat.ts
20 surfsense_backend/app/config/__init__.py
21 surfsense_backend/app/routes/workspaces_routes.py
22 surfsense_backend/tests/unit/routes/test_workspaces_limits.py
23 surfsense_web/contracts/types/workspace.types.ts
24 surfsense_web/lib/apis/workspaces-api.service.ts
25 surfsense_web/atoms/workspaces/workspace-query.atoms.ts
26 surfsense_web/lib/query-client/cache-keys.ts
27 surfsense_web/components/layout/providers/FreeLayoutDataProvider.tsx
28 surfsense_web/components/layout/ui/icon-rail/IconRail.tsx
29 surfsense_web/components/layout/ui/dialogs/CreateWorkspaceDialog.tsx
30 surfsense_web/components/layout/ui/sidebar/MobileSidebar.tsx
31 surfsense_web/components/layout/ui/sidebar/Sidebar.tsx
32 surfsense_web/lib/format-date.ts
33 surfsense_web/components/citation-panel/citation-panel.tsx
34 surfsense_web/components/report-panel/report-panel.tsx
35 surfsense_web/features/chat-artifacts/ui/artifacts-panel.tsx
36 surfsense_web/components/assistant-ui/inline-citation.tsx
37 surfsense_web/components/new-chat/chat-header.tsx
38 surfsense_web/components/new-chat/document-mention-picker.tsx
39 surfsense_web/components/mcp/connect-agent-dialog.tsx
40 surfsense_web/app/dashboard/[workspace_id]/automations/components/automations-loading.tsx

Need help? Join our Discord

…keleton loading components for better user experience
…ssageCircleMore for improved visual consistency
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

@AnishSarkar22 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d7070a35-e700-4c86-8d38-e4f292ab9ae6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@AnishSarkar22 AnishSarkar22 changed the title Fix/tabs refactor(tabs): live Zero-synced tabs with workspace limits and UI polish Jul 16, 2026
@AnishSarkar22
AnishSarkar22 marked this pull request as ready for review July 17, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant