feat: move boards between workspaces
Summary
Adds the ability to move a board (and all its contents) from one workspace to another. Closes #344.
- New
board.moveAPI mutation with dual permission checks (source + target workspace) - "Move to workspace" menu item in the board dropdown
- Workspace picker modal with warning about card member clearing
- Auto-resolves slug conflicts in the target workspace by appending a UID suffix
Design decisions
Per @hjball's comment about handling comments, activity, and assignees:
| Entity | References | Workspace-scoped? | Behaviour on move |
|---|---|---|---|
| Card assignees | workspaceMembers.id |
Yes | Cleared — these reference workspace-scoped member IDs that may not exist in the target workspace. User sees a warning before confirming. |
| Comments | users.id |
No | Preserved — comments reference the global user UUID, not workspace membership. They'll display correctly even if the author isn't a member of the target workspace. |
| Activity log | users.id |
No | Preserved — same as comments, activity entries reference global user IDs. Full history is retained. |
Permission model
- Requires
board:editpermission (or creator) in the source workspace - Requires
board:createpermission in the target workspace - Templates and archived boards cannot be moved
What moves
Everything: lists, cards, labels, checklists, checklist items, comments, activity, attachments. All of these reference the board (directly or transitively), not the workspace — so updating board.workspaceId is sufficient.
What gets cleared
Only _card_workspace_members entries (card assignees), because they join through workspace-scoped member IDs. Users can reassign cards after the move.
Files changed
packages/db/src/repository/board.repo.ts—moveToWorkspace()transactional functionpackages/api/src/routers/board.ts—board.movemutationapps/web/src/views/board/components/BoardDropdown.tsx— menu itemapps/web/src/views/board/components/MoveBoardForm.tsx— new componentapps/web/src/views/board/index.tsx— modal registrationapps/web/src/locales/— extracted + compiled translations
Test plan
- [ ] Move a board between workspaces — verify board appears in target, disappears from source
- [ ] Verify card member assignments are cleared after move
- [ ] Verify comments and activity history are preserved
- [ ] Test slug conflict: create boards with same name in both workspaces, move one
- [ ] Verify templates cannot be moved (menu item hidden)
- [ ] Verify archived boards show error message
- [ ] Verify user without
board:createin target workspace cannot move
🤖 Generated with Claude Code
Automated Code Review — Cage Match Edition
Two AI reviewers independently analyzed this PR:
MaxwellMergeSlam's Review 🤼
Verdict: APPROVE
Summary: A clean, well-architected feature that moves boards between workspaces with proper permission gates and data integrity — this PR gets it done without breaking a sweat.
Tyler Durden: "It's only after we've lost everything that we're free to do anything." And it's only after we've properly cleared workspace-scoped card assignments that we're free to move a board anywhere.
Findings:
-
board.repo.ts:moveToWorkspace— The transactional approach is correct. UpdatesworkspaceId, then walks theboards → lists → cards → _card_workspace_memberschain to clear orphaned assignments. Two SELECT queries inside the transaction (lists, then cards) before the DELETE is clean and readable. -
board.ts:movemutation — Dual permission model (assertCanEditon source,assertPermission("board:create")on target) is the right call. Template and archive guards are present. Slug conflict auto-resolution viagenerateUID()suffix matches the existing pattern used inboard.create. -
board.ts:~line 680— There's a secondary query to fetchboardDetails.slugusingctx.db.query.boards.findFirst()inline rather than through the repo layer. This works but breaks the pattern slightly — every other board query in this file goes throughboardRepo. Minor consistency nit, not a blocker. -
MoveBoardForm.tsx— Clean component. UsesswitchWorkspace()on success to redirect the user to the target workspace's boards page, which is good UX. The "no other workspaces" empty state is handled. Warning text about member clearing is present. -
MoveBoardForm.tsx:27—availableWorkspacesis filtered bypublicIdto exclude the current workspace. But there's no filtering for permission — a user might see workspaces where they're a guest withoutboard:createpermission. The server will reject it (permission check is in the mutation), so this isn't a security issue — but it's a minor UX annoyance (user selects workspace, gets error). Could filter byrole !== "guest"client-side as a heuristic. -
BoardDropdown.tsx— Menu item placement is logical: after archive, before favorites. Gated on!isTemplate && canEditBoard. TheHiArrowRightOnRectangleicon is a reasonable choice.
The Good:
- The PR description is chef's kiss — the entity reference table showing what's workspace-scoped vs global is exactly what a reviewer needs. Henry shouldn't have to dig through schema files to understand the design.
- Transaction in the repo layer keeps the mutation atomic.
- Follows every existing pattern: permission helpers, repo functions, modal system, Lingui translations, conventional commit message.
- Net new code is ~190 lines (excluding locale files). Tight.
The Concerns:
- Minor UX: Guest users might see workspaces they can't move to in the dropdown. Server rejects it safely, but an error popup for a predictable case isn't ideal.
- Minor consistency: The inline
ctx.db.query.boards.findFirst()in the mutation should ideally go through the repo layer. - No tests: There are no new unit/integration tests for
board.moveormoveToWorkspace. The existinghelpers.test.tspattern shows tests are valued in this codebase. Not blocking for a first pass, but would strengthen confidence.
Neo: "I know kung fu." This PR knows its schema. APPROVE.
KelvinBitBrawler's Review
Verdict: REQUEST_CHANGES
Summary: This PR introduces a functional board movement feature, complete with proper permission checks and transactional integrity, but suffers from thermal inefficiency and a frosty oversight in slug generation.
Findings:
packages/api/src/routers/board.ts: L658, L667, L707 - Multiple, redundant database queries are executed to retrieve board information (workspaceId,type,isArchived,slug). This is a gross thermal inefficiency. You're hitting the database repeatedly when a single, well-structured query could pull all necessary data. HAL 9000: "I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do." Your code isn't.packages/api/src/routers/board.ts: L712 - The fallback for slug generationgenerateSlug(input.boardPublicId)is utterly devoid of human sense. Slugs are meant to be readable identifiers, not a raw public ID. If the original board slug is missing, you should be deriving it from the board's name, not some cryptic identifier. This will result in an unreadable slug, and that's just poor form, a literal cold shoulder to user experience.
The Good:
packages/db/src/repository/board.repo.ts: L963-L1017 - ThemoveToWorkspacefunction is wrapped in adb.transaction, ensuring atomicity. This cold, hard transactional integrity is precisely what's needed for data consistency. Good.packages/api/src/routers/board.ts: L680, L700 - Permission checks for both the source (board:edit) and target (board:create) workspaces are explicitly handled and correctly enforced. Zero tolerance for unauthorized access.packages/api/src/routers/board.ts: L714-L716 - Automated slug conflict resolution by appending a UID suffix is a practical and robust solution to prevent data collisions. No icy stalemates there.apps/web/src/views/board/components/MoveBoardForm.tsx: L25, L31 - Clear user feedback with success and error popups, and the explicit warning about clearing card member assignments, shows a consideration for the end-user. It's not a complete deep freeze, but it's a good step.
The Concerns:
- The redundant database calls in
packages/api/src/routers/board.tsmust be refactored into a single, comprehensive query. This isn't just about performance; it's about not writing unnecessary boilerplate that obscures intent. Deckard: "Gifts for the boss, huh?" You're bringing too many separate gifts to the same table. - The
generateSlug(input.boardPublicId)fallback needs to be reconsidered. IfboardDetails?.slugis null, the system should retrieve the board'snameto generate a meaningful slug, rather than using thepublicId. This is a basic expectation for user-friendly URLs.
Consensus & Resolution
Maxwell: APPROVE | Kelvin: REQUEST_CHANGES
Kelvin caught two valid issues that Maxwell missed:
- Redundant DB queries — 3 separate queries for the same board consolidated into 1
- Slug fallback —
generateSlug(input.boardPublicId)changed togenerateSlug(board.name)for readable URLs
Both fixes addressed in commit 2c2a349.
Hey @hjball — heads up, the diff stats on this PR look scary (50k+ lines) but that's almost entirely auto-generated locale files (18 of 24 changed files).
I've added a .gitattributes file that marks those as linguist-generated, so GitHub should now auto-collapse them in the diff view. The actual feature code is just 6 files:
packages/db/src/repository/board.repo.ts— repo function for the movepackages/api/src/routers/board.ts—board.movemutationpackages/api/src/routers/board-move.test.ts— testsapps/web/src/views/board/components/BoardDropdown.tsx— menu itemapps/web/src/views/board/components/MoveBoardForm.tsx— workspace picker modalapps/web/src/views/board/index.tsx— modal registration
This is great @nickmeinhold - please could you remove the locale changes from this PR (it's all handled automatically on merge now)
Thanks @hjball — locale changes removed in 4f11ed4 (re-aligned to upstream/main since the earlier removal had used a stale local main). PR's Files changed should now be free of locale/i18n diffs. Ready for another look.
Hey @nickmeinhold, couple of bits needed before we can merge this:
- Looks like the locale changes have snuck back in
- There's a couple of comments that need addressing
@hjball — all three comments addressed in 272011d, plus a regression test for the soft-deleted target workspace case (board-move.test.ts now has 11 tests, all passing). Also merged latest upstream/main to clear conflicts. Ready for another look when you have a moment 🙏
Conflicts resolved and CI is green again. The PR went stale purely from upstream drift (main moved ~32 commits ahead with the partner/Stripe/subscriptions work), not from anything outstanding on the review.
Merged latest main:
- All locale/i18n conflicts resolved by taking main's version, so the locale files are dropped from the diff entirely (verified:
git diff main -- locales/is empty).Files changedis back to just the 7 feature files. - One real code conflict in
workspace.repo.ts: main addedcreatedByto thegetByPublicIdselect while this branch addeddeletedAt(for the soft-delete guard). Kept both.
11/11 board-move tests passing, @kan/db and @kan/api typecheck clean, build check green. Ready for another look when you get a chance.