Skip to content

feat(mcp,desktop): bulk workspace operations#1088

Merged
saddlepaddle merged 2 commits into
mainfrom
satya-patel/bulk-workspace-operations
Feb 1, 2026
Merged

feat(mcp,desktop): bulk workspace operations#1088
saddlepaddle merged 2 commits into
mainfrom
satya-patel/bulk-workspace-operations

Conversation

@saddlepaddle
Copy link
Copy Markdown
Collaborator

@saddlepaddle saddlepaddle commented Jan 31, 2026

Summary

  • Convert create_workspace and delete_workspace MCP tools from single-item to bulk (1-5 items per call)
  • Add new update_workspace tool for bulk renaming workspaces
  • Both MCP layer (packages/mcp) and desktop handler layer (apps/desktop) updated in lockstep

Details

API changes:

  • create_workspace: { deviceId, workspaces: [{ name?, branchName?, baseBranch? }] }
  • delete_workspace: { deviceId, workspaceIds: ["uuid", ...] }
  • update_workspace (new): { deviceId, updates: [{ workspaceId, name? }] }

Agent-friendly design:

  • All bulk results include a summary: { total, succeeded, failed } field for easy partial-failure detection
  • Error objects include context (index, workspaceId, name) for correlation
  • Shared BulkItemError type and buildBulkResult helper eliminate duplication across handlers
  • Sequential processing with partial failure support (one failure doesn't abort the batch)

Test plan

  • bun run typecheck passes (17/17 packages)
  • bun run lint passes
  • bun test passes (1195 pass, 0 fail)
  • Manual: create multiple workspaces in one MCP call
  • Manual: delete multiple workspaces in one MCP call
  • Manual: rename multiple workspaces in one MCP call

Summary by CodeRabbit

  • New Features
    • Bulk workspace creation: create up to 5 workspaces in one action.
    • Bulk workspace deletion: delete up to 5 workspaces in one action.
    • Bulk workspace updates: rename/update workspace properties for up to 5 items.
    • Per-item error reporting: batch operations report item-level successes and failures, allowing partial success.

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

Convert create_workspace, delete_workspace to accept arrays (1-5 items)
and add new update_workspace tool. Follows the bulk pattern established
by task operations, with sequential processing and partial failure support.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 31, 2026

📝 Walkthrough

Walkthrough

Adds bulk workspace operations across desktop and MCP: create, delete now accept 1–5 items; introduces a new update_workspace tool (renderer + MCP); adds BulkItemError and buildBulkResult utilities; wires updateWorkspace into ToolContext and MCP tool registry.

Changes

Cohort / File(s) Summary
Desktop: Bulk tools & types
apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/create-worktree.ts, apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/delete-workspace.ts, apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/types.ts
Convert create/delete to accept arrays (1–5). Add BulkItemError and buildBulkResult. Change execute flows to iterate items, collect successes and per-item errors, and return aggregated CommandResult.
Desktop: New update tool & registration
apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/update-workspace.ts, apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/tools/index.ts
Add updateWorkspace tool (batch updates 1–5 items). Register it in tools index.
Desktop: ToolContext wiring
apps/desktop/src/renderer/routes/_authenticated/components/AgentHooks/hooks/useCommandWatcher/useCommandWatcher.ts
Expose updateWorkspace mutation on ToolContext and include it in memoized context returned to tools.
MCP: Create/Delete tool input changes
packages/mcp/src/tools/devices/create-workspace/create-workspace.ts, packages/mcp/src/tools/devices/delete-workspace/delete-workspace.ts
Change MCP tool inputs to array-based shapes (workspaces, workspaceIds, 1–5). Update descriptions and params passed to executeOnDevice accordingly.
MCP: New update_workspace tool & registry
packages/mcp/src/tools/devices/update-workspace/update-workspace.ts, packages/mcp/src/tools/devices/update-workspace/index.ts, packages/mcp/src/tools/index.ts
Add MCP server tool update_workspace, export its register, and include it in the allTools registration list. Tool validates deviceId and forwards updates to executeOnDevice.

Sequence Diagram

sequenceDiagram
    participant Agent as Agent/User
    participant Renderer as Desktop Tool
    participant Context as ToolContext
    participant MCP as MCP Server / executeOnDevice
    participant Aggregator as buildBulkResult

    Agent->>Renderer: Invoke bulk tool (1-5 items)
    Renderer->>Context: Read mutation functions (create/delete/update)
    loop for each item
        Renderer->>MCP: executeOnDevice / mutation (item)
        alt Success
            MCP-->>Renderer: item success
            Renderer->>Renderer: push to items[]
        else Failure
            MCP-->>Renderer: item error
            Renderer->>Renderer: push to errors[] (index, id, message)
        end
    end
    Renderer->>Aggregator: buildBulkResult(items, errors, itemKey, total)
    Aggregator-->>Agent: CommandResult (data summary + optional errors)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐇 I hopped through loops and gathered the scores,
Five little worktrees, not just one anymore,
Successes in a stack, errors tucked with care,
Bulk hops get things done — I leave no snare! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(mcp,desktop): bulk workspace operations' clearly and concisely summarizes the main change: adding bulk operations to workspace tools across both MCP and desktop layers.
Description check ✅ Passed The pull request description comprehensively covers all required template sections with clear details: summary of changes, specific API shapes, design rationale including bulk result handling and error context, and a test plan showing verification status.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 satya-patel/bulk-workspace-operations

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.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 31, 2026

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch
  • ✅ Electric Fly.io app

Thank you for your contribution! 🎉

The schema said name was optional but the handler errored if omitted.
Since renaming is the only supported operation, make it required at
the schema level so agents get a clear validation error upfront.
Copy link
Copy Markdown
Collaborator Author

@saddlepaddle saddlepaddle left a comment

Choose a reason for hiding this comment

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

PR Review: bulk workspace operations

Overall Assessment

Clean, well-structured PR. The code is consistent, well-typed, and follows existing patterns appropriately. LGTM.

What's Good

Shared bulk infrastructureBulkItemError and buildBulkResult in types.ts eliminate duplication across all three handlers. The generic helper is well-typed and produces a consistent response shape (items + summary + optional errors). This is a meaningful improvement over duplicating the logic.

Consistent API surface — All three tools follow the same contract:

  • create_workspace: { deviceId, workspaces: [...] }
  • delete_workspace: { deviceId, workspaceIds: [...] }
  • update_workspace: { deviceId, updates: [...] }
  • Response: { [key]: items[], summary: { total, succeeded, failed }, errors?: [] }

Partial failure semantics — Each item is processed independently with try/catch per iteration. One failure doesn't abort the batch. success: true when any item succeeds. This is the right behavior for workspace operations where items are independent.

Schema discipline — The follow-up commit (cb117a9) correctly tightened name to required in update_workspace after noticing the schema/handler mismatch. Good catch.

Clean MCP↔desktop boundary — The MCP layer stays thin (validate + executeOnDevice), and the desktop renderer handles the actual bulk loop. This separation is correct since workspace mutations require React Query context.

Minor Notes (non-blocking)

  1. taskId removed from create_workspace — The old create_workspace accepted an optional taskId param. This PR silently drops it. Confirmed taskId is not referenced in any workspace tool handler, and no callers in the codebase pass it to create_workspace, so this is safe. Worth noting for changelog purposes though.

  2. Error context fields on BulkItemError — The [key: string]: unknown index signature is pragmatic (allows name, branchName, workspaceId etc. as contextual fields per-tool). A discriminated union per tool would be more precise, but given these are serialized for MCP responses, the flexibility is fine here.

  3. 5 vs 25 item limit — Workspace ops cap at 5 items while task ops allow 25. This makes sense given workspace creation involves git worktree operations (heavier), but the asymmetry could surprise callers. The .describe() annotations document it clearly.

  4. Sequential processing — All three tools use for...of with await inside the loop (sequential). For workspace operations this is correct — creating worktrees in parallel could cause git conflicts. Just noting the intentional choice.

Verification

  • bun run typecheck: 17/17 packages pass
  • bun run lint: 1506 files checked, no issues

@saddlepaddle saddlepaddle merged commit 4ee87d5 into main Feb 1, 2026
13 checks passed
@Kitenite Kitenite deleted the satya-patel/bulk-workspace-operations branch February 5, 2026 01:35
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