From 90789a56efed0b983c2ff2ce8b1f987051e9bb56 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:23:53 +0100 Subject: [PATCH 1/9] feat(onboarding): accept an unavailable reason on tour steps Co-Authored-By: Claude Opus 5.5 --- docs/developing/releasing.md | 3 +++ scripts/build/highlight_tours.py | 6 +++++- scripts/tests/test_highlight_tours.py | 21 +++++++++++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/docs/developing/releasing.md b/docs/developing/releasing.md index 400c90bf..647d5078 100644 --- a/docs/developing/releasing.md +++ b/docs/developing/releasing.md @@ -588,6 +588,9 @@ The rules: quotes inside the expression. * `title` and `text` need `en` and every language of `highlight_i18n.LANGUAGES`. No text may be empty. Unknown keys are an error. +* `unavailable` is optional. It needs `en` and every language like `text`. The tour bar + shows it under "Not visible right now" while the target is missing, and the tour spots + the target once it appears. * `*` and target keys work as for the details. A key with a target replaces the `*` object as a whole. diff --git a/scripts/build/highlight_tours.py b/scripts/build/highlight_tours.py index 66dcad5b..ff19fac0 100644 --- a/scripts/build/highlight_tours.py +++ b/scripts/build/highlight_tours.py @@ -48,7 +48,7 @@ DEFAULT_KEY = "*" DEVICES = ("any", "phone", "desktop") WHENS = ("companion",) -STEP_KEYS = {"panel", "page", "target", "device", "need", "when", "open", "title", "text"} +STEP_KEYS = {"panel", "page", "target", "device", "need", "when", "open", "title", "text", "unavailable"} OPTIONAL_KEYS = ("panel", "page", "need", "when") OPEN_ENTRY = re.compile(r"^@?[a-z0-9_-]+$") REPLACED_BY_PROBLEM = 'replaced_by must be {"pr": , "step": }' @@ -133,6 +133,8 @@ def _step_problems(prefix, step): problems.append(prefix + "open must be a non-empty list of data-tour ids or @actions") problems.extend(_texts_problems(prefix, "title", step.get("title"))) problems.extend(_texts_problems(prefix, "text", step.get("text"))) + if "unavailable" in step: + problems.extend(_texts_problems(prefix, "unavailable", step["unavailable"])) return problems @@ -235,6 +237,8 @@ def resolve(translations, pr, target): out["open"] = step["open"] out["title"] = {lang: step["title"][lang] for lang in _text_languages()} out["text"] = {lang: step["text"][lang] for lang in _text_languages()} + if "unavailable" in step: + out["unavailable"] = {lang: step["unavailable"][lang] for lang in _text_languages()} steps.append(out) result = {"steps": steps} if "replaced_by" in entry: diff --git a/scripts/tests/test_highlight_tours.py b/scripts/tests/test_highlight_tours.py index d4022475..95c07e9f 100644 --- a/scripts/tests/test_highlight_tours.py +++ b/scripts/tests/test_highlight_tours.py @@ -338,3 +338,24 @@ def test_check_passes_for_a_folded_highlight(tmp_path): write_file(repo, "191.json", {"de": {"*": "Haupt"}}) write_file(repo, "192.json", {"de": {"*": "Touren"}, "folded_into": 191}) assert ht.main(["check", "--repo", str(repo), "--pr", "192"]) == 0 + + +def test_unavailable_is_an_optional_text(): + step = {**STEP, "unavailable": {"en": "Appears once a chain exists", "de": "Erscheint, sobald es eine Messkette gibt"}} + assert ht.validate(tours({"steps": [step]})) == [] + resolved = ht.resolve(tours({"steps": [step]}), 190, "dashboard") + assert resolved["steps"][0]["unavailable"] == {"en": "Appears once a chain exists", "de": "Erscheint, sobald es eine Messkette gibt"} + + +def test_resolve_leaves_unavailable_out_when_missing(): + assert "unavailable" not in ht.resolve(tours({"steps": [STEP]}), 190, "dashboard")["steps"][0] + + +@pytest.mark.parametrize("value, problem", [ + ({"en": "x"}, "unavailable for de is missing"), + ({"en": "x", "de": " "}, "unavailable for de is empty"), + ("x", "unavailable must be an object keyed by language"), +]) +def test_unavailable_needs_every_language(value, problem): + problems = ht.validate(tours({"steps": [{**STEP, "unavailable": value}]})) + assert any(problem in p for p in problems) From cf6a66694e4dbbe288d6293245a15d87f691dbff Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:25:40 +0100 Subject: [PATCH 2/9] feat(onboarding): pass the unavailable reason of tour steps to the web UI Co-Authored-By: Claude Opus 5.5 --- dashboard/internal/versions/highlights.go | 12 +++++++----- dashboard/internal/versions/highlights_test.go | 5 ++++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/dashboard/internal/versions/highlights.go b/dashboard/internal/versions/highlights.go index 8093b77f..01c100ca 100644 --- a/dashboard/internal/versions/highlights.go +++ b/dashboard/internal/versions/highlights.go @@ -68,7 +68,8 @@ type TourReplacement struct { // as "companion" for a paired companion. The server keeps the step when it // does not hold and sets Unmet, so the tour shows the text with a note and no // spotlight instead of waiting for a missing target. Open lists the entries (data-tour ids or @actions) that must -// exist before the step runs, otherwise the tour is stale. +// exist before the step runs, otherwise the tour is stale. Unavailable holds +// the optional reason shown when the target is not visible right now. type TourStep struct { Panel string `json:"panel,omitempty"` Page string `json:"page,omitempty"` @@ -77,10 +78,11 @@ type TourStep struct { Need string `json:"need,omitempty"` When string `json:"when,omitempty"` // Unmet is set by the server per request, stored tours never carry it. - Unmet bool `json:"unmet,omitempty"` - Open []string `json:"open,omitempty"` - Title map[string]string `json:"title"` - Text map[string]string `json:"text"` + Unmet bool `json:"unmet,omitempty"` + Open []string `json:"open,omitempty"` + Title map[string]string `json:"title"` + Text map[string]string `json:"text"` + Unavailable map[string]string `json:"unavailable,omitempty"` } // HighlightsRelease is one release of a component inside the range. diff --git a/dashboard/internal/versions/highlights_test.go b/dashboard/internal/versions/highlights_test.go index 81da4657..c04fa30c 100644 --- a/dashboard/internal/versions/highlights_test.go +++ b/dashboard/internal/versions/highlights_test.go @@ -290,7 +290,7 @@ func TestHighlightsPassesTourThrough(t *testing.T) { {"version":"v0.9.0","groups":[{"type":"feat","entries":[ {"text":"favourites","pr":180,"breaking":false,"highlight":true, "tour":{"steps":[{"panel":"devices-panel","page":"users","target":"favorites","device":"phone","need":"view_devices", - "title":{"en":"Favourites","de":"Favoriten"},"text":{"en":"Star a device","de":"Markiere ein Gerät"}}]}}, + "title":{"en":"Favourites","de":"Favoriten"},"text":{"en":"Star a device","de":"Markiere ein Gerät"},"unavailable":{"en":"Appears with a device","de":"Erscheint mit einem Gerät"}}]}}, {"text":"backend only","pr":181,"breaking":false,"highlight":true, "tour":{"steps":[],"exempt":"Only the backend changed"}}]}]}]}]}`, "installed-manifest.json": `{"version":"v0.9.0","components":{"dashboard":"v0.9.0"}}`, @@ -314,6 +314,9 @@ func TestHighlightsPassesTourThrough(t *testing.T) { if step.Title["de"] != "Favoriten" || step.Text["en"] != "Star a device" { t.Fatalf("texts = %v %v", step.Title, step.Text) } + if step.Unavailable["de"] != "Erscheint mit einem Gerät" { + t.Fatalf("unavailable = %v", step.Unavailable) + } if exempt := entries[1].Tour; exempt == nil || exempt.Exempt != "Only the backend changed" || len(exempt.Steps) != 0 { t.Fatalf("exempt = %+v", exempt) } From 03bc06516f16c59dfbdcb1a5e0e0f381e0fe9884 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:28:14 +0100 Subject: [PATCH 3/9] feat(onboarding): keep tour step hints out of the step text Co-Authored-By: Claude Opus 5.5 --- dashboard/internal/webui/catalogs/de.json | 4 ++-- dashboard/internal/webui/catalogs/en.json | 4 ++-- .../webui/static/js/onboarding-model.js | 5 +++-- .../internal/webui/static/js/onboarding.js | 1 + dashboard/test/onboarding-model.test.mjs | 17 +++++++++++++++-- dashboard/test/onboarding-store.test.mjs | 2 +- 6 files changed, 24 insertions(+), 9 deletions(-) diff --git a/dashboard/internal/webui/catalogs/de.json b/dashboard/internal/webui/catalogs/de.json index c79a2666..00dc0fac 100644 --- a/dashboard/internal/webui/catalogs/de.json +++ b/dashboard/internal/webui/catalogs/de.json @@ -4248,7 +4248,7 @@ "onboarding.finish.welcome.title": "Viel Spaß", "onboarding.guest_note.text": "Der Admin muss sich einmal anmelden und die Ersteinrichtung durchgehen. Bis dahin fehlen hier Geräte und Energiewerte.", "onboarding.guest_note.title": "Noch nicht eingerichtet.", - "onboarding.hidden": "Zurzeit nicht sichtbar.", + "onboarding.hidden": "Zurzeit nicht sichtbar", "onboarding.rule_copy": "{name} (Kopie)", "onboarding.setup.admin.sub": "Name und Passwort des ersten Kontos", "onboarding.setup.admin.title": "Admin-Zugang", @@ -4297,7 +4297,7 @@ "onboarding.setup.users.title": "Weitere Benutzer anlegen", "onboarding.toast.setup_skipped": "Einrichtung übersprungen. Offene Punkte findest du in der Checkliste.", "onboarding.toast.tour_ended": "Tour beendet. Du findest sie in der Checkliste.", - "onboarding.unmet.companion": "Noch nicht sichtbar, nur mit gekoppeltem Home Assistant.", + "onboarding.unmet.companion": "Nur mit gekoppeltem Home Assistant.", "onboarding.welcome.w-devices.text": "Alle Geräte mit ihren Werten. Ein Tipp auf ein Gerät öffnet Details und Verlauf.", "onboarding.welcome.w-devices.title": "Geräte", "onboarding.welcome.w-overview.text": "Hier siehst du auf einen Blick, was gerade erzeugt, gespeichert und verbraucht wird.", diff --git a/dashboard/internal/webui/catalogs/en.json b/dashboard/internal/webui/catalogs/en.json index bf5de331..8c264f67 100644 --- a/dashboard/internal/webui/catalogs/en.json +++ b/dashboard/internal/webui/catalogs/en.json @@ -4248,7 +4248,7 @@ "onboarding.finish.welcome.title": "Have fun", "onboarding.guest_note.text": "An admin has to sign in once and go through the initial setup. Until then, devices and energy values are missing here.", "onboarding.guest_note.title": "Not set up yet.", - "onboarding.hidden": "Not visible right now.", + "onboarding.hidden": "Not visible right now", "onboarding.rule_copy": "{name} (copy)", "onboarding.setup.admin.sub": "Name and password of the first account", "onboarding.setup.admin.title": "Admin account", @@ -4297,7 +4297,7 @@ "onboarding.setup.users.title": "Add more users", "onboarding.toast.setup_skipped": "Setup skipped. You find open items in the checklist.", "onboarding.toast.tour_ended": "Tour ended. You find it in the checklist.", - "onboarding.unmet.companion": "Not visible yet, only with a paired Home Assistant.", + "onboarding.unmet.companion": "Only with a paired Home Assistant.", "onboarding.welcome.w-devices.text": "All devices with their values. A tap on a device opens details and history.", "onboarding.welcome.w-devices.title": "Devices", "onboarding.welcome.w-overview.text": "Here you see at a glance what is being generated, stored and used right now.", diff --git a/dashboard/internal/webui/static/js/onboarding-model.js b/dashboard/internal/webui/static/js/onboarding-model.js index 09a3e215..80c8140d 100644 --- a/dashboard/internal/webui/static/js/onboarding-model.js +++ b/dashboard/internal/webui/static/js/onboarding-model.js @@ -123,8 +123,9 @@ const flat = items.flatMap((item) => tourSteps(item, ctx) // Der Schritt zeigt seinen eigenen Titel und Text, nur ohne eigenen faellt er auf das Highlight zurueck. .map((s) => ({ ...s, id: item.id, title: s.title || item.title, check: 'leave', - // Gilt die Bedingung des Schritts nicht, steht der Hinweis dahinter und es gibt kein Ziel. - text: (s.text || item.text) + (s.unmet ? ` ${text(ctx, `onboarding.unmet.${s.when}`, {})}` : '') }))); + // Gilt die Bedingung des Schritts nicht, steht der Hinweis in der Statuszeile (hiddenNote), nicht im Text. + text: s.text || item.text, + hiddenNote: s.unmet ? text(ctx, `onboarding.unmet.${s.when}`, {}) : (s.unavailable || '') }))); const steps = flat.map((s, i) => ({ ...s, eyebrow: text(ctx, 'onboarding.eyebrow.explore', { version: short, i: i + 1, total: flat.length }), diff --git a/dashboard/internal/webui/static/js/onboarding.js b/dashboard/internal/webui/static/js/onboarding.js index ab6f8d0b..caa05cce 100644 --- a/dashboard/internal/webui/static/js/onboarding.js +++ b/dashboard/internal/webui/static/js/onboarding.js @@ -346,6 +346,7 @@ open: Array.isArray(s.open) ? s.open : [], title: localized(s.title, s.title?.en), text: localized(s.text, s.text?.en), + unavailable: s.unavailable ? localized(s.unavailable, s.unavailable.en) : '', literal: true, })), }; diff --git a/dashboard/test/onboarding-model.test.mjs b/dashboard/test/onboarding-model.test.mjs index ffbb92f9..b86612aa 100644 --- a/dashboard/test/onboarding-model.test.mjs +++ b/dashboard/test/onboarding-model.test.mjs @@ -345,7 +345,7 @@ test('a normal explore run has no intro, from an item or without from', () => { assert.equal(m.buildSteps({ mode: 'explore', explore, seen: {}, ctx: ctx() })[0].newsIntro, undefined); }); -test('an unmet step keeps its place and gets the hint behind its text', () => { +test('an unmet step keeps its place and carries the hint as hiddenNote', () => { const m = load(); const explore = [{ version: '0.12.0', current: true, items: [{ id: 'h1', title: 'H', text: '', steps: [ { title: 'A', text: 'Erster Text.', target: 'a' }, @@ -355,6 +355,19 @@ test('an unmet step keeps its place and gets the hint behind its text', () => { assert.equal(steps.length, 2); assert.equal(steps[0].text, 'Erster Text.'); assert.equal(steps[1].unmet, true); - assert.equal(steps[1].text, 'Zweiter Text. Noch nicht sichtbar, nur mit gekoppeltem Home Assistant.'); + assert.equal(steps[1].text, 'Zweiter Text.'); + assert.equal(steps[1].hiddenNote, 'Nur mit gekoppeltem Home Assistant.'); assert.equal(steps[1].eyebrow, 'Neu in 0.12 · 2 von 2'); }); + +test('a step carries its unavailable reason as hiddenNote', () => { + const m = load(); + const explore = [{ version: '0.12.0', current: true, items: [{ id: 'h1', title: 'H', text: '', steps: [ + { title: 'A', text: 'Text.', target: 'a', unavailable: 'Erscheint, sobald es eine Messkette gibt' }, + { title: 'B', text: 'Text.', target: 'b' }, + ] }] }]; + const steps = m.buildSteps({ mode: 'explore', from: null, explore, seen: {}, status: {}, ctx: ctx() }); + assert.equal(steps[0].hiddenNote, 'Erscheint, sobald es eine Messkette gibt'); + assert.equal(steps[0].text, 'Text.'); + assert.equal(steps[1].hiddenNote, ''); +}); diff --git a/dashboard/test/onboarding-store.test.mjs b/dashboard/test/onboarding-store.test.mjs index c7804edf..479117e7 100644 --- a/dashboard/test/onboarding-store.test.mjs +++ b/dashboard/test/onboarding-store.test.mjs @@ -286,7 +286,7 @@ test('exploreVersions groups the server highlights in the model shape', async () assert.equal(guest.steps.length, 1); assert.deepEqual({ ...guest.steps[0], open: [...guest.steps[0].open] }, { panel: 'settings-panel', page: 'users', target: '[data-tour="guest"]', device: '', need: 'user_management', when: undefined, unmet: false, - title: 'Gast', text: 'Hier', open: [], literal: true, + title: 'Gast', text: 'Hier', unavailable: '', open: [], literal: true, }); // tour null: nur Text, keine Schritte. From f0728dbf9011c022aaec9ae80940a073f7ebb892 Mon Sep 17 00:00:00 2001 From: DevSimon <73778205+Developer-Simon@users.noreply.github.com> Date: Mon, 30 Nov 2026 20:30:51 +0100 Subject: [PATCH 4/9] feat(onboarding): show a missing tour target as a status line and spot it once it appears Co-Authored-By: Claude Opus 5.5 --- .../internal/webui/cache-bust-history.csv | 3 +++ .../internal/webui/static/css/onboarding.css | 4 ++++ .../internal/webui/static/js/onboarding.js | 24 ++++++++++++------- dashboard/internal/webui/templates/base.html | 13 +++++++--- 4 files changed, 32 insertions(+), 12 deletions(-) diff --git a/dashboard/internal/webui/cache-bust-history.csv b/dashboard/internal/webui/cache-bust-history.csv index c53e5d42..0073185c 100644 --- a/dashboard/internal/webui/cache-bust-history.csv +++ b/dashboard/internal/webui/cache-bust-history.csv @@ -2,6 +2,9 @@ version,date,asset,v,note v0.11.23-pre.41,2026-11-30,js/automations.page.js,34, v0.11.23-pre.41,2026-11-30,js/monitoring-model.js,7, v0.11.23-pre.41,2026-11-30,js/monitoring.page.js,6, +v0.11.23-pre.41,2026-11-30,css/onboarding.css,7, +v0.11.23-pre.41,2026-11-30,js/onboarding-model.js,7, +v0.11.23-pre.41,2026-11-30,js/onboarding.js,10, v0.11.22-pre.40,2026-11-30,css/manager.css,54, v0.11.22-pre.40,2026-11-30,js/energy.page.js,19, v0.11.22-pre.40,2026-11-30,js/monitoring-model.js,6, diff --git a/dashboard/internal/webui/static/css/onboarding.css b/dashboard/internal/webui/static/css/onboarding.css index 57766861..7cf88cf2 100644 --- a/dashboard/internal/webui/static/css/onboarding.css +++ b/dashboard/internal/webui/static/css/onboarding.css @@ -166,6 +166,10 @@ .ob-bar-state { display: flex; align-items: center; gap: .45rem; margin: .25rem 0 0; font-size: .88rem; } .ob-bar-state--done { color: var(--ok); font-weight: 600; } .ob-bar-state--lost { flex-wrap: wrap; color: var(--text-muted); } +.ob-bar-state--hidden { align-items: flex-start; color: var(--text-muted); } +.ob-bar-state-icon { flex: none; width: 1em; height: 1em; } +.ob-bar-state-copy { display: grid; gap: .1rem; } +.ob-bar-state-head { font-weight: 600; } /* Sprachwahl in der Vorstellung: die Pille aus der Masthead (base.css), nur mit Beschriftung darueber. */ .ob-lang { display: grid; gap: .3rem; margin-top: .35rem; } diff --git a/dashboard/internal/webui/static/js/onboarding.js b/dashboard/internal/webui/static/js/onboarding.js index caa05cce..d07664ff 100644 --- a/dashboard/internal/webui/static/js/onboarding.js +++ b/dashboard/internal/webui/static/js/onboarding.js @@ -605,6 +605,7 @@ left: false, done: false, lost: false, + hidden: false, direction: 1, drag: null, cleanup: [], @@ -702,6 +703,7 @@ if (!step) return; this.done = this.s.mode !== 'explore' && this.s.mode !== 'welcome' && this.s.stateOf(step.id) === 'done' && this.s.mode !== 'change'; this.lost = false; + this.hidden = false; this.revealedAgain = false; // Neuer Schritt: Blatt wieder aufziehen, damit der Text zu lesen ist. // Verdeckt es danach das Ziel, klappt avoid() es erneut ein. @@ -716,6 +718,7 @@ if (step !== this.step) return; this.target = null; this.spot.hide(); + this.hidden = Boolean(step.unmet); return; } this.spot.hold(); @@ -742,21 +745,14 @@ // nicht zu sehen ist. So geht nichts verloren und die Tour springt nicht von selbst. if (step.literal) { this.target = null; - if (step.baseText === undefined) { - step.baseText = step.text; - this.s.steps[this.s.index].text = `${step.text} ${t('onboarding.hidden')}`; - } + this.hidden = true; + this.watchTarget(step); return; } // Ziel fehlt (anderer Dienst, Recht, Layout): Schritt ueberspringen. if (!this.last) this.s.index += 1; else this.s.finish(); return; } - // Das Ziel ist wieder da: der Hinweis auf das fehlende Ziel entfaellt. - if (step.baseText !== undefined) { - this.s.steps[this.s.index].text = step.baseText; - delete step.baseText; - } this.target = el; // Leerer Bereich: Leertext statt Erklärung, erst jetzt sind die Karten da. const empty = typeof step.emptyWhen === 'function' && step.emptyWhen(); @@ -893,6 +889,16 @@ }, back() { if (this.s.index > 0) this.s.index -= 1; }, again() { this.lost = false; this.show(); }, + // Fehlt das Ziel eines Neuerungs-Schritts, sieht die Tour jede Sekunde nach + // und zeigt den Schritt neu, sobald es da ist. Schrittwechsel beendet das. + watchTarget(step) { + const timer = setInterval(() => { + if (step !== this.step) return clearInterval(timer); + const el = resolveTarget(step.target, this.actions?.scope); + if (el && window.obSpotlight.visibleRect(el)) { clearInterval(timer); this.show(); } + }, 1000); + this.cleanup.push(() => clearInterval(timer)); + }, checklist() { const mode = this.s.mode === 'setup' || this.s.mode === 'change' || this.s.finished?.mode === 'setup' ? 'setup' : 'explore'; this.s.checklistMode = this.s.isAdmin ? mode : 'explore'; diff --git a/dashboard/internal/webui/templates/base.html b/dashboard/internal/webui/templates/base.html index 0215b70c..2c55dff9 100644 --- a/dashboard/internal/webui/templates/base.html +++ b/dashboard/internal/webui/templates/base.html @@ -73,7 +73,7 @@ - + @@ -345,10 +345,10 @@

- + - + @@ -539,6 +539,13 @@

{{t "onboarding.bar.lost"}}

+

+ + + {{t "onboarding.hidden"}} + + +