feat: [25] param set editor with schema-driven form #51

Merged
hobbypunk merged 28 commits from feature/25_param_set_editor into main 2026-11-13 15:00:18 +00:00
Contributor

Closes #25

Summary

Param set editor (/app/blueprints/:blueprint_id/versions/:version_id/param_sets/:id):

  • Schema-driven form generation from the customizer schema (#24): groups render as fieldsets, parameters map to number/text/select/checkbox fields with min/max/step constraints and defaults from the values column
  • Inline-editable headline: a turbo frame swapping between the title (with edit pencil) and a joined rename form; PATCH streams the updated headline plus a flash toast
  • Draft semantics: unnamed drafts show "Konfigurationsentwurf" + expiry hint; a named configuration cannot go back to being a draft

Advanced parameters:

  • $-prefixed OpenSCAD variables (e.g. $fa, $fs) are hidden from the main form: groups containing only $-params move to a collapsible "Erweitert" section at the end, mixed groups collapse them inside the group

Form infrastructure:

  • BaseField#with_label: one wrapper for label/hint/error across all field components (floating + above styles, width utilities extracted onto the floating label, w-full max-w-lg default)
  • Hints render as ?-tooltip icons in the label row (style: :label / style: :inline), driven by the Translatable::Hint convention
  • FormBuilder translate resolves relative keys against the owning view class via phlex's translation_path, with a superclass fallback chain
  • Select accepts both the rails positional signature and pure kwargs; drops the min/max/placeholder artifacts
  • Checkbox: only unprefixed colors count as the base color, responsive variants layer on top, checkbox-neutral as fallback
  • Components::Base normalizes class to an array; stream responses append flash toasts automatically

Editor layout:

  • Preview column (8/9 cols, sticky) beside the form (4/3 cols), stacked below lg — preview content lands with the next step

Test strategy

  • Controller tests: auth gates (owner-only show/update/rename), draft naming rules, values persistence, flash keys guard
  • Component tests: select kwargs/positional parity, tooltip rendering through the rails renderer (capture needs the phlex-rails capture_context)
  • Dev screenshot walkthrough (SCREENSHOTS=1) covering the editor at xl/lg/narrow viewports plus the inline rename form
Closes #25 ## Summary **Param set editor (`/app/blueprints/:blueprint_id/versions/:version_id/param_sets/:id`):** - Schema-driven form generation from the customizer schema (#24): groups render as fieldsets, parameters map to number/text/select/checkbox fields with min/max/step constraints and defaults from the values column - Inline-editable headline: a turbo frame swapping between the title (with edit pencil) and a joined rename form; PATCH streams the updated headline plus a flash toast - Draft semantics: unnamed drafts show "Konfigurationsentwurf" + expiry hint; a named configuration cannot go back to being a draft **Advanced parameters:** - `$`-prefixed OpenSCAD variables (e.g. `$fa`, `$fs`) are hidden from the main form: groups containing only `$`-params move to a collapsible "Erweitert" section at the end, mixed groups collapse them inside the group **Form infrastructure:** - `BaseField#with_label`: one wrapper for label/hint/error across all field components (floating + above styles, width utilities extracted onto the floating label, `w-full max-w-lg` default) - Hints render as `?`-tooltip icons in the label row (`style: :label` / `style: :inline`), driven by the `Translatable::Hint` convention - FormBuilder `translate` resolves relative keys against the owning view class via phlex's `translation_path`, with a superclass fallback chain - Select accepts both the rails positional signature and pure kwargs; drops the `min`/`max`/`placeholder` artifacts - Checkbox: only unprefixed colors count as the base color, responsive variants layer on top, `checkbox-neutral` as fallback - `Components::Base` normalizes `class` to an array; stream responses append flash toasts automatically **Editor layout:** - Preview column (8/9 cols, sticky) beside the form (4/3 cols), stacked below lg — preview content lands with the next step ## Test strategy - Controller tests: auth gates (owner-only show/update/rename), draft naming rules, values persistence, flash keys guard - Component tests: select kwargs/positional parity, tooltip rendering through the rails renderer (capture needs the phlex-rails capture_context) - Dev screenshot walkthrough (`SCREENSHOTS=1`) covering the editor at xl/lg/narrow viewports plus the inline rename form
The headline is an editable turbo frame; the pencil navigates to the
rename form, PATCH streams the updated headline plus a flash toast.
Flash normalization lives in FlashNormalization via
Flash::Notification.from_flash so the (title, message, body) view is
shared between the notifications container and the stream renderer.
GET with stream format renders the suffix-less view as a navigable
fragment; only mutations prefer a TurboStream subclass. Documented the
convention in AGENTS.md. Rename flash translations added.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
name_draft/title_draft split into title_draft plus page-level
description/description_draft following the layout slot convention;
the placeholder moves to the model-immanent helpers.placeholder
convention read automatically by BaseField.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
All field components render their label, hint and error through one
with_label wrapper instead of per-component copies. Floating labels
take the width utilities (w-*/max-w-*/grow) from options so the field
stays usable inside tables, defaulting to w-full max-w-md. Select
accepts the rails positional signature and pure kwargs alike; the
min/max/placeholder artifacts on selects are gone. Components::Base
normalizes class to an array (Link needed .presence for its default
because an empty array is truthy).

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
Only unprefixed checkbox-* classes count as the base color; responsive
variants (md:checkbox-primary) layer on top. checkbox-neutral is the
fallback when no explicit color is given.
Hints render through render_label's hint_tooltip; the empty stub was
left over from the text-line era.
Groups consisting only of $-variables move to a collapsible advanced
section at the end of the form; mixed groups collapse their $
parameters inside the group. The FormBuilder resolves relative i18n
keys against its owning class (phlex translation_path convention) with
a superclass fallback chain, so the advanced label lives once under
components.form.form_builder.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
Tooltips move from the left-opening variant to top with a shared
question-mark icon; the param set editor splits preview (8/9 cols,
sticky) and form (4/3 cols) across the lg/xl breakpoints and stacks
below lg.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
fix(test): render tooltips through the rails renderer
All checks were successful
PR Triage / Triage pull request-1 (pull_request) Successful in 25s
PR Triage / Triage pull request (pull_request) Successful in 0s
CI / Quality / Brakeman (pull_request) Successful in 1m25s
CI / Quality / Bundler Audit (pull_request) Successful in 1m34s
CI / Quality / RuboCop (pull_request) Successful in 1m35s
CI / Quality (pull_request) Successful in 0s
CI / Tests / Unit (pull_request) Successful in 2m13s
CI / Tests / System (pull_request) Successful in 2m18s
CI / Tests / Coverage (pull_request) Successful in 37s
CI / Tests (pull_request) Successful in 0s
CI / Container / Build and push (pull_request) Successful in 5s
CI / Container (pull_request) Successful in 0s
CI / Deploy (pull_request) Has been skipped
9047b08078
capture depends on phlex-rails' capture_context, which only exists when
rendering through the rails pipeline — direct .call tests bypassed it
and raw rejected the resulting buffer.
forgejo-actions changed title from [25] param set editor with schema-driven form to feat: [25] param set editor with schema-driven form 2026-11-07 15:43:29 +00:00

📊 Coverage

Metrik Abdeckung
Zeilen 97.31% (3476/3572)
Branches 81.41% (876/1076)
Methoden 98.06% (556/567)

Patch-Coverage: 93.79% (423/451 geänderte Zeilen)

Geänderte Dateien (schwach zuerst)

Datei Patch-Coverage Fehlende Zeilen
app/components/layout/notification.rb 73.33% (11/15) 39-42
app/components/form.rb 75.0% (12/16) 54, 56-58
app/components/form/field_set.rb 76.92% (10/13) 18-19, 21
app/views/app/param_sets/show.rb 85.0% (68/80) 47, 116, 121-124, 131-135, 163
app/components/form/select.rb 94.74% (18/19) 50
app/components/form/base_field.rb 95.74% (45/47) 94-95
app/controllers/app/param_sets_controller.rb 96.15% (25/26) 30
app/models/blueprint/param_set.rb 96.3% (26/27) 79
app/views/app/param_sets/rename.rb 100.0% (27/27)
app/components/alert.rb 100.0% (23/23)

Schwächste Dateien im Projekt

Datei Abdeckung
app/components/form/field_set.rb 81.25%
app/views/app/blueprints/show.rb 82.22%
app/components/layout/notification.rb 83.33%
app/components/concerns/inferrable.rb 84.38%
app/views/app/param_sets/show.rb 85.0%
app/views/app/blueprints/index.rb 85.0%
app/components/concerns/actionable.rb 86.67%
app/models/blueprint/category.rb 87.5%
app/components/users/avatar.rb 89.47%
app/models/concerns/has_uuid_v7.rb 90.91%

🔍 Report im Browser ansehen · 📄 Run-Artifact „coverage-report“

<!-- coverage-report --> ## 📊 Coverage | Metrik | Abdeckung | |---|---| | Zeilen | 97.31% (3476/3572) | | Branches | 81.41% (876/1076) | | Methoden | 98.06% (556/567) | **Patch-Coverage**: 93.79% (423/451 geänderte Zeilen) **Geänderte Dateien (schwach zuerst)** | Datei | Patch-Coverage | Fehlende Zeilen | |---|---|---| | app/components/layout/notification.rb | 73.33% (11/15) | 39-42 | | app/components/form.rb | 75.0% (12/16) | 54, 56-58 | | app/components/form/field_set.rb | 76.92% (10/13) | 18-19, 21 | | app/views/app/param_sets/show.rb | 85.0% (68/80) | 47, 116, 121-124, 131-135, 163 | | app/components/form/select.rb | 94.74% (18/19) | 50 | | app/components/form/base_field.rb | 95.74% (45/47) | 94-95 | | app/controllers/app/param_sets_controller.rb | 96.15% (25/26) | 30 | | app/models/blueprint/param_set.rb | 96.3% (26/27) | 79 | | app/views/app/param_sets/rename.rb | 100.0% (27/27) | | | app/components/alert.rb | 100.0% (23/23) | | **Schwächste Dateien im Projekt** | Datei | Abdeckung | |---|---| | app/components/form/field_set.rb | 81.25% | | app/views/app/blueprints/show.rb | 82.22% | | app/components/layout/notification.rb | 83.33% | | app/components/concerns/inferrable.rb | 84.38% | | app/views/app/param_sets/show.rb | 85.0% | | app/views/app/blueprints/index.rb | 85.0% | | app/components/concerns/actionable.rb | 86.67% | | app/models/blueprint/category.rb | 87.5% | | app/components/users/avatar.rb | 89.47% | | app/models/concerns/has_uuid_v7.rb | 90.91% | [🔍 Report im Browser ansehen](https://pages.hoppe-dev.eu/hobbypunk-blakopi/pr-51/coverage) · [📄 Run-Artifact „coverage-report“](https://code.hoppe-dev.eu/hobbypunk/blakopi/actions/runs/4080/artifacts/coverage-report)
feat: three.js mesh viewer and preview column
All checks were successful
PR Triage / Triage pull request-1 (pull_request) Successful in 53s
PR Triage / Triage pull request (pull_request) Successful in 0s
CI / Quality / Bundler Audit (pull_request) Successful in 1m25s
CI / Quality / Brakeman (pull_request) Successful in 1m33s
CI / Quality / RuboCop (pull_request) Successful in 1m34s
CI / Quality (pull_request) Successful in 0s
CI / Tests / Unit (pull_request) Successful in 2m22s
CI / Tests / System (pull_request) Successful in 2m24s
CI / Tests / Coverage (pull_request) Successful in 36s
CI / Tests (pull_request) Successful in 0s
CI / Container / Build and push (pull_request) Successful in 5s
CI / Container (pull_request) Successful in 0s
CI / Deploy (pull_request) Has been skipped
c646634438
The editor's preview column shows the param set's render (webp) and an
interactive STL viewer (three.js, z-up, OpenSCAD default orientation
with a clickable orientation gizmo) side by side in tabs, falling back
to the version's preview for fresh drafts and a placeholder when
nothing is rendered yet. Saving values enqueues a preview render job
that snapshots the values and applies them as -D overrides to both the
webp and the mesh render.
The scad camera sits in front of the model (-y), not behind it — the
negated y-component aligns the 3D view with the webp render. The
canvas shares the render's 4:3 aspect so switching tabs does not
jump.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
The preview uses global ambient 0.2 plus two camera-bound directional
lights at (-1,1,1) and (1,-1,-1) in eye space (GLView::initializeGL),
which sum to 0.2 + |dot(n,l)| so no face goes darker than 0.2. The
viewer now mirrors that with AmbientLight(0.2*pi) and two opposite
DirectionalLights(pi) attached to the camera, and uses a Lambert
material without specular and DoubleSide since the preview disables
face culling and its lights carry no specular component.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
Saving a param set unconditionally enqueued a preview render job, so
re-submitting unchanged settings re-rendered the same model. The update
now snapshots values into a RenderJob only when values actually changed;
name-only saves keep the existing render.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
The combined preview job rendered the png before the mesh, making the
editor wait on the thumbnail. Formats are renamed to match their
attachments (stl to mesh, png to image; preview stays as the combined
import render), image jobs enqueue with ActiveJob priority 10 so
SolidQueue serves the editor's mesh first, and render_preview is now
just a composition of both standalone paths.

The render trigger moves from the controller into an after_commit
callback on Blueprint::ParamSet (only when values changed) and
Blueprint::Version on create. Separate latest_mesh_job/latest_image_job
lookups replace the single latest job so image and mesh resolve
independently.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
The editor shows the interactive mesh viewer instead of tabbing between
the webp render and the 3D view — the image only remains for thumbnails
and as the version-level fallback.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
Split PerformRenderJob into per-format subclasses: the image render runs
at priority 10 so the editor's mesh render is served first, the preview
render composes image plus tolerated mesh. The job record is held as a
plain attr_accessor instead of an ActiveJob attribute — those serialize
into the job arguments and collide with perform's signature.

The preview state now derives from the newest mesh job of any status:
a spinner overlays the last successful mesh while a render runs, an
error alert with the job's error message when it failed. The mesh
resolves through latest_renderable_mesh_job so the viewer keeps working
either way.

The Alert component gains an icon/title/close_button API (blocks are
called in the caller's context to keep i18n resolution intact) and the
flash notification builds on it.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
Form inputs always arrive as strings, and schema-typed params expect
their real types: boolean params crash OpenSCAD asserts on "false"
strings (gridfinity's assert(is_bool(refined_hole))). The values are
cast before validation, so stored values carry the schema's types and
the values-changed comparison stays stable — resubmitting the same
values as strings no longer triggers a render.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
Finishing mesh jobs broadcast a turbo page refresh to the param set
stream; the editor subscribes and morphs the update in. The mesh viewer
survives morphs: idiomorph wipes js-created children, so an observer
re-attaches the canvas — and when the fresh mesh changed the url
attribute, the mesh reloads in place. The form morphs its redirect
response so saving keeps the viewer alive and shows the spinner over
the blurred old mesh.

Numbers cast integer-preserving so schema defaults compare equal to
resubmitted form strings — saving unchanged values triggers no render.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
feat: keep the camera view across mesh swaps
Some checks failed
PR Triage / Triage pull request-1 (pull_request) Successful in 24s
PR Triage / Triage pull request (pull_request) Successful in 0s
CI / Quality / Bundler Audit (pull_request) Successful in 1m17s
CI / Quality / RuboCop (pull_request) Successful in 1m37s
CI / Quality / Brakeman (pull_request) Successful in 1m40s
CI / Quality (pull_request) Successful in 0s
CI / Tests / Unit (pull_request) Failing after 2m15s
CI / Tests / System (pull_request) Failing after 2m27s
CI / Tests / Coverage (pull_request) Has been skipped
CI / Tests (pull_request) Failing after 0s
CI / Container / Build and push (pull_request) Has been skipped
CI / Container (pull_request) Failing after 0s
CI / Deploy (pull_request) Has been skipped
fedbc055e5
The preview framing (OpenSCAD orientation) only applies on the first
load — later swaps keep the user's camera position, zoom and rotation.
The old mesh stays visible until the replacement is fully built, so the
swap happens atomically without an empty frame, and a stale load is
dropped when the url changes again mid-flight.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
fix(test): stub openscad in broadcast tests and fix alert toast classes
Some checks failed
PR Triage / Triage pull request-1 (pull_request) Successful in 35s
PR Triage / Triage pull request (pull_request) Successful in 0s
CI / Quality / Brakeman (pull_request) Successful in 2m26s
CI / Quality / Bundler Audit (pull_request) Successful in 2m28s
CI / Quality / RuboCop (pull_request) Successful in 3m0s
CI / Quality (pull_request) Successful in 0s
CI / Tests / Unit (pull_request) Successful in 4m38s
CI / Tests / System (pull_request) Successful in 6m28s
CI / Tests / Coverage (pull_request) Failing after 1m50s
CI / Tests (pull_request) Failing after 0s
CI / Container / Build and push (pull_request) Has been skipped
CI / Container (pull_request) Failing after 0s
CI / Deploy (pull_request) Has been skipped
bca88e0877
The broadcast tests drain the enqueued render job, which spawns the
missing openscad binary on CI — the render is now stubbed to a scratch
file. The alert component skipped its toast classes when the caller
brought its own class list (||=), leaving the absolute close button
without a positioning context so the navbar intercepted its clicks.

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
chore: exclude the no-op template render from method coverage
All checks were successful
CI / Quality / Bundler Audit (pull_request) Successful in 1m13s
CI / Quality / Brakeman (pull_request) Successful in 1m14s
PR Triage / Triage pull request-1 (pull_request) Successful in 59s
PR Triage / Triage pull request (pull_request) Successful in 0s
CI / Quality / RuboCop (pull_request) Successful in 1m58s
CI / Quality (pull_request) Successful in 0s
CI / Tests / Unit (pull_request) Successful in 3m26s
CI / Tests / System (pull_request) Successful in 3m28s
CI / Tests / Coverage (pull_request) Successful in 1m42s
CI / Tests (pull_request) Successful in 0s
CI / Container / Build and push (pull_request) Successful in 54s
CI / Container (pull_request) Successful in 0s
CI / Deploy (pull_request) Has been skipped
d7bfa529f8
The empty base #render exists only to be overridden by the per-format
subclasses and dragged the Jobs group's method coverage below the 95%
target (90%).

---------

Co-Authored-By: opencode (Mistral GLM) <opencode-agent[bot]@hoppe-dev.eu>
hobbypunk deleted branch feature/25_param_set_editor 2026-11-13 15:00:19 +00:00
Sign in to join this conversation.
No description provided.