Skip to content

Conversation

@kylecarbs
Copy link
Member

Overview

Make workspace creation automatic and invisible. When no workspace exists, typing and sending a message creates one with an AI-generated title and branch name based on the message content.

Changes

Backend

  • New service: workspaceTitleGenerator.ts - Generates workspace titles and branch names using AI
    • Uses structured output with Zod schema validation
    • Prefers cheap models (Haiku → GPT-4o-mini)
    • Falls back to timestamp-based names if AI fails
  • New IPC handler: sendFirstMessage - Creates workspace and sends message in one operation
  • Updated IPC types and constants

Frontend

  • New component: ProjectSelector - Dropdown for selecting project (auto-hides if single project)
  • New component: FirstMessageInput - Simplified input for first message
  • Updated App.tsx to render empty state with project selector + chat input
  • Added mock API stubs for stories and browser tests

User Flow

Before:

  1. Click "Add Workspace"
  2. Fill out modal (branch name, trunk, runtime)
  3. Click "Create"
  4. Type message

After:

  1. Type message
  2. Hit Cmd+Enter
  3. ✨ Workspace auto-created with AI-generated title and branch

Key Design Decisions

Title vs Branch Name:

  • Git branch: AI-generated git-safe name (e.g., user-auth-rest-api)
  • Display name: Human-readable title (e.g., "Building user authentication REST API")

Graceful Degradation:

  • No API keys? Falls back to Chat ${timestamp}
  • AI generation fails? Same fallback
  • No user-facing errors (logged only)

Backwards Compatibility:

  • Existing workspaces: name equals branch name (unchanged)
  • Manual creation: User's name used for both title and branch
  • Only lazy creation uses AI generation

Testing

  • ✅ Typecheck passes
  • ✅ Lint passes
  • ✅ All mock APIs updated

Generated with cmux

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

- Add workspaceTitleGenerator service using Vercel AI SDK
- Generate human-readable titles and git-safe branch names
- Add sendFirstMessage IPC handler that creates workspace automatically
- Add ProjectSelector and FirstMessageInput components for empty state
- Update App.tsx to show project selector when no workspace exists
- Gracefully fall back to timestamp names if AI generation fails

Users can now type a message and hit send to create a workspace
with an AI-generated title and branch name based on their message.

Generated with `cmux`
The 'name' field is used throughout the backend to compute filesystem
paths (e.g., runtime.getWorkspacePath uses metadata.name as the directory).
Storing the AI-generated title there would break path resolution.

Solution:
- Add optional 'displayName' field to WorkspaceMetadata
- Store git-safe branch name in 'name' (used for paths)
- Store human-readable title in 'displayName' (used for display)
- UI prefers displayName over name when rendering

This maintains backward compatibility - existing workspaces without
displayName continue to work, showing the branch name as before.

Generated with `cmux`
FirstMessageInput was using useSendMessageOptions which internally uses
useThinking hook, causing 'useThinking must be used within a
ThinkingProvider' error in E2E tests when empty state was rendered.

Instead, directly use useModelLRU to get the most recent model without
requiring context providers.

Generated with `cmux`
Instead of showing a project selector dropdown when no workspace is
selected, we now:
- If only one project exists: Show FirstMessageInput immediately
- If multiple projects exist: Show welcome message asking user to
  select/create workspace via sidebar

This is cleaner UX - users already interact with projects via the
left sidebar, no need for duplicate selection UI.

Generated with `cmux`
1. Merge sendFirstMessage into sendMessage - make workspaceId optional
   to reduce duplication in IPC layer. When null, automatically creates
   workspace with AI-generated title/branch.

2. Use standard useSendMessageOptions in FirstMessageInput instead of
   manually managing model selection.

3. Use the same model as provided in send message options for title
   generation instead of hardcoding cheap models. This respects custom
   BaseURL configurations and avoids manual updates when models change.

4. Remove redundant WORKSPACE_SEND_FIRST_MESSAGE IPC channel and handler.

Generated with `cmux`
useSendMessageOptions internally uses useThinking which requires
ThinkingProvider context. Since FirstMessageInput is rendered outside
of context providers, manually build send options instead.

Generated with `cmux`
Fixes floating promise lint error in sendMessage when creating
workspaces without explicit workspaceId.

editConfig() returns a promise that must be awaited before
continuing to retrieve the complete metadata.
Changes workspace creation UX to show FirstMessageInput instead of
NewWorkspaceModal when user clicks the '+ Add Workspace' button.

User flow:
1. Click '+ Add Workspace' in sidebar
2. See FirstMessageInput (same as single-project empty state)
3. Type message and hit send
4. Workspace created with AI-generated title/branch
5. Message sent to new workspace

Added cancel functionality:
- Escape key cancels workspace creation
- Cancel button shown when in 'add workspace' mode
- Returns user to empty state on cancel

NewWorkspaceModal still exists for advanced users (can be triggered
via command palette or other flows in the future).
Redesigned FirstMessageInput to use the same visual style as ChatInput
for a unified user experience.

Changes:
- Replaced custom textarea with VimTextArea component (matches ChatInput)
- Added ModelSelector component for choosing AI model
- Added runtime config selector (Local vs SSH) with SSH host input
- Styled with same CSS classes as ChatInput (bg-separator, border-border-light, etc.)
- Options displayed inline below input (Model | Runtime | Cancel/Send)
- Added helpful tooltip for runtime configuration

All workspace creation options now visible and accessible without
needing to open a separate modal.
Changes:
- Removed Send and Cancel buttons (use Cmd+Enter to send like ChatInput)
- Input now takes full width (removed button constraints)
- Added project title in center of empty view
- Shows trunk branch below project name (auto-detected, informational)
- Removed manual trunk branch selector (backend auto-detects it)
- Cleaner, more unified UX matching ChatInput behavior
- Import useMode hook from ModeContext
- Add MODE_OPTIONS and ModeHelpTooltip (matching ChatInput)
- Add mode selector UI with responsive layouts (full and compact)
- VimTextArea now uses mode state instead of hardcoded 'exec'
- Includes tooltip explaining Exec vs Plan mode

Related to #500
…ut backend

- Import useThinkingLevel, use1MContext hooks and policy utilities
- Build SendMessageOptions with all required fields (mode, toolPolicy, thinkingLevel, providerOptions)
- Add ThinkingSliderComponent and Context1MCheckbox UI (matching ChatInput layout)
- Mode selector now positioned with ml-auto (right-aligned like ChatInput)
- All message options (mode, thinking, 1M context) now properly passed to backend

This ensures the first message respects the same settings as regular messages.

Related to #500
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.

2 participants