@scalio-cloud/ui 0.59.0 → 0.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -439,9 +439,13 @@ import { askConfirm, askText, showMessage } from "@scalio-cloud/ui/react";
439
439
  if (!(await askConfirm({ title: "Benutzer löschen", text: "Das lässt sich nicht rückgängig machen.", confirmLabel: "Löschen", danger: true }))) return;
440
440
  const name = await askText({ title: "Umbenennen", label: "Neuer Name", value: old, required: true }); // null on Abbrechen
441
441
  await showMessage({ title: "Gespeichert", text: "Alles da." });
442
+ const a = await askConfirm({ text: "Einschalten?", check: "Fehlerberichte senden" }); // false or { checked }
442
443
  ```
443
444
 
444
- Test IDs: `confirm-dialog`, `confirm-dialog-ok`, `confirm-dialog-cancel`, `confirm-dialog-input`. `SaasUpdatesPanel` asks
445
+ `check` (since 0.60.0) adds a checkbox under the text, off unless `checked: true`; OK then resolves `{ checked }`
446
+ (truthy) instead of `true`, Abbrechen still `false`. Without `check` nothing changes.
447
+
448
+ Test IDs: `confirm-dialog`, `confirm-dialog-ok`, `confirm-dialog-cancel`, `confirm-dialog-input`, `confirm-dialog-check`. `SaasUpdatesPanel` asks
445
449
  with `askConfirm` and then shows `UpdateProgress` (`saas-update-progress`): it polls `/version.json` (props
446
450
  `versionUrl`, `checkVersion`, `pollMs` 5 s, `timeoutMs` 20 min) and reloads the page once the new version runs.
447
451
 
@@ -552,6 +556,33 @@ const updates = saasUpdatesApi(api); // once, outside the component
552
556
  The banner is blue (orange for a security update); people without admin role only see when the update is planned.
553
557
  «Später» hides it for this version until the next browser session.
554
558
 
559
+ ### Vorabversionen (pre-releases)
560
+
561
+ Since 0.60.0 (scalio-docs ADR 0115, BL-404) the panel can show the switch «Vorabversionen anzeigen» (EN «Show
562
+ pre-releases»). It is optional: without `admin` and `onPrereleaseChange` the panel looks exactly as before.
563
+
564
+ ```jsx
565
+ <SaasUpdatesPanel client={updates} lang={lang} admin={isAdmin}
566
+ prerelease={settings.prerelease} // stored value, default off
567
+ onPrereleaseChange={(on, o) => api.put("/settings/prerelease", { on, ...o })} // the app saves it
568
+ notify={…} />
569
+ ```
570
+
571
+ - The switch shows only with `admin={true}` and an `onPrereleaseChange` function. Turning it on asks first (no way
572
+ back, only the backup before the update; best-effort support) with the checkbox «Fehlerberichte aus Vorabversionen
573
+ an Scalio senden» (off by default, ADR 0115 P9) and calls `onPrereleaseChange(true, { errorReports })`; turning it
574
+ off asks nothing and calls `onPrereleaseChange(false)` (stops only new pre-releases). A rejected promise keeps the old value and shows the error (`saas-updates-prerelease-error`).
575
+ - Self-hosted (`saas: false`) or while `/saas-updates` fails, the section shows only the switch (the Scalio Installer
576
+ reads the value from the app).
577
+ - An offer with `prerelease: true` gets the title «Vorabversion 1.3.0rc2 ist verfügbar» with an orange badge
578
+ «Vorabversion», a warning below it, «keine Frist, nur auf Klick» instead of the deadline, no «Verschieben bis», and
579
+ «Jetzt aktualisieren» asks with the warning and a red button. The banner shows the same badge and «Wird nur auf
580
+ Klick installiert.».
581
+ - `PrereleaseSwitch` (props `value`, `onChange`, `lang`, `labels`, `notify`, `disabled`) is exported for other pages.
582
+
583
+ Test IDs: `saas-updates-prerelease`, `saas-updates-prerelease-switch`, `saas-updates-prerelease-error`,
584
+ `saas-updates-prerelease-badge`, `saas-updates-prerelease-warning`, `saas-update-banner-prerelease`.
585
+
555
586
  ## Scalio Agent: Einstellungen → Scalio Agent (React)
556
587
 
557
588
  Since 0.56.0 (scalio-docs ADR 0107, `interfaces/agent-v2.md`) every app that uses the Scalio Agent shows the same
@@ -573,6 +604,37 @@ list. Test IDs: `agents-panel`, `agents-code-create`, `agents-code-value`, `agen
573
604
  `agent-role-<id>-<role>`, `agent-worker-state-<id>-<worker>`, `agent-worker-restart|stop|start-<id>-<worker>`,
574
605
  `agent-block-<id>`, `agent-remove-<id>`, `agents-tasks`.
575
606
 
607
+ Since 0.64.0 (self-update U2, scalio-platform 0.39.0) the block also shows the agent version bundled in the app, the
608
+ update rule of the instance (automatic, maintenance window with days and times, or only on request; `GET|PUT
609
+ /update[/policy]`) and per agent the update state reported by the agent (updating, updated, rolled back with reason,
610
+ refused), a hint when the agent is below the app's minimum version, «Jetzt aktualisieren» (with a question) and «Erneut
611
+ versuchen» after a rollback. Against an older backend without `/update` the section stays hidden. Test IDs:
612
+ `agents-update`, `agents-update-mode`, `agents-update-day-<0..6>`, `agents-update-save`, `agent-update-state-<id>`,
613
+ `agent-update-now-<id>`, `agent-update-retry-<id>`, `agent-outdated-<id>`.
614
+
615
+ Since 0.65.0 (scripts from the app U3, scalio-platform 0.40.0) every agent shows its script state (`scripts: {version,
616
+ current}`: «aktuell» or «werden aktualisiert») and «Passwörter verschlüsselt» when it reported an encryption key
617
+ (`sealed`). Test ID `agent-scripts-<id>`.
618
+
619
+ ### Scripts des Agents (U5)
620
+
621
+ Since 0.66.0 (customer customizations U5, scalio-platform 0.41.0) `AgentScriptsPanel` shows every script the app
622
+ brings for the agent with its state (Standard, Angepasst, Angepasst veraltet, Freigabe ausstehend). The admin writes a
623
+ hook (`<Name>.after.ps1`, shown first) or replaces the whole script with a reason; after a new standard the panel
624
+ shows what Scalio changed and the customer's version side by side with «Anpassung behalten» and «Zurück zum
625
+ Standard»; with the four-eyes switch a second person approves. `canEdit` = the app's right `agent.scripts.edit`.
626
+
627
+ ```jsx
628
+ import { AgentScriptsPanel, agentScriptsApi } from "@scalio-cloud/ui/react";
629
+
630
+ const scripts = agentScriptsApi(api); // once, outside the component
631
+ <AgentScriptsPanel client={scripts} lang={lang} canEdit={can("agent.scripts.edit")} notify={notify} />
632
+ ```
633
+
634
+ Test IDs: `agent-scripts-panel`, `agent-script-<worker>-<name>`, `agent-script-state-…`, `agent-script-edit-…`,
635
+ `agent-script-content`, `agent-script-reason`, `agent-script-save`, `agent-script-keep`, `agent-script-approve`,
636
+ `agent-scripts-four-eyes`.
637
+
576
638
  ## KI-Bausteine: Einstellungen → KI-Assistent, Knopf, Vorschlag, Assistent (React)
577
639
 
578
640
  Since 0.57.0 (scalio-docs ADR 0111, `concepts/ki-alle-apps.md`) every app shows AI the same way. Server side:
@@ -669,6 +731,24 @@ const jobs = jobsApi(api); // GET /jobs, /jobs/runs, /jobs/queue, POST /jobs
669
731
  `queueActions(item, reload)`, `renderQueueDetail(item, reload)`.
670
732
  - `AuditNav`: the tabs `/audit` and `/jobs` (`base` for another prefix, `jobs={false}` hides Jobs).
671
733
 
734
+ ## Markdown anzeigen (React)
735
+
736
+ Since 0.63.0 (scalio-docs ADR 0110 point 4) Beacon (knowledge base) and Folio (pages) show Markdown with the same
737
+ block. The text is parsed into plain data and shown as React elements, never as HTML: a `<script>` in a text stays
738
+ text, links work only with http, https, mailto or a relative address. GitHub flavour: headings, tables with
739
+ alignment, callouts (`> [!NOTE]`, TIP, IMPORTANT, WARNING, CAUTION), task lists, one nested list level, code blocks,
740
+ strikethrough. Styles: classes `scalio-md-*` in `nav.css`.
741
+
742
+ ```jsx
743
+ import { Markdown, markdownOutline } from "@scalio-cloud/ui/react";
744
+
745
+ <Markdown text={page.body} lang={lang} testId="page-body" />
746
+ markdownOutline(page.body) // [{ level, text, id }] for a table of contents; headings carry the same id
747
+ ```
748
+
749
+ `labels` overrides the callout titles (`{ note, tip, important, warning, caution }`). Also exported:
750
+ `parseMarkdownBlocks`, `parseMarkdownInline`, `markdownHeadingId`, `safeHref`. Test IDs: `callout-<kind>`.
751
+
672
752
  ## shadcn/ui components (from 0.38.0)
673
753
 
