Skip to content

Add dropdown create modal#391

Merged
Kitenite merged 6 commits intomainfrom
hissing-squid-c09726
Dec 17, 2025
Merged

Add dropdown create modal#391
Kitenite merged 6 commits intomainfrom
hissing-squid-c09726

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Dec 17, 2025

  • feat(desktop): add title and branch name fields to new workspace modal
  • refactor(desktop): simplify new workspace modal layout
  • refactor(desktop): declutter new workspace modal

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • New Features

    • Allow specifying a custom Git branch name when creating a workspace (auto-generated branch name remains as fallback).
    • Added a modal for creating new workspaces with project selection, editable title, and branch name.
  • UI/UX Changes

    • Replaced a complex dropdown with a streamlined modal-driven workflow and a compact trigger button.
    • Auto-selects current project on open and provides paginated project list with "Show more/less" and "Browse..." options.

✏️ Tip: You can customize this high-level summary in your review settings.

Kitenite and others added 4 commits December 16, 2025 18:52
Replace the dropdown menu for "more options" workspace creation with a
modal dialog. The split button UI remains the same - plus button for
quick create, chevron opens the new modal for project selection.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Update the new workspace modal to show project selection with optional
title and branch name fields in a single view. Users can:
- Select/reselect a project from the list
- Optionally provide a title (becomes workspace name)
- Optionally provide a custom branch name (auto-generated from title)

Backend now accepts branchName parameter in workspace creation.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove "Other projects" subsection, show all projects in flat list
- Current project sorted to top automatically
- Increase modal height (min-h-[500px])
- Increase project list scroll area (max-h-64)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove subtitle description
- Remove path display under project names
- Remove borders from project items (simple list style)
- Remove "(optional)" text from labels
- Remove helper text under branch field
- Narrower modal (max-w-sm)
- Shorter button text ("Create", "Browse...")
- Tighter spacing throughout

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 17, 2025

Walkthrough

This change implements a new workspace creation modal. The TRPC workspaces.create procedure accepts an optional branchName field. A new NewWorkspaceModal component provides UI for selecting a project, workspace name, and git branch. WorkspaceDropdown is refactored to trigger the modal instead of using a dropdown menu, with state managed via a new Zustand store.

Changes

Cohort / File(s) Summary
TRPC Backend Updates
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
Updated create procedure input schema to include optional branchName field; branch selection logic now prefers trimmed input.branchName, falling back to generateBranchName()
New Modal Component
apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx, apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
New React component providing modal UI for workspace creation with project selection, title input, auto-generated branch name (customizable), error handling, and TRPC mutation integration; barrel export added
Modal State Store
apps/desktop/src/renderer/stores/new-workspace-modal.ts
New Zustand-based store with isOpen state, openModal/closeModal actions, devtools middleware, and convenience hooks
UI Integration & Refactoring
apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx, apps/desktop/src/renderer/screens/main/index.tsx
WorkspaceDropdown refactored from multi-component dropdown menu to compact modal-trigger button; NewWorkspaceModal imported and rendered in MainScreen

Sequence Diagram

sequenceDiagram
    actor User
    participant Modal as NewWorkspaceModal
    participant Store as Modal Store
    participant TRPC as TRPC Backend
    participant API as Workspace API

    User->>Modal: Open modal / Mount component
    activate Modal
    
    Note over Modal: Auto-select current<br/>project if available
    Modal->>TRPC: Query active workspace<br/>& recent projects
    TRPC-->>Modal: Return projects
    
    User->>Modal: Select project
    User->>Modal: Enter workspace title
    
    Note over Modal: Auto-generate branch<br/>from title (unless edited)
    
    User->>Modal: Click Create Workspace
    Modal->>Store: Update internal state
    Store-->>Modal: State updated
    
    Modal->>TRPC: Call create mutation<br/>(projectId, name, branchName)
    activate TRPC
    TRPC->>API: Create workspace
    API-->>TRPC: Workspace created
    TRPC-->>Modal: Return result
    deactivate TRPC
    
    Note over Modal: Show success toast
    Modal->>Store: closeModal()
    Store-->>Modal: Modal closed
    deactivate Modal
    User->>User: Navigate to workspace
