diff --git a/.changeset/help-report-in-more.md b/.changeset/help-report-in-more.md new file mode 100644 index 000000000..b9f79fdcc --- /dev/null +++ b/.changeset/help-report-in-more.md @@ -0,0 +1,5 @@ +--- +"ftw": patch +--- + +The help file moves from under the plan chart to More, as a "Get help" tile next to Settings, Setup and Version. Asking for help is about the whole box, not the plan. It downloads the same file as before. diff --git a/web/app.css b/web/app.css index 408c9a549..c116f80ed 100644 --- a/web/app.css +++ b/web/app.css @@ -1894,24 +1894,9 @@ body.ftw-app .plan-warning-details > pre { } body.ftw-app .plan-actions { gap: 10px; display: flex; align-items: center; } -/* The "why is it doing that?" escape hatch, below the chart because - that's where the question forms. Understated: it should be findable - when something looks wrong, not compete with the plan itself. */ -body.ftw-app .plan-help-request { - margin: 10px 0 2px; - padding-top: 10px; - border-top: 1px solid var(--border); -} -body.ftw-app .plan-help-request button { padding-left: 0; } -body.ftw-app .plan-help-request button[disabled] { - opacity: 0.6; - cursor: default; - text-decoration: none; -} - body.ftw-app .more-actions { display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 18px; } @@ -1930,6 +1915,7 @@ body.ftw-app .more-action { text-decoration: none; cursor: pointer; } +body.ftw-app .more-action[disabled] { cursor: default; opacity: 0.7; } body.ftw-app .more-action:hover { border-color: var(--accent-e); background: color-mix(in oklch, var(--ink-raised) 92%, var(--accent-e)); diff --git a/web/diagnose.js b/web/diagnose.js index b7664168d..8a82af5b6 100644 --- a/web/diagnose.js +++ b/web/diagnose.js @@ -104,6 +104,51 @@ const badge = document.querySelector('ftw-update-badge'); if (badge && typeof badge.open === 'function') badge.open(); }); + const helpShortcut = document.getElementById('more-help-btn'); + if (helpShortcut) helpShortcut.addEventListener('click', downloadHelpReport); + } + + // Pulls GET /api/support/dump and saves it. The archive leads with + // 00-help-report.md, the readable answer to "why is it doing that?" and + // "what happened last night?", and carries the logs, config and a week of + // telemetry, plans and control journal behind it. One button and one + // file, so a user asking for help never has to work out which download we + // meant. The bare report is still at /api/support/report. + // + // It sits under More with Settings, Setup and Version: asking for help is + // about the whole box, not one view of it. + function downloadHelpReport() { + const btn = document.getElementById('more-help-btn'); + const status = document.getElementById('more-help-status'); + if (!btn || btn.disabled) return; + const original = status ? status.textContent : ''; + const say = text => { if (status) status.textContent = text; }; + btn.disabled = true; + say('Building the file…'); + const restore = text => { + say(text); + setTimeout(() => { + btn.disabled = false; + say(original); + }, 4000); + }; + apiFetch('/api/support/dump') + .then(resp => { + if (!resp.ok) throw new Error('HTTP ' + resp.status); + return resp.blob().then(blob => { + const stamp = new Date().toISOString().slice(0, 16).replace(/[-:T]/g, ''); + const url = URL.createObjectURL(blob); + const a = document.createElement('a'); + a.href = url; + a.download = 'ftw-help-' + stamp + '.zip'; + document.body.appendChild(a); + a.click(); + a.remove(); + setTimeout(() => URL.revokeObjectURL(url), 30000); + restore('Downloaded'); + }); + }) + .catch(err => restore('Failed: ' + (err && err.message ? err.message : String(err)))); } function applyHash() { diff --git a/web/help-report.test.mjs b/web/help-report.test.mjs index 4457c18ba..cb6cece90 100644 --- a/web/help-report.test.mjs +++ b/web/help-report.test.mjs @@ -3,29 +3,41 @@ import { readFileSync } from "node:fs"; import test from "node:test"; const plan = readFileSync(new URL("./plan.js", import.meta.url), "utf8"); +const diagnose = readFileSync(new URL("./diagnose.js", import.meta.url), "utf8"); const index = readFileSync(new URL("./index.html", import.meta.url), "utf8"); const diagnostics = readFileSync(new URL("./diagnostics-modal.js", import.meta.url), "utf8"); -test("the plan card offers a help report", () => { - assert.match(index, /id="plan-help-report"/); - // The label has to name the problem the user has, not the artefact we - // produce — someone whose battery is misbehaving does not search for - // "diagnostics". - assert.match(index, /Something looks wrong\?/); +function section(html, id) { + const start = html.indexOf(`id="${id}"`); + assert.notEqual(start, -1, `${id} is missing`); + const end = html.indexOf("", start); + return html.slice(start, end); +} + +// Asking for help is about the whole box, so the file sits under More with +// Settings, Setup and Version, not under one view such as the plan. +test("the help report lives under More, not under Plan", () => { + const more = section(index, "view-more"); + assert.match(more, /id="more-help-btn"/); + assert.match(more, /Get help<\/strong>/); + // The plan card is moved into the Plan view at run time, so check the + // whole page: the old button under the chart is gone. + assert.doesNotMatch(index, /plan-help-report|Download a help report/); + assert.doesNotMatch(plan, /support\/dump|downloadHelpReport/); }); // One button, one file. The archive leads with the readable report and // carries the logs behind it, so a user asking for help never has to work // out which of two downloads we meant. -test("the help-report button downloads the bundle, not just the text", () => { - assert.match(plan, /getElementById\('plan-help-report'\)/); - assert.match(plan, /apiFetch\('\/api\/support\/dump'\)/); - assert.match(plan, /a\.download = 'ftw-help-' \+ stamp \+ '\.zip'/); +test("the help button downloads the bundle, not just the text", () => { + assert.match(diagnose, /getElementById\('more-help-btn'\)/); + assert.match(diagnose, /apiFetch\('\/api\/support\/dump'\)/); + assert.match(diagnose, /a\.download = 'ftw-help-' \+ stamp \+ '\.zip'/); }); -test("the help-report button reports failure instead of failing silently", () => { - assert.match(plan, /restore\('Failed: '/); - assert.match(plan, /btn\.disabled = true/); +test("the help button reports failure instead of failing silently", () => { + assert.match(diagnose, /restore\('Failed: '/); + assert.match(diagnose, /btn\.disabled = true/); }); test("the driver diagnose modal also links the report", () => { diff --git a/web/index.html b/web/index.html index 0ddf47a4d..46dde3070 100644 --- a/web/index.html +++ b/web/index.html @@ -630,15 +630,6 @@