674
754
  One copy of the shadcn/ui components the apps used to keep in `src/components/ui` (code-quality plan QA6, decision
package/nav.css CHANGED
@@ -919,3 +919,37 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
919
919
  .scalio-ai-turn-text { white-space: pre-wrap; }
920
920
  .scalio-ai-panel-form { display: flex; gap: 0.5rem; align-items: flex-end; }
921
921
  .scalio-ai-panel-form textarea { flex: 1; resize: vertical; }
922
+
923
+ /* Markdown (react/markdown.js): Beacon knowledge base, Folio pages. */
924
+ .scalio-md { font-size: 0.875rem; line-height: 1.6; overflow-wrap: anywhere; }
925
+ .scalio-md > * + *, .scalio-md-quote > * + *, .scalio-md-callout > * + * { margin-top: 0.75rem; }
926
+ .scalio-md-h1, .scalio-md-h2 { font-family: 'Chivo', 'IBM Plex Sans', sans-serif; font-weight: 700; padding-top: 0.5rem; }
927
+ .scalio-md-h1 { font-size: 1.5rem; line-height: 2rem; }
928
+ .scalio-md-h2 { font-size: 1.25rem; line-height: 1.75rem; border-bottom: 1px solid hsl(var(--border)); padding-bottom: 0.25rem; }
929
+ .scalio-md-h3 { font-size: 1.125rem; font-weight: 700; padding-top: 0.25rem; }
930
+ .scalio-md-h4, .scalio-md-h5, .scalio-md-h6 { font-size: 1rem; font-weight: 700; }
931
+ .scalio-md-h5, .scalio-md-h6 { font-size: 0.875rem; }
932
+ .scalio-md-h6 { color: hsl(var(--muted-foreground)); }
933
+ .scalio-md-link { color: hsl(var(--primary)); text-decoration: underline; }
934
+ .scalio-md-code { padding: 0.125rem 0.25rem; border-radius: 2px; background: hsl(var(--secondary)); font-family: 'JetBrains Mono', monospace; font-size: 0.85em; }
935
+ .scalio-md-pre { padding: 0.75rem; border-radius: 2px; background: hsl(var(--secondary)); font-family: 'JetBrains Mono', monospace; font-size: 0.75rem; overflow-x: auto; white-space: pre; }
936
+ .scalio-md-rule { border: 0; border-top: 1px solid hsl(var(--border)); }
937
+ .scalio-md-list { list-style: disc; padding-left: 1.5rem; }
938
+ .scalio-md-list.is-ordered { list-style: decimal; }
939
+ .scalio-md-list.is-tasks { list-style: none; padding-left: 0.25rem; }
940
+ .scalio-md-list > li + li { margin-top: 0.25rem; }
941
+ .scalio-md-list > li.is-task { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: flex-start; }
942
+ .scalio-md-list > li.is-task > input { margin-top: 0.3rem; }
943
+ .scalio-md-list > li > .scalio-md-list { margin-top: 0.25rem; flex-basis: 100%; }
944
+ .scalio-md-quote { border-left: 4px solid hsl(var(--border)); padding-left: 1rem; color: hsl(var(--muted-foreground)); }
945
+ .scalio-md-callout { border-left: 4px solid rgb(59 130 246 / 0.6); background: rgb(59 130 246 / 0.05); border-radius: 2px; padding: 0.75rem 1rem; }
946
+ .scalio-md-callout[data-callout="tip"] { border-color: rgb(22 163 74 / 0.6); background: rgb(22 163 74 / 0.05); }
947
+ .scalio-md-callout[data-callout="important"] { border-color: rgb(168 85 247 / 0.6); background: rgb(168 85 247 / 0.05); }
948
+ .scalio-md-callout[data-callout="warning"] { border-color: rgb(245 158 11 / 0.7); background: rgb(245 158 11 / 0.05); }
949
+ .scalio-md-callout[data-callout="caution"] { border-color: rgb(220 38 38 / 0.6); background: rgb(220 38 38 / 0.05); }
950
+ .scalio-md-callout-title { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.875rem; }
951
+ .scalio-md-table-wrap { overflow-x: auto; }
952
+ .scalio-md-table { font-size: 0.875rem; border-collapse: collapse; border: 1px solid hsl(var(--border)); }
953
+ .scalio-md-table th, .scalio-md-table td { padding: 0.375rem 0.75rem; border: 1px solid hsl(var(--border)); vertical-align: top; }
954
+ .scalio-md-table thead { background: hsl(var(--secondary)); }
955
+ .scalio-md-table th { font-weight: 700; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scalio-cloud/ui",
3
- "version": "0.59.0",
3
+ "version": "0.66.0",
4
4
  "description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "private": false,
@@ -0,0 +1,295 @@
1
+ "use strict";
2
+ // Customer customizations of the Scalio Agent scripts (scalio-docs ADR 0107 U5, interfaces/agent-v2.md
3
+ // «Kunden-Anpassungen», concept agent-2 F5-F7, F9): Einstellungen -> Scalio Agent -> Scripts. Backend: scalio-platform
4
+ // 0.41.0 `agent.AgentHub.router` (GET /agent/v2/admin/scripts, GET|PUT|DELETE /scripts/{worker}/{name},
5
+ // POST /scripts/{worker}/{name}/approve|keep, PUT /scripts-policy).
6
+ // Hooks first (F6): a hook runs after the standard script; the whole script can be replaced too. After a new standard
7
+ // (contract change) the customization is «veraltet»: the panel shows what Scalio changed and the customer's version
8
+ // side by side, tasks wait until the admin keeps the customization or goes back to the standard (F7).
9
+ const React = require("react");
10
+ const h = React.createElement;
11
+ const Icons = require("./icons");
12
+ const { StatusBadge } = require("./blocks");
13
+ const { SettingsSection, SettingsField: Field } = require("./settings");
14
+ const { askConfirm } = require("./dialog");
15
+
16
+ const LABELS = {
17
+ de: {
18
+ title: "Scripts des Agents",
19
+ hint: "Hier passen Sie die Scripts an, die der Scalio Agent ausführt. Ein Hook läuft nach dem Standard-Script und ändert es nicht; Sie können das Script auch ganz ersetzen. Angepasste Scripts laufen nur auf Servern, auf denen «Eigene Scripts erlauben» (AllowCustomScripts) eingeschaltet ist.",
20
+ script: "Script",
21
+ actions: "Aktionen",
22
+ state: "Status",
23
+ version: "Version",
24
+ edit: "Bearbeiten",
25
+ close: "Schliessen",
26
+ none: "Diese App bringt keine Scripts für den Agent mit.",
27
+ states: { standard: "Standard", custom: "Angepasst", outdated: "Angepasst, veraltet", pending: "Freigabe ausstehend" },
28
+ fourEyes: "Vier-Augen-Prinzip: Änderungen an Scripts gibt eine zweite Person frei",
29
+ kindHook: "Hook (nach dem Standard-Script)",
30
+ kindFull: "Ganzes Script ersetzen",
31
+ content: "Inhalt",
32
+ reason: "Begründung (mindestens 10 Zeichen)",
33
+ save: "Speichern",
34
+ saved: "Gespeichert.",
35
+ savedPending: "Gespeichert. Die Änderung wartet auf die Freigabe einer zweiten Person.",
36
+ standardText: "Standard-Script von Scalio",
37
+ pendingBy: "Version {n} von {by} wartet auf Freigabe.",
38
+ approve: "Freigeben",
39
+ approved: "Freigegeben.",
40
+ outdatedTitle: "Scalio hat das Standard-Script geändert",
41
+ outdatedText: "Aufträge dieser Aktion warten, bis Sie entscheiden. Prüfen Sie, ob Ihre Anpassung zur neuen Fassung passt.",
42
+ scalioChanged: "Was Scalio geändert hat",
43
+ yourVersion: "Ihre Anpassung",
44
+ keep: "Anpassung behalten",
45
+ keepConfirm: "Ihre Anpassung für die neue Fassung des Standard-Scripts behalten? Wartende Aufträge laufen dann damit.",
46
+ reset: "Zurück zum Standard",
47
+ resetConfirm: "Die Anpassung von «{name}» entfernen? Aufträge laufen wieder mit dem Standard-Script. Die Versionen bleiben im Verlauf.",
48
+ history: "Verlauf",
49
+ noHistory: "Noch keine Anpassung.",
50
+ by: "von {by}",
51
+ hookTemplate: "param($Data, $Result)\n# Läuft nach dem Standard-Script. $Data = Auftragsdaten, $Result = Ergebnis des Standard-Scripts.\n",
52
+ },
53
+ en: {
54
+ title: "Agent scripts",
55
+ hint: "Customize the scripts the Scalio Agent runs. A hook runs after the standard script and leaves it unchanged; you can also replace the whole script. Customized scripts run only on servers where «Allow own scripts» (AllowCustomScripts) is switched on.",
56
+ script: "Script",
57
+ actions: "Actions",
58
+ state: "State",
59
+ version: "Version",
60
+ edit: "Edit",
61
+ close: "Close",
62
+ none: "This app brings no scripts for the agent.",
63
+ states: { standard: "Standard", custom: "Customized", outdated: "Customized, outdated", pending: "Waiting for approval" },
64
+ fourEyes: "Four-eyes principle: a second person approves changes to scripts",
65
+ kindHook: "Hook (after the standard script)",
66
+ kindFull: "Replace the whole script",
67
+ content: "Content",
68
+ reason: "Reason (at least 10 characters)",
69
+ save: "Save",
70
+ saved: "Saved.",
71
+ savedPending: "Saved. The change waits for a second person to approve it.",
72
+ standardText: "Standard script by Scalio",
73
+ pendingBy: "Version {n} by {by} waits for approval.",
74
+ approve: "Approve",
75
+ approved: "Approved.",
76
+ outdatedTitle: "Scalio changed the standard script",
77
+ outdatedText: "Tasks of this action wait until you decide. Check whether your customization fits the new version.",
78
+ scalioChanged: "What Scalio changed",
79
+ yourVersion: "Your customization",
80
+ keep: "Keep customization",
81
+ keepConfirm: "Keep your customization for the new version of the standard script? Waiting tasks then run with it.",
82
+ reset: "Back to standard",
83
+ resetConfirm: "Remove the customization of «{name}»? Tasks run with the standard script again. The versions stay in the history.",
84
+ history: "History",
85
+ noHistory: "No customization yet.",
86
+ by: "by {by}",
87
+ hookTemplate: "param($Data, $Result)\n# Runs after the standard script. $Data = task data, $Result = result of the standard script.\n",
88
+ },
89
+ };
90
+
91
+ const STATE_TONE = { standard: "neutral", custom: "ok", outdated: "warn", pending: "running" };
92
+
93
+ function labels(lang, overrides) {
94
+ return Object.assign({}, LABELS[lang === "en" ? "en" : "de"], overrides || {});
95
+ }
96
+
97
+ function fill(text, vars) {
98
+ return Object.keys(vars || {}).reduce((s, k) => s.split(`{${k}}`).join(vars[k] == null ? "" : vars[k]), text);
99
+ }
100
+
101
+ function errorText(err) {
102
+ const d = err && err.response && err.response.data && err.response.data.detail;
103
+ if (typeof d === "string") return d;
104
+ return (err && err.message) || String(err);
105
+ }
106
+
107
+ function agentScriptsApi(api, base) {
108
+ const b = base || "/agent/v2/admin";
109
+ const one = (w, n) => `${b}/scripts/${encodeURIComponent(w)}/${encodeURIComponent(n)}`;
110
+ return {
111
+ list: () => api.get(`${b}/scripts`).then((r) => r.data),
112
+ get: (w, n) => api.get(one(w, n)).then((r) => r.data),
113
+ save: (w, n, body) => api.put(one(w, n), body).then((r) => r.data),
114
+ approve: (w, n, number) => api.post(`${one(w, n)}/approve`, { number }).then((r) => r.data),
115
+ keep: (w, n) => api.post(`${one(w, n)}/keep`, {}).then((r) => r.data),
116
+ reset: (w, n) => api.delete(one(w, n)).then((r) => r.data),
117
+ setPolicy: (policy) => api.put(`${b}/scripts-policy`, policy).then((r) => r.data),
118
+ };
119
+ }
120
+
121
+ // Line diff (longest common subsequence): [{op: "same"|"add"|"del", text}].
122
+ function lineDiff(a, b) {
123
+ const x = String(a || "").split("\n");
124
+ const y = String(b || "").split("\n");
125
+ const n = x.length;
126
+ const m = y.length;
127
+ const len = Array.from({ length: n + 1 }, () => new Array(m + 1).fill(0));
128
+ for (let i = n - 1; i >= 0; i -= 1) {
129
+ for (let j = m - 1; j >= 0; j -= 1) len[i][j] = x[i] === y[j] ? len[i + 1][j + 1] + 1 : Math.max(len[i + 1][j], len[i][j + 1]);
130
+ }
131
+ const out = [];
132
+ let i = 0;
133
+ let j = 0;
134
+ while (i < n && j < m) {
135
+ if (x[i] === y[j]) { out.push({ op: "same", text: x[i] }); i += 1; j += 1; }
136
+ else if (len[i + 1][j] >= len[i][j + 1]) { out.push({ op: "del", text: x[i] }); i += 1; }
137
+ else { out.push({ op: "add", text: y[j] }); j += 1; }
138
+ }
139
+ while (i < n) { out.push({ op: "del", text: x[i] }); i += 1; }
140
+ while (j < m) { out.push({ op: "add", text: y[j] }); j += 1; }
141
+ return out;
142
+ }
143
+
144
+ const DIFF_STYLE = {
145
+ add: { background: "var(--scalio-success-soft, #e6f4ea)" },
146
+ del: { background: "var(--scalio-danger-soft, #fdecea)", textDecoration: "line-through" },
147
+ same: {},
148
+ };
149
+
150
+ function DiffView(props) {
151
+ const rows = lineDiff(props.from, props.to);
152
+ return h("pre", { className: "scalio-settings-text", "data-testid": props.testId,
153
+ style: { whiteSpace: "pre-wrap", fontFamily: "var(--scalio-font-mono, monospace)", fontSize: "0.85em", maxHeight: "24rem", overflow: "auto" } },
154
+ rows.map((r, i) => h("div", { key: i, style: DIFF_STYLE[r.op], "data-op": r.op }, `${r.op === "add" ? "+ " : r.op === "del" ? "- " : " "}${r.text}`)));
155
+ }
156
+
157
+ function stateOf(row) {
158
+ if (row.pending && row.state === "standard") return "pending";
159
+ return row.state;
160
+ }
161
+
162
+ // Props: client (agentScriptsApi), lang, labels, canEdit (right agent.scripts.edit, default true), notify, formatError.
163
+ function AgentScriptsPanel(props) {
164
+ const L = labels(props.lang, props.labels);
165
+ const fmtErr = props.formatError || errorText;
166
+ const canEdit = props.canEdit !== false;
167
+ const [data, setData] = React.useState(null);
168
+ const [open, setOpen] = React.useState(null); // detail of the opened script
169
+ const [kind, setKind] = React.useState("hook");
170
+ const [text, setText] = React.useState("");
171
+ const [reason, setReason] = React.useState("");
172
+ const [busy, setBusy] = React.useState(false);
173
+ const [error, setError] = React.useState("");
174
+
175
+ const load = React.useCallback(async () => {
176
+ try { setData(await props.client.list()); setError(""); } catch (e) { setError(fmtErr(e)); }
177
+ }, [props.client]); // eslint-disable-line react-hooks/exhaustive-deps
178
+ React.useEffect(() => { load(); }, [load]);
179
+
180
+ const fillEditor = (d, k) => {
181
+ const v = d.pending || d.active;
182
+ if (v && v.kind === k) setText(v.content || "");
183
+ else setText(k === "hook" ? L.hookTemplate : d.standard.content);
184
+ };
185
+ const openScript = async (row) => {
186
+ try {
187
+ const d = await props.client.get(row.worker, row.name);
188
+ const v = d.pending || d.active;
189
+ const k = v ? v.kind : "hook";
190
+ setOpen(d); setKind(k); fillEditor(d, k); setReason(""); setError("");
191
+ } catch (e) { setError(fmtErr(e)); }
192
+ };
193
+ const run = async (fn, ok) => {
194
+ setBusy(true);
195
+ try {
196
+ const res = await fn();
197
+ if (ok && props.notify) props.notify(typeof ok === "function" ? ok(res) : ok, "ok");
198
+ await load();
199
+ if (open) setOpen(await props.client.get(open.worker, open.name));
200
+ setBusy(false);
201
+ return res;
202
+ } catch (e) {
203
+ const t = fmtErr(e); setError(t); if (props.notify) props.notify(t, "error"); setBusy(false);
204
+ return null;
205
+ }
206
+ };
207
+
208
+ const rows = [];
209
+ const scripts = (data && data.scripts) || [];
210
+ const policy = (data && data.policy) || { four_eyes: false };
211
+ rows.push(h(Field, { key: "policy", label: L.fourEyes, testId: "agent-scripts-policy" },
212
+ h("label", { className: "scalio-settings-check" },
213
+ h("input", { type: "checkbox", checked: !!policy.four_eyes, disabled: busy || !canEdit, "data-testid": "agent-scripts-four-eyes",
214
+ onChange: () => run(() => props.client.setPolicy({ four_eyes: !policy.four_eyes }), L.saved) }),
215
+ h("span", null, L.fourEyes))));
216
+
217
+ rows.push(h(Field, { key: "list", label: L.title },
218
+ !data ? null : scripts.length === 0 ? h("p", { className: "scalio-settings-text", "data-testid": "agent-scripts-none" }, L.none)
219
+ : h("div", { style: { overflowX: "auto" } }, h("table", { className: "scalio-users-table", "data-testid": "agent-scripts-table" },
220
+ h("thead", null, h("tr", null, [L.script, L.actions, L.state, L.version, ""].map((t, i) => h("th", { key: i }, t)))),
221
+ h("tbody", null, scripts.map((s) => {
222
+ const st = stateOf(s);
223
+ const id = `${s.worker}-${s.name}`;
224
+ return h("tr", { key: id, "data-testid": `agent-script-${id}` },
225
+ h("td", null, h("div", { className: "font-medium" }, s.name), h("div", { className: "scalio-settings-text" }, s.worker)),
226
+ h("td", null, (s.actions || []).join(", ")),
227
+ h("td", null, h(StatusBadge, { tone: STATE_TONE[st] || "neutral", testId: `agent-script-state-${id}` }, L.states[st] || st)),
228
+ h("td", null, s.active ? `${s.active.number} · ${s.active.kind === "hook" ? "Hook" : "Script"}` : "–"),
229
+ h("td", null, h("button", { type: "button", className: "scalio-btn is-ghost", disabled: busy, "data-testid": `agent-script-edit-${id}`,
230
+ onClick: () => openScript(s) }, L.edit)));
231
+ }))))));
232
+
233
+ if (open) {
234
+ const d = open;
235
+ const tid = `${d.worker}-${d.name}`;
236
+ const parts = [];
237
+ if (d.state === "outdated" && d.active) {
238
+ parts.push(h("div", { key: "out", className: "scalio-notice is-warning", role: "status", "data-testid": "agent-script-outdated" },
239
+ h("div", { className: "scalio-notice-body" },
240
+ h("div", { className: "scalio-notice-title" }, L.outdatedTitle),
241
+ h("div", { className: "scalio-notice-text" }, L.outdatedText),
242
+ h("div", { style: { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(18rem, 1fr))", gap: "0.75rem", marginTop: "0.5rem" } },
243
+ h("div", null, h("div", { className: "font-medium" }, L.scalioChanged),
244
+ h(DiffView, { from: d.active.base_content, to: d.standard.content, testId: "agent-script-diff-standard" })),
245
+ h("div", null, h("div", { className: "font-medium" }, L.yourVersion),
246
+ d.active.kind === "full"
247
+ ? h(DiffView, { from: d.active.base_content, to: d.active.content, testId: "agent-script-diff-custom" })
248
+ : h("pre", { className: "scalio-settings-text", "data-testid": "agent-script-diff-custom", style: { whiteSpace: "pre-wrap" } }, d.active.content))),
249
+ canEdit ? h("div", { style: { display: "flex", gap: "0.5rem", marginTop: "0.5rem", flexWrap: "wrap" } },
250
+ h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy, "data-testid": "agent-script-keep",
251
+ onClick: async () => { if (await askConfirm({ title: L.title, text: L.keepConfirm, confirmLabel: L.keep, lang: props.lang })) run(() => props.client.keep(d.worker, d.name), L.saved); } }, L.keep),
252
+ h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "agent-script-reset-outdated",
253
+ onClick: async () => { if (await askConfirm({ title: L.title, text: fill(L.resetConfirm, { name: d.name }), confirmLabel: L.reset, lang: props.lang, danger: true })) run(() => props.client.reset(d.worker, d.name), L.saved); } }, L.reset)) : null)));
254
+ }
255
+ if (d.pending) {
256
+ parts.push(h("div", { key: "pend", className: "scalio-notice is-info", role: "status", "data-testid": "agent-script-pending" },
257
+ h("div", { className: "scalio-notice-body" },
258
+ h("div", { className: "scalio-notice-text" }, fill(L.pendingBy, { n: d.pending.number, by: d.pending.by }), " ", d.pending.reason || ""),
259
+ d.active || d.standard ? h(DiffView, { from: d.pending.kind === "full" ? (d.active && d.active.kind === "full" ? d.active.content : d.standard.content) : (d.active && d.active.kind === "hook" ? d.active.content : ""),
260
+ to: d.pending.content, testId: "agent-script-diff-pending" }) : null,
261
+ canEdit ? h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy, "data-testid": "agent-script-approve",
262
+ onClick: () => run(() => props.client.approve(d.worker, d.name, d.pending.number), L.approved) }, L.approve) : null)));
263
+ }
264
+ parts.push(h("div", { key: "kind", style: { display: "flex", gap: "1rem", flexWrap: "wrap" } },
265
+ [["hook", L.kindHook], ["full", L.kindFull]].map(([k, label]) => h("label", { key: k, className: "scalio-settings-check" },
266
+ h("input", { type: "radio", name: `agent-script-kind-${tid}`, checked: kind === k, disabled: busy || !canEdit, "data-testid": `agent-script-kind-${k}`,
267
+ onChange: () => { setKind(k); fillEditor(d, k); } }),
268
+ h("span", null, k === "hook" ? `${label}: ${d.hook}` : label)))));
269
+ parts.push(h("textarea", { key: "text", className: "scalio-input", rows: 16, value: text, disabled: busy || !canEdit, spellCheck: false,
270
+ "aria-label": L.content, "data-testid": "agent-script-content", style: { width: "100%", fontFamily: "var(--scalio-font-mono, monospace)" },
271
+ onChange: (e) => setText(e.target.value) }));
272
+ if (kind === "full") parts.push(h(DiffView, { key: "d", from: d.standard.content, to: text, testId: "agent-script-diff-edit" }));
273
+ parts.push(h("div", { key: "save", style: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center" } },
274
+ h("input", { className: "scalio-input", placeholder: L.reason, "aria-label": L.reason, value: reason, maxLength: 500, disabled: busy || !canEdit,
275
+ "data-testid": "agent-script-reason", style: { flex: "1 1 20rem" }, onChange: (e) => setReason(e.target.value) }),
276
+ canEdit ? h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy || reason.trim().length < 10, "data-testid": "agent-script-save",
277
+ onClick: async () => { const res = await run(() => props.client.save(d.worker, d.name, { kind, content: text, reason }), (r) => (r && r.status === "pending" ? L.savedPending : L.saved)); if (res) setReason(""); } }, L.save) : null,
278
+ canEdit && d.active && d.state !== "outdated" ? h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "agent-script-reset",
279
+ onClick: async () => { if (await askConfirm({ title: L.title, text: fill(L.resetConfirm, { name: d.name }), confirmLabel: L.reset, lang: props.lang, danger: true })) run(() => props.client.reset(d.worker, d.name), L.saved); } }, L.reset) : null,
280
+ h("button", { type: "button", className: "scalio-btn is-ghost", "data-testid": "agent-script-close", onClick: () => setOpen(null) }, L.close)));
281
+ parts.push(h("details", { key: "std" }, h("summary", null, L.standardText),
282
+ h("pre", { className: "scalio-settings-text", style: { whiteSpace: "pre-wrap" }, "data-testid": "agent-script-standard" }, d.standard.content)));
283
+ parts.push(h("div", { key: "hist", "data-testid": "agent-script-history" }, h("div", { className: "font-medium" }, L.history),
284
+ (d.versions || []).length === 0 ? h("p", { className: "scalio-settings-text" }, L.noHistory)
285
+ : h("ul", { className: "scalio-settings-text" }, d.versions.map((v) => h("li", { key: v.number },
286
+ `${v.number} · ${v.kind === "hook" ? "Hook" : "Script"} · ${fill(L.by, { by: v.by })} · ${v.reason || ""}${v.status === "pending" ? ` · ${L.states.pending}` : ""}`)))));
287
+ rows.push(h(Field, { key: "detail", label: `${d.worker} / ${d.name}`, testId: "agent-script-detail" },
288
+ h("div", { style: { display: "flex", flexDirection: "column", gap: "0.75rem" } }, parts)));
289
+ }
290
+
291
+ if (error) rows.push(h("div", { key: "err", className: "scalio-notice is-error", role: "alert", "data-testid": "agent-scripts-error" }, error));
292
+ return h(SettingsSection, { id: "agent-scripts", title: L.title, description: L.hint, testId: "agent-scripts-panel" }, rows);
293
+ }
294
+
295
+ module.exports = { AgentScriptsPanel, agentScriptsApi, agentScriptLineDiff: lineDiff, AGENT_SCRIPTS_LABELS: LABELS };
package/react/agents.js CHANGED
@@ -2,7 +2,8 @@
2
2
  // Scalio Agent in the app (scalio-docs ADR 0107, interfaces/agent-v2.md): AgentsPanel in Einstellungen -> Scalio Agent
