Skip to content

Delete an issue, from every surface that shows one - #139

Merged
imshashank merged 12 commits into
mainfrom
issues/delete-an-issue
Aug 7, 2026
Merged

imshashank merged 12 commits into
mainfrom
issues/delete-an-issue

Conversation

@imshashank

@imshashank imshashank commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Deleting an issue existed everywhere except in the product. deleteIssue in packages/core, DELETE /api/issues/[id] and the delete_issue MCP tool were all there, and nothing under apps/web/src ever 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

Surface How
Issue row, in every list (team, my issues, project) Overflow menu, revealed on hover and on focus
Board card, which also covers the standup board Overflow menu on the card, never on the card being dragged
Issue detail page and the peek, which share IssueDetailView Header menu
Multi select bar Delete button, confirmed with the count
Keyboard mod+shift+backspace, the binding Linear uses

Sprint lists render their own link rows from a server shaped CycleView rather than from Issue, so they are left alone; the row is a link straight to the issue page, where delete lives.

The shortcut is registered through useHotkey in the issues scope and shows up in the shortcuts sheet. It is deliberately quiet when something else owns the keyboard: ownsKeyboardLayer makes 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

useDeleteIssues snapshots every issues query, 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:

  • deleteIssue already 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 own update action alongside the delete.
  • The delta bridge dropped a deleted row from lists but left the detail cache alone. A tab sitting on the deleted issue now forgets it and falls back to the not found state; a tab sitting on its parent loses the sub issue entry.

Authorization

