Repository navigation
Description
Summary
Currently, a manager or owner can cancel (remove) individual items from an active order — but only while those items are still in pending status. Once kitchen staff mark an item as preparing or ready on the KDS, the trash icon disappears from the Orders page and there is no way to remove that item without first going to the KDS and reverting its status back to pending.
This is a real operational friction point: a customer changes their mind after the kitchen has already started on their food, or a manager wants to comp an item after it's been cooked.
Current behaviour (verified in code)
Frontend — Orders page
// frontend/src/app/(dashboard)/orders/page.tsx ~L986
{item.status === 'pending' && isOwnerOrManager && !paid && (
<button onClick={() => deleteItem(order.id, item.id)} ...>
<Trash2 size={14} />
</button>
)}The item.status === 'pending' guard is hard-coded. There is no path for a manager to remove a preparing or ready item from the Orders page UI.
Backend — item cancel route
// main/routes/index.ts ~L183
PATCH /api/orders/:orderId/items/:itemId/cancel- Role check: only
ownerormanager— ✅ already enforced - No item-status check — the backend will accept a cancel on a
preparingorreadyitem if called directly. The restriction is UI-only. - Handles edge case: if the last active item is cancelled, the whole order becomes
cancelledand the table is freed (fix Bug: Cancelling an order's last item leaves it in a broken empty-but-not-cancelled state #132).
Existing precedent — whole-order cancellation
Cancelling a whole order that is in progress already requires a manager PIN override (backend: main/routes/orders.ts ~L568-580). This pattern already exists in the codebase and the UI has a modal that collects the PIN.
Open questions for the team
Q1 — Should item removal in preparing/ready be allowed at all?
Option A — Yes, always (for owner/manager)
Allow it with a confirmation dialog, no PIN. Simple. No new setting. Risk: accidental removals are easy, and there is no audit trail for why items were removed after cooking started.
Option B — Yes, but require a manager PIN (like whole-order cancel)
Extend the existing override_pin pattern. When the item is preparing or ready, the trash icon opens a PIN dialog instead of a plain confirmation. The backend validates the PIN against any active owner/manager account. Consistent with existing UX precedent. Adds friction on purpose.
Option C — Owner-configurable setting in Settings → KDS
Add a toggle: "Allow item removal after kitchen has started" (default: off). If off, the current behaviour is unchanged. If on, item removal in preparing/ready status is allowed (possibly still requiring a PIN — could be a second toggle or always required). More flexible for different businesses.
Option D — Block it entirely
Keep the current hard block. Managers must go to KDS, revert the item to pending, then come back to the Orders page to remove it. Safest for kitchen workflow but terrible UX.
Q2 — If we allow it, should there be an audit log entry?
Right now, item cancellations are recorded via cloudSync.recordOrderChanged(orderId, 'order.item_cancelled') but there is no free-text reason captured for in-progress items the way whole-order cancellation captures a cancellation_reason. Should a reason be required?
Q3 — Should the KDS reflect the removal immediately?
Currently, deleteItem calls notifyKdsUpdate() on the backend, so the KDS will refresh. But if the item was already showing as preparing on the kitchen screen, the card will simply disappear. Should there be a visual indicator or sound on the KDS side when an in-progress item is voided? (Out of scope for this issue, but worth noting.)
Q4 — What roles should this gate apply to?
Currently both owner and manager can remove pending items. Should removing an in-progress item require strictly owner-level, or is manager sufficient (with or without a PIN)?
Recommendation
The PIN override approach (Option B) is the cleanest for this codebase because:
- The pattern already exists —
CancelModalhas anoverridePinfield, the backend already hascheckPinRateLimitand PIN validation logic inroutes/orders.ts. - It adds meaningful friction without a new Settings page.
- It is self-documenting: the PIN prompt message can say "Item is in progress — manager PIN required to remove".
The settings toggle (Option C) becomes relevant if different businesses have very different policies (e.g. a QSR might never want to allow it; a sit-down restaurant might always want it). This could be deferred to a follow-up.
If Option B is chosen, the changes needed are:
- Frontend: change the
item.status === 'pending'guard to also show the trash button forpreparing/readyitems, but route those into a PIN-collection modal instead of the plain confirm dialog. - Backend
/items/:itemId/cancel: add an optionaloverride_pinfield; if the item's current status ispreparingorready, require the PIN (same validation as the order-level cancel).
Files to change (if Option B)
frontend/src/app/(dashboard)/orders/page.tsx—deleteItemfunction (~L458), item trash button condition (~L986), extendCancelModalor add a separateItemCancelModalstatemain/routes/index.ts—PATCH /api/orders/:orderId/items/:itemId/cancelhandler (~L183), addoverride_pincheck when item status ispreparing/ready
Related
- Whole-order cancel with PIN:
main/routes/orders.ts ~L568-590 - Item cancel backend:
main/routes/index.ts ~L183-303 - KDS update notification: both routes call
notifyKdsUpdate()after mutation
Activity
itsbkm commentedon Jul 25, 2026
Decision — void flow for in-progress items
Resolves Q1–Q4 above: Option B, extended (manager-PIN-gated), with concrete financial/inventory/KDS behavior spelled out below.
The existing pending-item workflow is unchanged — trash icon, immediate delete, no PIN, exactly as today. This only adds a new path for items already
preparing/ready.What "void" does
override_pinpattern from whole-order cancel (checkPinRateLimit+ PIN validation inmain/routes/orders.ts ~L568-590), not a new mechanism.UI
pendingitem → unchanged: trash icon (Trash2), immediate delete, no PIN.preparing/readyitem → same icon slot, but shows 🚫 (U+1F6AB) instead of trash, and opens the PIN-gated void flow instead of a plain confirm.Implementation sketch
main/routes/index.ts—PATCH /api/orders/:orderId/items/:itemId/cancelgains anoverride_pinfield. When the item's current status ispreparing/ready, the PIN is required and validated. On success: insert the negative bill line, deduct inventory, and mark the itemvoidedwith avoided_attimestamp instead of hard-deleting it.voided, distinct fromcancelled(which currently only covers pre-kitchen removal). Item stage-change endpoints must reject any transition once an item isvoided.KdsTabsView.tsx/KdsKanbanBoard.tsx— rendervoideditems with a red strikethrough and disable their stage-advance controls.voided_atis more than 15 minutes old (same shape as other time-windowed KDS filtering already in the codebase).deleteItemstays as-is forpending; a newvoidItempath reuses theCancelModalPIN-collection pattern and calls the extended cancel endpoint.Out of scope
feat(orders): void in-progress items with manager PIN (#150)
itsbkm commentedon Jul 26, 2026
Reviewed the fix on main (commit
fabbe65). It covers the agreed void flow:override_pinwith the existing owner/manager PIN pattern and rate limitvoid_adjustmentbill line, marks the original itemvoided, and setsvoided_atvoidedOne note: the final implementation leaves inventory deducted / does not restock, which matches the operational intent that the item was already prepared/consumed.
Verification run on 2026-07-26:
npm run lintpassednpm run buildpassednpm testpassedClosing as fixed.
itsbkm commentedon Jul 26, 2026
Clarification on inventory wording:
Inventory handling is intentional and status-dependent:
pending, it follows the existing cancel path and inventory is not treated as consumed by that cancellation.preparingorready, voiding it does not restock inventory because the item has already been prepared/consumed operationally.Void: <item name>adjustment line, so the customer can clearly see that the item was revoked/comped instead of it silently disappearing.So the intended model is: pre-kitchen cancellation removes the item; post-kitchen void keeps the consumed inventory state and offsets the customer-facing bill with a negative line.
fix(deps): resolve security alerts #145-#150 (#1433)