3
3
  // for admins. Backend: scalio-platform `agent.AgentHub.router` (GET /agent/v2/admin/agents, PATCH /agents/{id},
4
4
  // POST /agents/{id}/block|unblock, DELETE /agents/{id}, POST /agents/{id}/workers/{worker}/{restart|stop|start},
5
- // POST|GET /agent/v2/admin/codes, DELETE /codes/{id}, GET /agent/v2/admin/tasks).
5
+ // POST|GET /agent/v2/admin/codes, DELETE /codes/{id}, GET /agent/v2/admin/tasks; self-update U2: GET /update,
6
+ // PUT /update/policy, POST /agents/{id}/update, POST /agents/{id}/update/retry).
6
7
  // Shows every agent of this instance with its roles and worker states, creates one-time enrollment codes (the
7
8
  // code is shown once) and lists the last tasks without their data.
8
9
  const React = require("react");
@@ -63,6 +64,30 @@ const LABELS = {
63
64
  states: { starting: "startet", running: "läuft", stopped: "angehalten", crashed: "abgestürzt, startet neu", disabled: "abgeschaltet nach Abstürzen", unavailable: "nicht verfügbar" },
64
65
  taskStates: { queued: "wartet", claimed: "läuft", finished: "fertig", error: "Fehler" },
65
66
  restarts: "{n} Neustarts",
67
+ updTitle: "Updates des Agents",
68
+ updAvailable: "In dieser App enthalten: Agent {version}",
69
+ updNone: "Diese App enthält keine freigegebene Agent-Version.",
70
+ updMode: "Regel",
71
+ updModes: { auto: "Automatisch, sobald verfügbar", window: "Im Wartungsfenster", manual: "Nur auf Knopfdruck" },
72
+ updDays: "Tage",
73
+ updFrom: "von",
74
+ updTo: "bis",
75
+ updSave: "Regel speichern",
76
+ updMinimum: "Agents unter Version {version} bekommen das Update immer, sie sind zu alt für diese App.",
77
+ days: ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
78
+ updateNow: "Jetzt aktualisieren",
79
+ updateRetry: "Erneut versuchen",
80
+ updateRequested: "Update auf {version} angefordert",
81
+ updateNowConfirm: "Agent «{name}» jetzt auf {version} aktualisieren? Laufende Aufträge werden fertig gemacht, dann startet der Dienst neu.",
82
+ outdated: "Zu alt für diese App, bitte aktualisieren",
83
+ scripts: "Scripts {version}",
84
+ scriptsCurrent: "aktuell",
85
+ scriptsOld: "werden aktualisiert",
86
+ sealed: "Passwörter verschlüsselt",
87
+ customAllowed: "eigene Scripts erlaubt",
88
+ updStates: { installing: "Wird aktualisiert auf {version}", verifying: "Prüft Version {version}", installed: "Aktualisiert auf {version}",
89
+ rolled_back: "Zurückgerollt auf {from} ({reason})", rollback_failed: "Rollback fehlgeschlagen ({reason})", failed: "Update fehlgeschlagen ({reason})",
90
+ refused: "Update abgelehnt ({reason})" },
66
91
  },
