Repository navigation
Delete an issue, from every surface that shows one - #139
Conversation
deleteIssue already re-parented sub issues to the top level, but it did it silently: no sync id bump and no action, so every other tab kept a cached child pointing at a row that no longer exists. Each freed child now gets the transaction's sync id and its own update action alongside the delete. The DELETE route resolves the issue first, so it accepts an identifier like the GET and PATCH beside it, validates the path with a shared Zod schema, and answers with the id and identifier that went. The MCP tool now parses its issue reference with the same schema.
…her tabs useDeleteIssues replaces the unused single issue hook. It snapshots every issues query, drops the rows optimistically, and restores the snapshot verbatim when the server refuses. A bulk delete that fails half way keeps the issues that really went rather than resurrecting them. The delta bridge dropped a deleted row from lists but left the detail cache alone, so a tab sitting on the deleted issue kept painting it. It now forgets that detail and trims the row out of any parent's sub issue list. Deleting a parent also clears parentId on cached children so nothing points at a row that is gone.
…e key ownsKeyboardLayer reports whether the focused element sits inside an open menu, dialog or listbox, so a destructive surface shortcut can refuse to fire while one of those is holding the keyboard. revealOnCardHover is a named group variant of revealOnHover, for a control that must appear on its own card rather than on every card in the column that wraps it.
Deleting was reachable from the core service, the REST route and the MCP tool, and from nowhere in the product. It is now on the row overflow menu in every list, the board card menu, the issue detail header, the peek, the multi select bar, and mod+shift+backspace. Every path confirms first through the shared dialog. A single delete names the issue by identifier and title, a bulk delete names the count, and the copy says the loss is permanent instead of leaving people to guess. The shortcut stands down while a menu or the peek holds the keyboard, and it is listed in the shortcuts sheet. The affordance reads the same policy the server enforces, through permissionsFor, so a contributor or guest never sees it and is still refused if they reach the endpoint another way.
Biome wanted an optional chain at each site that asked whether deletion is both provided and allowed. The route test also resets the database once rather than before every case, which keeps a truncate off the critical path of five tests that only need their own workspace.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughThis PR adds authorized single and bulk issue deletion. It updates API validation, child-issue promotion, query-cache and realtime synchronization, deletion controls, keyboard shortcuts, navigation, and comprehensive tests. ChangesIssue deletion
Estimated code review effort: 4 (Complex) | ~60 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant User
participant IssueDeletionProvider
participant DeleteAPI
participant QueryCache
User->>IssueDeletionProvider: Confirm issue deletion
IssueDeletionProvider->>DeleteAPI: Send DELETE request per issue
DeleteAPI-->>IssueDeletionProvider: Return deleted id and identifier
IssueDeletionProvider->>QueryCache: Remove deleted issues and related details
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🧹 Nitpick comments (2)
apps/web/tests/features/issues/issue-deletion.test.tsx (1)
11-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the
@/alias for application modules.Replace the relative imports, dynamic imports, and
mock.modulespecifier with@/features/issues/.... Use the same alias in every reference so the mock targets the same resolved module.As per coding guidelines, modules inside
apps/webmust use the@/alias for cross-directory imports.Also applies to: 94-103
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/tests/features/issues/issue-deletion.test.tsx` around lines 11 - 12, Replace the relative workspace-provider imports, dynamic imports, and mock.module specifier in issue-deletion.test.tsx with the `@/features/issues/workspace-provider.tsx` alias, using it consistently so all references resolve to the same module.Source: Coding guidelines
apps/web/src/features/issues/issue-actions.tsx (1)
34-39: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse the shared interaction helper for hover colors.
Line 36 adds a raw color transition. Line 37 adds raw hover color classes. Replace these classes with
surfaceHoverand retain the focus outline classes.As per coding guidelines, hover and focus color transitions must use shared interaction helpers.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/features/issues/issue-actions.tsx` around lines 34 - 39, Update the class list in the issue action component to replace the raw color transition and hover background/text classes with the shared surfaceHover interaction helper. Preserve the existing layout, motion-reduction, and focus-visible outline classes.Sources: Coding guidelines, Learnings
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/features/issues/bulk-edit-bar.tsx`:
- Line 91: Update the danger action styling in the relevant bulk-edit bar
component to replace the raw hover:text-danger class with the shared interaction
helper from `@/lib/interaction.ts`. If no suitable helper exists, add a reusable
danger-action helper there, then apply it through the className while preserving
the existing danger styling.
In `@apps/web/src/features/issues/issue-deletion.tsx`:
- Around line 79-85: Update the confirm flow around remove.mutate in the
deletion component so onDeleted is invoked only from the mutation’s
complete-success callback, not immediately after starting the request. Preserve
failed issues in selection when bulk deletion partially fails, while keeping the
existing request cleanup and successful deletion behavior.
In `@apps/web/src/features/issues/issue-detail.tsx`:
- Around line 17-24: The delete hotkey handler in the issue detail component
must ignore events owned by another keyboard layer. Match IssueList by checking
ownsKeyboardLayer(event.target) before invoking askToDelete, and apply the same
guard to the additional handler around the referenced binding.
In `@apps/web/src/features/issues/issue-list.tsx`:
- Around line 154-158: Update the deletion binding near useIssueDeletion so its
enabled condition requires deletionTargets.length > 0, and add an early return
in the associated delete handler when deletionTargets is empty. Preserve
existing behavior when one or more targets are available.
In `@apps/web/src/lib/interaction.ts`:
- Around line 4-5: Update the shared revealOnCardHover utility to include
motion-reduce:transition-none alongside transition-opacity, ensuring
reduced-motion users receive no opacity transition while preserving the existing
reveal states and behavior.
In `@apps/web/tests/app/api/issues/delete-issue.test.ts`:
- Around line 67-75: Replace the suite-wide resetDatabase call in beforeAll with
the project’s existing per-test rollback wrapper, applying it around each test
while retaining the published reset and workspace/actor setup in beforeEach.
Ensure every test rolls back its database changes after completion and remove
the beforeAll truncation.
In `@apps/web/tests/features/issues/workspace-provider.test.tsx`:
- Around line 20-25: Replace the relative cross-feature imports with `@/` aliases:
in apps/web/tests/features/issues/workspace-provider.test.tsx lines 20-25, use
`@/features/issues/workspace-provider.tsx` and
`@/features/issues/issue-deletion.tsx`; in
apps/web/tests/features/issues/issue-detail-delete.test.tsx lines 9-10 and
71-79, update the workspace-provider imports, mocked module specifier, and
dynamic imports to the corresponding `@/features/issues/`... aliases.
---
Nitpick comments:
In `@apps/web/src/features/issues/issue-actions.tsx`:
- Around line 34-39: Update the class list in the issue action component to
replace the raw color transition and hover background/text classes with the
shared surfaceHover interaction helper. Preserve the existing layout,
motion-reduction, and focus-visible outline classes.
In `@apps/web/tests/features/issues/issue-deletion.test.tsx`:
- Around line 11-12: Replace the relative workspace-provider imports, dynamic
imports, and mock.module specifier in issue-deletion.test.tsx with the
`@/features/issues/workspace-provider.tsx` alias, using it consistently so all
references resolve to the same module.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 6dc16dd1-8780-4c34-beb3-4a90ea951e98
📒 Files selected for processing (35)
apps/web/src/app/api/issues/[id]/route.tsapps/web/src/features/issues/bulk-edit-bar.tsxapps/web/src/features/issues/issue-actions.tsxapps/web/src/features/issues/issue-card.tsxapps/web/src/features/issues/issue-deletion.tsxapps/web/src/features/issues/issue-detail.tsxapps/web/src/features/issues/issue-list.tsxapps/web/src/features/issues/issue-peek.tsxapps/web/src/features/issues/issue-row.tsxapps/web/src/features/issues/workspace-provider.tsxapps/web/src/lib/interaction.tsapps/web/src/lib/keyboard/binding.tsapps/web/src/lib/keyboard/index.tsapps/web/src/lib/query/schemas.tsapps/web/src/lib/query/sync.tsapps/web/src/lib/query/use-issues.tsapps/web/src/lib/realtime/delta-bridge.tsxapps/web/tests/app/api/issues/delete-issue.test.tsapps/web/tests/components/ui/cursor-hover.test.tsxapps/web/tests/features/filters/filter-bar.test.tsxapps/web/tests/features/issues/board.test.tsxapps/web/tests/features/issues/issue-deletion.test.tsxapps/web/tests/features/issues/issue-detail-delete.test.tsxapps/web/tests/features/issues/issue-link.test.tsxapps/web/tests/features/issues/issue-list.test.tsxapps/web/tests/features/issues/my-issues-view.test.tsxapps/web/tests/features/issues/workspace-provider.test.tsxapps/web/tests/features/standup/standup-board.test.tsxapps/web/tests/lib/keyboard/binding.test.tsapps/web/tests/lib/query/use-issues.test.tsxapps/web/tests/lib/realtime/delta-bridge.test.tsxpackages/core/src/work/issue-service.tspackages/core/tests/work/issue-service.test.tspackages/mcp-server/src/tools/workspace.tspackages/shared/src/validators/issue.ts
Both purge paths used removeQueries, which empties the cache entry but leaves a mounted observer holding its last result, so a tab sitting on the deleted issue kept rendering it in full, interactive, and never refetched. Only a manual reload showed it was gone. resetQueries clears the observer too. The two tests that claimed to cover this called setQueryData with no observer mounted, so getQueryData returning undefined passed whether the feature worked or not. The new test mounts a real useQuery, and its second case pins the distinction directly: after removeQueries the component still paints the old row, which is the bug.
The bulk edit bar hand rolled hover:text-danger at the call site, which puts a hover colour change outside the one module the project audits for motion and interaction. Add dangerAction and dangerMenuAction there and spend them instead. Every transition token now also carries motion-reduce:transition-none. The global reduced motion block in globals.css already collapses every transition-duration to 0.01ms with !important, so no viewer was actually receiving the fade, but the tokens are the auditable set and every other motion site in the app states the guard for itself. The new test walks the module's exports rather than restating a literal, so a token added later without the guard, off the duration scale, or transitioning a property that reflows fails by name.
confirm called onDeleted immediately after remove.mutate, which returns before the request does. A refused delete still navigated the detail page away, still closed the peek, and still cleared the list selection, so the person was told work was destroyed that in fact still existed, or lost their place for nothing. Moving the callback into the mutation's success path also leaves a partly failed bulk delete with its selection intact, which is what the surviving issues need. The optimistic cache already rolled back on error, so this is purely the callback ordering. The tests make the server refuse and assert the caller stayed put: the detail does not navigate, the peek does not close, the selection bar still counts two. They wait on the mutation reaching an error state on the client the test owns, not on the error toast, because other suites leave @/components/ui/toast.tsx mocked process wide and that made the same assertions pass alone and fail in a full run.
The detail surface bound the shortcut without asking whether another keyboard layer owned the key, so a menu or dialog holding focus could still raise the delete confirmation behind it. The list already checked ownsKeyboardLayer; the detail now matches it. The list binding also stayed registered when it had nothing to delete. HotkeyProvider calls preventDefault on a match before it runs the handler, so an empty list swallowed the keystroke to reach a handler that could only return. Requiring a target in enabled hands the key back and drops the entry from the shortcuts sheet while the action is out of reach, which is how the peek already gates the same binding.
CLAUDE.md asks for @/ inside apps/web, and the new files reached into ../../../src instead. mock.module keys on the resolved path, so the alias intercepts the relative import a component makes of its own neighbour just as the relative specifier did.
WorkspaceData gained a required role on this branch while #133 added these three fixtures on main. Neither side is wrong on its own; the merge is where they meet.
Deleting an issue existed everywhere except in the product.
deleteIssueinpackages/core,DELETE /api/issues/[id]and thedelete_issueMCP tool were all there, and nothing underapps/web/srcever called them. This wires deletion into every surface that shows an issue, gives it a keyboard path, a confirmation, bulk support, optimistic cache handling with a real rollback, and closes the two places where a delete used to leave stale rows in other people's tabs.Where deleting is reachable now
IssueDetailViewmod+shift+backspace, the binding Linear usesSprint lists render their own link rows from a server shaped
CycleViewrather than fromIssue, so they are left alone; the row is a link straight to the issue page, where delete lives.The shortcut is registered through
useHotkeyin theissuesscope and shows up in the shortcuts sheet. It is deliberately quiet when something else owns the keyboard:ownsKeyboardLayermakes the list handler stand down while an open menu, dialog or listbox holds focus, and the list handler is disabled outright while the peek is open so the peek's own handler wins on priority.Confirming
Deleting is irreversible, so every path confirms through the existing dialog primitives. A single delete names the issue by identifier and by title, so nobody deletes the wrong one. A bulk delete names the count. The copy says the loss is permanent and covers the comments, activity and history that go with it, rather than leaving the reader to work out how this differs from archiving. There is no archive affordance in the UI today, so the copy does not offer one.
Cache and realtime
useDeleteIssuessnapshots everyissuesquery, removes the rows optimistically, and restores the snapshot verbatim if the server refuses. A bulk delete that fails half way restores the lists and then re-removes only the issues that really went, instead of resurrecting them. On success the deleted issue's detail query is dropped and it is trimmed out of any parent's sub issue list.Two realtime gaps are fixed:
deleteIssuealready re-parented children to the top level, but silently: no sync id bump and no action. Another tab kept a cached child pointing at a row that no longer exists. Each freed child now gets the transaction's sync id and its ownupdateaction alongside thedelete.Authorization
issue:deleteis a member level permission. Guests and contributors do not have it, andloadIssuescopes the delete to a team the caller is on, so a member cannot reach into a team they are not in. That shape is right and is unchanged. What is new is that the UI reads the same policy throughpermissionsFor(role), so a role that cannot delete is never shown the affordance and the shortcut does not arm, while the server keeps refusing regardless of what the client does.The route also resolves the issue before deleting it, so it accepts a human identifier like the
GETandPATCHbeside it, validates the path segment with a shared Zod schema, and answers with the id and identifier that went. The MCP tool now parses its issue reference with that same schema.Sub issues
Children are promoted to top level. They are never deleted with the parent and never left pointing at a row that is gone. That was already the database behaviour; what was missing was telling anybody about it, on the server and in the cache.
Greptile Summary
This PR adds issue deletion across list, board, detail, peek, bulk-selection, keyboard, API, and MCP surfaces, with authorization-aware affordances and confirmation.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Sequence Diagram
sequenceDiagram actor User participant UI as Issue surface participant Mutation as useDeleteIssues participant API as DELETE /api/issues/[id] participant Core as deleteIssue participant Cache as Query cache participant RT as Realtime clients User->>UI: Confirm deletion UI->>Mutation: Delete selected issues Mutation->>Cache: Optimistically remove rows loop Each selected issue Mutation->>API: DELETE issue API->>Core: Resolve and delete issue Core-->>RT: Publish delete and child updates API-->>Mutation: Deleted issue identity end alt Every deletion succeeds Mutation->>Cache: Reset deleted details and trim sub-issues Mutation-->>UI: Run completion callback else A deletion fails Mutation->>Cache: Restore snapshot Mutation->>Cache: Remove only successfully deleted issues Mutation-->>UI: Preserve current surface state endReviews (3): Last reviewed commit: "test(views): give the views workspace fi..." | Re-trigger Greptile