Loading

Estimated Code review effort

🎯 3 (Moderate) | ⏱️ ~20–25 minutes

Key areas requiring attention:

  • NewWorkspaceModal component: Verify TRPC integration, state management lifecycle, auto-generation logic for branch names, and error handling paths
  • WorkspaceDropdown refactor: Ensure modal trigger behavior correctly replaces previous dropdown flow and that focus/blur handling with modal ref works as intended
  • Branch name fallback logic: Confirm that input.branchName?.trim() || generateBranchName() properly handles edge cases (empty strings, whitespace-only input)
  • Modal state store integration: Validate that modal open/close flows correctly throughout the application

Possibly related PRs

Poem

🐰 A modal springs to life with flair,
Branch names dance through the air,
Projects picked with a gentle click,
Workspaces bloom so slick!
The dropdown bows, its duty done,
Modal workflows are such fun!

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ⚠️ Warning The PR description lacks critical details: no explicit type-of-change selection, no testing information, no screenshots, no related issues linked, and minimal clarity on specific changes despite multiple file modifications. Fill in all required template sections: select the type of change (New feature and/or Refactor apply), document testing steps for the new modal UI, add screenshots showing the modal changes, link related issues if applicable, and provide a clearer summary of the consolidated changes.
Title check ❓ Inconclusive The title 'Add dropdown create modal' is vague and doesn't accurately describe the main changes. The PR actually replaces a dropdown with a modal and adds a new workspace modal component with title and branch name fields. Consider a more descriptive title such as 'Replace workspace dropdown with new workspace creation modal' to better reflect the primary change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hissing-squid-c09726

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx (1)

32-43: Consider edge case handling in branch name generation.

The generateBranchFromTitle function handles most common cases well, but may produce unexpected results for certain edge cases:

  • Multiple consecutive spaces/hyphens are collapsed, which is good
  • Leading/trailing hyphens are removed
  • However, titles with only special characters would result in an empty string

Consider adding a fallback or validation to ensure the generated branch name is never empty when a title is provided:

 function generateBranchFromTitle(title: string): string {
 	if (!title.trim()) return "";
 
-	return title
+	const branch = title
 		.toLowerCase()
 		.trim()
 		.replace(/[^a-z0-9\s-]/g, "")
 		.replace(/\s+/g, "-")
 		.replace(/-+/g, "-")
 		.replace(/^-|-$/g, "")
 		.slice(0, 50);
+	
+	// Return empty if no valid characters remain (e.g., title was all special chars)
+	return branch || "";
 }

Note: The current implementation already returns empty string correctly, so this is just for clarity and maintainability.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b63b8d and b2e85b6.

📒 Files selected for processing (6)
  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (2 hunks)
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx (1 hunks)
  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts (1 hunks)
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx (4 hunks)
  • apps/desktop/src/renderer/screens/main/index.tsx (2 hunks)
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx
  • apps/desktop/src/renderer/screens/main/index.tsx
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx
  • apps/desktop/src/renderer/screens/main/index.tsx
**/*.{ts,tsx,js,jsx,json}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome for code formatting and linting, running at root level for speed

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx
  • apps/desktop/src/renderer/screens/main/index.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Avoid any type and prioritize type safety in TypeScript code

Files:

  • apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx
  • apps/desktop/src/renderer/screens/main/index.tsx
**/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/components/**/*.{ts,tsx}: Structure project folders as one folder per component with PascalCase naming (ComponentName/ComponentName.tsx + index.ts barrel export)
Co-locate component dependencies (utils, hooks, constants, config, tests, stories) next to the file using them
Use one component per file (no multi-component files)

Files:

  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Call IPC methods from renderer process using window.ipcRenderer.invoke with type-safe object parameters

Files:

  • apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts
  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
  • apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx
  • apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx
  • apps/desktop/src/renderer/screens/main/index.tsx
