Skip to content

docs(api): Phase 7e Template Layout System v2 — semantic schema + aggregation#86

Merged
strausmann merged 2 commits into
mainfrom
docs/phase-7e-template-layout-v2-spec
May 18, 2026
Merged

docs(api): Phase 7e Template Layout System v2 — semantic schema + aggregation#86
strausmann merged 2 commits into
mainfrom
docs/phase-7e-template-layout-v2-spec

Conversation

@strausmann
Copy link
Copy Markdown
Owner

@strausmann strausmann commented May 17, 2026

Phase 7e spec. Decisions: hard cut, aggregation included as qr-with-listing layout, auto-derived constants, 3 canonical layouts. Implementation comes after Phase 7c. Refs #22 Closes #81

Spec polish — deferred suggestions

The following bot findings were reviewed and intentionally deferred:

# Finding Reason deferred
1 62mm QL tape width missing in TAPE_HEIGHT_PX Out-of-scope per §10: "Multi-printer-model layouts — current scope assumes PT-series tape only." 62mm/QL support is a constants-table addition; no implementation exists yet.
2 Min-QR-size guard for qr-left-text-right Design refinement. A single-line template (18px) is an unusual but valid author choice; adding a floor constant is Phase 7e.1 work once we see real templates hit the limit.
3 Model validator for per-tape text_lines limit YAGNI. The per-tape max_text_lines in LAYOUT_CONSTANTS already documents the constraints. A cross-field Pydantic validator is a worthwhile hardening step; tracked as follow-up for Phase 7e implementation PR.

…ggregation

Replaces the absolute-pixel-coordinate v1 schema with semantic
layout fields. 3 canonical layouts: qr-left-text-right (1-N
text lines next to QR), qr-only (full-height QR), and
qr-with-listing (aggregation, 1 big label with N child items).
Renderer auto-derives paddings + font sizes per tape_mm. All
12 existing seed templates rewritten + 3 new Kallax-Regal-
Overview aggregation templates added. Hard cut from v1.

Refs #22
Closes #81
Copilot AI review requested due to automatic review settings May 17, 2026 22:50
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a significant redesign of the template layout system, moving from manual pixel-coordinate authoring to a semantic, renderer-driven model. By standardizing layout logic and automating geometry calculations, the system ensures consistent visual output across different tape widths while simplifying template creation. The update includes a new aggregation-capable layout and a strict migration path for existing seed templates.

Highlights

  • Semantic Layout System v2: Replaced absolute pixel-based template coordinates with a semantic, intent-based layout system that automatically calculates positioning and scaling based on tape width.
  • Canonical Layouts: Introduced three standardized layouts: qr-left-text-right, qr-only, and qr-with-listing, ensuring visual consistency across all templates.
  • Aggregation Support: Added the qr-with-listing layout and extended LabelData to support item lists, enabling complex labels like multi-compartment overviews.
  • Hard Cut Migration: Implemented a strict schema versioning system that requires all templates to be migrated to v2, removing support for legacy v1 templates.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

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

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 introduces a semantic layout system (v2) for label templates, transitioning from absolute pixel coordinates to intent-based declarations. The design includes Pydantic schema validation, deterministic geometry computation based on tape width, and a hard cut from the previous rendering engine. Review feedback identifies a regression in 62mm tape support for QL printers and documentation errors regarding DPI. Further improvements were suggested for layout validation, QR code scanability on small labels, and coordinate calculations to ensure compatibility with PIL's text rendering.

Comment thread docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md Outdated
Comment thread docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md Outdated
Comment thread docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.09%. Comparing base (cdaedeb) to head (8c457c3).
⚠️ Report is 6 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #86      +/-   ##
==========================================
- Coverage   91.98%   91.09%   -0.89%     
==========================================
  Files          70       71       +1     
  Lines        3055     3189     +134     
  Branches      261      271      +10     
