From feb446be1ca6dbacd03fa9e0a5d0008ef129170b Mon Sep 17 00:00:00 2001 From: CRT Date: Wed, 30 Sep 2026 16:25:13 +0000 Subject: [PATCH] Report a problem: a diagnostic summary with no personal data, shown as it would be shared, with Copy and the issue page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The app menu's "Report a problem…" opens a small dialog with the summary (reportModel.ts, English on purpose: the people who read reports do): the app and framework versions, the system and webview (coarse, from the user agent), the language and how it was chosen, the mode, the theme and icon pack ids, the file names of the plugins that are on, what paused itself (the panel's `reportDetails`), and safe mode. The model has no field for an account, a handle, an address, a tab or a path, and a value that is not made of id characters is left out rather than trimmed into shape, so nothing of that kind can ride along (tested with hostile input). The dialog sends nothing: Copy puts the text on the clipboard, and "Open the issue page" opens `ShellSite.menu.report.issueUrl` bare in the system browser (the summary is never put in a URL). Without an issue page the button is off and the dialog says so. --- packages/shell/src/frame/AppMenu.tsx | 4 + packages/shell/src/frame/ReportDialog.tsx | 102 ++++++++++++++ packages/shell/src/frame/appMenu.css | 17 +++ packages/shell/src/frame/icons.tsx | 1 + packages/shell/src/frame/index.ts | 2 +- packages/shell/src/frame/menuMessages.en.json | 7 +- packages/shell/src/frame/menuModel.ts | 14 +- packages/shell/src/frame/reportModel.ts | 126 ++++++++++++++++++ packages/shell/src/panel/PluginFeatures.tsx | 9 ++ packages/shell/src/panel/index.ts | 2 +- packages/shell/tests/menu.test.ts | 8 +- packages/shell/tests/report.test.ts | 113 ++++++++++++++++ 12 files changed, 396 insertions(+), 9 deletions(-) create mode 100644 packages/shell/src/frame/ReportDialog.tsx create mode 100644 packages/shell/src/frame/reportModel.ts create mode 100644 packages/shell/tests/report.test.ts diff --git a/packages/shell/src/frame/AppMenu.tsx b/packages/shell/src/frame/AppMenu.tsx index 734cfe6..509a74b 100644 --- a/packages/shell/src/frame/AppMenu.tsx +++ b/packages/shell/src/frame/AppMenu.tsx @@ -24,6 +24,7 @@ import { DEFAULT_MENU, ZOOM_MAX, ZOOM_MIN, findSpec, joinGroups, languageChoice, languageRows, menuText, moveStop, planMenu, shortcutText, specRows, submenuKeys, submenuLeft, typeahead, updateRow, type BuiltinMenuItem, type MenuEnv, type MenuItemRow, type MenuRow, } from './menuModel.ts'; +import { ReportDialog } from './ReportDialog.tsx'; import { safe, setSafeMode } from './safeStore.ts'; import { hasFeature, site } from './site.ts'; import { isWeb, setOverlay, shell, type TabParams } from './state.ts'; @@ -81,6 +82,7 @@ export function AppMenu() { const [version, setVersion] = useState(''); const [update, setUpdate] = useState({ state: 'idle' }); const [askedUpdate, setAskedUpdate] = useState(false); + const [reporting, setReporting] = useState(false); const [error, setError] = useState(''); const [, tick] = useReducer((n: number) => n + 1, 0); const button = useRef(null); @@ -306,6 +308,7 @@ export function AppMenu() { case 'safe-mode': return safe.active ? item(id, menuText('safeLeave'), 'shield', { run: () => setSafeMode(false) }) : item(id, menuText('safeRestart'), 'shield', { submenu: true }); + case 'report': return item(id, menuText('report'), 'flag', { run: () => setReporting(true) }); case 'about': return item(id, menuText('about', { product: config.product }), 'info', { run: () => shell.openPanelSection('home') }); case 'settings': return item(id, section(t('wb.panel.section.settings')), 'settings', { run: () => shell.openPanelSection('settings') }); } @@ -523,6 +526,7 @@ export function AppMenu() { {renderMenus()} , document.body)} + {reporting && setReporting(false)}/>} ; } diff --git a/packages/shell/src/frame/ReportDialog.tsx b/packages/shell/src/frame/ReportDialog.tsx new file mode 100644 index 0000000..2ccf796 --- /dev/null +++ b/packages/shell/src/frame/ReportDialog.tsx @@ -0,0 +1,102 @@ +// "Report a problem": a small dialog that shows the diagnostic summary (reportModel.ts) exactly as +// it would be shared, with Copy and a button that opens the project's new-issue page in the system +// browser. The app sends nothing itself: no request, and the summary is never put in a URL (the +// issue page opens bare; the owner pastes what they copied). Without a configured issue page the +// button is off and says why. + +import { useEffect, useRef, useState } from 'react'; +import { createPortal } from 'react-dom'; +import { invoke } from './bridge.ts'; +import { useT } from './hooks.ts'; +import { textLocale } from './i18n.ts'; +import { Icon } from './icons.tsx'; +import { menuText } from './menuModel.ts'; +import { buildReport, systemFromUserAgent, webviewFromUserAgent, type ReportInfo } from './reportModel.ts'; +import { safe } from './safeStore.ts'; +import { site } from './site.ts'; +import { setOverlay } from './state.ts'; + +type Hints = { platformVersion?: string; architecture?: string; bitness?: string }; + +/** What the engine says about the system when asked (Chromium webviews; others have the user agent only). */ +async function systemHints(): Promise { + try { + const data = (navigator as Navigator & { userAgentData?: { getHighEntropyValues(hints: string[]): Promise } }).userAgentData; + return data ? await data.getHighEntropyValues(['platformVersion', 'architecture', 'bitness']) : {}; + } catch { return {}; } +} + +/** Gathers the facts a report may say: from the app's config and the shell's own state, nothing about the person. */ +async function collect(): Promise { + const config = site(); + const menu = config.menu ?? {}; + const themes = config.themes; + const [appVersion, hints, mode, plugins, details] = await Promise.all([ + menu.version ? menu.version().catch(() => '') : Promise.resolve(''), + systemHints(), + menu.modes ? menu.modes.current().catch(() => null) : Promise.resolve(undefined), + invoke>('plugins_list').then(list => list.filter(plugin => plugin.enabled === true).map(plugin => String(plugin.file ?? '')), () => null), + menu.report?.details ? Promise.resolve(menu.report.details()).catch(() => []) : Promise.resolve([]), + ]); + if (themes) await themes.loadThemes().catch(() => {}); + const choice = themes?.current().choice; + const theme = themes ? themes.adapter.resolve(choice) as { id?: unknown; icons?: { pack?: unknown } } : null; + return { + product: config.product, + appVersion, + system: systemFromUserAgent(navigator.userAgent, hints), + webview: webviewFromUserAgent(navigator.userAgent), + language: menu.languages?.state().locale ?? textLocale(), + languageChoice: menu.languages?.state().preference ?? 'fixed', + mode, + theme: themes ? themes.adapter.preset(choice) : undefined, + iconPack: theme ? (typeof theme.icons?.pack === 'string' ? theme.icons.pack : '') : undefined, + plugins, + details, + safeMode: safe.active, + }; +} + +export function ReportDialog({ onClose }: { onClose(): void }) { + const t = useT(); + const [text, setText] = useState(null); + const [copied, setCopied] = useState(false); + const dialog = useRef(null); + const issueUrl = site().menu?.report?.issueUrl; + const canOpen = typeof issueUrl === 'string' && /^https:\/\//.test(issueUrl); + + useEffect(() => { + setOverlay(1); + invoke('shell_focus').catch(() => {}); + let live = true; + collect().then(info => { if (live) setText(buildReport(info)); }, () => { if (live) setText(''); }); + dialog.current?.focus(); + return () => { live = false; setOverlay(-1); }; + }, []); + + const copy = async () => { + if (!text) return; + try { await navigator.clipboard.writeText(text); setCopied(true); setTimeout(() => setCopied(false), 2200); } + catch { dialog.current?.querySelector('textarea')?.select(); } + }; + + return createPortal(
+
event.stopPropagation()} onKeyDown={event => { if (event.key === 'Escape') { event.preventDefault(); event.stopPropagation(); onClose(); } }}> +
+

{menuText('reportTitle')}

+ +
+

{menuText('reportLede')}

+