🧠 Learnings (1)
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Applied to files:

  • apps/desktop/src/renderer/stores/new-workspace-modal.ts
🧬 Code graph analysis (2)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)
apps/desktop/src/lib/trpc/routers/workspaces/utils/git.ts (1)
  • generateBranchName (120-130)
apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx (3)
apps/desktop/src/renderer/react-query/workspaces/useCreateWorkspace.ts (1)
  • useCreateWorkspace (12-61)
apps/desktop/src/renderer/react-query/projects/useOpenNew.ts (1)
  • useOpenNew (7-22)
apps/desktop/src/renderer/stores/new-workspace-modal.ts (1)
  • useOpenNewWorkspaceModal (30-31)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
  • GitHub Check: Deploy API
  • GitHub Check: Deploy Web
  • GitHub Check: Deploy Marketing
  • GitHub Check: Deploy Docs
  • GitHub Check: Deploy Admin
  • GitHub Check: Build
🔇 Additional comments (7)
apps/desktop/src/lib/trpc/routers/workspaces/workspaces.ts (1)

33-33: LGTM! Clean support for optional branch names.

The addition of the optional branchName field and the fallback logic using trim() to prevent empty strings is well-implemented. This aligns nicely with the new modal-based workflow.

Also applies to: 42-42

apps/desktop/src/renderer/stores/new-workspace-modal.ts (1)

1-33: LGTM! Well-structured Zustand store.

The modal state management is clean and follows the coding guidelines for preferring Zustand. The convenience hooks provide optimized selectors for consumers.

Based on coding guidelines: Prefers Zustand for state management as instructed.

apps/desktop/src/renderer/components/NewWorkspaceModal/index.ts (1)

1-1: LGTM! Proper barrel export.

The index barrel follows the component structure guidelines correctly.

Based on coding guidelines: Follows the pattern of ComponentName/ComponentName.tsx + index.ts barrel export.

apps/desktop/src/renderer/screens/main/index.tsx (1)

9-9: LGTM! Clean modal integration.

The NewWorkspaceModal is properly integrated into the main screen alongside existing modals.

Also applies to: 301-301

apps/desktop/src/renderer/screens/main/components/TopBar/WorkspaceTabs/WorkspaceDropdown.tsx (1)

5-5: LGTM! Effective simplification of workspace creation flow.

The refactor from a complex dropdown menu to a split button with modal integration significantly reduces complexity. The primary action creates a workspace in the current project (or opens a new project if none exists), while the chevron opens the full modal for more options. The ref blur pattern and toast promises are used appropriately.

Also applies to: 18-18, 24-24, 30-86, 112-128

apps/desktop/src/renderer/components/NewWorkspaceModal/NewWorkspaceModal.tsx (2)

76-87: useEffect usage is justified for UX requirements.

While the coding guidelines suggest avoiding effects unless necessary, both effects here serve clear UX purposes:

  1. Auto-selecting the current project when the modal opens
  2. Auto-generating branch names from the title (unless manually edited)

These effects are appropriate for this component's functionality.

Based on coding guidelines: Effects are used sparingly and only where necessary for the UX flow.


45-263: Well-structured modal component with good error handling.

The component is cleanly organized with:

  • Clear state management for form inputs
  • Proper integration with TRPC mutations
  • Comprehensive error handling for various edge cases (canceled, error, needsGitInit)
  • User-friendly error messages with actionable guidance
  • Clean separation of concerns between handlers and rendering

The branchNameEdited flag pattern effectively tracks user intent for auto-generation behavior.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 17, 2025

🚀 Preview Deployment

🔗 Preview Links

Service Status Link
Neon Database (Neon) View Branch
Vercel API (Vercel) Open Preview
Vercel Web (Vercel) Open Preview
Vercel Marketing (Vercel) Open Preview
Vercel Admin (Vercel) Open Preview
Vercel Docs (Vercel) Open Preview

Preview updates automatically with new commits

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