Skip to content

Feat/printer modal tab3 sl clock mode - #109

Merged
u8array merged 2 commits into
mainfrom
feat/printer-modal-tab3-sl-clock-mode
May 29, 2026
Merged

u8array merged 2 commits into
mainfrom
feat/printer-modal-tab3-sl-clock-mode

Conversation

@u8array

@u8array u8array commented May 29, 2026

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements support for the ZPL ^SL command to configure clock mode, tolerance, and language in the printer settings. It introduces schema validation to couple clock tolerance with the TOL mode, updates the ZPL parser and setup script generator, refactors the UI with a new reusable ZplEnumSubSelect component, and adds localized strings and unit tests. Feedback highlights two key improvements: clearing clockTolerance when parsing a mode change to S or T to avoid validation failures, and adding a defensive fallback to CLOCK_TOLERANCE_DEFAULT in the setup script emitter to prevent generating invalid ZPL if tolerance is undefined under TOL mode.

Comment thread src/lib/zplParser.ts
Comment thread src/lib/zplSetupScript.ts
Tab 3 (Clock & Time, Setup-Script channel) gains the third RTC
command, with the spec-correct three-shape mode slot and the
1-13 language enum.

Schema (ObjectType.ts):
- CLOCK_MODE_VALUES ['S', 'T', 'TOL'] (S = time at format start,
  T = time at print, TOL = time at print with tolerance seconds)
- CLOCK_TOLERANCE_RANGE {1, 999} + CLOCK_TOLERANCE_DEFAULT = 60
- CLOCK_LANGUAGE_VALUES ['1'..'13'] (English, Spanish, French,
  German, Italian, Norwegian, Portuguese, Swedish, Danish,
  Spanish 2, Dutch, Finnish, Japanese — separate enum from ^KL
  because the two commands use different code systems)
- isClockMode, isClockLanguage type guards
- 3 new schema fields plus a superRefine cross-field rule that
  pairs clockMode=TOL bidirectionally with clockTolerance

Generator + parser:
- SETUP_SCRIPT_EMITTERS gains 3 entries; clockMode is the
  anchor, clockTolerance / clockLanguage ride along via the
  fold-in pattern. Emitter is fallback-free — the cross-field
  rule guarantees tolerance is set whenever mode is TOL, so
  no UI default leaks back into persisted state through the
  parser
- SL handler in zplParser uses strParam, splits the wire mode
  slot (S/T enum vs numeric tolerance), and gates language
  assignment on a successful mode parse so an orphan language
  cannot land in the store

UI (ClockAndTimeTab):
- All three ^SL inputs sit under one shared command tag —
  mode select, conditional tolerance row when mode='TOL',
  language sub-select. Mode-switch onChange seeds the
  CLOCK_TOLERANCE_DEFAULT on transition into TOL and clears
  the tolerance on transition out, so the store never
  observes the half-set combo the schema rejects.
- Persistence hint surfaces the on-board-battery semantic
  ("persists on printer until overwritten") so users know
  ^SL is sticky once sent
- Language options render as "1 – English" so the code and
  the label read as two pieces

Primitive:
- ZplEnumSubSelect extracts the "select sharing a parent
  command tag" pattern. FeedSubSelect in MediaFeedTab is
  replaced by direct calls; ClockAndTimeTab language uses
  it; mode-select stays hand-rolled because the cross-field
  seeding makes its onChange non-trivial

Locales: 20 new keys (mode + 3 mode-labels, tolerance,
language + 13 language-labels, persistence-hint) in all 32
locales. Language names reuse the existing per-locale
printer-locale translations for consistency.

Memory closeout: project_ticket_sl_clock_formatting removed
(done). Epic project_ticket_printer_settings_modal is fully
shipped.
@u8array
u8array force-pushed the feat/printer-modal-tab3-sl-clock-mode branch from 7abaccd to 0b3f301 Compare May 29, 2026 21:58
PR #109 Gemini-finding: when an earlier ^SL60,1 set clockMode=TOL
and clockTolerance=60, a subsequent ^SLS in the same stream left
the tolerance in place — the (mode=S, tolerance=60) combo then
fails the schema cross-field rule and the persisted state cannot
round-trip through save.

Plus dropped the redundant isClockMode guard (a was already
statically narrowed to 'S'|'T') and the now-unused import.

The other Gemini finding (defensive ?? CLOCK_TOLERANCE_DEFAULT
fallback in the emitter) was intentionally NOT applied — that
fallback was removed earlier this PR after a clean-architecture
review found it leaked the UI default back into persisted state
via the parser. The schema cross-field rule already guarantees
tolerance is set whenever mode is TOL, making the fallback
defensive validation outside a system boundary.
@u8array
u8array merged commit 15e7fb9 into main May 29, 2026
2 checks passed
@u8array
u8array deleted the feat/printer-modal-tab3-sl-clock-mode branch May 29, 2026 22:01
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