issue:delete is a member level permission. Guests and contributors do not have it, and loadIssue scopes 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 through permissionsFor(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 GET and PATCH beside 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.

  • Adds optimistic deletion with rollback and partial-bulk-failure reconciliation.
  • Updates realtime processing and core deletion actions to reconcile deleted issues and promoted children across clients.
  • Adds shared issue-reference validation and broad deletion-focused test coverage.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/web/src/features/issues/issue-deletion.tsx Centralizes permission-aware confirmation and runs completion callbacks only after successful deletion.
apps/web/src/lib/query/use-issues.ts Implements optimistic bulk deletion, exact rollback, partial-success reconciliation, and detail-cache cleanup.
apps/web/src/lib/realtime/delta-bridge.tsx Resets deleted detail queries and removes deleted children from cached parent details.
packages/core/src/work/issue-service.ts Publishes synchronized updates for children promoted when their parent issue is deleted.
apps/web/src/app/api/issues/[id]/route.ts Validates and resolves issue references before deletion and returns the deleted issue identity.

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
  end
Loading

Reviews (3): Last reviewed commit: "test(views): give the views workspace fi..." | Re-trigger Greptile

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.
@vercel

vercel Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orbit Ready Ready Preview Aug 7, 2026 10:03am

Request Review

@github-actions github-actions Bot added tests Test coverage and test infrastructure area: web The Next.js app and its UI area: mcp The MCP server, its tools and its OAuth area: issues Issues, lists and boards labels Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This 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.

Changes

Issue deletion

Layer / File(s) Summary
Deletion contracts and backend behavior
packages/shared/..., packages/core/..., apps/web/src/app/api/issues/[id]/route.ts, apps/web/tests/app/api/issues/delete-issue.test.ts
Issue references and deletion responses use shared schemas. Parent deletion promotes children and publishes update actions.
Bulk mutation and cache reconciliation
apps/web/src/lib/query/..., apps/web/src/lib/realtime/..., apps/web/tests/lib/query/..., apps/web/tests/lib/realtime/...
Deletion removes issues from list and detail caches, supports partial failures, refreshes related queries, and applies realtime deletion deltas.
Deletion context and interaction primitives
apps/web/src/features/issues/workspace-provider.tsx, apps/web/src/features/issues/issue-deletion.tsx, apps/web/src/lib/keyboard/..., apps/web/src/lib/interaction.ts, related tests
Workspace roles control deletion access. The provider manages confirmation state, callbacks, and deletion shortcuts.
Issue-view deletion actions
apps/web/src/features/issues/{bulk-edit-bar,issue-actions,issue-card,issue-detail,issue-list,issue-peek,issue-row}.tsx, apps/web/tests/features/issues/...
Lists, rows, cards, bulk editing, detail views, and peek views expose authorized deletion actions and completion behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Possibly related PRs

  • Noveum/orbit#11: Directly extends earlier issue deletion, cache synchronization, and workspace-provider paths.
  • Noveum/orbit#12: Also changes delta-bridge.tsx realtime synchronization.
  • Noveum/orbit#89: Also changes use-issues.ts issue-list reconciliation and rollback behavior.

Suggested reviewers: pulkitxm

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: adding issue deletion across all product surfaces that display issues.
Description check ✅ Passed The description directly explains the deletion surfaces, permissions, confirmations, cache handling, realtime updates, and API changes.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch issues/delete-an-issue

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (2)
apps/web/tests/features/issues/issue-deletion.test.tsx (1)

11-12: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Use the @/ alias for application modules.

Replace the relative imports, dynamic imports, and mock.module specifier 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/web must 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 win

Use 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 surfaceHover and 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

📥 Commits

Reviewing files that changed from the base of the PR and between 76b38cc and 887b118.

📒 Files selected for processing (35)
  • apps/web/src/app/api/issues/[id]/route.ts
  • apps/web/src/features/issues/bulk-edit-bar.tsx
  • apps/web/src/features/issues/issue-actions.tsx
  • apps/web/src/features/issues/issue-card.tsx
  • apps/web/src/features/issues/issue-deletion.tsx
  • apps/web/src/features/issues/issue-detail.tsx
  • apps/web/src/features/issues/issue-list.tsx
  • apps/web/src/features/issues/issue-peek.tsx
  • apps/web/src/features/issues/issue-row.tsx
  • apps/web/src/features/issues/workspace-provider.tsx
  • apps/web/src/lib/interaction.ts
  • apps/web/src/lib/keyboard/binding.ts
  • apps/web/src/lib/keyboard/index.ts
  • apps/web/src/lib/query/schemas.ts
  • apps/web/src/lib/query/sync.ts
  • apps/web/src/lib/query/use-issues.ts
  • apps/web/src/lib/realtime/delta-bridge.tsx
  • apps/web/tests/app/api/issues/delete-issue.test.ts
  • apps/web/tests/components/ui/cursor-hover.test.tsx
  • apps/web/tests/features/filters/filter-bar.test.tsx
  • apps/web/tests/features/issues/board.test.tsx
  • apps/web/tests/features/issues/issue-deletion.test.tsx
  • apps/web/tests/features/issues/issue-detail-delete.test.tsx
  • apps/web/tests/features/issues/issue-link.test.tsx
  • apps/web/tests/features/issues/issue-list.test.tsx
  • apps/web/tests/features/issues/my-issues-view.test.tsx
  • apps/web/tests/features/issues/workspace-provider.test.tsx
  • apps/web/tests/features/standup/standup-board.test.tsx
  • apps/web/tests/lib/keyboard/binding.test.ts
  • apps/web/tests/lib/query/use-issues.test.tsx
  • apps/web/tests/lib/realtime/delta-bridge.test.tsx
  • packages/core/src/work/issue-service.ts
  • packages/core/tests/work/issue-service.test.ts
  • packages/mcp-server/src/tools/workspace.ts
  • packages/shared/src/validators/issue.ts

Comment thread apps/web/src/lib/interaction.ts Resolved
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.

This branch was successfully deployed

1 active deployment
Preview — 64c7f2cc Deployed Aug 7, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: issues Issues, lists and boards area: mcp The MCP server, its tools and its OAuth area: web The Next.js app and its UI tests Test coverage and test infrastructure

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant