Skip to content

fix(kds): default view to kanban and persist mode - #1525

Merged
khaira777 merged 5 commits into
mainfrom
fm/flocafe-kds-default-view-and-clickability
Nov 8, 2026
Merged

khaira777 merged 5 commits into
mainfrom
fm/flocafe-kds-default-view-and-clickability

Conversation

@khaira777

@khaira777 khaira777 commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1515

Intent

also default kds screen to kanban board and remember what was last selected, for current installations, do not change default, keep track of default goign forward?
one thing i noticed, when i first logged into kds page, in browser, everything was there but i could not click anything, idk what was the issue, until i refreshed the page/screen works fine now, not sure why

What Changed

  • Changed the initial kds_default_view seed migration and fallback resolution across the main API, standalone KDS server, and frontend hooks from 'tabs' to 'kanban' using INSERT OR IGNORE so existing installations keep their stored setting.
  • Added PUT /api/kds/view on both the main API and standalone KDS server, broadened /api/settings/kds permissions to include kitchen.use, and wired KdsWorkspace and KdsDefaultViewCard to persist view selections to both the backend setting and localStorage (kds_view_override).
  • Added clearStaleBodyPointerEvents cleanup across useConfirm and AuthGuard, deferred Radix dropdown-to-dialog/logout transitions by a macrotask, and hydrated the dashboard auth store when logging in via /kds so the KDS screen remains interactive after authentication and modal dismissal.

Risk Assessment

✅ Low: All KDS default view, view-selection persistence, and Radix modal pointer-events cleanup changes are well-bounded, preserve existing installation defaults while defaulting fresh installs to Kanban, and resolve the prior round's test-quality and modal-selector findings cleanly.

Testing

Ran focused backend KDS contract and integration suites, UI regression checks (fixing the Kanban column header assertion in tests/ui-regressions-621-623-626.test.ts from Pending/Served to Waiting/Delivered), RTL, migration, schema health, upgrade path, authorization, and documentation checks, then built the backend and static frontend and drove all 5 live browser and API scenarios against an isolated FloCafe server with Playwright, capturing screenshots and JSON verification evidence. All checks and live scenarios passed.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Fresh installation defaults KDS screen to Kanban board on first login ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-default-kanban.png
Switching KDS view mode remembers the selected view in localStorage and backend across page reloads ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-persisted-tabs.png
Existing installation with kds_default_view='tabs' preserves Tabs default when opened without localStorage override ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-existing-install-preserved-tabs.png
Adversarial PUT /api/kds/view with an invalid view mode is rejected with HTTP 400 without corrupting stored setting ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-live-verification.json
Logging out via dropdown confirmation dialog and logging into KDS keeps document.body.style.pointerEvents clear and controls immediately clickable without refresh ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-clickable-after-dialog-login.png

KDS default Kanban view on fresh installation
KDS Tabs view persisted across page reload
KDS preserves existing Tabs default in a fresh browser session without localStorage override
KDS immediately clickable after dropdown/confirm dialog logout and re-login without refresh

Evidence: Live scenario verification output (JSON)

{ "scenario1_fresh_default_kanban": { "apiKdsInfo": { "language": null, "country": "TH", "kds_default_view": "kanban" }, "kanbanButtonAriaPressed": "true", "bodyPointerEvents": "" }, "scenario2_persist_view_selection": { "tabsPressedAfterClick": "true", "localOverrideAfterClick": "tabs", "backendKdsInfoAfterClick": { "language": null, "country": "TH", "kds_default_view": "tabs" }, "tabsPressedAfterReload": "true" }, "scenario3_existing_install_preserves_tabs": { "preservedTabsPressed": "true", "initialLocalStorageOverride": null }, "scenario4_adversarial_invalid_view": { "status": 400, "response": { "error": "kds_default_view must be "tabs" or "kanban"" }, "kdsDefaultViewUnchanged": "tabs" }, "scenario5_post_dialog_clickability": { "pointerEventsAfterSidebarLogout": "", "pointerEventsAfterKdsLogout": "", "pointerEventsAfterRelogin": "", "kanbanPressedAfterImmediateClick": "true" } }

