feat: add workspace system and sidebar layout (UI design system Phase A+B)

Backend: Workspace model, migration (036), schemas, CRUD API endpoints.
Adds workspace_id to trees and categories, seeds 4 default workspaces
per account, auto-assigns existing trees by tree_type.

Frontend: Complete AppLayout rewrite from top-nav to CSS Grid shell
with persistent sidebar + topbar. New components: WorkspaceSwitcher,
NavItem, CategoryList, TagCloud, TopBar, Sidebar. Dashboard components:
QuickStats, FiltersBar, SectionGroup, TreeListItem, SessionsPanel.
WorkspaceStore with localStorage persistence.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Michael Chihlas
2026-02-15 01:16:33 -05:00
parent ef829f06a4
commit d6f4286570
31 changed files with 1431 additions and 250 deletions

View File

@@ -20,6 +20,7 @@ from .session_share import SessionShare, SessionShareView
from .account_limit_override import AccountLimitOverride
from .feature_flag import FeatureFlag, PlanFeatureDefault, AccountFeatureOverride
from .platform_setting import PlatformSetting
from .workspace import Workspace
__all__ = [
"User",
@@ -51,4 +52,5 @@ __all__ = [
"PlanFeatureDefault",
"AccountFeatureOverride",
"PlatformSetting",
"Workspace",
]

View File

@@ -15,6 +15,7 @@ if TYPE_CHECKING:
from app.models.step_category import StepCategory
from app.models.step_library import StepLibrary
from app.models.account_limit_override import AccountLimitOverride
from app.models.workspace import Workspace
class Account(Base):
@@ -45,3 +46,4 @@ class Account(Base):
step_categories: Mapped[list["StepCategory"]] = relationship("StepCategory", foreign_keys="[StepCategory.account_id]", back_populates="account")
step_library: Mapped[list["StepLibrary"]] = relationship("StepLibrary", foreign_keys="[StepLibrary.account_id]", back_populates="account")
limit_override: Mapped[Optional["AccountLimitOverride"]] = relationship("AccountLimitOverride", back_populates="account", uselist=False)
workspaces: Mapped[list["Workspace"]] = relationship("Workspace", back_populates="account")

View File

@@ -11,6 +11,7 @@ if TYPE_CHECKING:
from app.models.team import Team
from app.models.account import Account
from app.models.user import User
from app.models.workspace import Workspace
class TreeCategory(Base):
@@ -47,6 +48,17 @@ class TreeCategory(Base):
)
display_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0, index=True)
is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True)
color: Mapped[Optional[str]] = mapped_column(
String(7), nullable=True, default='#3b82f6',
comment="Hex color for category dot indicator"
)
workspace_id: Mapped[Optional[uuid.UUID]] = mapped_column(
UUID(as_uuid=True),
ForeignKey("workspaces.id", ondelete="SET NULL"),
nullable=True,
index=True,
comment="Workspace this category belongs to"
)
created_by: Mapped[Optional[uuid.UUID]] = mapped_column(
UUID(as_uuid=True),
ForeignKey("users.id", ondelete="SET NULL"),
@@ -67,6 +79,7 @@ class TreeCategory(Base):
account: Mapped[Optional["Account"]] = relationship("Account", foreign_keys=[account_id], back_populates="categories")
creator: Mapped[Optional["User"]] = relationship("User", foreign_keys=[created_by])
trees: Mapped[list["Tree"]] = relationship("Tree", back_populates="category_rel")
workspace: Mapped[Optional["Workspace"]] = relationship("Workspace", back_populates="categories")
@property
def is_global(self) -> bool:

View File

@@ -15,6 +15,7 @@ if TYPE_CHECKING:
from app.models.tag import TreeTag
from app.models.folder import UserFolder
from app.models.tree_share import TreeShare
from app.models.workspace import Workspace
class Tree(Base):
@@ -120,6 +121,13 @@ class Tree(Base):
onupdate=lambda: datetime.now(timezone.utc)
)
usage_count: Mapped[int] = mapped_column(Integer, default=0)
workspace_id: Mapped[Optional[uuid.UUID]] = mapped_column(
UUID(as_uuid=True),
ForeignKey("workspaces.id", ondelete="SET NULL"),
nullable=True,
index=True,
comment="Workspace this tree belongs to (organizational context)"
)
# Fork tracking
parent_tree_id: Mapped[Optional[uuid.UUID]] = mapped_column(
@@ -184,6 +192,8 @@ class Tree(Base):
cascade="all, delete-orphan"
)
workspace: Mapped[Optional["Workspace"]] = relationship("Workspace", back_populates="trees")
# New organization relationships
category_rel: Mapped[Optional["TreeCategory"]] = relationship("TreeCategory", back_populates="trees")
tags: Mapped[list["TreeTag"]] = relationship(

View File

@@ -0,0 +1,57 @@
import uuid
from datetime import datetime, timezone
from typing import Optional, TYPE_CHECKING
from sqlalchemy import String, Text, DateTime, ForeignKey, Boolean, Integer, UniqueConstraint
from sqlalchemy.orm import Mapped, mapped_column, relationship
from sqlalchemy.dialects.postgresql import UUID
from app.core.database import Base
if TYPE_CHECKING:
from app.models.account import Account
from app.models.tree import Tree
from app.models.category import TreeCategory
class Workspace(Base):
"""Workspaces are the top-level organizational context for trees/flows.
They sit above the folder system — a workspace scopes which trees/flows
are visible, while folders remain for personal organization within.
"""
__tablename__ = "workspaces"
__table_args__ = (
UniqueConstraint('slug', 'account_id', name='uq_workspaces_slug_account'),
)
id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
primary_key=True,
default=uuid.uuid4
)
name: Mapped[str] = mapped_column(String(100), nullable=False)
slug: Mapped[str] = mapped_column(String(100), nullable=False, index=True)
description: Mapped[Optional[str]] = mapped_column(Text, nullable=True)
icon: Mapped[Optional[str]] = mapped_column(String(10), nullable=True)
accent_color: Mapped[Optional[str]] = mapped_column(String(7), nullable=True)
account_id: Mapped[uuid.UUID] = mapped_column(
UUID(as_uuid=True),
ForeignKey("accounts.id", ondelete="CASCADE"),
nullable=False,
index=True
)
is_default: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
default=lambda: datetime.now(timezone.utc)
)
updated_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True),
default=lambda: datetime.now(timezone.utc),
onupdate=lambda: datetime.now(timezone.utc)
)
# Relationships
account: Mapped["Account"] = relationship("Account", back_populates="workspaces")
trees: Mapped[list["Tree"]] = relationship("Tree", back_populates="workspace")
categories: Mapped[list["TreeCategory"]] = relationship("TreeCategory", back_populates="workspace")