67
92
  en: {
68
93
  title: "Scalio Agent",
@@ -114,10 +139,36 @@ const LABELS = {
114
139
  states: { starting: "starting", running: "running", stopped: "stopped", crashed: "crashed, restarting", disabled: "switched off after crashes", unavailable: "not available" },
115
140
  taskStates: { queued: "waiting", claimed: "running", finished: "done", error: "error" },
116
141
  restarts: "{n} restarts",
142
+ updTitle: "Agent updates",
143
+ updAvailable: "Included in this app: agent {version}",
144
+ updNone: "This app includes no released agent version.",
145
+ updMode: "Rule",
146
+ updModes: { auto: "Automatically when available", window: "In the maintenance window", manual: "Only on request" },
147
+ updDays: "Days",
148
+ updFrom: "from",
149
+ updTo: "to",
150
+ updSave: "Save rule",
151
+ updMinimum: "Agents below version {version} always get the update, they are too old for this app.",
152
+ days: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
153
+ updateNow: "Update now",
154
+ updateRetry: "Try again",
155
+ updateRequested: "Update to {version} requested",
156
+ updateNowConfirm: "Update agent «{name}» to {version} now? Running tasks are finished first, then the service restarts.",
157
+ outdated: "Too old for this app, please update",
158
+ scripts: "Scripts {version}",
159
+ scriptsCurrent: "current",
160
+ scriptsOld: "being updated",
161
+ sealed: "passwords encrypted",
162
+ customAllowed: "own scripts allowed",
163
+ updStates: { installing: "Updating to {version}", verifying: "Checking version {version}", installed: "Updated to {version}",
164
+ rolled_back: "Rolled back to {from} ({reason})", rollback_failed: "Rollback failed ({reason})", failed: "Update failed ({reason})",
165
+ refused: "Update refused ({reason})" },
117
166
  },
118
167
  };
119
168
 
120
169
  const STATE_TONE = { starting: "running", running: "ok", stopped: "neutral", crashed: "warn", disabled: "error", unavailable: "neutral" };
170
+ const UPDATE_TONE = { installing: "running", verifying: "running", installed: "ok", rolled_back: "warn", rollback_failed: "error", failed: "error", refused: "error" };
171
+ const RETRY_STATES = ["rolled_back", "rollback_failed", "failed", "refused"];
121
172
  const TASK_TONE = { queued: "neutral", claimed: "running", finished: "ok", error: "error" };
122
173
 
123
174
  function labels(lang, overrides) {
@@ -154,6 +205,10 @@ function agentsApi(api, base) {
154
205
  createCode: (body) => api.post(`${b}/codes`, body || {}).then((r) => r.data),
155
206
  revokeCode: (id) => api.delete(`${b}/codes/${id}`).then((r) => r.data),
156
207
  tasks: (limit) => api.get(`${b}/tasks?limit=${limit || 20}`).then((r) => r.data),
208
+ updateInfo: () => api.get(`${b}/update`).then((r) => r.data),
209
+ setPolicy: (policy) => api.put(`${b}/update/policy`, policy).then((r) => r.data),
210
+ updateNow: (id) => api.post(`${b}/agents/${id}/update`, {}).then((r) => r.data),
211
+ retryUpdate: (id) => api.post(`${b}/agents/${id}/update/retry`, {}).then((r) => r.data),
157
212
  };
158
213
  }
159
214
 
@@ -180,6 +235,8 @@ function AgentsPanel(props) {
180
235
  const [codeRoles, setCodeRoles] = React.useState(null);
181
236
  const [note, setNote] = React.useState("");
182
237
  const [shown, setShown] = React.useState(null); // {code, expires_at} right after «Code erzeugen»
238
+ const [upd, setUpd] = React.useState(null); // GET /update; stays null with an older backend
239
+ const [policy, setPolicy] = React.useState(null); // the rule being edited
183
240
 
184
241
  const load = React.useCallback(async () => {
185
242
  try {
@@ -191,6 +248,13 @@ function AgentsPanel(props) {
191
248
  } catch (e) {
192
249
  setError(fmtErr(e));
193
250
  }
251
+ if (props.client.updateInfo) {
252
+ try {
253
+ const u = await props.client.updateInfo();
254
+ setUpd(u);
255
+ setPolicy((p) => p || (u && u.policy) || null);
256
+ } catch (e) { setUpd(null); } // older backend without self-update
257
+ }
194
258
  }, [props.client]); // eslint-disable-line react-hooks/exhaustive-deps
195
259
 
196
260
  React.useEffect(() => {
@@ -283,10 +347,63 @@ function AgentsPanel(props) {
283
347
  onClick: () => run(() => props.client.revokeCode(c.id)) }, L.revoke))))));
284
348
  }
285
349
 
