Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

Adds /new <workspace> [-t <trunk>] slash command for creating workspaces from chat input.

Changes

  • New slash command: /new <workspace-name> [-t <branch>] creates workspace with optional trunk specification
  • Centralized command handlers: Extracted command logic from ChatInput to src/utils/chatCommands.ts (~350 lines)
  • Modal integration: NewWorkspaceModal displays equivalent command string for user education
  • Shared creation logic: Both modal and command paths use same backend API

Implementation

Command Syntax

/new feature-x              # Auto-detect trunk
/new feature-x -t develop   # Specify trunk
/new feature-x\nStart here  # With initial message

Invalid syntax (unknown flags, extra args, no args) opens the modal for guidance.

Architecture

Created chatCommands.ts utility with:

  • createNewWorkspace() - Workspace creation with optional start message
  • handleNewCommand() - Type-safe command handler
  • handleCompactCommand() - Refactored from inline code
  • formatNewCommand() - Command string generation (shared by modal)

ChatInput simplified from ~110 lines of inline logic to clean handler calls.

Testing

All 65 slash command tests pass:

  • 11 new tests for /new command variations
  • No regressions in existing commands
  • TypeScript type checking passes

Design Decisions

Anti-pattern avoided: No /new-help command type. Invalid input opens modal instead, providing better UX than text help.

Type safety: Used CommandHandlerContext interface and discriminated unions throughout.

DRY: Both modal and command share backend API - no logic duplication.

Generated with cmux

- Added /new <workspace> [-t <trunk>] slash command
- Extracted command handling to chatCommands.ts utility
- NewWorkspaceModal displays equivalent command
- Shared workspace creation logic via backend API
- Comprehensive test coverage (11 tests for /new)

Generated with `cmux`
@ammario ammario marked this pull request as ready for review October 19, 2025 01:03
@ammario ammario added this pull request to the merge queue Oct 19, 2025
@ammario ammario removed this pull request from the merge queue due to a manual request Oct 19, 2025
@ammario ammario merged commit 979de51 into main Oct 19, 2025
8 checks passed
@ammario ammario deleted the model-parity branch October 19, 2025 01:03
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