Skip to content

feat(server-app): forward table order moves - #1300

Merged
khaira777 merged 7 commits into
mainfrom
fm/ship-c1a0a11c-server-app-move-table
Oct 22, 2026
Merged

khaira777 merged 7 commits into
mainfrom
fm/ship-c1a0a11c-server-app-move-table

Conversation

@khaira777

@khaira777 khaira777 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1291

Intent

Implement the missing Server App (:3003) table-order move forwarder (POST /api/tables/:id/move-order with serverAppApiRateLimit and requireServerAppAuth), wire MoveTableModal into frontend/src/app/server-standalone/page.tsx with apiClient and formatPrice support and proper selectTable ref synchronization, and update docs/reference/api.md and tests/server-app-server-role.test.ts (Issue #1291). Follow Ponytail / YAGNI and Superpowers Obra TDD, validate through /no-mistakes, trigger @greptileai review this at apex on the PR, and resolve any review findings.

What Changed

  • Forward POST /api/tables/:id/move-order on the Server App (main/server-app.ts) with serverAppApiRateLimit and requireServerAppAuth, and update the Server App route inventory in docs/reference/api.md.
  • Extend MoveTableModal (frontend/src/components/tables/MoveTableModal.tsx) to accept optional apiClient and formatPrice props and disable header close and floor-filter controls while a move request is in flight.
  • Wire MoveTableModal into frontend/src/app/server-standalone/page.tsx when tables.orders.move is granted (including served active orders, /api/auth/me permission refreshes, and preserving pending send retry keys across table moves), and add backend, UI, and E2E test coverage.

Risk Assessment

✅ Low: The Server App table-order move forwarder, MoveTableModal integration, state/idempotency safeguards, documentation updates, and test coverage are well-bounded and match all acceptance criteria without defects.

Testing

Built the backend and static frontend, ran the Server App role integration suite (tests/server-app-server-role.test.ts), the MoveTableModal UI unit suite (tests/table-move-ui.test.ts), and the full 7-test Playwright E2E suite (frontend/e2e/server-app-ordering.spec.ts) against isolated Server App, KDS, and main POS servers, and captured reviewer-visible screenshots (server-app-move-table-modal.png, server-app-after-table-move.png) plus live API evidence (server-app-move-order-api.json); all checks and live scenarios passed.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Authenticated server opens MoveTableModal on the Server App, views the active dine-in order (including served orders) with tenant currency formatting, and moves the order to an available destination t… ✅ pass live ~/.no-mistakes/evidence/01M5JM9WEDW633KW519NBAHTNG/server-app-move-table-modal.png, ~/.no-mistakes/evidence/01M5JM9WEDW633KW519NBAHTNG/server-app-after-table-mo…
Adversarial auth and permission boundary: unauthenticated POST /api/tables/:id/move-order on the Server App is rejected with 401, the Move Table control stays hidden when tables.orders.move is omitted… ✅ pass live node tests/run-electron-node-test.cjs tests/server-app-server-role.test.ts, ~/.no-mistakes/evidence/01M5JM9WEDW633KW519NBAHTNG/server-app-move-order-api.json, and `npx playwright…
Adversarial UI and idempotency guards: tapping Move Table in the mobile ticket drawer closes the drawer before opening MoveTableModal, in-flight move requests disable the modal close/cancel buttons, a… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/server-app-ordering.spec.ts and npx ts-node --transpile-only -P tests/tsconfig.json tests/table-move-ui.test.ts

Server App MoveTableModal open with tenant-formatted order total and destination selection
Server App after moving active table order to destination table

Evidence: Live Server App POST /api/tables/:id/move-order API response and auth rejection evidence

{ "unauthenticatedMoveAttempt": { "status": 401, "body": { "error": "No token provided" } }, "authenticatedServerMoveViaUi": { "status": 200, "url": "http://127.0.0.1:43203/api/tables/tbl-8f0f263e/move-order",
"order": { "id": 1, "order_number": "ORD-20261023-0001", "table_id": "tbl-96737391", "total": 128.4 }, "sourceTable": { "id": "tbl-8f0f263e", "name": "Table 10", "status": "available" }, "targetTable": { "id": "tbl-96737391", "name": "Table 11", "status": "occupied" } } }

{
  "unauthenticatedMoveAttempt": {
    "status": 401,
    "body": {
      "error": "No token provided"
    }
  },
  "authenticatedServerMoveViaUi": {
    "status": 200,
    "url": "http://127.0.0.1:43203/api/tables/tbl-8f0f263e/move-order",
    "body": {
      "order": {
        "id": 1,
        "order_number": "ORD-20261023-0001",
        "table_id": "tbl-96737391",
        "customer_id": null,
        "user_id": "e2e-server",
        "type": "dine_in",
        "delivery_address": null,
        "expected_payment_method": null,
        "delivery_note": null,
        "guest_count": null,
        "special_instructions": null,
        "packaging_charge": 0,
        "delivery_charge": 0,
        "service_charge": 0,
        "charges_breakdown": null,
        "status": "pending",
        "subtotal": 120,
        "tax_amount": 8.4,
        "tax_breakdown": [
          {
            "title": "Tax",
            "rate": 7,
            "amount": 8.4
          }
        ],
        "tax_snapshot": [
          {
            "packId": "test-th-pack",
            "packVersion": "1.0.0",
            "effectiveFrom": "2026-01-01",
            "taxRounding": {
              "scope": "line",
              "method": "half_up",
              "decimalPlaces": 2,
              "remainderAllocation": "largest_remainder"
            },
            "payableRounding": {
              "increment": "0.01",
              "method": "half_up"
            },
            "appliedRuleIds": [
              "tax"
            ],
            "lines": [
              {
                "lineId": "line-0001:e2e-product",
                "categoryId": "standard",
                "categorySource": "explicit",
                "taxBehavior": "exclusive",
                "grossAmount": "120.00",
                "taxableBase": "120.00",
                "taxAmount": "8.40",
                "components": [
                  {
                    "ruleId": "tax",
                    "label": "Tax",
                    "type": "percent",
                    "rate": "7",
                    "baseRuleIds": [],
                    "amount": "8.40",
                    "roundingRemainder": "0"
                  }
                ]
              }
            ],
            "country": "TH",
            "currency": "THB",
            "merchantOverridesApplied": []
          }
        ],
        "packaging_tax_category_id": null,
        "delivery_tax_category_id": null,
        "service_charge_tax_category_id": null,
        "discount_amount": 0,
        "discount_type": null,
        "discount_value": null,
        "discount_reason": null,
        "round_off": 0,
        "total": 128.4,
        "cooking_started_at": null,
        "ready_at": null,
        "served_at": null,
        "completed_at": null,
        "cancelled_at": null,
        "cancellation_reason": null,
        "created_at": "2026-10-22 20:34:34",
        "updated_at": "2026-10-22 20:34:35",
        "online_platform": null,
        "external_order_id": null,
        "expected_payment_method_id": null,
        "items": [
          {
            "id": 1,
            "order_id": 1,
            "product_id": "e2e-product",
            "product_name": "E2E Coffee",
            "product_sku": null,
            "unit_price": 60,
            "quantity": 2,
            "inventory_deducted_quantity": 0,
            "inventory_product_id": null,
            "subtotal": 120,
            "tax_amount": 8.4,
            "tax_breakdown": "[{\"title\":\"Tax\",\"rate\":7,\"amount\":8.4}]",
            "tax_snapshot": "{\"packId\":\"test-th-pack\",\"packVersion\":\"1.0.0\",\"effectiveFrom\":\"2026-01-01\",\"taxRounding\":{\"scope\":\"line\",\"method\":\"half_up\",\"decimalPlaces\":2,\"remainderAllocation\":\"largest_remainder\"},\"payableRounding\":{\"increment\":\"0.01\",\"method\":\"half_up\"},\"appliedRuleIds\":[\"tax\"],\"lines\":[{\"lineId\":\"line-0001:e2e-product\",\"categoryId\":\"standard\",\"categorySource\":\"explicit\",\"taxBehavior\":\"exclusive\",\"grossAmount\":\"120.00\",\"taxableBase\":\"120.00\",\"taxAmount\":\"8.40\",\"components\":[{\"ruleId\":\"tax\",\"label\":\"Tax\",\"type\":\"percent\",\"rate\":\"7\",\"baseRuleIds\":[],\"amount\":\"8.40\",\"roundingRemainder\":\"0\"}]}],\"country\":\"TH\",\"currency\":\"THB\",\"merchantOverridesApplied\":[]}",
            "tax_type": "exclusive",
            "discount_amount": 0,
            "total": 128.4,
            "variant_selection": "null",
            "modifier_selection": "null",
            "special_instructions": null,
            "status": "pending",
            "created_at": "2026-10-22 20:34:34",
            "updated_at": "2026-10-22 20:34:34",
            "voided_at": null,
            "recipe_snapshot": null,
            "variant_id": null,
            "inventory_variant_id": null,
            "price_overridden": 0,
            "original_unit_price": null,
            "price_override_reason": null,
            "price_overridden_by": null,
            "price_overridden_at": null
          }
        ],
        "table": {
          "id": "tbl-96737391",
          "number": "Table 11",
          "capacity": 4,
          "status": "occupied",
          "floor": "Main Hall",
          "section": null,
          "position_x": null,
          "position_y": null,
          "kitchen_station_id": null,
          "is_active": 1,
          "created_at": "2026-10-22 20:34:32",
          "updated_at": "2026-10-22 20:34:35",
          "reservation_customer_id": null,
          "name": "Table 11"
        }
      },
      "sourceTable": {
        "id": "tbl-8f0f263e",
        "number": "Table 10",
        "capacity": 4,
        "status": "available",
        "floor": "Main Hall",
        "section": null,
        "position_x": null,
        "position_y": null,
        "kitchen_station_id": null,
        "is_active": 1,
        "created_at": "2026-10-22 20:34:32",
        "updated_at": "2026-10-22 20:34:35",
        "reservation_customer_id": null,
        "name": "Table 10",
        "reservation_customer_name": null,
        "reservation_customer_phone": null,
        "activeOrder": null,
        "current_order": null,
        "seated_at": null
      },
      "targetTable": {
        "id": "tbl-96737391",
        "number": "Table 11",
        "capacity": 4,
        "status": "occupied",
        "floor": "Main Hall",
        "section": null,
        "position_x": null,
        "position_y": null,
        "kitchen_station_id": null,
        "is_active": 1,
        "created_at": "2026-10-22 20:34:32",
        "updated_at": "2026-10-22 20:34:35",
        "reservation_customer_id": null,
        "name": "Table 11",
        "reservation_customer_name": null,
        "reservation_customer_phone": null,
        "activeOrder": {
          "id": 1,
          "order_number": "ORD-20261023-0001",
          "table_id": "tbl-96737391",
          "customer_id": null,
          "user_id": "e2e-server",
          "type": "dine_in",
          "delivery_address": null,
          "expected_payment_method": null,
          "delivery_note": null,
          "guest_count": null,
          "special_instructions": null,
          "packaging_charge": 0,
          "delivery_charge": 0,
          "service_charge": 0,
          "charges_breakdown": null,
          "status": "pending",
          "subtotal": 120,
          "tax_amount": 8.4,
          "tax_breakdown": [
            {
              "title": "Tax",
              "rate": 7,
              "amount": 8.4
            }
          ],
          "tax_snapshot": [
            {
              "packId": "test-th-pack",
              "packVersion": "1.0.0",
              "effectiveFrom": "2026-01-01",
              "taxRounding": {
                "scope": "line",
                "method": "half_up",
                "decimalPlaces": 2,
                "remainderAllocation": "largest_remainder"
              },
              "payableRounding": {
                "increment": "0.01",
                "method": "half_up"
              },
              "appliedRuleIds": [
                "tax"
              ],
              "lines": [
                {
                  "lineId": "line-0001:e2e-product",
                  "categoryId": "standard",
                  "categorySource": "explicit",
                  "taxBehavior": "exclusive",
                  "grossAmount": "120.00",
                  "taxableBase": "120.00",
                  "taxAmount": "8.40",
                  "components": [
                    {
                      "ruleId": "tax",
                      "label": "Tax",
                      "type": "percent",
                      "rate": "7",
                      "baseRuleIds": [],
                      "amount": "8.40",
                      "roundingRemainder": "0"
                    }
                  ]
                }
              ],
              "country": "TH",
              "currency": "THB",
              "merchantOverridesApplied": []
            }
          ],
          "packaging_tax_category_id": null,
          "delivery_tax_category_id": null,
          "service_charge_tax_category_id": null,
          "discount_amount": 0,
          "discount_type": null,
          "discount_value": null,
          "discount_reason": null,
          "round_off": 0,
          "total": 128.4,
          "cooking_started_at": null,
          "ready_at": null,
          "served_at": null,
          "completed_at": null,
          "cancelled_at": null,
          "cancellation_reason": null,
          "created_at": "2026-10-22 20:34:34",
          "updated_at": "2026-10-22 20:34:35",
          "online_platform": null,
          "external_order_id": null,
          "expected_payment_method_id": null
        },
        "current_order": {
          "id": 1,
          "order_number": "ORD-20261023-0001",
          "table_id": "tbl-96737391",
          "customer_id": null,
          "user_id": "e2e-server",
          "type": "dine_in",
          "delivery_address": null,
          "expected_payment_method": null,
          "delivery_note": null,
          "guest_count": null,
          "special_instructions": null,
          "packaging_charge": 0,
          "delivery_charge": 0,
          "service_charge": 0,
          "charges_breakdown": null,
          "status": "pending",
          "subtotal": 120,
          "tax_amount": 8.4,
          "tax_breakdown": [
            {
              "title": "Tax",
              "rate": 7,
              "amount": 8.4
            }
          ],
          "tax_snapshot": [
            {
              "packId": "test-th-pack",
              "packVersion": "1.0.0",
              "effectiveFrom": "2026-01-01",
              "taxRounding": {
                "scope": "line",
                "method": "half_up",
                "decimalPlaces": 2,
                "remainderAllocation": "largest_remainder"
              },
              "payableRounding": {
                "increment": "0.01",
                "method": "half_up"
              },
              "appliedRuleIds": [
                "tax"
              ],
              "lines": [
                {
                  "lineId": "line-0001:e2e-product",
                  "categoryId": "standard",
                  "categorySource": "explicit",
                  "taxBehavior": "exclusive",
                  "grossAmount": "120.00",
                  "taxableBase": "120.00",
                  "taxAmount": "8.40",
                  "components": [
                    {
                      "ruleId": "tax",
                      "label": "Tax",
                      "type": "percent",
                      "rate": "7",
                      "baseRuleIds": [],
                      "amount": "8.40",
                      "roundingRemainder": "0"
                    }
                  ]
                }
              ],
              "country": "TH",
              "currency": "THB",
              "merchantOverridesApplied": []
            }
          ],
          "packaging_tax_category_id": null,
          "delivery_tax_category_id": null,
          "service_charge_tax_category_id": null,
          "discount_amount": 0,
          "discount_type": null,
          "discount_value": null,
          "discount_reason": null,
          "round_off": 0,
          "total": 128.4,
          "cooking_started_at": null,
          "ready_at": null,
          "served_at": null,
          "completed_at": null,
          "cancelled_at": null,
          "cancellation_reason": null,
          "created_at": "2026-10-22 20:34:34",
          "updated_at": "2026-10-22 20:34:35",
          "online_platform": null,
          "external_order_id": null,
          "expected_payment_method_id": null
        },
        "seated_at": "2026-10-22 20:34:34"
      }
    }
  }
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 3 of 3 scenarios driven live against the product
Scenario Result Live Evidence
Authenticated server opens MoveTableModal on the Server App, views the active dine-in order (including served orders) with tenant currency formatting, and moves the order to an available destination t… ✅ pass live ~/.no-mistakes/evidence/01M5JM9WEDW633KW519NBAHTNG/server-app-move-table-modal.png, ~/.no-mistakes/evidence/01M5JM9WEDW633KW519NBAHTNG/server-app-after-table-mo…
Adversarial auth and permission boundary: unauthenticated POST /api/tables/:id/move-order on the Server App is rejected with 401, the Move Table control stays hidden when tables.orders.move is omitted… ✅ pass live node tests/run-electron-node-test.cjs tests/server-app-server-role.test.ts, ~/.no-mistakes/evidence/01M5JM9WEDW633KW519NBAHTNG/server-app-move-order-api.json, and `npx playwright…
Adversarial UI and idempotency guards: tapping Move Table in the mobile ticket drawer closes the drawer before opening MoveTableModal, in-flight move requests disable the modal close/cancel buttons, a… ✅ pass live npx playwright test --config=playwright.config.ts --project=chromium e2e/server-app-ordering.spec.ts and npx ts-node --transpile-only -P tests/tsconfig.json tests/table-move-ui.test.ts
  • node tests/run-electron-node-test.cjs tests/server-app-server-role.test.ts
  • npx ts-node --transpile-only -P tests/tsconfig.json tests/table-move-ui.test.ts
  • npm run build && npm run build:frontend
  • cd frontend && E2E_TASK_LOCAL_PORTS=1 E2E_BASE_URL=http://127.0.0.1:43101 E2E_KDS_BASE_URL=http://127.0.0.1:43102 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43103 npx playwright test --config=playwright.config.ts --project=chromium e2e/server-app-ordering.spec.ts
  • Live Playwright browser capture against tests/e2e-server.cjs producing server-app-move-table-modal.png, server-app-after-table-move.png, and server-app-move-order-api.json
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@khaira777 khaira777 changed the title feat: allow moving active table orders in the Server App feat(server-app): forward table order moves Oct 22, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptileai review this at apex

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: apex

[Medium impact] This PR appears safe to merge.

Summary

Adds table-order moves to the Server App.

  • The Server App forwards table-order moves to the main POS API.
  • Servers can move an active order from the standalone ordering page.
  • A table move keeps a pending order send tied to its original retry key.

No new actionable issues found. The six earlier findings are addressed in the current code. This review used code inspection and git diff --check; builds, tests, and browser checks were not run.

Diagram

sequenceDiagram
    participant Staff
    participant Page as Server App page
    participant Proxy as Server App :3003
    participant API as Main API :3001
    participant DB as SQLite
    Staff->>Page: Choose destination table
    Page->>Proxy: POST /api/tables/:id/move-order
    Proxy->>Proxy: Check session and Server App access
    Proxy->>API: Forward token and request body
    API->>API: Check move permission
    API->>DB: Move order and update both tables together
    DB-->>API: Updated order and tables
    API-->>Page: Move result
    Page->>Page: Preserve retry key and select destination
Loading

Reviews (4) · Last reviewed commit: "fix(server-app): include served orders i..." · Reviewed by Greptile

@khaira777 khaira777 changed the title feat(server-app): forward table order moves feat: allow moving active table orders in the Server App Oct 22, 2026
@khaira777 khaira777 changed the title feat: allow moving active table orders in the Server App feat(server-app): forward table order moves Oct 22, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptileai review this at apex

@khaira777
khaira777 force-pushed the fm/ship-c1a0a11c-server-app-move-table branch from 5dcd6a8 to a366c3b Compare October 22, 2026 19:39
@khaira777 khaira777 changed the title feat(server-app): forward table order moves feat: support moving active table orders in the Server App Oct 22, 2026
@khaira777 khaira777 changed the title feat: support moving active table orders in the Server App feat(server-app): forward table order moves Oct 22, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptileai review this at apex

@khaira777
khaira777 force-pushed the fm/ship-c1a0a11c-server-app-move-table branch from a366c3b to 7ffc066 Compare October 22, 2026 20:40
@khaira777 khaira777 changed the title feat(server-app): forward table order moves feat: support moving active table orders from the Server App Oct 22, 2026
@khaira777 khaira777 changed the title feat: support moving active table orders from the Server App feat(server-app): forward table order moves Oct 22, 2026
@khaira777

Copy link
Copy Markdown
Contributor Author

@greptileai review this at apex

@khaira777
khaira777 merged commit 0e30d5d into main Oct 22, 2026
24 checks passed
@khaira777
khaira777 deleted the fm/ship-c1a0a11c-server-app-move-table branch October 22, 2026 20:55
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.

feat(server-app): forward table order moves and wire MoveTableModal on :3003

1 participant