{
  "scenario1_fresh_default_kanban": {
    "apiKdsInfo": {
      "language": null,
      "country": "TH",
      "kds_default_view": "kanban"
    },
    "kanbanButtonAriaPressed": "true",
    "bodyPointerEvents": ""
  },
  "scenario2_persist_view_selection": {
    "tabsPressedAfterClick": "true",
    "localOverrideAfterClick": "tabs",
    "backendKdsInfoAfterClick": {
      "language": null,
      "country": "TH",
      "kds_default_view": "tabs"
    },
    "tabsPressedAfterReload": "true"
  },
  "scenario3_existing_install_preserves_tabs": {
    "preservedTabsPressed": "true",
    "initialLocalStorageOverride": null
  },
  "scenario4_adversarial_invalid_view": {
    "status": 400,
    "response": {
      "error": "kds_default_view must be \"tabs\" or \"kanban\""
    },
    "kdsDefaultViewUnchanged": "tabs"
  },
  "scenario5_post_dialog_clickability": {
    "pointerEventsAfterSidebarLogout": "",
    "pointerEventsAfterKdsLogout": "",
    "pointerEventsAfterRelogin": "",
    "kanbanPressedAfterImmediateClick": "true"
  }
}

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • ⚠️ tests/ui-regressions-621-623-626.test.ts:639 - Newly added assertions in tests/ui-regressions-621-623-626.test.ts:639-661 read frontend/src/hooks/useKdsView.ts, frontend/src/components/kds/KdsWorkspace.tsx, and frontend/src/components/layout/Sidebar.tsx as raw text and regex-match implementation strings (const viewMode = override ?? serverDefault ?? 'kanban', setViewMode(nextView); conn.persistViewMode?.(nextView);, and window.setTimeout(...)). Replace these source-string regex checks with executable behavioral assertions (for example, rendering KdsWorkspace via renderWithIntl with serverDefault={null} and serverDefault="tabs" and asserting the rendered Kanban/Tabs view output alongside the executable clearStaleBodyPointerEvents checks).
  • ⚠️ frontend/src/hooks/use-confirm.tsx:27 - clearStaleBodyPointerEvents() in frontend/src/hooks/use-confirm.tsx:27 and its duplicated inline implementation in frontend/src/components/layout/AuthGuard.tsx:86-102 only check for open [data-slot="dialog-content"] and [data-slot="dropdown-menu-content"] elements, omitting Radix-backed [data-slot="sheet-content"][data-state="open"] and [data-slot="drawer-content"][data-state="open"] overlays that also set document.body.style.pointerEvents = 'none'. If a component inside an open Sheet or Drawer mounts or closes useConfirm(), clearStaleBodyPointerEvents() prematurely clears document.body.style.pointerEvents while the sheet or drawer remains open. Include sheet-content and drawer-content in clearStaleBodyPointerEvents() and call clearStaleBodyPointerEvents() directly from AuthGuard.tsx instead of duplicating the DOM query.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 5 of 5 scenarios driven live against the product
Scenario Result Live Evidence
Fresh installation defaults KDS screen to Kanban board on first login ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-default-kanban.png
Switching KDS view mode remembers the selected view in localStorage and backend across page reloads ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-persisted-tabs.png
Existing installation with kds_default_view='tabs' preserves Tabs default when opened without localStorage override ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-existing-install-preserved-tabs.png
Adversarial PUT /api/kds/view with an invalid view mode is rejected with HTTP 400 without corrupting stored setting ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-live-verification.json
Logging out via dropdown confirmation dialog and logging into KDS keeps document.body.style.pointerEvents clear and controls immediately clickable without refresh ✅ pass live ~/.no-mistakes/evidence/01M6YF9ZP0JFK5J7872AJQ7HS3/kds-clickable-after-dialog-login.png
  • npm run test:kds-contract
  • npm run test:kds-integration
  • npm run test:ui-regressions-621-623-626
  • npm run test:rtl-kds-server-whatsapp
  • npm run test:migration-registry
  • npm run test:schema-health
  • npm run test:upgrade-path
  • npm run test:authorization-permissions
  • npm run docs:check
  • npm run build && npm run build:frontend
  • CI=1 E2E_BASE_URL=http://127.0.0.1:43001 E2E_KDS_BASE_URL=http://127.0.0.1:43002 E2E_SERVER_APP_BASE_URL=http://127.0.0.1:43003 npx playwright test e2e/kds-login.spec.ts --config=playwright.config.ts --project=chromium --retries=0
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@qodo-code-review