Plan

SoC - -
- -
@@ -866,6 +857,10 @@

Setup, settings and system

VersionRunning version and updates + diff --git a/web/plan.js b/web/plan.js index 56f20c496..da5a26b0f 100644 --- a/web/plan.js +++ b/web/plan.js @@ -1564,52 +1564,6 @@ import { else helpModal.setAttribute('open', ''); }); } - const reportBtn = document.getElementById('plan-help-report'); - if (reportBtn) reportBtn.addEventListener('click', downloadHelpReport); - } - - // Pulls GET /api/support/dump and saves it. That archive leads with - // 00-help-report.md — the readable answer to "why is it doing that?" and - // "what happened last night?" — and carries the logs, config and a week - // of telemetry, plans and control journal behind it. One button and - // one file, because a user asking for help should not have to work out - // which of two downloads we wanted. The bare report is still at - // /api/support/report for anyone who wants only the text. - // - // Lives here rather than in the driver Diagnose modal because the - // question is asked while looking at the plan, not at a device. - function downloadHelpReport() { - const btn = document.getElementById('plan-help-report'); - if (!btn || btn.disabled) return; - const original = btn.textContent; - btn.disabled = true; - btn.textContent = 'Building report…'; - const restore = function (text) { - btn.textContent = text; - setTimeout(function () { - btn.disabled = false; - btn.textContent = original; - }, 4000); - }; - apiFetch('/api/support/dump') - .then(function (resp) { - if (!resp.ok) throw new Error('HTTP ' + resp.status); - return resp.blob().then(function (blob) { - const stamp = new Date().toISOString().slice(0, 16).replace(/[-:T]/g, ''); - const url = URL.createObjectURL(blob); - const a = document.createElement('a'); - a.href = url; - a.download = 'ftw-help-' + stamp + '.zip'; - document.body.appendChild(a); - a.click(); - a.remove(); - setTimeout(function () { URL.revokeObjectURL(url); }, 30000); - restore('Downloaded'); - }); - }) - .catch(function (err) { - restore('Failed: ' + (err && err.message ? err.message : String(err))); - }); } if (document.readyState === 'loading') {