From 9c8a75448d45a887a49db02bdcf334b8d3db74d0 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: Sun, 29 Nov 2026 03:00:26 -0700 Subject: [PATCH] feat(ui,runtime): split Engine/Settings tabs, add footer telemetry, and fix GitCode alpha detection --- frontend/src/App.tsx | 59 ++++-- frontend/src/components/AppSettingsPage.tsx | 191 ++++++++++++++++++++ frontend/src/components/HostView.tsx | 129 +------------ frontend/src/components/LogPanel.tsx | 65 ++++++- frontend/src/components/Sidebar.tsx | 13 +- frontend/src/i18n.ts | 38 +++- frontend/src/styles/app.css | 40 +++- internal/runtime/remote.go | 19 +- internal/runtime/remote_test.go | 23 ++- 9 files changed, 399 insertions(+), 178 deletions(-) create mode 100644 frontend/src/components/AppSettingsPage.tsx diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 1aa6b86..ba0a177 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,10 +6,11 @@ import { CloneDialog } from './components/CloneDialog' import { OnlineRecoveryDialog } from './components/OnlineRecoveryDialog' import { SendTextDialog } from './components/SendTextDialog' import { HostView } from './components/HostView' +import { AppSettingsPage, ThemeMode } from './components/AppSettingsPage' import { LogPanel, LogTab } from './components/LogPanel' import { SettingsModal } from './components/SettingsModal' import { Setup } from './components/Setup' -import { HOST_ID, INSTALLERS_ID, Sidebar } from './components/Sidebar' +import { HOST_ID, INSTALLERS_ID, SETTINGS_ID, Sidebar } from './components/Sidebar' import { InstallersPage } from './components/InstallersPage' import { VMAction, VMPage } from './components/VMPage' import { I18nKey, t } from './i18n' @@ -59,38 +60,40 @@ export const App: React.FC = () => { const [sendTextTarget, setSendTextTarget] = useState(null) const [busy, setBusy] = useState>({}) const [loadError, setLoadError] = useState('') - const [theme, setTheme] = useState<'light' | 'dark'>(() => { + const [themeMode, setThemeModeState] = useState(() => { try { const saved = localStorage.getItem('reims-go-theme') if (saved === 'dark' || saved === 'light') return saved } catch {} - return typeof window !== 'undefined' && window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light' + return 'system' }) + const [sysDark, setSysDark] = useState(() => + typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-color-scheme: dark)').matches, + ) + const theme: 'light' | 'dark' = themeMode === 'system' ? (sysDark ? 'dark' : 'light') : themeMode useEffect(() => { document.documentElement.dataset.theme = theme }, [theme]) - // Follow system appearance automatically unless the user has explicitly toggled it. useEffect(() => { const mq = window.matchMedia?.('(prefers-color-scheme: dark)') if (!mq) return - const onChange = (e: MediaQueryListEvent) => { - try { if (localStorage.getItem('reims-go-theme')) return } catch {} - setTheme(e.matches ? 'dark' : 'light') - } + const onChange = (e: MediaQueryListEvent) => setSysDark(e.matches) mq.addEventListener('change', onChange) return () => mq.removeEventListener('change', onChange) }, []) - const toggleTheme = () => { - setTheme((cur) => { - const next = cur === 'light' ? 'dark' : 'light' - try { localStorage.setItem('reims-go-theme', next) } catch {} - return next - }) + const setThemeMode = (mode: ThemeMode) => { + setThemeModeState(mode) + try { + if (mode === 'system') localStorage.removeItem('reims-go-theme') + else localStorage.setItem('reims-go-theme', mode) + } catch {} } + const toggleTheme = () => setThemeMode(theme === 'light' ? 'dark' : 'light') + const [logsOpen, setLogsOpen] = useState(false) const [logTab, setLogTab] = useState('app') const [logLines, setLogLines] = useState([]) @@ -112,7 +115,7 @@ export const App: React.FC = () => { setState(s) setLoadError('') setSelected((cur) => { - if (cur === HOST_ID || cur === INSTALLERS_ID) return cur + if (cur === HOST_ID || cur === INSTALLERS_ID || cur === SETTINGS_ID) return cur if ((s.vms ?? []).some((v) => v.name === cur)) return cur return s.vms && s.vms.length > 0 ? s.vms[0].name : HOST_ID }) @@ -140,11 +143,18 @@ export const App: React.FC = () => { setTaskMap((prev) => (list ?? []).reduce(upsertTask, prev)) }).catch(() => {}) const offTask = events.onTask((task) => onTaskRef.current(task)) - return () => { offState(); offLog(); offTask() } + // Keep host telemetry (memory load, free disk) fresh while the window is visible. + const hostTimer = window.setInterval(() => { + if (!document.hidden) void refresh() + }, 10000) + return () => { offState(); offLog(); offTask(); window.clearInterval(hostTimer) } }, [refresh]) const vms = state?.vms ?? [] - const selectedVM = selected !== HOST_ID ? vms.find((v) => v.name === selected) : undefined + const runningVMCount = vms.filter((v) => (state?.transitions[v.name] ?? v.state) === 'running').length + const selectedVM = selected !== HOST_ID && selected !== INSTALLERS_ID && selected !== SETTINGS_ID + ? vms.find((v) => v.name === selected) + : undefined useEffect(() => { if (!selectedVM) { setDetail(null); setVmStats(null); return } @@ -592,13 +602,22 @@ export const App: React.FC = () => { .catch((e) => fail(tr('failGuestTools'), e)) }} /> + ) : selected === SETTINGS_ID ? ( + ) : ( { task={activeTask} runningTasks={runningTasks} onCancelTask={cancelTask} - statusText={state ? tr(hostReady ? 'statusBarWhpxReady' : 'statusBarNeedsAction') : ''} - statusWarn={!!state && !hostReady} + host={state?.host} + runningVMs={runningVMCount} /> )} diff --git a/frontend/src/components/AppSettingsPage.tsx b/frontend/src/components/AppSettingsPage.tsx new file mode 100644 index 0000000..5619b90 --- /dev/null +++ b/frontend/src/components/AppSettingsPage.tsx @@ -0,0 +1,191 @@ +import { Download } from 'lucide-react' +import React, { useEffect, useState } from 'react' +import { I18nKey, t } from '../i18n' +import { findOptimization, optBadgeClass, optStatusLabel } from '../lib/optimizations' +import { AppState, AppUpdateInfo, Locale } from '../types' +import { Button } from '../ui/controls' +import { Segmented, Switch } from '../ui/settings' +import { api } from '../wails' + +export type ThemeMode = 'light' | 'dark' | 'system' + +interface Props { + state: AppState + locale: Locale + themeMode: ThemeMode + onThemeMode: (mode: ThemeMode) => void + onSetLocale: (l: Locale) => void + onRefresh: () => void + onError: (title: string, e: unknown) => void +} + +export const AppSettingsPage: React.FC = ({ + state, locale, themeMode, onThemeMode, onSetLocale, onRefresh, onError, +}) => { + const tr = (k: I18nKey, v?: Record) => t(locale, k, v) + const { host, config, optimizations } = state + const [appUpdate, setAppUpdate] = useState(null) + const [checkingUpdate, setCheckingUpdate] = useState(false) + const [updateErr, setUpdateErr] = useState('') + + const pcoreOpt = findOptimization(optimizations, 'pcore_pin') + + const runUpdateCheck = async (force: boolean) => { + setCheckingUpdate(true) + setUpdateErr('') + try { + const info = await api.CheckAppUpdate(force) + setAppUpdate(info) + } catch (e) { + setUpdateErr(String(e).replace(/^Error:\s*/, '')) + } finally { + setCheckingUpdate(false) + } + } + + useEffect(() => { + void runUpdateCheck(false) + }, []) + + const guard = (fn: () => Promise) => async () => { + try { + await fn() + onRefresh() + } catch (e) { + onError(tr('failGeneric'), e) + } + } + + const pickDataRoot = guard(async () => { + const dir = await api.PickDirectory(tr('hostDataRoot')) + if (dir) await api.SetDataRoot(dir) + }) + + return ( +
+
+

{tr('sidebarSettings')}

+
+ +
+
{tr('settingsGeneral')}
+
+
+
+
{tr('hostDataRoot')}
+
{config.data_root}
+
+
+
+
+
+
+ {tr('autoPinPCores')} + + {optStatusLabel(locale, pcoreOpt?.status)} + +
+
+ {pcoreOpt?.supported + ? tr('optPCoreSub', { detail: pcoreOpt.detail ?? `${host.p_core_count}P+${host.e_core_count}E` }) + : tr('optPCoreUnavailable')} +
+
+
+ guard(() => api.SetAutoPinPCores(checked))()} + /> +
+
+
+
+
{tr('minimizeToTray')}
+
{tr('minimizeToTraySub')}
+
+
+ guard(() => api.SetMinimizeToTray(checked))()} + /> +
+
+
+
+ +
+
{tr('settingsAppearance')}
+
+
+
{tr('themeLabel')}
+
+ +
+
+
+
{tr('language')}
+
+ +
+
+
+
+ +
+
{tr('settingsAbout')}
+
+
+
+
+ {tr('appVersionTitle')} {state.app_version ?? appUpdate?.current ?? 'v0.2.2'} + {appUpdate && !appUpdate.has_update && ( + {tr('appUpToDate')} + )} +
+ {appUpdate?.has_update ? ( +
{tr('appUpdateAvailable', { v: appUpdate.latest })}
+ ) : updateErr ? ( +
{tr('appUpdateLookupFailed')}
+ ) : null} +
+
+ {appUpdate?.has_update && (appUpdate.page_url || appUpdate.download_url) ? ( + + ) : ( + + )} +
+
+
+
+
+ ) +} diff --git a/frontend/src/components/HostView.tsx b/frontend/src/components/HostView.tsx index fcb2e78..6d61a8f 100644 --- a/frontend/src/components/HostView.tsx +++ b/frontend/src/components/HostView.tsx @@ -1,10 +1,9 @@ -import { Cpu, Download, HardDrive, MemoryStick, RefreshCw, ShieldCheck } from 'lucide-react' -import React, { useEffect, useState } from 'react' +import { Cpu, HardDrive, MemoryStick, RefreshCw, ShieldCheck } from 'lucide-react' +import React, { useState } from 'react' import { I18nKey, t } from '../i18n' import { findOptimization, kernelIrqchipHint, optBadgeClass, optStatusLabel } from '../lib/optimizations' -import { AppState, AppUpdateInfo, Locale, RuntimeSource, Task } from '../types' +import { AppState, Locale, RuntimeSource, Task } from '../types' import { Button, IconButton } from '../ui/controls' -import { Segmented, Switch } from '../ui/settings' import { api } from '../wails' import { RuntimeOnline } from './RuntimeOnline' @@ -13,7 +12,6 @@ interface Props { locale: Locale onRefresh: () => void onError: (title: string, e: unknown) => void - onSetLocale: (l: Locale) => void runtimeTask: Task | null onChannel: (alpha: boolean) => void onSource: (source: RuntimeSource) => void @@ -21,33 +19,12 @@ interface Props { onCancelTask: (id: string) => void } -export const HostView: React.FC = ({ state, locale, onRefresh, onError, onSetLocale, runtimeTask, onChannel, onSource, onInstallRuntime, onCancelTask }) => { +export const HostView: React.FC = ({ state, locale, onRefresh, onError, runtimeTask, onChannel, onSource, onInstallRuntime, onCancelTask }) => { const [importing, setImporting] = useState(false) const [enabling, setEnabling] = useState(false) const [openingSched, setOpeningSched] = useState(false) - const [appUpdate, setAppUpdate] = useState(null) - const [checkingUpdate, setCheckingUpdate] = useState(false) - const [updateErr, setUpdateErr] = useState('') const { host, config, runtimes, optimizations } = state const tr = (k: I18nKey, v?: Record) => t(locale, k, v) - - const runUpdateCheck = async (force: boolean) => { - setCheckingUpdate(true) - setUpdateErr('') - try { - const info = await api.CheckAppUpdate(force) - setAppUpdate(info) - } catch (e) { - setUpdateErr(String(e).replace(/^Error:\s*/, '')) - } finally { - setCheckingUpdate(false) - } - } - - useEffect(() => { - void runUpdateCheck(false) - }, []) - const pcoreOpt = findOptimization(optimizations, 'pcore_pin') const irqOpt = findOptimization(optimizations, 'kernel_irqchip') const rebootOpt = findOptimization(optimizations, 'cold_reboot') const gpuOpt = findOptimization(optimizations, 'discrete_gpu') @@ -82,11 +59,6 @@ export const HostView: React.FC = ({ state, locale, onRefresh, onError, o setOpeningSched(false) } - const pickDataRoot = guard(async () => { - const dir = await api.PickDirectory(tr('hostDataRoot')) - if (dir) await api.SetDataRoot(dir) - }) - const importRuntime = async () => { setImporting(true) await guard(async () => { @@ -183,99 +155,6 @@ export const HostView: React.FC = ({ state, locale, onRefresh, onError, o -
-
{tr('settings')}
-
-
-
-
{tr('hostDataRoot')}
-
{config.data_root}
-
-
-
-
-
-
- {tr('autoPinPCores')} - - {optStatusLabel(locale, pcoreOpt?.status)} - -
-
- {pcoreOpt?.supported - ? tr('optPCoreSub', { detail: pcoreOpt.detail ?? `${host.p_core_count}P+${host.e_core_count}E` }) - : tr('optPCoreUnavailable')} -
-
-
- guard(() => api.SetAutoPinPCores(checked))()} - /> -
-
-
-
-
{tr('minimizeToTray')}
-
{tr('minimizeToTraySub')}
-
-
- guard(() => api.SetMinimizeToTray(checked))()} - /> -
-
-
-
{tr('language')}
-
- -
-
-
-
-
- {tr('appVersionTitle')} {state.app_version ?? appUpdate?.current ?? 'v0.2.2'} - {appUpdate && !appUpdate.has_update && ( - {tr('appUpToDate')} - )} -
- {appUpdate?.has_update ? ( -
{tr('appUpdateAvailable', { v: appUpdate.latest })}
- ) : updateErr ? ( -
{tr('appUpdateLookupFailed')}
- ) : null} -
-
- {appUpdate?.has_update && (appUpdate.page_url || appUpdate.download_url) ? ( - - ) : ( - - )} -
-
-
-
-
{tr('hostOptimizations')}
diff --git a/frontend/src/components/LogPanel.tsx b/frontend/src/components/LogPanel.tsx index f31a3e3..3eb9196 100644 --- a/frontend/src/components/LogPanel.tsx +++ b/frontend/src/components/LogPanel.tsx @@ -1,9 +1,9 @@ -import { ArrowDown, ChevronDown, ChevronUp, Eraser, LoaderCircle, Pause, RefreshCw } from 'lucide-react' +import { ArrowDown, ChevronDown, ChevronUp, Eraser, HardDrive, LoaderCircle, MemoryStick, Pause, RefreshCw } from 'lucide-react' import React, { useLayoutEffect, useRef, useState } from 'react' import { t } from '../i18n' import { LogLine } from '../lib/logs' import { taskDetail, taskTitle } from '../lib/tasks' -import { Locale, Task } from '../types' +import { HostReport, Locale, Task } from '../types' import { Button, IconButton, Tip } from '../ui/controls' export type LogTab = 'app' | 'serial' | 'qemu' @@ -25,8 +25,8 @@ interface Props { task: Task | null runningTasks: number onCancelTask: (id: string) => void - statusText?: string - statusWarn?: boolean + host?: HostReport + runningVMs?: number } /** Sticks to the bottom until the user scrolls up; offers "jump to latest" then. */ @@ -59,12 +59,23 @@ const MAX_LOG_HEIGHT = 520 export const LogPanel: React.FC = ({ locale, open, onToggle, tab, onTab, lines, unseenErrors, onClear, serialText, qemuText, showSerial, onRefreshSerial, onRefreshQemu, - task, runningTasks, onCancelTask, statusText, statusWarn, + task, runningTasks, onCancelTask, host, runningVMs = 0, }) => { - const tr = (k: Parameters[1]) => t(locale, k) + const tr = (k: Parameters[1], v?: Record) => t(locale, k, v) const content = tab === 'app' ? lines : tab === 'serial' ? serialText : qemuText const { ref, stuck, onScroll, jump } = useStickToBottom(content, open) + const memPct = host + ? Math.max(0, Math.min(100, host.memory_load_pct > 0 + ? host.memory_load_pct + : host.total_ram_gb > 0 + ? Math.round(((host.total_ram_gb - host.avail_ram_gb) / host.total_ram_gb) * 100) + : 0)) + : 0 + const usedMemGB = host && host.total_ram_gb > 0 ? Math.max(0, host.total_ram_gb - host.avail_ram_gb) : 0 + const memTone = memPct >= 90 ? ' high' : memPct >= 80 ? ' warn' : '' + const lowDisk = !!host && host.free_disk_gb > 0 && host.free_disk_gb < 30 + const [height, setHeight] = useState(() => { try { const saved = Number(localStorage.getItem(LOG_HEIGHT_KEY)) @@ -138,8 +149,46 @@ export const LogPanel: React.FC = ({ } onClick={() => onCancelTask(task.id)} /> )} - ) : statusText ? ( - {statusText} + ) : host ? ( +
+ {host.total_ram_gb > 0 && ( + + + + )} + {host.free_disk_gb > 0 && ( + <> + + + + + )} + {runningVMs > 0 && ( + <> + + + + + )} +
) : null} {open && ( diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index 6b33a15..a460212 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -1,4 +1,4 @@ -import { Cpu, Download, Monitor, Plus } from 'lucide-react' +import { Cpu, Download, Monitor, Plus, Settings } from 'lucide-react' import React, { useRef } from 'react' import { I18nKey, t } from '../i18n' import { Locale, VMListItem } from '../types' @@ -6,6 +6,7 @@ import { IconButton, StatusShape, Tip, statusKind } from '../ui/controls' export const HOST_ID = '__host__' export const INSTALLERS_ID = '__installers__' +export const SETTINGS_ID = '__settings__' interface Props { locale: Locale @@ -21,7 +22,7 @@ interface Props { export const Sidebar: React.FC = ({ locale, vms, transitions, selected, hostReady, onSelect, onNew, downloading }) => { const listRef = useRef(null) - const ids = [...vms.map((v) => v.name), INSTALLERS_ID, HOST_ID] + const ids = [...vms.map((v) => v.name), INSTALLERS_ID, HOST_ID, SETTINGS_ID] // Listbox keyboard model: ↑/↓/Home/End move selection and focus together. const onKeyDown = (e: React.KeyboardEvent) => { @@ -97,6 +98,14 @@ export const Sidebar: React.FC = ({ locale, vms, transitions, selected, h t(locale, hostReady ? 'hostReady' : 'hostNeedsAction'), hostReady ? 'running' : 'warn', )} + {item( + SETTINGS_ID, + t(locale, 'sidebarSettings'), + , + 'nav-icon-settings', + '', + null, + )}
diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index e504b34..757bd2d 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -7,7 +7,8 @@ const dict = { // Shell sidebarVMs: '虚拟机', sidebarSystem: '系统', - sidebarHost: '宿主与运行时', + sidebarHost: '内核', + sidebarSettings: '设置', sidebarInstallers: '安装包', installersTitle: '安装包', installersDownloaded: '已下载', @@ -34,8 +35,18 @@ const dict = { copyTechInfo: '复制技术信息', resizeLogPanel: '拖动调整日志高度', logButton: '日志', - statusBarWhpxReady: 'WHPX 硬件加速 · 就绪', - statusBarNeedsAction: '宿主环境需要处理', + footerMem: '内存 {pct}%', + footerMemAvail: '可用 {avail} GB', + footerMemTip: '系统内存:已用 {used} GB / 共 {total} GB(可用 {avail} GB)', + footerDisk: '磁盘可用 {gb} GB', + footerRunningVMs: '{n} 台运行中', + settingsGeneral: '常规', + settingsAppearance: '外观与语言', + settingsAbout: '关于', + themeLabel: '外观', + themeLight: '浅色', + themeDark: '深色', + themeSystem: '跟随系统', // Actions newVM: '新建虚拟机', @@ -246,7 +257,7 @@ const dict = { onlineRecoveryTitle: '拉取在线恢复镜像?', onlineRecoveryDesc: '本地没有恢复镜像。要从 Apple 下载约 1 GB 的恢复镜像并挂载到「{name}」吗?', onlineRecoveryConfirm: '拉取并挂载(约 1 GB)', - noRuntimeAlert: '先在「宿主与运行时」导入运行时包', + noRuntimeAlert: '先在「内核」导入运行时包', // Host hostRuntime: '运行时', @@ -542,7 +553,8 @@ const dict = { 'en-US': { sidebarVMs: 'Virtual machines', sidebarSystem: 'System', - sidebarHost: 'Host & runtime', + sidebarHost: 'Engine', + sidebarSettings: 'Settings', sidebarInstallers: 'Installers', installersTitle: 'Installers', installersDownloaded: 'Downloaded', @@ -569,8 +581,18 @@ const dict = { copyTechInfo: 'Copy technical details', resizeLogPanel: 'Drag to resize log panel', logButton: 'Logs', - statusBarWhpxReady: 'WHPX acceleration · Ready', - statusBarNeedsAction: 'Host needs attention', + footerMem: 'Memory {pct}%', + footerMemAvail: '{avail} GB free', + footerMemTip: 'System memory: {used} GB used / {total} GB total ({avail} GB free)', + footerDisk: 'Disk {gb} GB free', + footerRunningVMs: '{n} running', + settingsGeneral: 'General', + settingsAppearance: 'Appearance & language', + settingsAbout: 'About', + themeLabel: 'Appearance', + themeLight: 'Light', + themeDark: 'Dark', + themeSystem: 'System', newVM: 'New virtual machine', start: 'Start', @@ -773,7 +795,7 @@ const dict = { onlineRecoveryTitle: 'Download online recovery image?', onlineRecoveryDesc: 'No recovery image is on this PC. Download Apple’s recovery image (about 1 GB) and attach it to “{name}”?', onlineRecoveryConfirm: 'Download & attach (~1 GB)', - noRuntimeAlert: 'Import a runtime under Host & runtime first', + noRuntimeAlert: 'Import a runtime under Engine first', hostRuntime: 'Runtime', hostGPUs: 'Graphics cards', diff --git a/frontend/src/styles/app.css b/frontend/src/styles/app.css index 990bf71..9fe1310 100644 --- a/frontend/src/styles/app.css +++ b/frontend/src/styles/app.css @@ -164,7 +164,8 @@ h1, h2, h3, p { margin: 0; } box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.22); } .nav-icon-vm { background: linear-gradient(145deg, #32a0ff 0%, #007aff 100%); } -.nav-icon-host { background: linear-gradient(145deg, #8e8e93 0%, #636366 100%); } +.nav-icon-host { background: linear-gradient(145deg, #6e7cf0 0%, #4d5be0 100%); } +.nav-icon-settings { background: linear-gradient(145deg, #8e8e93 0%, #636366 100%); } .nav-icon-installers { background: linear-gradient(145deg, #34c759 0%, #248a3d 100%); } .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-13); } @@ -491,8 +492,11 @@ h1, h2, h3, p { margin: 0; } .badge-warn { background: var(--warn-soft); color: var(--warn-text); } .badge-error { background: var(--danger); color: #fff; min-width: 18px; height: 18px; padding: 0 var(--sp-1); justify-content: center; border-radius: 999px; font-variant-numeric: tabular-nums; } -/* Host summary tiles (responsive, uniform hierarchy) */ -.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; } +/* Host summary tiles (4-up single row, 2x2 on narrow windows) */ +.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; } +@media (max-width: 820px) { + .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } +} .tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 13px 14px; display: flex; flex-direction: column; gap: 6px; min-width: 0; @@ -589,11 +593,33 @@ h1, h2, h3, p { margin: 0; } width: 48px; background: var(--border-strong); } .logbar { height: var(--logbar-h); display: flex; align-items: center; gap: var(--sp-2); padding: 0 var(--sp-3) 0 var(--sp-4); } -.status-ambient { - display: inline-flex; align-items: center; gap: 6px; - font-size: var(--fs-12); color: var(--text-3); user-select: none; +.status-telemetry { + display: inline-flex; align-items: center; gap: 8px; min-width: 0; + font-size: var(--fs-12); color: var(--text-2); user-select: none; + font-variant-numeric: tabular-nums; } -.status-ambient.warn { color: var(--warn-text); } +.status-metric { + display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; +} +.status-metric > svg { color: var(--text-3); flex-shrink: 0; } +.status-metric.warn { color: var(--warn-text); } +.status-metric.warn > svg { color: var(--warn-text); } +.status-metric.high { color: var(--danger-text); } +.status-metric.high > svg { color: var(--danger-text); } +.status-metric.ok { color: var(--ok-text); } +.status-metric-dim { color: var(--text-3); } +.status-sep { color: var(--border-strong); flex-shrink: 0; } +.status-mini-bar { + display: inline-block; width: 34px; height: 4px; border-radius: 999px; + background: var(--surface-active); overflow: hidden; flex-shrink: 0; +} +.status-mini-fill { + display: block; width: 100%; height: 100%; border-radius: 999px; + background: var(--accent); transform-origin: left center; + transition: transform 260ms var(--ease-out), background var(--dur) var(--ease-out); +} +.status-mini-fill.warn { background: var(--status-busy); } +.status-mini-fill.high { background: var(--status-error); } .log-toggle-btn { height: 24px; padding: 0 8px; display: inline-flex; align-items: center; gap: 4px; diff --git a/internal/runtime/remote.go b/internal/runtime/remote.go index af3f791..b4616e6 100644 --- a/internal/runtime/remote.go +++ b/internal/runtime/remote.go @@ -177,6 +177,7 @@ type Remote struct { type ghRelease struct { TagName string `json:"tag_name"` + Name string `json:"name"` Draft bool `json:"draft"` Prerelease bool `json:"prerelease"` PublishedAt string `json:"published_at"` @@ -185,6 +186,18 @@ type ghRelease struct { Assets []ghAsset `json:"assets"` } +// isAlphaRelease treats either an explicit prerelease flag or an "(alpha)" / +// "(candidate)" marker in the release title as alpha. GitCode API v5 currently +// returns prerelease=false even when created with prerelease=true, while +// preserving the mirrored GitHub release title. +func isAlphaRelease(prerelease bool, name string) bool { + if prerelease { + return true + } + lower := strings.ToLower(name) + return strings.Contains(lower, "(alpha)") || strings.Contains(lower, "(candidate)") +} + type ghAsset struct { Name string `json:"name"` Size int64 `json:"size"` @@ -310,7 +323,7 @@ func (s Source) listRemoteSingle(ctx context.Context, includeAlpha bool) ([]Remo PageURL: pageURL, Channel: ChannelStable, } - if r.Prerelease { + if isAlphaRelease(r.Prerelease, r.Name) { rem.Channel = ChannelAlpha } for _, a := range r.Assets { @@ -428,10 +441,10 @@ func (s Source) listRemoteWeb(ctx context.Context, includeAlpha bool) ([]Remote, tagURL := fmt.Sprintf("%s/%s/releases/tag/%s", web, s.Repo, tag) channel := ChannelStable if tagHTML, err := s.fetchText(ctx, tagURL, "text/html"); err == nil { - if rePrereleaseBadge.MatchString(tagHTML) { + if isAlphaRelease(rePrereleaseBadge.MatchString(tagHTML), e.Title) { channel = ChannelAlpha } - } else if strings.Contains(strings.ToLower(e.Title), "(alpha)") { + } else if isAlphaRelease(false, e.Title) { channel = ChannelAlpha } if channel == ChannelAlpha && !includeAlpha { diff --git a/internal/runtime/remote_test.go b/internal/runtime/remote_test.go index 8d24717..4154d8e 100644 --- a/internal/runtime/remote_test.go +++ b/internal/runtime/remote_test.go @@ -309,14 +309,20 @@ func TestListRemoteAutoFallsBackToGitCode(t *testing.T) { http.NotFound(w, r) return } - // Matches real GitCode API v5 shape: created_at (+08:00), no published_at or html_url. + // Matches real GitCode API v5 shape: created_at (+08:00), no published_at or html_url, + // and prerelease=false even on mirrored alpha prereleases whose title carries "(alpha)". fmt.Fprintf(w, `[ - {"tag_name":"runtime-3731afd","prerelease":false,"created_at":"2026-11-28T19:03:04+08:00","assets":[ + {"tag_name":"runtime-3731afd-p2","name":"Portable Runtime runtime-3731afd-p2 (alpha)","prerelease":false,"created_at":"2026-11-29T17:39:03+08:00","assets":[ + {"name":"reims-runtime-win-x64-3731afd-p2.tar.zst","size":169000000,"browser_download_url":"%s/dl/rt-p2"}, + {"name":"reims-runtime-src-3731afd-p2.tar.zst","size":500,"browser_download_url":"%s/dl/src-p2"}, + {"name":"SHA256SUMS.txt","size":100,"browser_download_url":"%s/dl/sums-p2"} + ]}, + {"tag_name":"runtime-3731afd","name":"Runtime 3731afd","prerelease":false,"created_at":"2026-11-28T19:03:04+08:00","assets":[ {"name":"reims-runtime-win-x64-3731afd.tar.zst","size":168000000,"browser_download_url":"%s/dl/rt"}, {"name":"reims-runtime-src-3731afd.tar.zst","size":500,"browser_download_url":"%s/dl/src"}, {"name":"SHA256SUMS.txt","size":100,"browser_download_url":"%s/dl/sums"} ]} -]`, gcSrv.URL, gcSrv.URL, gcSrv.URL) +]`, gcSrv.URL, gcSrv.URL, gcSrv.URL, gcSrv.URL, gcSrv.URL, gcSrv.URL) })) defer gcSrv.Close() @@ -337,7 +343,14 @@ func TestListRemoteAutoFallsBackToGitCode(t *testing.T) { if err != nil { t.Fatal(err) } - if len(list) != 1 || list[0].Commit != "3731afd" || list[0].Source != SourceGitCode || list[0].PageURL != "https://gitcode.com/o/r/releases/tag/runtime-3731afd" { - t.Fatalf("gitcode fallback = %+v", list) + if len(list) != 1 || list[0].Commit != "3731afd" || list[0].Channel != ChannelStable || list[0].Source != SourceGitCode || list[0].PageURL != "https://gitcode.com/o/r/releases/tag/runtime-3731afd" { + t.Fatalf("gitcode fallback stable = %+v", list) + } + all, err := src.ListRemote(context.Background(), true) + if err != nil { + t.Fatal(err) + } + if len(all) != 2 || all[0].Commit != "3731afd-p2" || all[0].Channel != ChannelAlpha { + t.Fatalf("gitcode fallback with alpha = %+v", all) } }