Skip to content

Add InPreparation intermediate state to kitchen item workflow#52

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-in-preparation-state-again
Draft

Add InPreparation intermediate state to kitchen item workflow#52
Copilot wants to merge 2 commits intomainfrom
copilot/add-in-preparation-state-again

Conversation

Copy link
Contributor

Copilot AI commented Mar 4, 2026

Kitchen items previously only had two states (AwaitingPreparationFinished), making it impossible for cooks to signal that work has started on an item. This adds InPreparation as an intermediate state with a full AwaitingPreparation → InPreparation → Finished transition chain.

Backend (KitchenService)

  • Enums: Added InPreparation = 1 to KitchenOrderItemState and KitchenOrderItemDtoState with explicit ordinal values to preserve cast-based DTO conversion
  • Entity/DTO: Added nullable StartedAt: DateTimeOffset? to KitchenOrderItem and KitchenOrderItemDto; mapped in DtoConverter
  • New event: KitchenItemInPreparationEvent + FastFoodConstants.EventNames.KitchenItemInPreparation = "kitcheniteminpreparation" + dead letter constant
  • SetItemAsInPreparation(Guid id): Validates state is AwaitingPreparation, sets State = InPreparation, stamps StartedAt, publishes kitcheniteminpreparation event
  • SetItemAsFinished: Now requires InPreparation state (rejects AwaitingPreparation); uses StartedAt for preparation duration metric
  • GetPendingOrders/GetPendingItems: Include InPreparation items (not yet finished)
  • New endpoint: POST api/kitchenwork/iteminpreparation/{id}
  • Dead letter handler for kitcheniteminpreparation in DeadLetterHandlerController

Frontend proxy (FrontendKitchenMonitor ASP.NET host)

  • Proxy endpoint POST api/kitchenwork/iteminpreparation/{id} → Dapr invoke to KitchenService
  • FrontendKitchenMonitorEventHandlerController subscribes to kitcheniteminpreparation topic and broadcasts kitchenorderupdated via SignalR

Frontend Vue (FrontendKitchenMonitor SPA)

  • apiClient.js: startOrderItemPreparation(itemId)POST /api/kitchenwork/iteminpreparation/${itemId}
  • kitchenStore.js: startOrderItemPreparation action
  • WorkMonitor.vue: Three-state rendering with correct sort order (Awaiting → InPreparation → Finished):
<!-- AwaitingPreparation -->
<button data-testid="start-item-btn" @click="startOrderItem(item.id)">Start</button>

<!-- InPreparation -->
<span class="animate-pulse ..." data-testid="item-in-preparation-{id}">In Progress</span>
<button data-testid="finish-item-btn" @click="finishOrderItem(item.id)">Finish</button>

<!-- Finished -->
<span data-testid="item-finished-{id}">Finished</span>

Dark mode classes added to all new and updated UI elements.

Tests

  • KitchenServiceTests: Updated SetItemAsFinished tests to transition through InPreparation first; added tests for SetItemAsInPreparation (happy path, already in-preparation, already finished, not found) and SetItemAsFinished on AwaitingPreparation item (invalid transition)
  • KitchenWorkControllerTests (both KitchenService and FrontendKitchenMonitor): Tests for new iteminpreparation endpoint
  • FrontendKitchenMonitorEventHandlerControllerTests: New test file for kitcheniteminpreparation subscription handler
  • kitchenStore.test.js: Test for startOrderItemPreparation action

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • registry.npmmirror.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install 53 -j ACCEPT (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --prefer-offline (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

[DEMO] Kitchen Items: Add "In Preparation" intermediate state between "Awaiting Preparation" and "Finished"

Work Item Details

Note: Please focus on the descriptions and information that provide context about the task requirements, functionality, and implementation details. Dates, priorities, and administrative metadata are less relevant for coding tasks.

Description

Currently, kitchen items in the FrontendKitchenMonitor and KitchenService only support two states: AwaitingPreparation and Finished. A cook can only mark an item as finished — there is no way to indicate that preparation has started. This makes it impossible for other cooks to see which items are already being worked on, leading to potential double-work or confusion during busy periods.
This work item introduces a new InPreparation state between AwaitingPreparation and Finished. A cook will first click a "Start" button to claim an item (transitioning it to InPreparation), and then click "Finish" when done. The state transition chain becomes:
AwaitingPreparation → InPreparation → Finished
Scope: KitchenService backend + FrontendKitchenMonitor frontend only. The OrderService and FrontendCustomerOrderStatus are not in scope — the OrderService continues to consume only the existing kitchenitemfinished event.

Backend Changes (KitchenService)

  1. Add InPreparation value to KitchenOrderItemState enum in KitchenOrderItemState.cs — insert between AwaitingPreparation (0) and Finished. Assign explicit ordinal values to all members to avoid breaking the DTO cast.

  2. Add InPreparation value to KitchenOrderItemDtoState enum in KitchenOrderItemDtoState.cs — matching ordinal to the entity enum.

  3. Add StartedAt property to KitchenOrderItem entity in KitchenOrderItem.cs — nullable DateTimeOffset? to record when preparation started, consistent with existing CreatedAt/FinishedAt pattern.

  4. Add StartedAt property to KitchenOrderItemDto in KitchenOrderItemDto.cs and update the DtoConverter to map it.

  5. Add new SetItemAsInPreparation(Guid id) method to IKitchenService and implement in KitchenService.cs:

    • Find the item across all orders in _mockStorage
    • Validate current state is AwaitingPreparation (throw InvalidOperationException otherwise)
    • Set State = InPreparationStartedAt = DateTimeOffset.UtcNow
    • Publish new kitcheniteminpreparation Dapr pub/sub event
    • Return the updated item as DTO
  6. Update SetItemAsFinished in KitchenService.cs — validate that item is in InPreparation state (not AwaitingPreparation) before allowing finish. Record observability metric for preparation duration using StartedAt.

  7. Add new KitchenItemInPreparationEvent class in KitchenService.Common/Events/ — matching the pattern of KitchenItemFinishedEvent with OrderId and ItemId properties.

  8. Add new event name constant KitchenItemInPreparation = "kitcheniteminpreparation" to FastFoodConstants.EventNames.

  9. Add dead letter constant DeadLetterKitchenItemInPreparation in FastFoodConstants.EventNames and add handler in DeadLetterHandlerController.cs.

  10. Add new endpoint POST api/kitchenwork/iteminpreparation/{id} to KitchenWorkController that calls SetItemAsInPreparation.

  11. Update GetPendingOrders/GetPendingItems in KitchenService.cs — items with InPreparation state should still be included in pending results (they are not finished yet).

  12. Update backend unit tests:
    * KitchenServiceTests.cs — add tests for SetItemAsInPreparation ...

Work item: AB#361
Created via Azure DevOps


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: marc-mueller <13311299+marc-mueller@users.noreply.github.com>
Copilot AI changed the title [WIP] Add 'In Preparation' state for kitchen items Add InPreparation intermediate state to kitchen item workflow Mar 4, 2026
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.

2 participants