Copy link
Copy Markdown

ⓘ Your Qodo trial ends soon. Ask your workspace admin to set up billing to keep reviews running after the trial. Manage billing

@coderabbitai

coderabbitai Bot commented Nov 8, 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

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Default new KDS installations to Kanban and restore clickability

🐞 Bug fix ✨ Enhancement 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Default fresh KDS installations to Kanban while preserving existing stored Tabs settings.
• Persist view changes locally and through both KDS APIs so selections survive reloads.
• Restore clickability after login or modal dismissal by clearing stale pointer locks.
Diagram

graph TD
  AG["Auth Guard"] --> MC["Modal Cleanup"] --> UI["KDS View Controls"] --> API["KDS APIs"] --> DB[("Settings DB")]
  API --> VR["View Resolver"] --> UI
  UI --> LS["Local Override"] --> VR
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Persist views per user
  • ➕ A chef's selection would not change the default seen by other users or devices.
  • ➖ Requires a user-scoped setting and migration, rather than reusing the existing shared KDS setting.

Recommendation: Keep the PR's shared-setting approach if switching views is intended to update the installation-wide KDS default; it preserves existing data and works across both servers. If the intended behavior is strictly a personal preference, use a user-scoped setting instead, since the current backend write affects other users.

Files changed (20) +518 / -63

Enhancement (7) +120 / -36
page.tsxDefault KDS settings card to Kanban +10/-4

Default KDS settings card to Kanban

• Treats absent settings as Kanban and propagates a successfully saved view to the browser override and its change event.

frontend/src/app/(dashboard)/settings/page.tsx

page.tsxConnect standalone KDS to view persistence +1/-0

Connect standalone KDS to view persistence

• Supplies the standalone '/api/kds/view' endpoint to the shared KDS connection hook.

frontend/src/app/kds-standalone/page.tsx

KdsWorkspace.tsxPersist KDS workspace view changes +5/-1

Persist KDS workspace view changes

• Routes Tabs and Kanban selections through both the local view setter and the connection's backend persistence callback.

frontend/src/components/kds/KdsWorkspace.tsx

useKdsConnection.tsPersist view selections through the active KDS API +23/-0

Persist view selections through the active KDS API

• Adds a configurable view endpoint and fire-and-forget view update callback. Dashboard KDS login also stores tenant and user data when returned, enabling shared auth hydration.

frontend/src/hooks/useKdsConnection.ts

kds-server.tsExpose standalone KDS view persistence +23/-1

Expose standalone KDS view persistence

• Returns Kanban when the public KDS view setting is unset and adds an authenticated, KDS-enabled endpoint that validates and stores Tabs or Kanban.

main/kds-server.ts

kds.tsAdd main API KDS view update endpoint +20/-0

Add main API KDS view update endpoint

• Adds a kitchen-permission-gated endpoint that validates and persists the shared KDS view when KDS is enabled.

main/routes/kds.ts

settings.tsAllow kitchen users to access KDS view settings +38/-30

Allow kitchen users to access KDS view settings

• Expands KDS settings read and write permissions to kitchen users and returns Kanban when the stored value is absent.

main/routes/settings.ts

Bug fix (7) +93 / -17
page.tsxRefresh dashboard KDS default and hydrate auth +17/-4

Refresh dashboard KDS default and hydrate auth

• Uses Kanban when the server setting is absent, refetches the default when the KDS user changes, and hydrates the shared auth store for an eligible '/kds' session.

frontend/src/app/(dashboard)/kds/page.tsx

page.tsxDefer support dialog opening from dropdown +1/-1

Defer support dialog opening from dropdown

• Opens the ticket dialog on the next macrotask, allowing the dropdown to close before the dialog transition.

frontend/src/app/auth/login/page.tsx

AuthGuard.tsxRecover pointer events and hydrate dashboard KDS sessions +19/-3

