Files
WidgetWorkbench/.agents/skills/workbench-hmi-clients/SKILL.md
2026-10-20 20:15:46 +00:00

5.8 KiB
Raw Blame History

name, description
name description
workbench-hmi-clients Migrates existing Workbench HTML clients to native Vue 3 + GridStack.js HMI widgets while preserving iTAC IMSAPI behavior, user customization, ios.css tokens and GlassFish dsCustNJTA persistence.

Workbench HMI – AI Implementation Skill

Use this skill when the user asks to create a new HMI page, migrate legacy Workbench HTML, compose widgets, modify ios.css, or add a MES action. Read the current repository first. Do not hallucinate IMSAPI parameters.

Source of truth

  • Existing Workbench HTML code: backend/src/main/webapp/*.html.
  • Existing business/REST endpoints: backend/src/main/java/com/workbenchclassic.
  • Shared MES action adapter: hmi-frontend/src/widgets/mesClient.ts.
  • Catalog and rendering: hmi-frontend/src/widgets/catalog.ts, WidgetRenderer.vue.
  • GridStack layouts: hmi-frontend/src/widgets/presets.ts.
  • Visual tokens: backend/src/main/webapp/ios.css, hmi-frontend/src/ios-widget.css, hmi-frontend/src/mes-widget.css.
  • Styles admin API: HmiStyleResource.java, GET /backend/api/hmi/v1/styles/ios.
  • CSS delivery: GET /backend/hmi-theme/ios.css.
  • Existing GlassFish datasource dsCustNJTA; server determines Oracle or SQL Server via JDBC metadata. Never add a separate PostgreSQL database.

1. Understand the old client before implementing

  1. Read the original HTML and all script blocks, not only the UI.
  2. Inventory every fetch, IMSAPI action, query parameters, sessionStorage, table key order, modal, failure state and station-specific rule.
  3. Record user-visible workflows and the accepted/nonzero IMSAPI return codes.
  4. Classify all functions as read, write, administrative or visual. For writes, retain exact serial-number positions, process layers and keys.
  5. Create an operation mapping in hmi-docs/CLIENT_MIGRATION_MATRIX.md.

2. Convert to native Vue

  • Single File Component with <script setup lang="ts">, <template>; no iframe, jQuery or DOM innerHTML.
  • Props must be {widget:HmiWidget; station:string; demo:boolean}.
  • Use props.widget.props only for appearance/allowed configuration. No custom API URL from untrusted widget configuration.
  • Use shared mesAction() and readMesSession() from mesClient.ts, never store session tokens in PostgreSQL, localStorage, logs or cookies.
  • Preserve original structured result keys and flat-to-row conversion using structuredRows().
  • Bind all text through Vue interpolation, never insert untrusted MES text with v-html.
  • Use Teleport to="body" for dialogs because GridStack tiles may clip fixed overlays.
  • Distinguish local form changes from successful MES writes; inspect result.return_value, do not trust HTTP 200 alone.
  • Writes: require valid station, serial, authorization/session, correct active order, explicit confirmation for consequential actions, refresh data after acknowledged success.
  • Never activate MES write features in demo / offline mode.
  • Provide loading, empty, error, success states and a fully usable keyboard flow.

3. Register the widget

  1. Implement src/widgets/<Name>Widget.vue and optionally isolated helpers.
  2. Add an entry to widgetCatalog with a unique type such as wb.<slug>, group, icon, default 12-column geometry and props.
  3. Register the type on the server allowlist HmiApiResource.WIDGET_TYPES (mandatory; unpublished unknown widgets are rejected).
  4. Add explicit import and <Component v-else-if=...> branch to WidgetRenderer.vue before the legacy module fallback.
  5. Add/adjust a designer preset in presets.ts and a test configuration.
  6. Keep all CSS in mes-widget.css (namespace .wb-mes-*) or ios-widget.css, using tokens like --itac-red, --itac-border; do not import full legacy ios.css into the HMI shell.

Quick scaffold (does NOT auto-wire IMSAPI behavior):

node .agents/skills/workbench-hmi-clients/scripts/new-widget.mjs quality-check "Qualitätsprüfung"

4. Theme / online ios.css editing

  • The WAR's original ios.css is an immutable fallback. All legacy HTML pages read /backend/hmi-theme/ios.css, backed by published DB revisions.
  • Use the HMI Designer sidebar ios.css bearbeiten to save a draft, preview inside a sandboxed iframe, and publish; publishing requires hmi-publisher or hmi-admin.
  • Do not edit runtime WAR files on disk or make user CSS executable JavaScript.
  • Themes use published --itac-* token values via loadThemeTokens() in the Vue shell. Structural changes to old CSS selectors primarily affect old HTML pages, not Vue internals.

5. Backend and database

  • New REST resources are in com.workbenchclassic.hmi and use existing Jersey /backend/api/*.
  • All configuration storage uses HmiDb.open() -> DBService("dsCustNJTA").
  • Deployment creates missing tables via HmiSchemaBootstrap in CUST (Oracle) or cust (SQL Server). Never drop or overwrite existing tables automatically.
  • Prepare statements; never concatenate user input into SQL identifiers.
  • Use GlassFish principal/roles and existing CSRF validation; don't trust role or station claims in POST body.
  • A newly added schema table needs Oracle and SQL Server DDL, bootstrap migration behavior, and tests for both.

6. Definition of done

  • Original client functionality is mapped 1:1 or explicit omissions are documented.
  • Build: cd hmi-frontend && npm ci && npm run build; cd ../backend && mvn clean package.
  • Automated validation and hands-on checks: Java 11 compilation, Vue typecheck, happy and error paths, 401/403, booking success and error return codes, security, 6+ tabs, disabled UI in demo.
  • Test with a dedicated iTAC test station before production; manual transaction paths are never considered live-tested merely because code compiled.
  • Deliver updated complete source ZIP, updated migration matrix, and tests/build-status summary.

See migration checklist for IMSAPI-specific examples.