350
+ // self-update rule (U2)
351
+ if (upd && policy) {
352
+ const win = policy.window || { days: [], start: "22:00", end: "04:00" };
353
+ const setWin = (k, v) => setPolicy(Object.assign({}, policy, { window: Object.assign({}, win, { [k]: v }) }));
354
+ const days = win.days || [];
355
+ rows.push(h(Field, { key: "update", label: L.updTitle, testId: "agents-update" },
356
+ h("p", { className: "scalio-settings-text", "data-testid": "agents-update-available" },
357
+ upd.available ? fill(L.updAvailable, { version: upd.available.version }) : L.updNone),
358
+ upd.minimum_version ? h("p", { className: "scalio-settings-text", "data-testid": "agents-update-minimum" }, fill(L.updMinimum, { version: upd.minimum_version })) : null,
359
+ h("div", { style: { display: "flex", gap: "0.5rem", flexWrap: "wrap", alignItems: "center", marginTop: "0.5rem" } },
360
+ h("select", { className: "scalio-input", value: policy.mode, "aria-label": L.updMode, disabled: busy, "data-testid": "agents-update-mode",
361
+ onChange: (e) => setPolicy(Object.assign({}, policy, { mode: e.target.value })) },
362
+ ["auto", "window", "manual"].map((m) => h("option", { key: m, value: m }, L.updModes[m]))),
363
+ policy.mode === "window" ? [
364
+ h("span", { key: "d", style: { display: "flex", gap: "0.5rem", flexWrap: "wrap" } }, `${L.updDays}:`,
365
+ L.days.map((d, i) => h("label", { key: i, className: "scalio-settings-check" },
366
+ h("input", { type: "checkbox", checked: days.includes(i), disabled: busy, "data-testid": `agents-update-day-${i}`,
367
+ onChange: () => setWin("days", days.includes(i) ? days.filter((x) => x !== i) : days.concat([i]).sort()) }),
368
+ h("span", null, d)))),
369
+ h("label", { key: "s" }, L.updFrom, " ", h("input", { type: "time", className: "scalio-input", value: win.start, disabled: busy,
370
+ "data-testid": "agents-update-start", onChange: (e) => setWin("start", e.target.value) })),
371
+ h("label", { key: "e" }, L.updTo, " ", h("input", { type: "time", className: "scalio-input", value: win.end, disabled: busy,
372
+ "data-testid": "agents-update-end", onChange: (e) => setWin("end", e.target.value) })),
373
+ ] : null,
374
+ h("button", { type: "button", className: "scalio-btn", disabled: busy, "data-testid": "agents-update-save",
375
+ onClick: async () => { const res = await run(() => props.client.setPolicy(policy), L.saved); if (res) setPolicy(res); } }, L.updSave))));
376
+ }
377
+
286
378
  // agents
287
379
  const agents = (data && data.agents) || [];
288
380
  const roleLabel = (name) => (offered.find((r) => r.name === name) || {}).label || name;
289
381
  const setRoles = (a, roles) => run(() => props.client.update(a.id, { roles }), L.saved);
