feat(ui,runtime): split Engine/Settings tabs, add footer telemetry, and fix GitCode alpha detection

This commit is contained in:
Nwflower committed 2026-11-29 03:00:26 -07:00
1 parent 3b26f6117f
commit 9c8a75448d
9 files changed
+399 -178

No files matched your search

+39 -20
View File
@@ -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<string | null>(null)
const [busy, setBusy] = useState<Record<string, VMAction>>({})
const [loadError, setLoadError] = useState('')
const [theme, setTheme] = useState<'light' | 'dark'>(() => {
const [themeMode, setThemeModeState] = useState<ThemeMode>(() => {
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<boolean>(() =>
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<LogTab>('app')
const [logLines, setLogLines] = useState<LogLine[]>([])
@@ -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 ? (
<AppSettingsPage
state={state}
locale={locale}
themeMode={themeMode}
onThemeMode={setThemeMode}
onSetLocale={setLang}
onRefresh={refresh}
onError={fail}
/>
) : (
<HostView
state={state}
locale={locale}
onRefresh={refresh}
onError={fail}
onSetLocale={setLang}
runtimeTask={runtimeTask}
onChannel={setChannel}
onSource={setSource}
@@ -629,8 +648,8 @@ export const App: React.FC = () => {
task={activeTask}
runningTasks={runningTasks}
onCancelTask={cancelTask}
statusText={state ? tr(hostReady ? 'statusBarWhpxReady' : 'statusBarNeedsAction') : ''}
statusWarn={!!state && !hostReady}
host={state?.host}
runningVMs={runningVMCount}
/>
)}
+191
View File
@@ -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<Props> = ({
state, locale, themeMode, onThemeMode, onSetLocale, onRefresh, onError,
}) => {
const tr = (k: I18nKey, v?: Record<string, string | number>) => t(locale, k, v)
const { host, config, optimizations } = state
const [appUpdate, setAppUpdate] = useState<AppUpdateInfo | null>(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<unknown>) => 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 (
<div className="page">
<header className="page-head">
<div className="page-title"><h1>{tr('sidebarSettings')}</h1></div>
</header>
<section className="section">
<div className="section-title">{tr('settingsGeneral')}</div>
<div className="list">
<div className="row">
<div className="row-main">
<div className="row-title">{tr('hostDataRoot')}</div>
<div className="row-sub mono">{config.data_root}</div>
</div>
<div className="row-right"><Button onClick={pickDataRoot}>{tr('choose')}</Button></div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">
{tr('autoPinPCores')}
<span className={`badge ${optBadgeClass(pcoreOpt?.status)}`}>
{optStatusLabel(locale, pcoreOpt?.status)}
</span>
</div>
<div className="row-sub">
{pcoreOpt?.supported
? tr('optPCoreSub', { detail: pcoreOpt.detail ?? `${host.p_core_count}P+${host.e_core_count}E` })
: tr('optPCoreUnavailable')}
</div>
</div>
<div className="row-right">
<Switch
label={tr('autoPinPCores')}
disabled={!pcoreOpt?.supported}
checked={!!pcoreOpt?.supported && config.auto_pin_pcores}
onChange={(checked) => guard(() => api.SetAutoPinPCores(checked))()}
/>
</div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">{tr('minimizeToTray')}</div>
<div className="row-sub">{tr('minimizeToTraySub')}</div>
</div>
<div className="row-right">
<Switch
label={tr('minimizeToTray')}
checked={config.minimize_to_tray !== false}
onChange={(checked) => guard(() => api.SetMinimizeToTray(checked))()}
/>
</div>
</div>
</div>
</section>
<section className="section">
<div className="section-title">{tr('settingsAppearance')}</div>
<div className="list">
<div className="row">
<div className="row-main"><div className="row-title">{tr('themeLabel')}</div></div>
<div className="row-right">
<Segmented
label={tr('themeLabel')}
value={themeMode}
onChange={onThemeMode}
options={[
{ value: 'light', label: tr('themeLight') },
{ value: 'dark', label: tr('themeDark') },
{ value: 'system', label: tr('themeSystem') },
]}
/>
</div>
</div>
<div className="row">
<div className="row-main"><div className="row-title">{tr('language')}</div></div>
<div className="row-right">
<Segmented
label={tr('language')}
value={locale}
onChange={onSetLocale}
options={[
{ value: 'zh-CN', label: '中文' },
{ value: 'en-US', label: 'English' },
]}
/>
</div>
</div>
</div>
</section>
<section className="section">
<div className="section-title">{tr('settingsAbout')}</div>
<div className="list">
<div className="row">
<div className="row-main">
<div className="row-title">
{tr('appVersionTitle')} <span className="mono">{state.app_version ?? appUpdate?.current ?? 'v0.2.2'}</span>
{appUpdate && !appUpdate.has_update && (
<span className="badge badge-ok">{tr('appUpToDate')}</span>
)}
</div>
{appUpdate?.has_update ? (
<div className="row-sub">{tr('appUpdateAvailable', { v: appUpdate.latest })}</div>
) : updateErr ? (
<div className="row-sub" title={updateErr}>{tr('appUpdateLookupFailed')}</div>
) : null}
</div>
<div className="row-right">
{appUpdate?.has_update && (appUpdate.page_url || appUpdate.download_url) ? (
<Button
variant="primary"
icon={<Download size={14} aria-hidden="true" />}
onClick={() => guard(() => api.OpenURL(appUpdate.page_url || appUpdate.download_url || ''))()}
>
{tr('appDownloadUpdate')}
</Button>
) : (
<Button busy={checkingUpdate} onClick={() => void runUpdateCheck(true)}>
{tr('appCheckUpdate')}
</Button>
)}
</div>
</div>
</div>
</section>
</div>
)
}
+4 -125
View File
@@ -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<Props> = ({ state, locale, onRefresh, onError, onSetLocale, runtimeTask, onChannel, onSource, onInstallRuntime, onCancelTask }) => {
export const HostView: React.FC<Props> = ({ 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<AppUpdateInfo | null>(null)
const [checkingUpdate, setCheckingUpdate] = useState(false)
const [updateErr, setUpdateErr] = useState('')
const { host, config, runtimes, optimizations } = state
const tr = (k: I18nKey, v?: Record<string, string | number>) => 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<Props> = ({ 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<Props> = ({ state, locale, onRefresh, onError, o
</div>
</section>
<section className="section">
<div className="section-title">{tr('settings')}</div>
<div className="list">
<div className="row">
<div className="row-main">
<div className="row-title">{tr('hostDataRoot')}</div>
<div className="row-sub mono">{config.data_root}</div>
</div>
<div className="row-right"><Button onClick={pickDataRoot}>{tr('choose')}</Button></div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">
{tr('autoPinPCores')}
<span className={`badge ${optBadgeClass(pcoreOpt?.status)}`}>
{optStatusLabel(locale, pcoreOpt?.status)}
</span>
</div>
<div className="row-sub">
{pcoreOpt?.supported
? tr('optPCoreSub', { detail: pcoreOpt.detail ?? `${host.p_core_count}P+${host.e_core_count}E` })
: tr('optPCoreUnavailable')}
</div>
</div>
<div className="row-right">
<Switch
label={tr('autoPinPCores')}
disabled={!pcoreOpt?.supported}
checked={!!pcoreOpt?.supported && config.auto_pin_pcores}
onChange={(checked) => guard(() => api.SetAutoPinPCores(checked))()}
/>
</div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">{tr('minimizeToTray')}</div>
<div className="row-sub">{tr('minimizeToTraySub')}</div>
</div>
<div className="row-right">
<Switch
label={tr('minimizeToTray')}
checked={config.minimize_to_tray !== false}
onChange={(checked) => guard(() => api.SetMinimizeToTray(checked))()}
/>
</div>
</div>
<div className="row">
<div className="row-main"><div className="row-title">{tr('language')}</div></div>
<div className="row-right">
<Segmented
label={tr('language')}
value={locale}
onChange={onSetLocale}
options={[
{ value: 'zh-CN', label: '中文' },
{ value: 'en-US', label: 'English' },
]}
/>
</div>
</div>
<div className="row">
<div className="row-main">
<div className="row-title">
{tr('appVersionTitle')} <span className="mono">{state.app_version ?? appUpdate?.current ?? 'v0.2.2'}</span>
{appUpdate && !appUpdate.has_update && (
<span className="badge badge-ok">{tr('appUpToDate')}</span>
)}
</div>
{appUpdate?.has_update ? (
<div className="row-sub">{tr('appUpdateAvailable', { v: appUpdate.latest })}</div>
) : updateErr ? (
<div className="row-sub" title={updateErr}>{tr('appUpdateLookupFailed')}</div>
) : null}
</div>
<div className="row-right">
{appUpdate?.has_update && (appUpdate.page_url || appUpdate.download_url) ? (
<Button
variant="primary"
icon={<Download size={14} />}
onClick={() => guard(() => api.OpenURL(appUpdate.page_url || appUpdate.download_url || ''))()}
>
{tr('appDownloadUpdate')}
</Button>
) : (
<Button busy={checkingUpdate} onClick={() => void runUpdateCheck(true)}>
{tr('appCheckUpdate')}
</Button>
)}
</div>
</div>
</div>
</section>
<section className="section">
<div className="section-title">{tr('hostOptimizations')}</div>
<div className="list">
+57 -8
View File
@@ -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<Props> = ({
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<typeof t>[1]) => t(locale, k)
const tr = (k: Parameters<typeof t>[1], v?: Record<string, string | number>) => 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<number>(() => {
try {
const saved = Number(localStorage.getItem(LOG_HEIGHT_KEY))
@@ -138,8 +149,46 @@ export const LogPanel: React.FC<Props> = ({
<IconButton small tipSide="top" label={tr('pauseDownload')} icon={<Pause size={14} />} onClick={() => onCancelTask(task.id)} />
)}
</>
) : statusText ? (
<span className={`status-ambient${statusWarn ? ' warn' : ''}`}>{statusText}</span>
) : host ? (
<div className="status-telemetry">
{host.total_ram_gb > 0 && (
<Tip
side="top"
label={tr('footerMemTip', {
used: usedMemGB.toFixed(1),
total: host.total_ram_gb.toFixed(1),
avail: host.avail_ram_gb.toFixed(1),
})}
>
<span className={`status-metric${memTone}`} tabIndex={0}>
<MemoryStick size={12} aria-hidden="true" />
<span>{tr('footerMem', { pct: memPct })}</span>
<span className="status-mini-bar" aria-hidden="true">
<span className={`status-mini-fill${memTone}`} style={{ transform: `scaleX(${memPct / 100})` }} />
</span>
<span className="status-metric-dim">({tr('footerMemAvail', { avail: host.avail_ram_gb.toFixed(1) })})</span>
</span>
</Tip>
)}
{host.free_disk_gb > 0 && (
<>
<span className="status-sep" aria-hidden="true">·</span>
<span className={`status-metric${lowDisk ? ' warn' : ''}`}>
<HardDrive size={12} aria-hidden="true" />
<span>{tr('footerDisk', { gb: host.free_disk_gb.toFixed(0) })}</span>
</span>
</>
)}
{runningVMs > 0 && (
<>
<span className="status-sep" aria-hidden="true">·</span>
<span className="status-metric ok">
<span className="status status-running" aria-hidden="true" />
<span>{tr('footerRunningVMs', { n: runningVMs })}</span>
</span>
</>
)}
</div>
) : null}
<span className="spacer" />
{open && (
+11 -2
View File
@@ -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<Props> = ({ locale, vms, transitions, selected, hostReady, onSelect, onNew, downloading }) => {
const listRef = useRef<HTMLDivElement>(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<Props> = ({ locale, vms, transitions, selected, h
t(locale, hostReady ? 'hostReady' : 'hostNeedsAction'),
hostReady ? 'running' : 'warn',
)}
{item(
SETTINGS_ID,
t(locale, 'sidebarSettings'),
<Settings size={13} />,
'nav-icon-settings',
'',
null,
)}
</div>
</aside>
</div>
+30 -8
View File
@@ -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',
+33 -7
View File
@@ -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;
+16 -3
View File
@@ -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 {
+18 -5
View File
@@ -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)
}
}