Skip to content

fix: Windows USB printer status and installed KDS/Server App - #1630

Merged
itsbkm merged 2 commits into
mainfrom
fix/windows-usb-printer-and-installed-apps
Nov 26, 2026
Merged

itsbkm merged 2 commits into
mainfrom
fix/windows-usb-printer-and-installed-apps

Conversation

@itsbkm

@itsbkm itsbkm commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Related work

Issue / Discussion: None (bug fixes)

Summary

  • Windows raw print: the generic printer error flag (0x2) alone no longer refuses a job. Windows prints with it set. The specific refusals and their order are unchanged, and StartDocPrinter, StartPagePrinter and WritePrinter failures still surface.
  • Windows queue status: a queue is offline only for PrinterStatus 6 or 7, or when WorkOffline is true. Other (1) and Unknown (2) no longer show the offline badge.
  • Installed apps: the standalone KDS and Server App link their own manifests. Before, an installed app opened /dashboard on :3002 or :3003, where sign-in showed "Could not reach the server".

Scope

PRE_SPOOL_REFUSALS, failure classification, user-facing strings and macOS/CUPS paths are unchanged.

Verification

Commands run: npm test, npm run lint, npm run build, npm run build:frontend, npm run i18n:check, git diff --check.

Results: all passed. npm test ran on a working tree that also held an unrelated uncommitted About-screen text change. docs:check link, index and policy checks pass; its Markdown lint failed locally only on untracked files. format:check:backend failed locally, including on unedited files.

Both install failures were reproduced in a browser against a throwaway database, and the fixed pages loaded with the new manifests. Installing as an app was not tested.

Not tested on Windows or on a printer.

Compatibility & data safety

  • Database/data impact: None
  • Migration: None
  • User-visible behavior: Ready USB queues print and stop showing offline. Already installed KDS and Server App copies should be removed and installed again.
  • Offline/network impact: None
  • Known risk: if a driver reports only 0x2 for an unplugged printer, the job spools and is reported as success. Offline, Use Printer Offline and not-available still block.

Developer documentation

  • Existing developer documentation updated: docs/architecture/printing.md (Windows refusal and offline rules), docs/architecture/overview.md (install manifests)

Manual check after release

  1. FloCafe test print succeeds on the Windows USB printer (XP-80).
  2. The badge does not show offline while Windows shows Idle.
  3. With the printer unplugged, a test print fails and does not report success.
  4. Reinstalled KDS and Server App open their own sign-in screens.

🤖 Generated with Claude Code

itsbkm and others added 2 commits November 26, 2026 21:51
Do not refuse a job on the generic printer error flag alone, and report a
queue offline only for PrinterStatus 6 or 7 or when WorkOffline is true.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Both pages inherited the POS manifest, so an installed app opened /dashboard
on a server that cannot back it and sign-in failed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

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

@itsbkm
itsbkm enabled auto-merge (squash) November 26, 2026 16:21
@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Fix Windows USB printer status and standalone app installation

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Allow Windows raw printing when only the generic error flag is set, while preserving specific
 refusals.
• Mark Windows queues offline only for explicit offline signals, avoiding false offline badges.
• Give installed KDS and Server App distinct launch pages instead of the unsupported POS dashboard.
Merge Risk 🟢 Low

Blast radius 🔴 High 💥 3 capabilities

  • 3 affected capabilities span independent functional scopes: Windows printer integration, standalone web-app installation and launch.
  • The manifest and route metadata jointly control the installed KDS app identity and entry route; this is one bounded installation behavior, independent of POS dashboard routing.
  • The manifest and route metadata jointly control the installed Server App identity and entry route; this is a second user-visible operation within the same bounded standalone installation integration.
  • The changed discovery result is consumed by the USB printer status route to distinguish missing, offline, and available queues; discovery and diagnostics are one bounded Windows printer integration behavior.
Sources

frontend/src/app/kds-standalone/layout.tsx[5-9]

export const metadata: Metadata = {
  title: 'Flo KDS - Kitchen Display',
  description: 'Kitchen Display System',
  // The root manifest starts at /dashboard, which the KDS server cannot back.
  manifest: '/kds-manifest.json',

frontend/public/kds-manifest.json[2-7]

  "id": "/kds-standalone",
  "name": "Flo KDS",
  "short_name": "Flo KDS",
  "description": "Kitchen Display System",
  "start_url": "/kds-standalone",
  "display": "standalone",

frontend/src/app/server-standalone/layout.tsx[9-13]

export const metadata: Metadata = {
  title: 'Flo Server App',
  description: 'Tableside ordering for FloCafe',
  // The root manifest starts at /dashboard, which the Server App cannot back.
  manifest: '/server-manifest.json',

frontend/public/server-manifest.json[2-7]

  "id": "/server-standalone",
  "name": "Flo Server App",
  "short_name": "Flo Server",
  "description": "Tableside ordering for FloCafe",
  "start_url": "/server-standalone",
  "display": "standalone",
Behavioral complexity 🟢 Low 🧩 Straightforward

  • Before, the standalone route inherited the root manifest target; after, it selects a route-specific manifest with a matching start URL.
  • The new correctness condition is that the metadata and manifest must agree on the KDS route.
Sources

frontend/src/app/kds-standalone/layout.tsx[5-9]

export const metadata: Metadata = {
  title: 'Flo KDS - Kitchen Display',
  description: 'Kitchen Display System',
  // The root manifest starts at /dashboard, which the KDS server cannot back.
  manifest: '/kds-manifest.json',

frontend/public/kds-manifest.json[2-7]

  "id": "/kds-standalone",
  "name": "Flo KDS",
  "short_name": "Flo KDS",
  "description": "Kitchen Display System",
  "start_url": "/kds-standalone",
  "display": "standalone",
Potential damage 🟡 Medium 🩹 Temporary loss

  • If the manifest or metadata regresses, an installed KDS shortcut could open the wrong page or fail to provide the intended standalone KDS entry point.
  • Reverting the frontend restores behavior; no persistent order or printer state requires repair.
  • Code revert restores the launch metadata.
  • A user may need to reinstall or update the shortcut if the incorrect manifest was already adopted.
Sources

frontend/src/app/kds-standalone/layout.tsx[5-9]

export const metadata: Metadata = {
  title: 'Flo KDS - Kitchen Display',
  description: 'Kitchen Display System',
  // The root manifest starts at /dashboard, which the KDS server cannot back.
  manifest: '/kds-manifest.json',

frontend/public/kds-manifest.json[2-7]

  "id": "/kds-standalone",
  "name": "Flo KDS",
  "short_name": "Flo KDS",
  "description": "Kitchen Display System",
  "start_url": "/kds-standalone",
  "display": "standalone",
Assessed commit 4cc7701
Diagram

graph TD
  OS["Windows queues"] --> Status["Status mapping"] --> Badge["Printer badge"]
  OS --> Raw["Raw print helper"] --> Spool["Windows spooler"]
  Layouts["Standalone layouts"] --> Manifests["App manifests"] --> Routes["Standalone pages"]
Loading
High-Level Assessment

Keep the targeted changes: distinguishing explicit offline signals from ambiguous status values preserves the existing refusal path, and route-specific static manifests fit the existing standalone pages. A shared dynamic manifest would add machinery without a clear benefit for two fixed apps. Verify the printer behavior on Windows hardware before release, particularly drivers that report only the generic error flag when unplugged.

Files changed (10) +154 / -25

Bug fix (5) +71 / -21
kds-manifest.jsonAdd a distinct KDS install manifest +25/-0

Add a distinct KDS install manifest

• Defines the KDS app identity and sets its installed launch URL to /kds-standalone.

frontend/public/kds-manifest.json

server-manifest.jsonAdd a distinct Server App install manifest +25/-0

Add a distinct Server App install manifest

• Defines the Server App identity and sets its installed launch URL to /server-standalone.

frontend/public/server-manifest.json

layout.tsxLink the KDS layout to its manifest +3/-5

Link the KDS layout to its manifest

• Overrides the root POS manifest in KDS page metadata so an installed KDS launches its own page. Also condenses the layout function signature.

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

layout.tsxLink the Server App layout to its manifest +3/-5

Link the Server App layout to its manifest

• Overrides the root POS manifest in Server App page metadata so an installed copy launches its own page. Also condenses the layout function signature.

frontend/src/app/server-standalone/layout.tsx

thermal.tsAvoid false Windows queue refusals and offline status +15/-11

Avoid false Windows queue refusals and offline status

• Queries WorkOffline and maps only that flag or PrinterStatus 6 or 7 to offline; Other and Unknown now map to idle. Removes the generic 0x2 flag as a pre-spool refusal while retaining specific fault checks, and exports the status mapping and detection script for tests.

main/printers/thermal.ts

Documentation (2) +8 / -2
overview.mdDocument standalone app installation routes +4/-0

Document standalone app installation routes

• Explains that KDS and Server App use separate manifests so installed copies launch their respective standalone pages rather than the POS dashboard.

docs/architecture/overview.md

printing.mdClarify Windows print refusal and offline rules +4/-2

Clarify Windows print refusal and offline rules

• Documents that the generic error flag alone does not refuse a raw job, while specific faults and spooler failures still do. Specifies which Win32_Printer signals mark a detected queue offline.

docs/architecture/printing.md

Other (3) +75 / -2
package.jsonRegister install-manifest regression tests +2/-1

Register install-manifest regression tests

• Adds a test:install-manifests script and includes it in the main test sequence.

package.json

install-manifests.test.tsGuard standalone manifest links and launch URLs +24/-0

Guard standalone manifest links and launch URLs

• Checks that both standalone layouts select their own manifests and that each manifest has the matching start URL and distinct app ID.

tests/install-manifests.test.ts

windows-queue-bypass.test.tsCover Windows status mapping and generic-error behavior +49/-1

Cover Windows status mapping and generic-error behavior

• Verifies that 0x2 alone permits printing while specific faults still refuse it. Covers each documented PrinterStatus value, the WorkOffline override, and inclusion of WorkOffline in the detection script.

tests/windows-queue-bypass.test.ts

@qodo-free-for-open-source-projects

qodo-free-for-open-source-projects Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (1) 📘 Rule violations (1) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Unrelated signature reflow rides along with the manifest fix 📘 Rule violation ⚙ Maintainability
Description
The KDS standalone layout's default export signature is collapsed from a multi-line destructured
parameter to a single line, and the Server App layout gets the same change. This is a
formatting-only rewrite with no behavioral effect, unrelated to the manifest fix that the same hunk
adds. It adds reviewer noise to a PR scoped to printer status and installed-app manifests, and it
makes the two layouts diverge in style from other standalone layouts they are meant to mirror.
Code

frontend/src/app/kds-standalone/layout.tsx[12]

+export default function KdsStandaloneLayout({ children }: { children: React.ReactNode }) {
Evidence
The PR's stated scope is the Windows raw print and queue status fixes plus the installed-app
manifest link. The signature change in both layout files is a refactor that is not needed for either
fix, which the checklist item for approved scope prohibits.

Rule 8: Keep Implementation Changes Within the Approved Scope
frontend/src/app/kds-standalone/layout.tsx[12-12]
frontend/src/app/server-standalone/layout.tsx[16-16]

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 PR rewrites the default export signature of `KdsStandaloneLayout` and `ServerStandaloneLayout` from a multi-line destructured parameter to a single line. This is unrelated to the manifest fix in the same hunk and is opportunistic churn.
## Fix Focus Areas
- frontend/src/app/kds-standalone/layout.tsx[12-19]
- frontend/src/app/server-standalone/layout.tsx[16-23]
## Recommended Fix
Restore the original multi-line `export default function ...({ children, }: { children: React.ReactNode; })` signature in both layout files, keeping only the added `manifest:` metadata lines. If the formatter insists on the single-line form, confirm it is a repo-wide prettier change and split it into its own commit outside this PR.

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


2. Installed apps open the wrong offline page 🐞 Bug ≡ Correctness
Description
The root service worker falls back to cached /dashboard when a requested page is unavailable, but
the new KDS and Server App manifests launch their standalone pages instead. If either installed app
launches before its standalone page has been cached and the server is unreachable or returns a 5xx
response, it receives the POS dashboard rather than its own page.
Code

frontend/public/kds-manifest.json[6]

+  "start_url": "/kds-standalone",
Evidence
Both new manifests launch standalone routes, while the root layout registers the same service worker
on those pages. That worker precaches /dashboard but not either standalone route, then uses
/dashboard when a failed request has no cached match. The standalone servers serve the dashboard
export at /dashboard when it exists.

frontend/public/kds-manifest.json[2-6]
frontend/public/server-manifest.json[2-6]
frontend/src/app/layout.tsx[88-98]
frontend/public/sw.js[1-10]
frontend/public/sw.js[94-117]
main/kds-server.ts[1085-1103]
main/server-app.ts[653-669]

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

## Issue description
Installed KDS and Server App launches can receive the cached POS dashboard when their standalone page is unavailable.
## Fix Focus Areas
- frontend/public/sw.js[1-9]
- frontend/public/sw.js[103-117]
- frontend/public/kds-manifest.json[2-6]
- frontend/public/server-manifest.json[2-6]
## Recommended Fix
Precache the standalone pages and make the service worker's navigation fallback return the matching cached standalone page for either app. Do not fall back to `/dashboard` for those routes; preserve the dashboard fallback for POS navigation.

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


Grey Divider

Tip of the day
💡 Did you know, you can tweak Display settings with a live preview to see your comment before it ships

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@itsbkm
itsbkm merged commit adec087 into main Nov 26, 2026
23 checks passed
@itsbkm
itsbkm deleted the fix/windows-usb-printer-and-installed-apps branch November 26, 2026 16:28
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.

1 participant