382
+ const updateCell = (a) => {
383
+ const u = a.update;
384
+ const out = [];
385
+ if (u && u.state) {
386
+ const text = fill((L.updStates || {})[u.state] || u.state, { version: u.version, from: u.from_version || a.version, reason: u.reason || "–" });
387
+ out.push(h("div", { key: "s" }, h(StatusBadge, { tone: UPDATE_TONE[u.state] || "neutral", testId: `agent-update-state-${a.id}` }, text)));
388
+ }
389
+ if (a.scripts) {
390
+ out.push(h("div", { key: "sc", className: "scalio-settings-text", "data-testid": `agent-scripts-${a.id}` },
391
+ fill(L.scripts, { version: a.scripts.version || "–" }), " · ", a.scripts.current ? L.scriptsCurrent : L.scriptsOld,
392
+ a.sealed ? ` · ${L.sealed}` : "", a.custom_scripts ? ` · ${L.customAllowed}` : ""));
393
+ }
394
+ if (a.outdated) out.push(h("div", { key: "o", className: "scalio-settings-text", "data-testid": `agent-outdated-${a.id}` }, h(Icons.Alert, { className: "scalio-icon" }), " ", L.outdated));
395
+ const target = upd && upd.available ? upd.available.version : "";
396
+ if (a.update_requested) out.push(h("div", { key: "r", className: "scalio-settings-text", "data-testid": `agent-update-requested-${a.id}` }, fill(L.updateRequested, { version: a.update_requested })));
397
+ else if (u && RETRY_STATES.includes(u.state) && u.version === target) {
398
+ out.push(h("button", { key: "b", type: "button", className: "scalio-btn is-ghost", disabled: busy || a.blocked, "data-testid": `agent-update-retry-${a.id}`,
399
+ onClick: () => run(() => props.client.retryUpdate(a.id), L.sent) }, h(Icons.RotateCcw, { className: "scalio-icon" }), L.updateRetry));
400
+ } else if (a.update_available && !(u && (u.state === "installing" || u.state === "verifying"))) {
401
+ out.push(h("button", { key: "b", type: "button", className: "scalio-btn is-ghost", disabled: busy || a.blocked, "data-testid": `agent-update-now-${a.id}`,
402
+ onClick: () => confirmThen(fill(L.updateNowConfirm, { name: a.name, version: target }), L.updateNow, () => props.client.updateNow(a.id), L.sent) },
403
+ h(Icons.Download, { className: "scalio-icon" }), L.updateNow));
404
+ }
405
+ return out.length ? out : null;
406
+ };
290
407
  const agentRow = (a) => {
291
408
  const st = statusOf(a);
292
409
  const can = new Set(((a.capabilities || {}).workers) || []);
@@ -295,7 +412,7 @@ function AgentsPanel(props) {
295
412
  return h("tr", { key: a.id, "data-testid": `agent-${a.id}` },
296
413
  h("td", null, h("div", { className: "font-medium" }, a.name || a.hostname), a.domain ? h("div", { className: "scalio-settings-text" }, a.domain) : null),
297
414
  h("td", null, a.hostname || "", a.os ? h("div", { className: "scalio-settings-text" }, a.os) : null),
298
- h("td", null, a.version || "–"),
415
+ h("td", null, a.version || "–", updateCell(a)),
299
416
  h("td", null, h(StatusBadge, { tone: st === "online" ? "ok" : st === "blocked" ? "error" : "warn", testId: `agent-status-${a.id}` }, L[st]),
300
417
  h("div", { className: "scalio-settings-text" }, a.last_seen ? when(a.last_seen, props.lang) : L.never)),
301
418
  h("td", null, offered.map((r) => h("label", { key: r.name, className: "scalio-settings-check", title: can.has(r.name) ? "" : L.notOnHost },
package/react/dialog.js CHANGED
@@ -4,6 +4,8 @@
4
4
  // from `if (!confirm(t)) return;` to `if (!(await askConfirm({ text: t }))) return;`.
5
5
  // The dialog mounts itself into document.body on first use; apps need no provider. Keyboard as ADR 0095: the focus
6
6
  // starts on OK (or the text field), Enter confirms, Escape cancels, Tab stays inside.
7
+ // askConfirm({ check: "Label", checked }) adds a checkbox (off unless `checked`); OK then resolves { checked } instead
8
+ // of true (still truthy), cancel stays false (ADR 0115 P9, e.g. «Fehlerberichte an Scalio senden»).
7
9
 
8
10
  const React = require("react");
9
11
  const { labelsFor } = require("./labels");
@@ -65,12 +67,14 @@ function ConfirmDialog(props) {
65
67
  const { kind, title, text, label, placeholder, danger, required, onDone } = props;
66
68
  const L = Object.assign({}, labelsFor(props.lang || pageLang()).dialog);
67
69
  const [value, setValue] = React.useState(props.value == null ? "" : String(props.value));
70
+ const withCheck = kind === "confirm" && !!props.check;
71
+ const [checked, setChecked] = React.useState(!!props.checked);
68
72
  const panel = React.useRef(null);
69
73
  const okRef = React.useRef(null);
70
74
  const inputRef = React.useRef(null);
71
75
  const blocked = kind === "text" && required && !value.trim();
72
76
  const cancelValue = kind === "confirm" ? false : kind === "text" ? null : undefined;
73
- const ok = () => { if (!blocked) onDone(kind === "confirm" ? true : kind === "text" ? value.trim() : undefined); };
77
+ const ok = () => { if (!blocked) onDone(kind === "confirm" ? (withCheck ? { checked } : true) : kind === "text" ? value.trim() : undefined); };
74
78
  const cancel = () => onDone(cancelValue);
75
79
 
76
80
  React.useEffect(() => {
@@ -114,6 +118,11 @@ function ConfirmDialog(props) {
114
118
  onChange: (e) => setValue(e.target.value), onInput: (e) => setValue(e.target.value),
115
119
  }))
116
120
  : null,
121
+ withCheck
122
+ ? h("label", { className: "scalio-settings-check scalio-dialog-check" },
123
+ h("input", { type: "checkbox", checked, "data-testid": "confirm-dialog-check", onChange: (e) => setChecked(e.target.checked) }),
124
+ h("span", null, props.check))
125
+ : null,
117
126
  h(
118
127
  "div",
119
128
  { className: "scalio-dialog-actions" },
package/react/icons.js CHANGED
@@ -32,6 +32,7 @@ const LifeBuoy = icon([
32
32
  ["circle", { cx: 12, cy: 12, r: 4 }],
33
33
  ["path", { d: "m4.93 4.93 4.24 4.24M14.83 9.17l4.24-4.24M14.83 14.83l4.24 4.24M9.17 14.83l-4.24 4.24" }],
34
34
  ]);
35
+ const Library = icon([["path", { d: "m16 6 4 14" }], ["path", { d: "M12 6v14" }], ["path", { d: "M8 8v12" }], ["path", { d: "M4 4v16" }]]);
35
36
  const BookOpen = icon([["path", { d: "M12 7v14" }], ["path", { d: "M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z" }]]);
36
37
  const LogOut = icon([["path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9" }]]);
37
38
  const Menu = icon([["path", { d: "M4 6h16M4 12h16M4 18h16" }]]);
@@ -140,6 +141,6 @@ const Sparkles = icon([
140
141
  ]);
141
142
  const Download = icon([["path", { d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" }], ["path", { d: "m7 10 5 5 5-5" }], ["path", { d: "M12 15V3" }]]);
142
143
 
143
- module.exports = { Sun, Moon, Monitor, LifeBuoy, BookOpen, LogOut, Menu, Check, X, Search, ChevronDown, Fingerprint, FileStack, ShieldCheck, Hammer, Activity,
144
+ module.exports = { Sun, Moon, Monitor, LifeBuoy, BookOpen, Library, LogOut, Menu, Check, X, Search, ChevronDown, Fingerprint, FileStack, ShieldCheck, Hammer, Activity,
144
145
  Smartphone, KeyRound, Trash, Copy, Puzzle, Plus, Pencil, Link2, Alert, History, CornerDownLeft,
145
146
  Users, Settings, ScrollText, Info, RadioTower, Globe, Clock, Download, Upload, RotateCcw, Sparkles };
package/react/index.js CHANGED
@@ -243,6 +243,7 @@ const DOCS_DOMAINS = {
243
243
  rosetta: "scaliorosetta.com",
244
244
  beacon: "scaliobeacon.com",
245
245
  pulse: "scaliopulse.com",
246
+ folio: "scaliofolio.com",
246
247
  };
247
248
 
248
249
  function manualUrl(product, opts) {
@@ -378,6 +379,6 @@ module.exports = {
378
379
  TEST_IDS,
379
380
  initials,
380
381
  };
381
- Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./ai"));
382
+ Object.assign(module.exports, Nav, Blocks, require("./settings"), require("./support"), require("./beacon"), require("./security"), require("./license"), require("./palette"), require("./unify"), require("./profile"), require("./actions"), require("./selftest"), require("./users"), require("./customers"), require("./roles"), require("./wizard"), require("./maintenance"), require("./backup"), require("./audit"), require("./mail"), require("./saas_updates"), require("./pages"), require("./tenant"), require("./fields"), require("./dialog"), require("./keyboard"), require("./agents"), require("./agent_scripts"), require("./ai"), require("./markdown"));
382
383
  // After the exports above: auth.js uses LanguageToggle and ThemeToggle from this module.
383
384
  Object.assign(module.exports, require("./auth"), require("./session"), require("./setup"), require("./clientErrors"));
package/react/labels.js CHANGED
@@ -17,6 +17,7 @@ const LABELS = {
17
17
  demoHint: "Wählen Sie ein Demo-Konto. Die Demo setzt sich jede Nacht zurück.",
18
18
  demoPassword: "Passwort",
19
19
  dialog: { ok: "OK", cancel: "Abbrechen", confirm: "Bestätigen", input: "Eingabe" },
20
+ markdown: { note: "Hinweis", tip: "Tipp", important: "Wichtig", warning: "Warnung", caution: "Vorsicht" },
20
21
  wizard: {
21
22
  step: "Schritt {n} von {total}",
22
23
  back: "Zurück",
@@ -592,6 +593,7 @@ const LABELS = {
592
593
  demoHint: "Pick a demo account. The demo resets itself every night.",
593
594
  demoPassword: "Password",
594
595
  dialog: { ok: "OK", cancel: "Cancel", confirm: "Confirm", input: "Input" },
596
+ markdown: { note: "Note", tip: "Tip", important: "Important", warning: "Warning", caution: "Caution" },
595
597
  wizard: {
596
598
  step: "Step {n} of {total}",
597
599
  back: "Back",
@@ -0,0 +1,240 @@
1
+ "use strict";
2
+ // Markdown (GitHub flavour) for every app: parsed into plain data and shown as React elements, never as HTML, so a
3
+ // text can hold no script (Beacon knowledge base, Folio pages; scalio-docs ADR 0110 point 4). Blocks: headings,
4
+ // paragraphs, fenced code, quotes and callouts (> [!NOTE]), lists with task boxes and one level of nesting, tables,
5
+ // rules. Inline: code, bold, italic, strikethrough, links (http, https, mailto, relative; anything else stays text)
6
+ // and images (shown as a link). Styles: classes "scalio-md-*" in nav.css.
7
+ const React = require("react");
8
+ const h = React.createElement;
9
+ const Icons = require("./icons");
10
+ const { labelsFor } = require("./labels");
11
+
12
+ const CALLOUTS = ["NOTE", "TIP", "IMPORTANT", "WARNING", "CAUTION"];
13
+
14
+ function safeHref(href) {
15
+ const h = String(href || "").trim();
16
+ if (/^(https?:|mailto:)/i.test(h)) return h;
17
+ if (/^[a-z][a-z0-9+.-]*:/i.test(h)) return null; // javascript:, data:, file: ...
18
+ if (h.startsWith("//")) return null;
19
+ return h || null;
20
+ }
21
+
22
+ function splitRow(line) {
23
+ let s = line.trim();
24
+ if (s.startsWith("|")) s = s.slice(1);
25
+ if (s.endsWith("|") && !s.endsWith("\\|")) s = s.slice(0, -1);
26
+ const cells = [];
27
+ let cur = "";
28
+ for (let i = 0; i < s.length; i += 1) {
29
+ if (s[i] === "\\" && s[i + 1] === "|") { cur += "|"; i += 1; continue; }
30
+ if (s[i] === "|") { cells.push(cur.trim()); cur = ""; continue; }
31
+ cur += s[i];
32
+ }
33
+ cells.push(cur.trim());
34
+ return cells;
35
+ }
36
+
37
+ const isTableSep = (line) => /^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(line) && line.includes("-");
38
+ const LIST_RE = /^(\s*)([-*+]|\d+[.)])\s+(.*)$/;
39
+
40
+ function listItem(text) {
41
+ const task = text.match(/^\[( |x|X)\]\s+(.*)$/);
42
+ return task ? { text: task[2], task: true, checked: task[1] !== " ", children: null }
43
+ : { text, task: false, checked: false, children: null };
44
+ }
45
+
46
+ function parseBlocks(src) {
47
+ const lines = String(src || "").replace(/\r\n?/g, "\n").split("\n");
48
+ const blocks = [];
49
+ let i = 0;
50
+ while (i < lines.length) {
51
+ const line = lines[i];
52
+ if (!line.trim()) { i += 1; continue; }
53
+
54
+ const fence = line.match(/^\s*(```|~~~)\s*([\w+-]*)/);
55
+ if (fence) {
56
+ const code = [];
57
+ i += 1;
58
+ while (i < lines.length && !lines[i].trim().startsWith(fence[1])) { code.push(lines[i]); i += 1; }
59
+ i += 1;
60
+ blocks.push({ type: "code", lang: fence[2] || "", text: code.join("\n") });
61
+ continue;
62
+ }
63
+
64
+ const h = line.match(/^(#{1,6})\s+(.*?)\s*#*\s*$/);
65
+ if (h) { blocks.push({ type: "heading", level: h[1].length, text: h[2] }); i += 1; continue; }
66
+
67
+ if (/^\s*([-*_])(\s*\1){2,}\s*$/.test(line)) { blocks.push({ type: "rule" }); i += 1; continue; }
68
+
69
+ if (/^\s*>/.test(line)) {
70
+ const inner = [];
71
+ while (i < lines.length && /^\s*>/.test(lines[i])) { inner.push(lines[i].replace(/^\s*>\s?/, "")); i += 1; }
72
+ const first = (inner[0] || "").match(/^\[!(\w+)\]\s*$/);
73
+ const kind = first && CALLOUTS.includes(first[1].toUpperCase()) ? first[1].toLowerCase() : null;
74
+ blocks.push({ type: kind ? "callout" : "quote", kind, blocks: parseBlocks((kind ? inner.slice(1) : inner).join("\n")) });
75
+ continue;
76
+ }
77
+
78
+ if (line.includes("|") && i + 1 < lines.length && isTableSep(lines[i + 1])) {
79
+ const head = splitRow(line);
80
+ const align = splitRow(lines[i + 1]).map((c) => (c.startsWith(":") && c.endsWith(":") ? "center"
81
+ : c.endsWith(":") ? "right" : "left"));
82
+ const rows = [];
83
+ i += 2;
84
+ while (i < lines.length && lines[i].includes("|") && lines[i].trim()) { rows.push(splitRow(lines[i])); i += 1; }
85
+ blocks.push({ type: "table", head, align, rows: rows.map((r) => head.map((_, k) => r[k] ?? "")) });
86
+ continue;
87
+ }
88
+
89
+ const li = line.match(LIST_RE);
90
+ if (li) {
91
+ const ordered = /\d/.test(li[2]);
92
+ const start = ordered ? parseInt(li[2], 10) : 1;
93
+ const base = li[1].length;
94
+ const items = [];
95
+ while (i < lines.length) {
96
+ const m = lines[i].match(LIST_RE);
97
+ if (m && m[1].length <= base + 1) {
98
+ if (/\d/.test(m[2]) !== ordered) break;
99
+ items.push(listItem(m[3]));
100
+ i += 1;
101
+ } else if (m && items.length) { // nested list, one level
102
+ const sub = [];
103
+ const subOrdered = /\d/.test(m[2]);
104
+ while (i < lines.length) {
105
+ const n = lines[i].match(LIST_RE);
106
+ if (!n || n[1].length <= base + 1) break;
107
+ sub.push(listItem(n[3]));
108
+ i += 1;
109
+ }
110
+ items[items.length - 1].children = { ordered: subOrdered, items: sub };
111
+ } else if (lines[i].trim() && /^\s{2,}\S/.test(lines[i]) && items.length) {
112
+ items[items.length - 1].text += ` ${lines[i].trim()}`; // continuation line
113
+ i += 1;
114
+ } else break;
115
+ }
116
+ blocks.push({ type: "list", ordered, start, items });
117
+ continue;
118
+ }
119
+
120
+ const para = [];
121
+ while (i < lines.length && lines[i].trim() && !/^(#{1,6})\s/.test(lines[i]) && !/^\s*(```|~~~)/.test(lines[i])
122
+ && !/^\s*>/.test(lines[i]) && !LIST_RE.test(lines[i])
123
+ && !(lines[i].includes("|") && i + 1 < lines.length && isTableSep(lines[i + 1]))) {
124
+ para.push(lines[i].trim());
125
+ i += 1;
126
+ }
127
+ blocks.push({ type: "paragraph", text: para.join("\n") });
128
+ }
129
+ return blocks;
130
+ }
131
+
132
+ // code | image | link | bold | strike | italic | bare url
133
+ const INLINE = /(`+)([\s\S]*?[^`])\1(?!`)|!\[([^\]]*)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\[([^\]]+)\]\(([^)\s]+)(?:\s+"[^"]*")?\)|\*\*([\s\S]+?)\*\*|__([\s\S]+?)__|~~([\s\S]+?)~~|\*([^*\s][^*]*?)\*|(?<![\w])_([^_\s][^_]*?)_(?![\w])|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g;
134
+
135
+ function parseInline(src) {
136
+ const out = [];
137
+ const text = String(src || "");
138
+ let last = 0;
139
+ for (const m of text.matchAll(INLINE)) {
140
+ if (m.index > last) out.push({ type: "text", text: text.slice(last, m.index) });
141
+ if (m[1]) out.push({ type: "code", text: m[2].trim() ? m[2].replace(/^ (.*) $/, "$1") : m[2] });
142
+ else if (m[4] !== undefined) {
143
+ const href = safeHref(m[4]);
144
+ out.push(href ? { type: "image", alt: m[3], href } : { type: "text", text: m[0] });
145
+ } else if (m[6] !== undefined) {
146
+ const href = safeHref(m[6]);
147
+ out.push(href ? { type: "link", href, children: parseInline(m[5]) } : { type: "text", text: m[5] });
148
+ } else if (m[7] !== undefined || m[8] !== undefined) out.push({ type: "bold", children: parseInline(m[7] ?? m[8]) });
149
+ else if (m[9] !== undefined) out.push({ type: "strike", children: parseInline(m[9]) });
150
+ else if (m[10] !== undefined || m[11] !== undefined) out.push({ type: "italic", children: parseInline(m[10] ?? m[11]) });
151
+ else if (m[12]) out.push({ type: "link", href: m[12], children: [{ type: "text", text: m[12] }] });
152
+ last = m.index + m[0].length;
153
+ }
154
+ if (last < text.length) out.push({ type: "text", text: text.slice(last) });
155
+ return out;
156
+ }
157
+
158
+ // Headings with an anchor id (for the table of contents on a page).
159
+ function headingId(text) {
160
+ return String(text || "").toLowerCase().replace(/[^\p{L}\p{N}]+/gu, "-").replace(/^-|-$/g, "") || "abschnitt";
161
+ }
162
+
163
+ function outline(src) {
164
+ return parseBlocks(src).filter((b) => b.type === "heading" && b.level <= 3)
165
+ .map((b) => ({ level: b.level, text: b.text, id: headingId(b.text) }));
166
+ }
167
+
168
+ function Inline(props) {
169
+ return h(React.Fragment, null, props.nodes.map((n, i) => {
170
+ if (n.type === "code") return h("code", { key: i, className: "scalio-md-code" }, n.text);
171
+ if (n.type === "bold") return h("strong", { key: i }, h(Inline, { nodes: n.children }));
172
+ if (n.type === "italic") return h("em", { key: i }, h(Inline, { nodes: n.children }));
173
+ if (n.type === "strike") return h("del", { key: i }, h(Inline, { nodes: n.children }));
174
+ if (n.type === "image") {
175
+ return h("a", { key: i, href: n.href, target: "_blank", rel: "noopener noreferrer", className: "scalio-md-link" }, "🖼 " + (n.alt || n.href));
176
+ }
177
+ if (n.type === "link") {
178
+ const external = /^(https?:|mailto:)/i.test(n.href);
179
+ return h("a", Object.assign({ key: i, href: n.href, className: "scalio-md-link" },
180
+ external ? { target: "_blank", rel: "noopener noreferrer" } : {}), h(Inline, { nodes: n.children }));
181
+ }
182
+ return h(React.Fragment, { key: i }, n.text);
183
+ }));
184
+ }
185
+
186
+ const inline = (text) => h(Inline, { nodes: parseInline(text) });
187
+
188
+ function List(props) {
189
+ const list = props.list;
190
+ const allTasks = list.items.every((x) => x.task);
191
+ return h(list.ordered ? "ol" : "ul", {
192
+ start: list.ordered && list.start !== 1 ? list.start : undefined,
193
+ className: "scalio-md-list" + (list.ordered ? " is-ordered" : "") + (allTasks ? " is-tasks" : ""),
194
+ }, list.items.map((it, k) => h("li", { key: k, className: it.task ? "is-task" : undefined },
195
+ it.task ? h("input", { type: "checkbox", checked: it.checked, readOnly: true, disabled: true, "aria-label": it.text }) : null,
196
+ h("span", null, inline(it.text)),
197
+ it.children ? h(List, { list: it.children }) : null)));
198
+ }
199
+
200
+ const CALLOUT_ICON = { note: "Info", tip: "Info", important: "Info", warning: "Alert", caution: "Alert" };
201
+
202
+ function Blocks(props) {
203
+ const L = props.labels;
204
+ return h(React.Fragment, null, props.blocks.map((b, i) => {
205
+ if (b.type === "heading") return h("h" + b.level, { key: i, id: headingId(b.text), className: "scalio-md-h" + b.level }, inline(b.text));
206
+ if (b.type === "code") return h("pre", { key: i, "data-lang": b.lang || undefined, className: "scalio-md-pre" }, b.text);
207
+ if (b.type === "rule") return h("hr", { key: i, className: "scalio-md-rule" });
208
+ if (b.type === "list") return h(List, { key: i, list: b });
209
+ if (b.type === "quote") return h("blockquote", { key: i, className: "scalio-md-quote" }, h(Blocks, { blocks: b.blocks, labels: L }));
210
+ if (b.type === "callout") {
211
+ const Icon = Icons[CALLOUT_ICON[b.kind]];
212
+ return h("div", { key: i, className: "scalio-md-callout", "data-callout": b.kind, "data-testid": "callout-" + b.kind },
213
+ h("div", { className: "scalio-md-callout-title" }, Icon ? h(Icon, { className: "scalio-icon" }) : null, L[b.kind]),
214
+ h(Blocks, { blocks: b.blocks, labels: L }));
215
+ }
216
+ if (b.type === "table") {
217
+ return h("div", { key: i, className: "scalio-md-table-wrap" }, h("table", { className: "scalio-md-table" },
218
+ h("thead", null, h("tr", null, b.head.map((c, k) => h("th", { key: k, style: { textAlign: b.align[k] } }, inline(c))))),
219
+ h("tbody", null, b.rows.map((r, n) => h("tr", { key: n }, r.map((c, k) => h("td", { key: k, style: { textAlign: b.align[k] } }, inline(c))))))));
220
+ }
221
+ return h("p", { key: i, className: "scalio-md-p" }, b.text.split("\n").map((line, k) =>
222
+ h(React.Fragment, { key: k }, k > 0 ? h("br") : null, inline(line))));
223
+ }));
224
+ }
225
+
226
+ // <Markdown text="..." lang="de" /> shows the text; labels.markdown overrides the callout titles.
227
+ function Markdown(props) {
228
+ const L = Object.assign({}, labelsFor(props.lang).markdown, props.labels);
229
+ return h("div", { className: "scalio-md" + (props.className ? " " + props.className : ""), "data-testid": props.testId },
230
+ h(Blocks, { blocks: parseBlocks(props.text), labels: L }));
231
+ }
232
+
233
+ module.exports = {
234
+ Markdown,
235
+ parseMarkdownBlocks: parseBlocks,
236
+ parseMarkdownInline: parseInline,
237
+ markdownOutline: outline,
238
+ markdownHeadingId: headingId,
239
+ safeHref,
240
+ };
package/react/nav.js CHANGED
@@ -312,6 +312,8 @@ const PRODUCTS = [
312
312
  { key: "citadel", name: "Citadel", icon: Icons.ShieldCheck },
313
313
  { key: "beacon", name: "Beacon", icon: Icons.RadioTower },
314
314
  { key: "pulse", name: "Pulse", icon: Icons.Activity },
315
+ { key: "folio", name: "Folio", icon: Icons.Library },
316
+ { key: "atrium", name: "Atrium", icon: Icons.Monitor },
315
317
  ];
316
318
 
317
319
  function productStatus(product, current) {
@@ -7,7 +7,7 @@ const React = require("react");
7
7
  const h = React.createElement;
8
8
  const Icons = require("./icons");
9
9
  const { Notice } = require("./blocks");
10
- const { SettingsSection, SettingsField: Field } = require("./settings");
10
+ const { SettingsSection, SettingsField: Field, SettingsRow } = require("./settings");
11
11
  const { askConfirm } = require("./dialog");
12
12
  const { trapTab } = require("./wizard");
13
13
 
@@ -65,6 +65,18 @@ const LABELS = {
65
65
  notConnected: "Die Verbindung dieser Instanz zu Scalio wird gerade eingerichtet. Danach sehen Sie hier die Updates. Bleibt diese Meldung länger als eine Stunde, melden Sie sich bitte beim Support.",
66
66
  saved: "Gespeichert.",
67
67
  weekdays: ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"],
68
+ prerelease: "Vorabversion",
69
+ prereleaseAvailable: "Vorabversion {version} ist verfügbar",
70
+ prereleaseSwitch: "Vorabversionen anzeigen",
71
+ prereleaseHint: "Vorabversionen sind Release Candidates, die Scalio vor dem Release für Kunden freigibt. Sie werden nie automatisch installiert, nur auf Ihren Klick. Ausschalten stoppt nur neue Vorabversionen; eine installierte bleibt, bis das nächste Release kommt.",
72
+ prereleaseConfirmTitle: "Vorabversionen anzeigen?",
73
+ prereleaseConfirm: "Vorabversionen sind Testversionen vor dem Release. Nach dem Update gibt es kein Zurück auf die alte Version, nur die Wiederherstellung der Sicherung vor dem Update. Support nach bestem Bemühen, ohne SLA. Vorabversionen werden nur auf Ihren Klick installiert.",
74
+ prereleaseConfirmGo: "Einschalten",
75
+ prereleaseErrorReports: "Fehlerberichte aus Vorabversionen an Scalio senden",
76
+ prereleaseWarning: "Vorabversion: Testversion vor dem Release. Nach dem Update gibt es kein Zurück auf die alte Version, nur die Wiederherstellung der Sicherung vor dem Update. Support nach bestem Bemühen, ohne SLA.",
77
+ prereleaseNoDue: "keine Frist, nur auf Klick",
78
+ prereleaseNowConfirm: "Vorabversion {version} jetzt installieren? Es gibt kein Zurück auf die alte Version, nur die Wiederherstellung der Sicherung vor dem Update. Die Anwendung ist einige Minuten nicht erreichbar.",
79
+ bannerPrerelease: "Wird nur auf Klick installiert.",
68
80
  },
69
81
  en: {
70
82
  title: "Updates",
@@ -119,6 +131,18 @@ const LABELS = {
119
131
  notConnected: "Scalio is still setting up the connection of this instance. The updates show here once it is ready. If this message stays for more than an hour, please contact support.",
120
132
  saved: "Saved.",
121
133
  weekdays: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"],
134
+ prerelease: "Pre-release",
135
+ prereleaseAvailable: "Pre-release {version} is available",
136
+ prereleaseSwitch: "Show pre-releases",
137
+ prereleaseHint: "Pre-releases are release candidates Scalio opens to customers before the release. They are never installed automatically, only on your click. Turning this off only stops new pre-releases; an installed one stays until the next release.",
138
+ prereleaseConfirmTitle: "Show pre-releases?",
139
+ prereleaseConfirm: "Pre-releases are test versions before the release. After the update there is no way back to the old version, only restoring the backup taken before the update. Best-effort support, no SLA. Pre-releases are installed only on your click.",
140
+ prereleaseConfirmGo: "Turn on",
141
+ prereleaseErrorReports: "Send error reports from pre-releases to Scalio",
142
+ prereleaseWarning: "Pre-release: a test version before the release. After the update there is no way back to the old version, only restoring the backup taken before the update. Best-effort support, no SLA.",
143
+ prereleaseNoDue: "no deadline, only on a click",
144
+ prereleaseNowConfirm: "Install pre-release {version} now? There is no way back to the old version, only restoring the backup taken before the update. The application is unavailable for a few minutes.",
145
+ bannerPrerelease: "Installed only on a click.",
122
146
  },
123
147
  };
124
148
 
@@ -178,19 +202,31 @@ function UpdateBanner(props) {
178
202
  return h(Notice, { kind: "info", banner: true, testId: "saas-update-banner", title: fill(L.plannedTitle, { planned: when(offer.planned_at, props.lang) }),
179
203
  onDismiss: later, dismissLabel: L.later }, fill(L.plannedText, { version: offer.version }));
180
204
  }
181
- const text = [fill(L.bannerText, { due: when(offer.due_at, props.lang) }),
182
- offer.planned_at ? fill(L.bannerPlanned, { planned: when(offer.planned_at, props.lang) }) : L.bannerManual].join(" ");
205
+ // A pre-release (ADR 0115) never has a deadline and installs only on a click.
206
+ const pre = !!offer.prerelease;
207
+ const text = (pre
208
+ ? [offer.planned_at ? fill(L.bannerPlanned, { planned: when(offer.planned_at, props.lang) }) : L.bannerPrerelease]
209
+ : [fill(L.bannerText, { due: when(offer.due_at, props.lang) }),
210
+ offer.planned_at ? fill(L.bannerPlanned, { planned: when(offer.planned_at, props.lang) }) : L.bannerManual]).join(" ");
183
211
  // onOpen (e.g. the router's navigate) wins over a plain link to settingsTo.
184
212
  const action = props.onOpen
185
213
  ? { label: L.bannerAction, onClick: props.onOpen, testId: "saas-update-banner-open" }
186
214
  : props.settingsTo ? { label: L.bannerAction, href: props.settingsTo, testId: "saas-update-banner-open" } : null;
187
215
  return h(Notice, {
188
216
  kind: offer.kind === "security" ? "warn" : "info", banner: true, testId: "saas-update-banner",
189
- title: fill(offer.kind === "security" ? L.security : L.available, { version: offer.version }),
217
+ title: offerTitle(offer, L, "saas-update-banner-prerelease"),
190
218
  action, onDismiss: later, dismissLabel: L.later,
191
219
  }, text);
192
220
  }
193
221
 
222
+ // «Version 1.1.0 ist verfügbar»; a pre-release gets its own wording and the badge «Vorabversion».
223
+ function offerTitle(offer, L, badgeId) {
224
+ const text = fill(offer.prerelease ? L.prereleaseAvailable : offer.kind === "security" ? L.security : L.available, { version: offer.version });
225
+ if (!offer.prerelease) return text;
226
+ return h(React.Fragment, null, text, " ",
227
+ h("span", { className: "scalio-badge is-warn", "data-testid": badgeId }, L.prerelease));
228
+ }
229
+
194
230
  const EMPTY_WINDOW = { days: [], start: "02:00", hours: 3, tz: "Europe/Zurich" };
195
231
 
196
232
  // The running version as the instance itself reports it (/version.json of the frontend image, ADR 0074).
@@ -260,10 +296,53 @@ function UpdateProgress(props) {
260
296
  : null)));
261
297
  }
262
298
 
299
+ // Switch «Vorabversionen anzeigen» (ADR 0115 P3/P6/P7): per app, admin only, off by default. The app stores the value
300
+ // (onChange(on) may return a promise; a rejection keeps the old value and shows the error). Turning it on asks first,
301
+ // with the checkbox «Fehlerberichte aus Vorabversionen an Scalio senden» (off): onChange(true, { errorReports }).
302
+ function PrereleaseSwitch(props) {
303
+ const L = labels(props.lang, props.labels);
304
+ const fmtErr = props.formatError || errorText;
305
+ const [on, setOn] = React.useState(!!props.value);
306
+ const [busy, setBusy] = React.useState(false);
307
+ const [error, setError] = React.useState("");
308
+ React.useEffect(() => { setOn(!!props.value); }, [props.value]);
309
+ const change = async (next) => {
310
+ let opts = null;
311
+ if (next) {
312
+ const yes = await askConfirm({ title: L.prereleaseConfirmTitle, text: L.prereleaseConfirm, confirmLabel: L.prereleaseConfirmGo,
313
+ check: L.prereleaseErrorReports, lang: props.lang });
314
+ if (!yes) return;
315
+ opts = { errorReports: !!yes.checked }; // ADR 0115 P9, off unless ticked
316
+ }
317
+ setBusy(true);
318
+ setError("");
319
+ try {
320
+ await (opts ? props.onChange(next, opts) : props.onChange(next));
321
+ setOn(next);
322
+ } catch (e) {
323
+ const t = fmtErr(e);
324
+ if (props.notify) props.notify(t, "error");
325
+ setError(t);
326
+ }
327
+ setBusy(false);
328
+ };
329
+ return h("div", { "data-testid": "saas-updates-prerelease" },
330
+ h(SettingsRow, { title: L.prereleaseSwitch, hint: L.prereleaseHint },
331
+ h("input", { type: "checkbox", role: "switch", className: "scalio-switch", checked: on, disabled: busy || props.disabled,
332
+ "aria-label": L.prereleaseSwitch, "data-testid": "saas-updates-prerelease-switch", onChange: (e) => change(e.target.checked) })),
333
+ error ? h("div", { className: "scalio-notice is-error", role: "alert", "data-testid": "saas-updates-prerelease-error" }, error) : null);
334
+ }
335
+
263
336
  // Props: client (saasUpdatesApi), lang, labels, notify(message, tone), formatError(err).
337
+ // Pre-releases (ADR 0115, optional): admin (true shows the switch), prerelease (stored value, default off),
338
+ // onPrereleaseChange(on, { errorReports }) (the app saves it; the options come only when turning on). Without onPrereleaseChange and admin the panel looks as before.
264
339
  function SaasUpdatesPanel(props) {
265
340
  const L = labels(props.lang, props.labels);
266
341
  const fmtErr = props.formatError || errorText;
342
+ const preSwitch = props.admin === true && typeof props.onPrereleaseChange === "function"
343
+ ? h(PrereleaseSwitch, { key: "prerelease", value: props.prerelease, onChange: props.onPrereleaseChange, lang: props.lang,
344
+ labels: props.labels, notify: props.notify, formatError: props.formatError })
345
+ : null;
267
346
  const [st, setSt] = React.useState(null);
268
347
  const [busy, setBusy] = React.useState(false);
269
348
  const [error, setError] = React.useState("");
@@ -298,21 +377,23 @@ function SaasUpdatesPanel(props) {
298
377
  return ok;
299
378
  };
300
379
  const updateNow = async (offer) => {
301
- const yes = await askConfirm({ title: L.now, text: fill(L.nowConfirm, { version: offer.version }), confirmLabel: L.nowGo, lang: props.lang });
380
+ const yes = await askConfirm({ title: L.now, text: fill(offer.prerelease ? L.prereleaseNowConfirm : L.nowConfirm, { version: offer.version }),
381
+ confirmLabel: L.nowGo, danger: !!offer.prerelease, lang: props.lang });
302
382
  if (!yes) return;
303
383
  const from = st && st.current_version;
304
384
  if (await act("now")) setUpdating({ version: offer.version, from });
305
385
  };
306
386
 
307
387
  if (!st) return h(SettingsSection, { id: "updates", title: L.title, description: L.hint, testId: "saas-updates" },
308
- error ? h("div", { className: "scalio-notice is-error", role: "alert" }, error) : null);
309
- if (st.saas === false) return null;
388
+ error ? h("div", { key: "err", className: "scalio-notice is-error", role: "alert" }, error) : null, preSwitch);
389
+ // Self-hosted: no Compass offers here, but the switch stays (the Scalio Installer reads it, ADR 0115 P6).
390
+ if (st.saas === false) return preSwitch ? h(SettingsSection, { id: "updates", title: L.title, testId: "saas-updates" }, preSwitch) : null;
310
391
 
311
392
  // No active support connection: nothing to show or change until Compass has paired the instance (in SaaS
312
393
  // Compass pairs it, never the customer). Older scalio-connect only sends the error text.
313
394
  if (st.connected === false || (st.connected === undefined && st.error === "Keine Verbindung zu Compass")) {
314
395
  return h(SettingsSection, { id: "updates", title: L.title, description: L.hint, testId: "saas-updates" },
315
- h("div", { className: "scalio-notice is-warn", "data-testid": "saas-updates-not-connected" }, L.notConnected));
396
+ h("div", { key: "nc", className: "scalio-notice is-warn", "data-testid": "saas-updates-not-connected" }, L.notConnected), preSwitch);
316
397
  }
317
398
 
318
399
  const offer = st.offer;
@@ -323,12 +404,17 @@ function SaasUpdatesPanel(props) {
323
404
  if (st.reachable !== false) rows.push(h("p", { key: "none", className: "scalio-settings-text", "data-testid": "saas-updates-none" }, L.none));
324
405
  } else {
325
406
  const due = offer.due_at ? offer.due_at.slice(0, 10) : "";
407
+ const pre = !!offer.prerelease; // ADR 0115: no deadline, never forced, only on a click
326
408
  rows.push(h("div", { key: "offer", className: cxNotice(offer), "data-testid": "saas-updates-offer" },
327
409
  h("div", { className: "scalio-notice-body" },
328
- h("div", { className: "scalio-notice-title" }, fill(offer.kind === "security" ? L.security : L.available, { version: offer.version })),
410
+ h("div", { className: "scalio-notice-title" }, offerTitle(offer, L, "saas-updates-prerelease-badge")),
329
411
  h("div", { className: "scalio-notice-text" },
330
- `${L.due}: ${when(offer.due_at, props.lang)} · ${L.planned}: ${offer.planned_at ? when(offer.planned_at, props.lang) : L.plannedNone}`,
412
+ pre && !offer.due_at
413
+ ? [L.prereleaseNoDue].concat(offer.planned_at ? [`${L.planned}: ${when(offer.planned_at, props.lang)}`] : []).join(" · ")
414
+ : `${L.due}: ${when(offer.due_at, props.lang)} · ${L.planned}: ${offer.planned_at ? when(offer.planned_at, props.lang) : L.plannedNone}`,
331
415
  offer.held ? h("div", null, L.held) : null, offer.forced ? h("div", null, L.forced) : null))));
416
+ if (pre) rows.push(h("div", { key: "prewarn", className: "scalio-notice is-warn", role: "note", "data-testid": "saas-updates-prerelease-warning" },
417
+ L.prereleaseWarning));
332
418
  if (offer.notes) rows.push(h(Field, { key: "notes", label: L.notes },
333
419
  h("pre", { className: "scalio-settings-text", style: { whiteSpace: "pre-wrap" }, "data-testid": "saas-updates-notes" }, offer.notes)));
334
420
  if (!offer.forced) {
@@ -336,7 +422,8 @@ function SaasUpdatesPanel(props) {
336
422
  h("button", { type: "button", className: "scalio-btn is-solid", disabled: busy || offer.held, "data-testid": "saas-updates-now",
337
423
  onClick: () => updateNow(offer) },
338
424
  h(Icons.Download, { className: "scalio-icon" }), L.now)));
339
- rows.push(h(Field, { key: "post", id: "saas-updates-until", label: L.postpone },
425
+ // Postponing only makes sense against a deadline; a pre-release has none.
426
+ if (offer.due_at || !pre) rows.push(h(Field, { key: "post", id: "saas-updates-until", label: L.postpone },
340
427
  h("div", { style: { display: "flex", gap: "0.5rem" } },
341
428
  h("input", { id: "saas-updates-until", type: "date", className: "scalio-input", value: until, max: due, disabled: busy,
342
429
  "data-testid": "saas-updates-until", onChange: (e) => setUntil(e.target.value) }),
@@ -344,6 +431,7 @@ function SaasUpdatesPanel(props) {
344
431
  onClick: () => act("postpone", { until: new Date(`${until}T00:00:00`).toISOString() }) }, L.postponeGo))));
345
432
  }
346
433
  }
434
+ if (preSwitch) rows.push(preSwitch);
347
435
  rows.push(h(Field, { key: "mode", label: L.mode },
348
436
  ["auto", "manual"].map((m) => h("label", { key: m, className: "scalio-settings-check" },
349
437
  h("input", { type: "radio", name: "saas-updates-mode", checked: st.mode === m, disabled: busy, "data-testid": `saas-updates-mode-${m}`,
@@ -382,4 +470,4 @@ function cxNotice(offer) {
382
470
  return `scalio-notice ${offer.kind === "security" ? "is-warn" : "is-info"}`;
383
471
  }
384
472
 
385
- module.exports = { UpdateBanner, SaasUpdatesPanel, UpdateProgress, saasUpdatesApi, SAAS_UPDATE_LABELS: LABELS };
473
+ module.exports = { UpdateBanner, SaasUpdatesPanel, PrereleaseSwitch, UpdateProgress, saasUpdatesApi, SAAS_UPDATE_LABELS: LABELS };