From 08b3089569b2f3a705e06fbe6d37846c7faf7d47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8D=83=E5=B7=9D=E7=99=BD=E6=B5=AA?= <1679659@qq.com> Date: Tue, 1 Dec 2026 09:19:36 -0700 Subject: [PATCH] chore: clean up stale and redundant comments across backend and frontend --- frontend/scripts/check-ui-contract.mjs | 2 +- frontend/scripts/test-i18n.mjs | 8 ++--- frontend/src/App.tsx | 8 ++--- frontend/src/components/CreateWizard.tsx | 4 +-- frontend/src/components/PluginPanelFrame.tsx | 9 ++---- frontend/src/components/PluginsPage.tsx | 8 ++--- frontend/src/components/SchemaForm.tsx | 2 +- frontend/src/components/SettingsModal.tsx | 2 +- frontend/src/components/VMPage.tsx | 9 +++--- frontend/src/lib/bridgeContract.ts | 2 +- frontend/src/lib/format.ts | 2 +- frontend/src/lib/themeEngine.ts | 30 +++++++------------ frontend/src/lib/uiSdk.ts | 11 ++++--- frontend/src/macos/InstallersPage.tsx | 4 +-- frontend/src/main.tsx | 2 +- frontend/src/styles/app.css | 20 +++++-------- frontend/src/styles/tokens.css | 2 +- frontend/src/styles/ui-contract.ts | 6 ++-- frontend/src/ui/controls.tsx | 2 +- frontend/src/ui/settings.tsx | 5 +--- frontend/src/ui/themeVisuals.tsx | 2 +- frontend/src/wails.ts | 4 +-- internal/app/app.go | 2 +- internal/app/appupdate_flow.go | 8 ++--- internal/app/install_flow.go | 20 +++++-------- internal/app/install_guide.go | 7 ++--- internal/app/installer_bindings.go | 3 +- internal/app/macos_lifecycle_native.go | 9 +++--- internal/app/plugins_flow.go | 4 +-- internal/archtest/macos_boundary_test.go | 2 +- internal/cli/plugin.go | 2 +- internal/config/config.go | 4 +-- internal/datamigrate/datamigrate.go | 15 +++------- internal/downloader/parallel.go | 4 --- internal/driver/driver.go | 6 ++-- internal/host/host.go | 9 ++---- internal/host/memory.go | 15 ++++------ internal/host/optimizations.go | 6 ++-- internal/host/progress.go | 2 +- internal/host/redact.go | 6 ++-- internal/i18n/error.go | 2 +- internal/macos/guest/migrate.go | 6 ++-- internal/macos/installer/installer.go | 5 ++-- .../macos/installguide/appearance_windows.go | 7 ----- internal/macos/installguide/manager.go | 6 ++-- internal/macos/reims/compat.go | 6 ++-- internal/macos/startprep/startprep.go | 17 ++++------- internal/plugin/blockers_test.go | 2 +- internal/plugin/builtin/builtin.go | 6 ++-- internal/plugin/contract.go | 10 +++---- internal/plugin/hooks.go | 14 ++++----- internal/plugin/ledger.go | 28 +++++++---------- internal/plugin/manager.go | 6 ++-- internal/plugin/package.go | 15 +++------- internal/plugin/registry.go | 28 ++++++++--------- internal/plugin/rpc.go | 2 +- internal/plugin/scanner.go | 6 ---- internal/plugin/sidecar.go | 4 +-- internal/plugin/theme_css.go | 6 ++-- internal/runtime/remote.go | 21 ++++--------- internal/runtime/runtime.go | 13 ++++---- internal/selfupdate/selfupdate.go | 13 ++------ pkg/pluginsdk/sdk.go | 7 ++--- scripts/io-bench/run-bench.ps1 | 5 ---- 64 files changed, 194 insertions(+), 309 deletions(-) diff --git a/frontend/scripts/check-ui-contract.mjs b/frontend/scripts/check-ui-contract.mjs index ceec94a..2ebba00 100644 --- a/frontend/scripts/check-ui-contract.mjs +++ b/frontend/scripts/check-ui-contract.mjs @@ -1,4 +1,4 @@ -// Checks the UI and bridge contracts (docs/plugin-architecture.md §5.1, §5.6, §6.3) +// Checks the UI and bridge contracts (see docs/plugin-architecture.md) // and writes ui-contract.json / bridge-contract.json for plugin authors. // // Rule "public means implemented": every stable part, state attribute, slot and diff --git a/frontend/scripts/test-i18n.mjs b/frontend/scripts/test-i18n.mjs index 454b255..450abfb 100644 --- a/frontend/scripts/test-i18n.mjs +++ b/frontend/scripts/test-i18n.mjs @@ -20,7 +20,7 @@ function walkFiles(dir, exts) { return out } -test('Static Guard (CRITICAL-1): lazy i18n domain keys are always backed by domain .gen imports', () => { +test('lazy i18n domain keys are always backed by domain .gen imports', () => { const lazyDomains = ['wizard', 'settings', 'plugins'] const keyToDomain = new Map() for (const dom of ['core', 'vm', ...lazyDomains]) { @@ -90,7 +90,7 @@ test('Static Guard (CRITICAL-1): lazy i18n domain keys are always backed by doma } }) -test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and toast-* class in TSX exists in CSS', () => { +test('every stack-*, notice-*, error-boundary*, and toast-* class in TSX exists in CSS', () => { const css = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') + '\n' + @@ -114,7 +114,7 @@ test('Static Guard (CRITICAL-2): every stack-*, notice-*, error-boundary*, and t } }) -test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never replay on close', () => { +test('Radix Presence .menu/.tooltip animations never replay on close', () => { const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '') const titleMenus = fs.readFileSync(path.join(srcDir, 'components', 'TitleMenus.tsx'), 'utf8') @@ -171,7 +171,7 @@ test('Static Guard (CRITICAL-3): Radix Presence .menu/.tooltip animations never ) }) -test('Static Guard (CRITICAL-4): software-composited UI avoids backdrop-filter and slow pre shaping', () => { +test('software-composited UI avoids backdrop-filter and slow pre shaping', () => { const rawCss = fs.readFileSync(path.join(srcDir, 'styles', 'app.css'), 'utf8') const css = rawCss.replace(/\/\*[\s\S]*?\*\//g, '') diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b0dffc0..bd29262 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -233,7 +233,7 @@ export const App: React.FC = () => { refreshSubscribedVMStats() setThemeRevision((r) => r + 1) }) - // Logs never pop the panel open (docs/design-guidelines.md §7.3); errors only bump a badge. + // Logs never pop the panel open (see docs/design-guidelines.md); errors only bump a badge. const offLog = events.onLog((entry) => { if (!entry || typeof entry !== 'object') return const lineText = typeof entry.line === 'string' ? entry.line : String(entry.line ?? '') @@ -465,7 +465,7 @@ export const App: React.FC = () => { // changed, so the workspace gives way to a screen that explains why. const showReadOnly = !!state && !showSetup && !!state.data_root_status?.read_only - // UI Contract v1 read-only document state attributes (§5.1). + // UI Contract v2 read-only document state attributes. const currentView = showSetup ? 'setup' : selected === HOST_ID ? 'host' : selected === INSTALLERS_ID ? 'installers' : selected === PLUGINS_ID ? 'plugins' : selected === SETTINGS_ID ? 'settings' : selected === ABOUT_ID ? 'about' : 'vm' const isBusyAny = Object.keys(busy).length > 0 || runningTasks > 0 const hasAnyError = unseenErrors > 0 || !!loadError @@ -544,7 +544,7 @@ export const App: React.FC = () => { } }, [taskMap]) - // Apply active theme pack (zero extra CSS for builtin default theme, §5.1 & §8.1). + // Apply active theme pack (zero extra CSS for builtin default theme). useEffect(() => { api.GetActiveTheme().then(setActiveThemePayload).catch((e) => console.warn('[app] GetActiveTheme failed:', e)) api.GetPluginUIContributions().then(setPluginUI).catch((e) => console.warn('[app] GetPluginUIContributions failed:', e)) @@ -932,7 +932,7 @@ export const App: React.FC = () => { refresh() } - // Global shortcuts (docs/design-guidelines.md §6). Dialogs own the keyboard while open. + // Global shortcuts (see docs/design-guidelines.md). Dialogs own the keyboard while open. const shortcutRef = useRef<(e: KeyboardEvent) => void>(() => {}) const appDialogOpen = showSetup || showReadOnly || showWizard || showSettings || affinityTarget || deleteTarget || discardSuspendTarget || sendTextTarget || cloneSource || onlineRecoveryTarget || confirmUpdate diff --git a/frontend/src/components/CreateWizard.tsx b/frontend/src/components/CreateWizard.tsx index 78df128..275f6a5 100644 --- a/frontend/src/components/CreateWizard.tsx +++ b/frontend/src/components/CreateWizard.tsx @@ -100,8 +100,8 @@ export const CreateWizard: React.FC = ({ locale, host, tasks = [], draft, const [opts, setOpts] = useState(draft?.opts ?? { name: 'macos-tahoe', dir: '', - // Offline by default: one exact release that installs with no network - // (roadmap M2.3; `reims-ctl create --help`, upstream 3731afd). + // Offline by default: installs an exact release without guest network access + // (`reims-ctl create --help`, upstream 3731afd). source_mode: 'offline', macos: '', offline: true, diff --git a/frontend/src/components/PluginPanelFrame.tsx b/frontend/src/components/PluginPanelFrame.tsx index 74cf5c8..0937e5a 100644 --- a/frontend/src/components/PluginPanelFrame.tsx +++ b/frontend/src/components/PluginPanelFrame.tsx @@ -20,11 +20,8 @@ interface Props { } /** - * Sandboxed L4 iframe panel with strict bridge verification (§4.2, §7.3): - * - `sandbox="allow-scripts"` (no allow-same-origin, no top-navigation) - * - Only responds to postMessage where `event.source === iframe.contentWindow` - * - Routes all Host API calls through Go `PanelBridgeCall` for permission & rate checks - * - Syncs theme tokens into iframe and provides error placeholder + retry. + * Sandboxed L4 iframe panel verifying window identity (`event.source === iframe.contentWindow` + * and opaque `null` origin) and routing Host API calls through `PanelBridgeCall`. */ const RE_SAFE_TOKEN = /^[a-f0-9]+$/ const RE_SAFE_PLUGIN_ID = /^[a-z0-9][a-z0-9._-]*$/ @@ -91,7 +88,7 @@ export const PluginPanelFrame: React.FC = ({ const onMessage = async (e: MessageEvent) => { const win = iframeRef.current?.contentWindow - // Strict origin + window identity check for sandbox="allow-scripts" opaque origin (§7.3). + // Require opaque origin and exact contentWindow identity for sandbox="allow-scripts". if (!win || e.source !== win || e.origin !== 'null') return const msg = e.data if (!msg || typeof msg !== 'object' || msg.type !== 'reims:rpc' || typeof msg.id !== 'string' || typeof msg.method !== 'string') return diff --git a/frontend/src/components/PluginsPage.tsx b/frontend/src/components/PluginsPage.tsx index 2c12af4..de62b3c 100644 --- a/frontend/src/components/PluginsPage.tsx +++ b/frontend/src/components/PluginsPage.tsx @@ -42,10 +42,7 @@ function hasAppSettings(p: PluginInfo): boolean { return Object.values(schema.properties ?? {}).some((prop) => (prop['x-scope'] || schema['x-scope'] || 'app') === 'app') } -/** - * Dedicated top-level Plugins & Themes management page (§5.1, §8.1, §10). - * Grouped inset list, same pattern as the installers page. - */ +/** Top-level Plugins & Themes management page. */ export const PluginsPage: React.FC = ({ locale, appearance, safeMode, onRefresh, onError, onThemeChanged, onLocaleSwitch, }) => { @@ -75,13 +72,12 @@ export const PluginsPage: React.FC = ({ } | null>(null) const [scanBusy, setScanBusy] = useState(false) - // The market mounts (and touches the network) only once its tab is opened (§8.1). + // Mount the market (and touch the network) only after its tab is opened. const [marketOpened, setMarketOpened] = useState(false) const [marketRefresh, setMarketRefresh] = useState(0) const [marketBusy, setMarketBusy] = useState(false) const [reloading, setReloading] = useState(false) - // Theme scheme editor state (§5.1) const [schemeEditorOpen, setSchemeEditorOpen] = useState(false) const [schemeName, setSchemeName] = useState('') const [seedAccent, setSeedAccent] = useState('#007aff') diff --git a/frontend/src/components/SchemaForm.tsx b/frontend/src/components/SchemaForm.tsx index ca4ff9c..cc212d3 100644 --- a/frontend/src/components/SchemaForm.tsx +++ b/frontend/src/components/SchemaForm.tsx @@ -20,7 +20,7 @@ interface Props { const SECRET_MASK = '••••••••' const FORBIDDEN_KEYS = new Set(['__proto__', 'constructor', 'prototype']) -/** Lazy-loaded JSON Schema form renderer supporting x-secret, x-effect, x-scope (§6.2, §8.1, §10). */ +/** Lazy-loaded JSON Schema form renderer supporting x-secret, x-effect, and x-scope. */ export const SchemaForm: React.FC = ({ locale, schema, values, scopeFilter, groupFilter, onChange, hideGroupHeader, }) => { diff --git a/frontend/src/components/SettingsModal.tsx b/frontend/src/components/SettingsModal.tsx index e4cdf42..177b2a3 100644 --- a/frontend/src/components/SettingsModal.tsx +++ b/frontend/src/components/SettingsModal.tsx @@ -44,7 +44,7 @@ import type { VMKeymapPreset, VMKeymapHostModifier, VMKeymapGuestModifier } from const SchemaForm = lazy(() => import('./SchemaForm').then((m) => ({ default: m.SchemaForm }))) -// VM settings (docs/design-guidelines.md §2–3): edits are staged here and written in +// VM settings (see docs/design-guidelines.md): edits are staged here and written in // one `reims-ctl set` on Save, because upstream applies every change on the // next start. Each row marks itself when it differs from the VM's current // value and can be put back on its own. diff --git a/frontend/src/components/VMPage.tsx b/frontend/src/components/VMPage.tsx index 9065fb4..6b6b2f4 100644 --- a/frontend/src/components/VMPage.tsx +++ b/frontend/src/components/VMPage.tsx @@ -103,7 +103,7 @@ interface Props { canSuspend: boolean /** Whether the native VM-window installation guide is currently active for this boot. */ guideActive: boolean - /** Whether the builtin.install-guide plugin is enabled. */ + /** Whether the VM-window install guide setting on builtin.guest.macos is enabled. */ installGuideEnabled: boolean detail: VMDetail | null host: HostReport @@ -366,7 +366,7 @@ export const VMPage: React.FC = ({ } } - // One primary action per state (docs/design-guidelines.md §4): Start while + // One primary action per state (see docs/design-guidelines.md): Start while // stopped, Resume while suspended, Show Window while running. Ctrl+Enter triggers it (App.tsx). let primary: React.ReactNode = null let secondary: React.ReactNode = null @@ -424,7 +424,7 @@ export const VMPage: React.FC = ({ primary = } - // "More" menu, grouped by purpose; destructive items last (docs/design-guidelines.md §5.2). + // "More" menu, grouped by purpose with destructive items last (see docs/design-guidelines.md). const menu = ( = ({ ) - // Summary: each fact once, in the user's words (docs/design-guidelines.md §5.2). - // Row 1 carries live usage bars; raw upstream values stay in "Technical details". + // Summary presents each fact once in user-facing words; raw upstream values stay in "Technical details". const specs: Spec[] = [] if (detail) { const live = running && !!stats diff --git a/frontend/src/lib/bridgeContract.ts b/frontend/src/lib/bridgeContract.ts index f631b1b..57a8360 100644 --- a/frontend/src/lib/bridgeContract.ts +++ b/frontend/src/lib/bridgeContract.ts @@ -1,4 +1,4 @@ -// Plugin UI bridge contract, bridgeApi 1.0 (docs/plugin-architecture.md §5.6, §6.3). +// Plugin UI bridge contract, bridgeApi 1.0 (see docs/plugin-architecture.md). // // Sandboxed plugin views and panels talk to the host only through these // postMessage envelopes. Stable methods and events are implemented and covered diff --git a/frontend/src/lib/format.ts b/frontend/src/lib/format.ts index cccccb8..3b468d7 100644 --- a/frontend/src/lib/format.ts +++ b/frontend/src/lib/format.ts @@ -7,7 +7,7 @@ function currentDocLocale(): string { return document.documentElement.dataset.locale || document.documentElement.lang || 'en-US' } -// Human-readable values for the main view (docs/design-guidelines.md §7.1). +// Human-readable values for the main view (see docs/design-guidelines.md). // Raw values stay available under "Technical details". const MEMORY_CHOICES = [4, 6, 8, 12, 16, 24, 32, 48, 64] diff --git a/frontend/src/lib/themeEngine.ts b/frontend/src/lib/themeEngine.ts index 9879bdd..15adb4a 100644 --- a/frontend/src/lib/themeEngine.ts +++ b/frontend/src/lib/themeEngine.ts @@ -1,10 +1,5 @@ -// Three-tier Theme Engine (docs/plugin-architecture.md §5.1): -// - Builtin theme: zero extra CSS injected, zero UI SDK loaded (§8.1). -// - Tier 1 (Token theme): seed colors + declarative lightness/chroma/alpha derivation, -// bundled fonts, brand mark, background, and event sounds. -// - Tier 2 (Style theme): sanitized stylesheet wrapped in `@layer theme` + -// declarative state-driven slot decorations. -// - Tier 3 (Interactive theme): lazy-loads `./uiSdk` only when a trusted `ui_script_url` is active. +// Theme engine applying token, stylesheet, and interactive theme packs (see docs/plugin-architecture.md). +// Builtin default theme injects zero extra CSS and never loads the interactive UI SDK. import { UI_CONTRACT_LAYOUT_OPTIONS, UI_CONTRACT_TOKENS, type UIContractSDKEvent } from '../styles/ui-contract' import type { ActiveThemePayload, ThemeDecoration, ThemeDecorationState, TokenDeriveRule } from '../types' @@ -90,7 +85,7 @@ function decodeCSSEscapes(s: string): string { return out } -/** Validates a token key+value against the UI Contract whitelist and CSS injection rules (B5). */ +/** Validates a token key+value against the UI Contract whitelist and CSS injection rules. */ export function sanitizeTokenValue(key: string, value: string): string | null { if (!ALLOWED_CONTRACT_TOKENS.has(key)) return null if (typeof value !== 'string') return null @@ -147,7 +142,7 @@ export function applyThemeLayout(layout: Record | null | undefi } } -/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme` (B5). */ +/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme`. */ export function isBalancedThemeCSS(css: string): boolean { if (css.toLowerCase().includes('): string { /** * Applies cached theme tokens via a `@layer theme` `