==========================================
+ Hits         2810     2905      +95     
- Misses        181      216      +35     
- Partials       64       68       +4     
Components Coverage Δ
Printer Backends (transport) 87.50% <ø> (ø)
Printer Models (drivers) 91.42% <ø> (ø)
Services 91.87% <ø> (-0.23%) ⬇️
REST API 87.04% <ø> (-4.26%) ⬇️
Pydantic Schemas 100.00% <ø> (ø)
Integration Plugins 100.00% <ø> (ø)
see 5 files with indirect coverage changes
Flag Coverage Δ
backend 91.09% <ø> (-0.89%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cdaedeb...8c457c3. Read the comment docs.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds the Phase 7e design spec for moving templates from absolute-coordinate v1 definitions to a semantic v2 layout system with canonical QR/text layouts and aggregation support.

Changes:

  • Defines Template Schema v2 with semantic layouts and renderer-computed geometry.
  • Documents migration from seed v1 templates to v2, including aggregation templates.
  • Lays out expected renderer, endpoint, testing, documentation, and Definition of Done work.
Comments suppressed due to low confidence (4)

docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md:76

  • The preview_sample type does not support the aggregation sample shown later in this spec: items is a YAML list of objects, but this annotation only allows scalar values or tuple[str, ...]. Update the schema to allow nested LabelDataItem/JSON values for aggregation previews, or the seeded qr-with-listing templates will fail validation when their preview samples are parsed.
    preview_sample: dict[str, str | int | float | bool | tuple[str, ...]] | None = None

docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md:217

  • This snippet drops existing fields/config from LabelData: the current model includes required source_app and uses ConfigDict(frozen=True) in backend/app/schemas/label_data.py:21-27. Please show the extension as additive so the spec does not prescribe a breaking change or weaken the established immutability convention.
class LabelData(BaseModel):
    model_config = ConfigDict(extra="forbid")

    primary_id: str
    title: str
    qr_payload: str
    secondary: tuple[str, ...] = ()
    items: tuple[LabelDataItem, ...] = ()     # NEW — for qr-with-listing aggregation

docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md:201

  • make seed-resync is described as an existing target, but there is no Makefile target with that name in the repository. Either add the target as part of the planned implementation or replace this with the actual supported operator command so the migration guidance is executable.
If a deployed DB has v1 templates seeded, they survive the upgrade until next seed-sync (then they get overwritten). To force-clean: operator runs `make seed-resync` (existing target) to wipe + re-seed from the new YAML files.

docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md:335

  • These Definition of Done commands refer to make targets that do not currently exist (make oapi and make docs-svg-samples). The existing frontend Makefile exposes refresh-snapshot and gen-client instead, so please either define these targets in the implementation plan or update the DoD to the actual commands contributors can run.
- [ ] `make oapi` regenerates client if any endpoint signature changed (likely none)
- [ ] `make docs-svg-samples` produces updated SVGs for all 15 (12 + 3 new) templates

Comment thread docs/superpowers/specs/2026-05-17-phase-7e-template-layout-v2-design.md Outdated
- Fix DPI comment: 180 DPI → 300 DPI (pixel values match 300 DPI, not 180)
- Fix PIL anchor: remove `+ first_line.font_size` from text line Y (PIL draw.text
  uses top-left anchor, not baseline; the offset would shift text block down)
- Tighten qr-with-listing validation: "at least 1" → "exactly 1" text_line
  (renderer only uses text_lines[0] as item-line template; >1 silently ignored)
- Fix listing_field/LabelData inconsistency: replace `compartments` examples with
  `items` everywhere (LabelData.items is the actual field; compartments was a
  stale placeholder that would fail runtime validation)

Deferred (subjective / out-of-scope per §10):
  62mm QL tape width, min-QR-size guard, model validator for tape-width limits

Refs #22
@strausmann strausmann merged commit 0bab0c0 into main May 18, 2026
14 checks passed
@strausmann strausmann deleted the docs/phase-7e-template-layout-v2-spec branch May 18, 2026 07:13
github-actions Bot pushed a commit that referenced this pull request May 19, 2026
## <small>0.6.1 (2026-05-19)</small>

* fix(ui): preview-PNG data-URL must use template.URL type (#90) ([0f84976](0f84976)), closes [#90](#90) [#87](#87) [#22](#22) [#89](#89) [#22](#22)
* docs(api): Phase 7c API-Auth design — 3-scope keys + rate-limit + /admin/api-keys UI (#85) ([8792e84](8792e84)), closes [#85](#85) [#22](#22) [#78](#78) [#85](#85) [#22](#22) [#79](#79) [#22](#22)
* docs(api): Phase 7e Template Layout System v2 — semantic schema + aggregation (#86) ([0bab0c0](0bab0c0)), closes [#86](#86) [#22](#22) [#81](#81) [#22](#22)
* chore(deps): bump the go-minor-and-patch group (#89) ([d6ba346](d6ba346)), closes [#89](#89)

[skip ci]
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.

Phase 7e: Template Layout System v2 — semantic qr-first + N-text-lines deklarativ

2 participants