Recover pointer events and hydrate dashboard KDS sessions

• Clears stale body pointer locks on route or user changes and loads shared auth state on '/kds' when a dashboard token and tenant exist.

frontend/src/components/layout/AuthGuard.tsx

Sidebar.tsxDefer sidebar lock and logout transitions +7/-3

Defer sidebar lock and logout transitions

• Schedules lock and logout confirmation after the dropdown click, avoiding overlap with dropdown dismissal.

frontend/src/components/layout/Sidebar.tsx

use-confirm.tsxClear stale modal pointer locks +46/-3

Clear stale modal pointer locks

• Adds guarded body pointer-event cleanup around confirmation lifecycle transitions while preserving the lock for an open dialog, dropdown, sheet, or drawer.

frontend/src/hooks/use-confirm.tsx

useKdsView.tsUse Kanban as the unresolved view fallback +2/-2

Use Kanban as the unresolved view fallback

• Changes the final view-resolution fallback from Tabs to Kanban without changing local-override precedence.

frontend/src/hooks/useKdsView.ts

db.tsSeed Kanban for fresh KDS settings +1/-1

Seed Kanban for fresh KDS settings

• Changes the 'kds_default_view' seed to Kanban; 'INSERT OR IGNORE' leaves an existing stored value untouched.

main/db.ts

Tests (4) +298 / -6
kds-login.spec.tsExercise KDS view persistence and post-login clickability +66/-4

Exercise KDS view persistence and post-login clickability

• Checks the fresh Kanban view, view selection across reloads, and interactive login flows after sidebar and KDS logout dialogs.

frontend/e2e/kds-login.spec.ts

kds-contract.test.tsCover main API KDS default and persistence contracts +62/-0

Cover main API KDS default and persistence contracts

• Tests the fresh Kanban seed, chef settings access, view updates, preservation of stored Tabs, invalid values, and unset-setting fallback.

tests/kds-contract.test.ts

kds-integration.test.tsCover standalone KDS view behavior +39/-2

Cover standalone KDS view behavior

• Tests standalone public defaults, authenticated updates, stored Tabs, invalid values, and Kanban fallback; adjusts rate-limit request counting for the added calls.

tests/kds-integration.test.ts

ui-regressions-621-623-626.test.tsRegress KDS rendering, persistence, and pointer cleanup +131/-0

Regress KDS rendering, persistence, and pointer cleanup

• Verifies Kanban and stored Tabs rendering, local and backend persistence callbacks, and preservation or clearing of body pointer locks according to modal state.

tests/ui-regressions-621-623-626.test.ts

Documentation (2) +7 / -4
frontend.mdDocument dashboard KDS auth hydration +2/-1

Document dashboard KDS auth hydration

• Clarifies that '/kds' loads the shared auth store only when a token and tenant are already stored; standalone surfaces continue to manage their own sessions.

docs/architecture/frontend.md

api.mdDocument KDS view endpoints and permissions +5/-3

Document KDS view endpoints and permissions

• Describes the Kanban fallback, expanded KDS settings permissions, and view-update endpoints on the main and standalone servers.

docs/reference/api.md

@khaira777 khaira777 changed the title fix: default KDS view to kanban, persist view selection, and clear stale body pointer lock fix(kds): default view to kanban and persist mode Nov 8, 2026
Comment thread main/kds-server.ts Fixed
Comment thread main/kds-server.ts Fixed
@qodo-code-review

qodo-code-review Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (7) 📘 Rule violations (0) 🔗 Cross-repo conflicts (1) 📜 Skill insights (0)

Grey Divider


Action required

1. KDS logout leaves a dashboard session open 🐞 Bug ≡ Correctness
Description
The new KDS login path populates shared session storage and hydrates the dashboard auth store, but
KDS logout removes only the stored token and does not clear that store. After logout,
loadFromStorage() finds no token and leaves its existing user and tenant untouched, so navigating
to a protected dashboard page can pass the client route guard with the stale session.
Code

frontend/src/hooks/useKdsConnection.ts[R712-717]

