Skip to content

fix(orders): make held-order restore single-consumer #256

Description

@khaira777

Summary

Held-order restore is not a single-consumer operation across terminals. Two terminals can read the same local hold and both proceed with restoration because the server DELETE is idempotent and the client ignores whether it actually deleted the row.

Current behavior

  • frontend/src/store/held-orders.ts:71-81 returns the local order after DELETE without checking the server deletion result.
  • main/routes/held-orders.ts:170-188 treats deleting an already-consumed hold as a successful no-op.

Expected behavior

Only one terminal should consume a held order. A stale second consumer should receive a conflict/not-found result and must not restore the order locally.

Acceptance criteria

  • Implement conditional consume semantics returning the order only when this request consumed it.
  • Handle stale local state and clear/reload the client cache appropriately.
  • Add a two-client concurrent restore test.
  • Preserve shared-floor behavior for listing holds unless ownership policy changes.

Relevant files

main/routes/held-orders.ts, frontend/src/store/held-orders.ts

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendBackend (Express/SQLite)area:frontendFrontend (React/Next.js)bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions