Skip to content

fix: wrap KOT item descriptions and comments to prevent comment overlay - #1462

Merged
khaira777 merged 1 commit into
mainfrom
fm/flocafe-kot-comment-overlay-fix
Nov 4, 2026
Merged

khaira777 merged 1 commit into
mainfrom
fm/flocafe-kot-comment-overlay-fix

Conversation

@khaira777

Copy link
Copy Markdown
Contributor

Intent

some one reported: The comment in the kitchen receipt is overlaying over the item description , check, investigate and fix.

What Changed

  • Wrap long KOT item headings and special_instructions comments across indented continuation lines instead of truncating them in main/printers/document-kot.ts (via pushWrappedShapedLine) and frontend/src/lib/printer/kot-encoder.ts.
  • Align sourceLines and sourceControlLines tracking with wrapped KOT item rows and keep indented continuation lines in the same semanticLineGroups entry so raster fallback renders item descriptions and comments as separate requests without style bleed.
  • Reset active ESC/POS bold state (ESC E 0) in buildEscPos when transitioning from bold item lines to normal lines, flush banner newlines before resetting text size in buildKotBytes, and add explicit line-height: 1.4 and top margins to web KOT item/addon/comment rows in generateKotHtml.

Testing

  • ⏭️ Test - skipped

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

⏭️ **Review** - skipped

Step was skipped.

⏭️ **Test** - skipped

Step was skipped.

⏭️ **Document** - skipped

Step was skipped.

⏭️ **Lint** - skipped

Step was skipped.

⏭️ **Push** - skipped

Step was skipped.

@coderabbitai

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

Prevent KOT comments from overlapping long item descriptions

🐞 Bug fix 🧪 Tests 🕐 40+ Minutes

Grey Divider

AI Description

• Wrap long KOT item headings and comments instead of truncating them on thermal receipts.
• Keep wrapped raster lines grouped correctly and reset print styles before comments.
• Increase web-print line spacing and add regression coverage across print paths.
Diagram

graph TD
  O(["KOT order"]) --> D["Document renderer"] --> W["Wrapped lines"] --> E["ESC POS bytes"]
  D --> G["Raster grouping"] --> R["Raster requests"]
  O --> F["Frontend encoder"] --> E
  O --> H["Web print HTML"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Share a KOT row-layout formatter
  • ➕ Could prevent the document and frontend thermal paths from diverging on wrapping rules.
  • ➖ Would couple tokenized document output to a direct printer encoder with different shaping and rendering constraints.

Recommendation: Keep the path-specific changes for this targeted fix: the document renderer needs raster source metadata that the frontend encoder does not. A shared row-layout abstraction is worth revisiting only if future changes repeatedly require matching edits in both thermal paths.

Files changed (6) +360 / -61

Bug fix (5) +148 / -61
kot-encoder.tsWrap frontend thermal KOT headings and comments +73/-23

Wrap frontend thermal KOT headings and comments

• Prints long headings and special instructions on indented continuation lines, retaining the existing truncation path for Arabic shaping. Moves the banner newline before text-size and bold resets.

frontend/src/lib/printer/kot-encoder.ts

kot-web-print.tsSeparate web-print KOT rows with explicit spacing +4/-4

Separate web-print KOT rows with explicit spacing

• Sets a 1.4 line height on the ticket and item rows, with top margins on addons and comments to reduce visual overlap.

frontend/src/lib/printer/kot-web-print.ts

document-kot.tsWrap document KOT rows and preserve raster mappings +37/-33

Wrap document KOT rows and preserve raster mappings

• Wraps item names and comments into indented lines while collecting source and control-line metadata as each row is built. This keeps raster source ranges aligned when a heading or comment spans multiple printed lines.

main/printers/document-kot.ts

formatting-helpers.tsAdd shaped-line wrapping and reset ESC/POS bold +27/-0

Add shaped-line wrapping and reset ESC/POS bold

• Adds a wrapping helper that preserves the Arabic-shaping truncation path. Tracks active ESC/POS bold state and explicitly turns it off before normal lines.

main/printers/formatting-helpers.ts

raster-renderer.tsKeep indented KOT continuations in their raster group +7/-1

Keep indented KOT continuations in their raster group

• Stops treating an indented bold, double-height continuation as the start of a new KOT item during semantic grouping.

main/printers/raster-renderer.ts

Tests (1) +212 / -0
kot-order-notes.test.tsCover long KOT text across thermal, raster, and web output +212/-0

Cover long KOT text across thermal, raster, and web output

• Adds regression assertions for wrapped item and comment text, column limits, style resets, and separate raster requests. Also checks frontend thermal output and web-print line spacing.

tests/kot-order-notes.test.ts

@qodo-code-review

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

Copy link
Copy Markdown

Code Review by Qodo

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

Grey Divider


Remediation recommended

1. Long names flood kitchen printers ✗ Dismissed
Description
pushWrappedShapedLine and the frontend heading loop emit every segment of a product or variant
name without a line limit. Catalog names have no length cap, so a large name copied into an order
can generate thousands of KOT lines and a correspondingly large print job instead of the previously
single-line heading.

Grey Divider

Context sources
✅ Compliance rules (platform): 5 rules
✅ Cross-repo context — repo relationships
  Explored: repo: FreeOpenSourcePOS/FloCafe-Plugins (sha: 19dcb656) — View relationship
Review mode: Auto: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 15/18, lines 421/200; both must reach the floor). Router rationale: Dense logic across six files: wrapping, raster grouping, ESC/POS bold state, and HTML.

Grey Divider

Tip of the day
💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab)

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

Comment thread main/printers/document-kot.ts Resolved
@khaira777
khaira777 merged commit 2560168 into main Nov 4, 2026
23 checks passed
@khaira777
khaira777 deleted the fm/flocafe-kot-comment-overlay-fix branch November 4, 2026 10:17
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