+        if (Array.isArray(data.tenants) && data.tenants.length > 0) {
+          try {
+            window.localStorage.setItem('user', JSON.stringify(data.user));
+            if (!window.localStorage.getItem('tenant')) {
+              window.localStorage.setItem('tenant', JSON.stringify(data.tenants[0]));
+            }
Relevance

●● Moderate

Stale dashboard session after KDS logout is plausible; no matching precedent found.

PR-#425

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The PR now creates a shared KDS/POS session, while logout removes only its storage token; no-token
hydration retains the store identity that AuthGuard uses for route decisions.

frontend/src/hooks/useKdsConnection.ts[705-718]
frontend/src/hooks/useKdsConnection.ts[750-763]
frontend/src/app/(dashboard)/kds/page.tsx[60-70]
frontend/src/store/auth.ts[292-316]
frontend/src/components/layout/AuthGuard.tsx[162-168]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
KDS logout does not undo the dashboard auth-store hydration introduced by KDS login, leaving protected client routes reachable with stale auth state.
## Fix Focus Areas
- frontend/src/hooks/useKdsConnection.ts[712-718]
- frontend/src/hooks/useKdsConnection.ts[750-763]
- frontend/src/store/auth.ts[245-316]
## Recommended Fix
For dashboard KDS sessions, clear the shared auth store and tenant alongside the token on logout and session invalidation. Ensure hydration with no token also clears previously hydrated identity rather than only changing the loading flag, without clearing an unrelated standalone session.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


2. Kitchen screens get auto-locked and logged out 🐞 Bug ☼ Reliability
Description
After a KDS login on /kds, the new useEffect in KdsPage (and the matching AuthGuard branch)
calls useAuthStore.loadFromStorage(), which fills the dashboard auth store's
token/currentTenant, and that turns on useIdleAutoLock in the dashboard layout. On a store
where auto_lock_minutes > 0, a kitchen display left untouched for that long runs lock(), which
revokes the token on the server and removes token/tenant from localStorage, so the KDS session
dies in the middle of service.
Code

frontend/src/app/(dashboard)/kds/page.tsx[R60-70]

+  useEffect(() => {
+    if (
+      conn.user &&
+      !useAuthStore.getState().user &&
+      typeof window !== 'undefined' &&
+      Boolean(window.localStorage.getItem('token')) &&
+      Boolean(window.localStorage.getItem('tenant'))
+    ) {
+      useAuthStore.getState().loadFromStorage();
+    }
+  }, [conn.user]);
Relevance

●● Moderate

Real auto-lock risk on shared token, but no close accepted or rejected precedent; the only nearby
/kds guard rejection pushes the opposite direction.

PR-#425

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The dashboard layout wraps /kds and runs useIdleAutoLock, which only arms when the auth store
has a token and tenant. Before this PR, /kds skipped loadFromStorage, so a KDS-only login never
armed it. The PR now hydrates the store, and lock() revokes and clears the shared token.

frontend/src/app/(dashboard)/layout.tsx[20-69]
frontend/src/store/auth.ts[145-171]
frontend/src/components/layout/AuthGuard.tsx[95-105]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Loading the shared auth store on `/kds` turns on the dashboard idle auto-lock, which revokes the KDS token when the kitchen screen sits idle.

## Fix Focus Areas
- frontend/src/app/(dashboard)/layout.tsx[20-69]
- frontend/src/app/(dashboard)/kds/page.tsx[60-70]

## Recommended Fix
Pass the normalized pathname into `useIdleAutoLock` and return early when `pathname === '/kds'`. Alternatively, stop hydrating the dashboard store from the KDS login and find another fix for the clickability problem.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Remediation recommended

3. A brief outage on reload logs kitchen out 🐞 Bug ☼ Reliability
Description
The new /kds branch in AuthGuard and the hydration effect in KdsPage call loadFromStorage(),
whose catch removes token and tenant from localStorage whenever /auth/me fails for any
reason. If the main API is briefly unreachable or slow when the kitchen screen reloads, the KDS
session token is deleted. This is the 'loading it there would clear their token' behaviour that the
standalone-path skip was added to prevent.
Code

frontend/src/components/layout/AuthGuard.tsx[R95-104]

+    if (isStandalonePath) {
+      if (
+        pathname === '/kds' &&
+        typeof window !== 'undefined' &&
+        Boolean(window.localStorage.getItem('token')) &&
+        Boolean(window.localStorage.getItem('tenant'))
+      ) {
+        loadFromStorage();
+      }
+      return;
Relevance

●● Moderate

loadFromStorage clearing tokens on any error is a real concern; no direct precedent in history.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
loadFromStorage does not tell network errors apart from auth errors; any rejection clears the
token. The docs record that the shared store was skipped on these paths for this reason, and the PR
re-enables it on /kds.

frontend/src/store/auth.ts[268-310]
docs/architecture/frontend.md[313-317]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
On `/kds`, `loadFromStorage` now runs, and any `/auth/me` failure (including network errors) wipes the KDS token.

## Fix Focus Areas
- frontend/src/components/layout/AuthGuard.tsx[95-105]
- frontend/src/store/auth.ts[298-310]

## Recommended Fix
Only remove `token`/`tenant` in `loadFromStorage` when the error is a 401/403 response, not when there is no response. Or, on `/kds`, use a hydration path that never clears storage when it fails.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


4. Kitchen staff can edit a settings endpoint 🐞 Bug ⛨ Security
Description
PUT /api/settings/kds now accepts requireAnyPermission('settings.manage', 'kitchen.use'), so any
kitchen account can write through the general settings router. No KDS client calls this route (KDS
uses the new /kds/view), so the wider permission is never needed.
Code

main/routes/settings.ts[R748-751]

+router.put(
+  '/kds',
+  requireAnyPermission('settings.manage', 'kitchen.use'),
+  (req: Request, res: Response) => {
Relevance

●● Moderate

Least-privilege concern on settings PUT is reasonable, but the broadening appears intentional and no
close precedent exists.

PR-#489
PR-#1392

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The KDS client's view persistence goes to VIEW_ENDPOINT = '/kds/view'. Only the Settings page card
calls PUT /settings/kds, and that page is for owners and managers.

frontend/src/hooks/useKdsConnection.ts[207-240]
frontend/src/app/(dashboard)/settings/page.tsx[295-301]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
`PUT /settings/kds` was widened to `kitchen.use` even though KDS uses `/kds/view`.

## Fix Focus Areas
- main/routes/settings.ts[748-751]

## Recommended Fix
Change the middleware back to `requirePermission('settings.manage')` and update the row in docs/reference/api.md to match.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


5. Older shops switch to Kanban on upgrade 🐞 Bug ≡ Correctness
Description
Changing the already-shipped version 26 migration seeds kanban when a database that has not yet
run that migration upgrades. Shops upgrading from a pre-version-26 installation previously had the
effective Tabs fallback, so INSERT OR IGNORE does not preserve their prior default when the row
does not yet exist.
Code

main/db.ts[7410]

+        `INSERT OR IGNORE INTO settings (key, value, updated_at) VALUES ('kds_default_view', 'kanban', ?)`,
Relevance

●● Moderate

Editing a shipped migration conflicts with the PR's 'keep existing defaults' intent; no matching
precedent, so uncertain.

PR-#640

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
Version 26 now inserts Kanban only when no setting exists; the earlier effective fallback was Tabs,
and the current readers return Kanban for that newly inserted value.

main/db.ts[7407-7419]
main/routes/settings.ts[731-739]
frontend/src/hooks/useKdsView.ts[18-43]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Pre-version-26 installations change their effective KDS default on upgrade because the historical migration now inserts Kanban rather than Tabs.
## Fix Focus Areas
- main/db.ts[7407-7412]
## Recommended Fix
Keep the shipped migration's Tabs value for databases upgrading through version 26, and introduce a fresh-install-specific initialization or migration path that seeds Kanban without changing the effective default of older installations.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


View medium (3)
6. Failed view saves still look persistent 🐞 Bug ☼ Reliability
Description
persistViewMode discards every failed PUT while the workspace has already written the chosen view
to the local override. If the request fails, that browser continues showing the choice after reload,
but a display reading the backend setting still receives the old view.
Code

frontend/src/hooks/useKdsConnection.ts[R768-770]

+      if (typeof api.put === 'function') {
+        void api.put(viewPath, { kds_default_view: view }).catch(() => {});
+      }
Relevance

●● Moderate

Swallowed PUT failure is a reliability nit; accepted error-state suggestions exist but none exactly
match.

PR-#1306

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
The workspace updates local storage first, the request rejection is swallowed, and the stored
override takes precedence over subsequent server reads.

frontend/src/components/kds/KdsWorkspace.tsx[9-14]
frontend/src/hooks/useKdsConnection.ts[765-773]
frontend/src/hooks/useKdsView.ts[4-14]
frontend/src/hooks/useKdsView.ts[33-43]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A rejected view update is silently treated as a saved selection because the browser override has already changed.
## Fix Focus Areas
- frontend/src/hooks/useKdsConnection.ts[765-773]
- frontend/src/components/kds/KdsWorkspace.tsx[11-14]
## Recommended Fix
Return the persistence result to the workspace and report failure. Reconcile or roll back the local override on failure so a reload does not present an unsaved backend choice as successfully persisted.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


7. KDS login keeps the prior user's sidebar ✓ Resolved

Resolving commit: ed9bd1f

Resolution reason
N/A
Description
The KDS-page hydration effect skips loadFromStorage() whenever the shared auth store already has a
user, although KDS login can replace the token and KDS user with a different account. When someone
signs into KDS while an earlier dashboard session remains hydrated, the KDS workspace uses the new
account but the sidebar and its permission-based navigation continue using the earlier account.

8. One cook's toggle changes every kitchen screen's view 🐞 Bug ≡ Correctness
Description
KdsWorkspace.handleChangeView saves each view toggle in device-local storage but also calls
conn.persistViewMode, which writes the shared kds_default_view setting through PUT /kds/view.
When a kitchen user changes one display, other KDS screens without local overrides and the owner’s
Settings control subsequently read that choice as the default.
Code

frontend/src/components/kds/KdsWorkspace.tsx[R11-14]

+  const handleChangeView = (nextView: 'tabs' | 'kanban') => {
+    setViewMode(nextView);
+    conn.persistViewMode?.(nextView);
+  };
Relevance

●● Moderate

Shared-setting write conflicts with the PR's stated 'remember last selected' intent; no close
precedent to decide.

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
useKdsView.setViewMode already stores the selection per device in localStorage, but the toggle
also invokes a write endpoint on every selection. That endpoint replaces the shared setting read by
the Settings card and by KDS displays without a local override; the standalone server endpoint
writes the same shared setting.

frontend/src/hooks/useKdsView.ts[33-43]
frontend/src/hooks/useKdsConnection.ts[765-773]
main/routes/kds.ts[84-102]
frontend/src/components/kds/KdsWorkspace.tsx[9-24]
main/routes/kds.ts[84-96]
main/kds-server.ts[252-267]
frontend/src/app/(dashboard)/settings/page.tsx[278-286]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A display-specific KDS view toggle overwrites the business-wide default managed in Settings.

## Fix Focus Areas
- frontend/src/components/kds/KdsWorkspace.tsx[11-14]
- frontend/src/hooks/useKdsConnection.ts[765-773]
- main/routes/kds.ts[84-96]

## Recommended Fix
Remove the `conn.persistViewMode?.(nextView)` call from the toggle and rely on `useKdsView` to remember the selection per device. Reserve writes to `kds_default_view` for the owner/manager Settings control. If backend persistence is needed, store selections per user or device separately from the shared default, including in the standalone server endpoint.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗



Informational

9. KDS guide omits view saving 🔗 Cross-repo conflict ≡ Correctness
Description
main/kds-server.ts adds PUT /api/kds/view, but the standalone API inventory in docs.flopos.com
does not include it. Developers consulting that guide for standalone KDS endpoints will not find how
to persist a display's view selection.
Code

main/kds-server.ts[252]

+    app.put('/api/kds/view', requireAuth, (req: Request, res: Response) => {
Relevance

●● Moderate

Docs-inventory gap is minor; docs suggestions are mixed in history (some accepted, some rejected).

PR-#895
PR-#1011

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
FloCafe adds an authenticated standalone endpoint for writing the view, while the related
repository's standalone API inventory lists the older endpoints without it.

FloCafe -> docs.flopos.com
main/kds-server.ts[252-267]
External repo: FreeOpenSourcePOS/docs.flopos.com, products/flocafe/developers/kds.md [63-77]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The standalone KDS API inventory in docs.flopos.com omits the new view-persistence endpoint.

## Fix Focus Areas
- main/kds-server.ts[252-267]
- /cross_repos/docs.flopos.com/products/flocafe/developers/kds.md[63-77]

## Recommended Fix
Update the docs.flopos.com standalone KDS API table with `PUT /api/kds/view`, its authentication requirement, accepted view values, and response.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools

Dismiss ↗ | View ↗


Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #39
  🌐 PR #10
  🌐 PR #34
✅ Compliance rules (platform): 5 rules
✅ Cross-repo context — repo relationships
  Explored: repo: FreeOpenSourcePOS/docs.flopos.com (sha: abe7cff3) — View relationship
Review mode: Auto: 🧠 Deep: Dense multi-file change touching permissions, auth hydration, migrations, and modal logic.

Grey Divider

Tip of the day
💡 Did you know, you can pick a display mode instead of tweaking every Display option by hand

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread main/db.ts Resolved
Comment thread frontend/src/hooks/useKdsConnection.ts Resolved
Comment thread frontend/src/hooks/useKdsConnection.ts Resolved
Comment thread main/routes/settings.ts Resolved
Comment thread main/kds-server.ts Resolved
khaira777 and others added 2 commits November 8, 2026 17:20
…**CodeQL (`ci-1`)**: Added explicit `express-rate-limit` middleware to all added/modified KDS view and settings routes across [`main/kds-server.ts`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/main/kds-server.ts#L252-L280) (`PUT /api/kds/view`), [`main/routes/kds.ts`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/main/routes/kds.ts#L85-L109) (`PUT /api/kds/view`), and [`main/routes/settings.ts`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/main/routes/settings.ts#L731-L772) (`GET /api/settings/kds` and `PUT /api/settings/kds`) so CodeQL's `js/missing-rate-limiting` query is satisfied at every route boundary. 2. **Core Test Suite Shard 1/4 (`ci-2` - `test:auth-ui-deterministic`)**: Moved [`clearStaleBodyPointerEvents`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/frontend/src/lib/utils.ts#L47-L61) into `frontend/src/lib/utils.ts` (re-exported from [`frontend/src/hooks/use-confirm.tsx`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/frontend/src/hooks/use-confirm.tsx#L14-L16)) and imported it from `@/lib/utils` in [`frontend/src/components/layout/AuthGuard.tsx`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/frontend/src/components/layout/AuthGuard.tsx#L10) so `tests/auth-ui-deterministic.test.ts` can resolve `AuthGuard` without loading TSX dialog dependencies. 3. **Playwright E2E Shard 3/4 & End-to-End Playwright Tests (`ci-5`, `ci-3`)**: Scoped the dashboard `/kds` check in [`AuthGuard`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/frontend/src/components/layout/AuthGuard.tsx#L85-L120) to `isDashboardKdsPath = pathname === '/kds'` and guarded `loadFromStorage()` when `user` and `currentTenant` are already hydrated so client-side navigation between dashboard routes (e.g. `/pos` -> `/settings`) does not re-run bootstrap print policy fetches (`settings-request-budget.spec.ts`), and replaced the synchronous `isVisible()` check in [`frontend/e2e/kds-login.spec.ts`](file:///Users/gurkiratkhaira/.no-mistakes/worktrees/de2296f2e6f8/01M6YF9ZP0JFK5J7872AJQ7HS3/frontend/e2e/kds-login.spec.ts#L101) with `await expect(page.getByTestId('kds-login-form')).toBeVisible()`. 4. **Lint & Build Validation & Required Checks Gate (`ci-4`, `ci-6`)**: Formatted all touched files with `oxfmt` to satisfy `scripts/ci/check-changed-format.cjs` and verified lint, budgets, docs, builds, and E2E suites
@khaira777
khaira777 merged commit 5b03cc6 into main Nov 8, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-kds-default-view-and-clickability branch November 8, 2026 22:43
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.

fix(kds): default new installs to kanban, persist view, and fix pointer lock

2 participants