fix(ui): refine VM suspend actions and confirmation
This commit is contained in:
1 parent
5f8d96a401
commit
003821a28a
20 files changed
+161
-102
No files matched your search
@@ -20,7 +20,7 @@ Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台
|
||||
| :--- | :--- |
|
||||
| **声明式配置** | 一台虚拟机对应一份声明式配置,界面只编辑配置项,不让用户直接拼 QEMU 命令行参数。 |
|
||||
| **先校验,后保存** | 保存前在 Go 端完成前置校验(CPU 核数、可用提交内存上限、Vulkan ICD 路径存在性、切换磁盘控制器前是否已弹出安装盘),非法值在提交前拦截。 |
|
||||
| **随时可编辑,标明生效时机** | 无论虚拟机运行与否,设置面板均可打开编辑;每项设置明确标注生效时机。运行中保存「下次启动生效」的修改时,详情页汇总待生效项并提供「重启以应用」。 |
|
||||
| **标明设置的生效时机** | 虚拟机运行中或已停止时可编辑设置。每项设置明确标注生效时机。运行中保存「下次启动生效」的修改时,详情页汇总待生效项并提供「重启以应用」。 |
|
||||
|
||||
**写入约束**:凡属于上游 `reims-ctl` 管理的配置项,一律通过 `reims-ctl set` 写入,不直接改写 `vm.toml`,确保上游校验与 OpenCore 重建逻辑照常生效。
|
||||
|
||||
@@ -55,11 +55,14 @@ Reims-Go 的桌面外壳遵循「**macOS 的结构与词表,Windows 的平台
|
||||
| **正在创建** | 创建流程进行中 | 无(展示分步进度) | 取消创建 |
|
||||
| **已停止** | 上游 `stopped` | **启动** | 设置、恢复点、更多(派生副本、扩容/回收、打开目录、删除) |
|
||||
| **正在启动** | 发起 `start` 至 `running` | 启动中(忙碌态,禁用) | 设置、强制关机 |
|
||||
| **运行中** | 上游 `running` | **显示 VM 窗口** | 关机、截屏、设置、更多(重启、强制关机、发送文本、进入/退出恢复模式、导出排障包) |
|
||||
| **运行中** | 上游 `running` | **显示 VM 窗口** | 挂起(需支持此功能的内核)、关机、截屏、设置、更多(重启、强制关机、发送文本、进入/退出恢复模式、导出排障包) |
|
||||
| **正在停止** | 发起 `stop` 至 `stopped` | 停止中(忙碌态,禁用) | 强制关机 |
|
||||
| **正在挂起** | 正在保存运行状态 | 挂起中(忙碌态,禁用) | 强制关机 |
|
||||
| **已挂起** | 运行状态已保存到磁盘 | **恢复**(需支持此功能的内核) | 更多(放弃挂起状态、打开目录) |
|
||||
| **正在恢复** | 正在从磁盘恢复运行状态 | 恢复中(忙碌态,禁用) | 强制关机 |
|
||||
| **配置损坏** | 上游 `broken` | **查看问题** | 打开目录、删除 |
|
||||
|
||||
- 暂不提供暂停或运行中热快照状态(`paused` / `saving` / `restoring`),直到上游验证 `reims-vgpu` 显存与设备状态序列化。
|
||||
- 已挂起时,恢复或放弃挂起状态后才可修改配置、管理磁盘和安装或弹出 Guest Tools。切换到不支持挂起的内核时,禁用恢复并提示用户切换内核。放弃挂起状态须经破坏性操作确认框确认。
|
||||
- 禁用按钮不占据主操作位置;状态变化时直接切换为当前最合适的主操作。
|
||||
|
||||
---
|
||||
|
||||
+15
-26
@@ -20,7 +20,7 @@ import { applyActiveLocaleFonts, applyActiveTheme, disposeActiveThemeAndLocaleFo
|
||||
import { latestVMStats, refreshSubscribedVMStats, refreshVMStats } from './lib/vmStats'
|
||||
import { ActiveThemePayload, AppState, AppUpdateInfo, CachedInstaller, CreateOpts, Locale, PluginUIContributions, Task, VMDetail } from './types'
|
||||
import { Button, Tip, TooltipProvider } from './ui/controls'
|
||||
import { Modal } from './ui/dialog'
|
||||
import { ConfirmDialog, Modal } from './ui/dialog'
|
||||
import { Toaster, useToasts } from './ui/toast'
|
||||
import { api, events, OnFileDrop, OnFileDropOff, WindowMinimise, WindowToggleMaximise } from './wails'
|
||||
|
||||
@@ -335,15 +335,7 @@ export const App: React.FC = () => {
|
||||
const effectiveState = selectedVM ? (state?.transitions[selectedVM.name] ?? selectedVM.state) : ''
|
||||
const pending = selectedVM ? (state?.pending_changes[selectedVM.name] ?? []) : []
|
||||
const hostReady = !!state && state.host.whpx === 'ready' && !!state.active_runtime
|
||||
const activeManifest = state?.active_runtime?.manifest
|
||||
const canSuspend = Boolean(
|
||||
activeManifest?.capabilities?.some((c) => c.toLowerCase() === 'vm-suspend')
|
||||
|| (
|
||||
activeManifest?.patches?.some((p) => p.name.toLowerCase().includes('win32-mapped-ram-io'))
|
||||
&& activeManifest?.patches?.some((p) => p.name.toLowerCase().includes('intel-whpx-suspend'))
|
||||
&& activeManifest?.patches?.some((p) => p.name.toLowerCase().includes('reims-vgpu-snapshot-replay'))
|
||||
),
|
||||
)
|
||||
const canSuspend = state?.can_suspend ?? false
|
||||
|
||||
onTaskRef.current = (task: Task) => {
|
||||
if (task.kind === 'app-update' && task.status === 'failed' && !notifiedTasks.current.has(task.id)) {
|
||||
@@ -669,6 +661,7 @@ export const App: React.FC = () => {
|
||||
}
|
||||
|
||||
const onVMActionFor = (name: string, action: VMAction, isRunning: boolean) => {
|
||||
if (!canSuspend && (action === 'suspend' || action === 'resume')) return
|
||||
const activeBusy = activeVMBusy(name)
|
||||
if (
|
||||
activeBusy
|
||||
@@ -905,7 +898,11 @@ export const App: React.FC = () => {
|
||||
useEffect(() => {
|
||||
const offSelect = events.onTraySelectVM((name) => { setSelected(name) })
|
||||
const offNew = events.onTrayNewVM(() => { openWizardRef.current() })
|
||||
return () => { offSelect(); offNew() }
|
||||
const offDiscard = events.onTrayDiscardSuspend((name) => {
|
||||
setSelected(name)
|
||||
setDiscardSuspendTarget(name)
|
||||
})
|
||||
return () => { offSelect(); offNew(); offDiscard() }
|
||||
}, [])
|
||||
|
||||
// Native Wails file drag-and-drop delivery into the selected VM's shared folder.
|
||||
@@ -1309,22 +1306,14 @@ export const App: React.FC = () => {
|
||||
)}
|
||||
|
||||
{discardSuspendTarget && (
|
||||
<Modal
|
||||
<ConfirmDialog
|
||||
title={tr('discardSuspendTitle', { name: displayNames[discardSuspendTarget] || discardSuspendTarget })}
|
||||
closeLabel={tr('close')}
|
||||
onClose={() => setDiscardSuspendTarget(null)}
|
||||
>
|
||||
<div className="dialog-body">
|
||||
<p className="dialog-desc">{tr('discardSuspendDesc')}</p>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<span />
|
||||
<span className="hstack">
|
||||
<Button variant="ghost" onClick={() => setDiscardSuspendTarget(null)}>{tr('cancel')}</Button>
|
||||
<Button variant="danger" onClick={confirmDiscardSuspend}>{tr('discardSuspendConfirm')}</Button>
|
||||
</span>
|
||||
</div>
|
||||
</Modal>
|
||||
description={tr('discardSuspendDesc')}
|
||||
cancelLabel={tr('cancel')}
|
||||
confirmLabel={tr('discardSuspendConfirm')}
|
||||
onCancel={() => setDiscardSuspendTarget(null)}
|
||||
onConfirm={confirmDiscardSuspend}
|
||||
/>
|
||||
)}
|
||||
|
||||
{cloneSource && (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import * as Alert from '@radix-ui/react-alert-dialog'
|
||||
import React, { useState } from 'react'
|
||||
import { t } from '../i18n'
|
||||
import { Locale } from '../types'
|
||||
import { ConfirmDialog } from '../ui/dialog'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
@@ -13,32 +13,18 @@ interface Props {
|
||||
export const DeleteDialog: React.FC<Props> = ({ locale, name, onCancel, onConfirm }) => {
|
||||
const [keepFiles, setKeepFiles] = useState(false)
|
||||
return (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{t(locale, 'deleteTitle', { name })}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">
|
||||
{t(locale, keepFiles ? 'deleteDescKeep' : 'deleteDesc')}
|
||||
</Alert.Description>
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={keepFiles} onChange={(e) => setKeepFiles(e.target.checked)} />
|
||||
{t(locale, 'deleteKeepFiles')}
|
||||
</label>
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild>
|
||||
<button type="button" className="btn">{t(locale, 'cancel')}</button>
|
||||
</Alert.Cancel>
|
||||
<Alert.Action asChild>
|
||||
<button type="button" className="btn btn-danger" onClick={() => onConfirm(keepFiles)}>
|
||||
{t(locale, 'deleteConfirm')}
|
||||
</button>
|
||||
</Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
<ConfirmDialog
|
||||
title={t(locale, 'deleteTitle', { name })}
|
||||
description={t(locale, keepFiles ? 'deleteDescKeep' : 'deleteDesc')}
|
||||
cancelLabel={t(locale, 'cancel')}
|
||||
confirmLabel={t(locale, 'deleteConfirm')}
|
||||
onCancel={onCancel}
|
||||
onConfirm={() => onConfirm(keepFiles)}
|
||||
>
|
||||
<label className="choice">
|
||||
<input type="checkbox" checked={keepFiles} onChange={(e) => setKeepFiles(e.target.checked)} />
|
||||
{t(locale, 'deleteKeepFiles')}
|
||||
</label>
|
||||
</ConfirmDialog>
|
||||
)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ interface Props {
|
||||
selected: string
|
||||
hostReady: boolean
|
||||
/** Whether the active runtime supports VM suspend/resume. */
|
||||
canSuspend?: boolean
|
||||
canSuspend: boolean
|
||||
onSelect: (id: string) => void
|
||||
/** VM name → display name (its note); empty or missing shows the name. */
|
||||
displayNames?: Record<string, string>
|
||||
@@ -164,9 +164,10 @@ export const Sidebar: React.FC<Props> = ({
|
||||
)}
|
||||
{suspended && (
|
||||
<>
|
||||
<Ctx.Item className="menu-item" disabled={vmBusy} onSelect={() => onVMContextAction(vm.name, 'resume')}>
|
||||
<Ctx.Item className="menu-item" disabled={vmBusy || !canSuspend} onSelect={() => onVMContextAction(vm.name, 'resume')}>
|
||||
<Play size={14} /> {tr('resume')}
|
||||
</Ctx.Item>
|
||||
{!canSuspend && <Ctx.Label className="menu-group-label">{tr('resumeUnavailable')}</Ctx.Label>}
|
||||
<Ctx.Item className="menu-item danger" disabled={vmBusy} onSelect={() => onVMContextAction(vm.name, 'discardSuspend')}>
|
||||
<Power size={14} /> {tr('discardSuspend')}
|
||||
</Ctx.Item>
|
||||
|
||||
@@ -27,7 +27,7 @@ interface Props {
|
||||
canDark?: boolean
|
||||
onThemeMode: (mode: ThemeMode) => void
|
||||
/** The selected VM and its current state, or null on the system pages. */
|
||||
vm: { name: string; state: string; busy: boolean; graphics?: string; canSuspend?: boolean } | null
|
||||
vm: { name: string; state: string; busy: boolean; graphics?: string; canSuspend: boolean } | null
|
||||
onNewVM: () => void
|
||||
onVMAction: (action: VMAction) => void
|
||||
onVMSettings: () => void
|
||||
@@ -220,8 +220,9 @@ export const TitleMenus: React.FC<Props> = ({
|
||||
{running
|
||||
? item(tr('showWindow'), () => onVMAction('focus'), { shortcut: 'Ctrl+Enter', disabled: vmBusy })
|
||||
: suspended
|
||||
? item(tr('resume'), () => onVMAction('resume'), { shortcut: 'Ctrl+Enter', disabled: vmBusy })
|
||||
? item(tr('resume'), () => onVMAction('resume'), { shortcut: vm?.canSuspend ? 'Ctrl+Enter' : undefined, disabled: vmBusy || !vm?.canSuspend })
|
||||
: item(tr('start'), () => onVMAction('start'), { shortcut: 'Ctrl+Enter', disabled: vmBusy || !stopped })}
|
||||
{suspended && !vm?.canSuspend && <Menu.Label className="menu-group-label">{tr('resumeUnavailable')}</Menu.Label>}
|
||||
{item(fullscreenLabel, () => onVMAction('fullscreen'), { disabled: vmBusy || !canFullscreen })}
|
||||
{item(tr('suspend'), () => onVMAction('suspend'), { disabled: vmBusy || !running || !vm?.canSuspend })}
|
||||
{item(tr('stop'), () => onVMAction('stop'), { disabled: vmBusy || !running })}
|
||||
|
||||
@@ -41,7 +41,7 @@ import {
|
||||
Upload,
|
||||
UserRound,
|
||||
} from 'lucide-react'
|
||||
import React, { useEffect, useRef, useState } from 'react'
|
||||
import React, { useEffect, useId, useRef, useState } from 'react'
|
||||
import { I18nKey, locText, t } from '../i18n'
|
||||
import {
|
||||
controllerLabel, formatBytes, formatDiskUsage, formatMemory, formatUptime, graphicsLabel,
|
||||
@@ -97,7 +97,7 @@ interface Props {
|
||||
macosMajor: number | null
|
||||
state: string
|
||||
/** Whether the active runtime supports VM suspend/resume. */
|
||||
canSuspend?: boolean
|
||||
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. */
|
||||
@@ -144,6 +144,9 @@ export const VMPage: React.FC<Props> = ({
|
||||
const busy = busyAction !== undefined
|
||||
const running = state === 'running'
|
||||
const suspended = state === 'suspended'
|
||||
const guestToolsLocked = suspended || state === 'suspending' || state === 'resuming'
|
||||
const resumeHintId = useId()
|
||||
const guestToolsHintId = useId()
|
||||
const installing = !!detail && (detail.has_installer || detail.recovery_mode)
|
||||
const transitioning = state === 'starting' || state === 'stopping' || state === 'suspending' || state === 'resuming'
|
||||
// Polled here rather than in App so each tick re-renders only this page.
|
||||
@@ -338,17 +341,19 @@ export const VMPage: React.FC<Props> = ({
|
||||
)
|
||||
} else if (suspended) {
|
||||
primary = (
|
||||
<Tip label={tr('resume')} shortcut={PRIMARY_SHORTCUT}>
|
||||
<Button variant="primary" icon={<Play size={14} aria-hidden="true" />} busy={busyAction === 'resume'} disabled={busy} onClick={() => onAction('resume')}>
|
||||
<Tip label={tr('resume')} shortcut={PRIMARY_SHORTCUT} disabled={!canSuspend}>
|
||||
<Button
|
||||
variant={canSuspend ? 'primary' : 'secondary'}
|
||||
icon={<Play size={14} aria-hidden="true" />}
|
||||
busy={busyAction === 'resume'}
|
||||
disabled={busy || !canSuspend}
|
||||
aria-describedby={!canSuspend ? resumeHintId : undefined}
|
||||
onClick={() => onAction('resume')}
|
||||
>
|
||||
{tr('resume')}
|
||||
</Button>
|
||||
</Tip>
|
||||
)
|
||||
secondary = (
|
||||
<Button icon={<Power size={13} aria-hidden="true" />} busy={busyAction === 'discardSuspend'} disabled={busy} onClick={() => onAction('discardSuspend')}>
|
||||
{tr('discardSuspend')}
|
||||
</Button>
|
||||
)
|
||||
} else if (state === 'starting') {
|
||||
primary = <Button variant="primary" busy>{tr('state_starting')}</Button>
|
||||
} else if (state === 'stopping') {
|
||||
@@ -444,11 +449,6 @@ export const VMPage: React.FC<Props> = ({
|
||||
: <><Maximize2 size={14} /> {tr('enterFullscreen')}</>}
|
||||
</Menu.Item>
|
||||
)}
|
||||
{canSuspend && (
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('suspend')}>
|
||||
<Pause size={14} /> {tr('suspend')}
|
||||
</Menu.Item>
|
||||
)}
|
||||
<Menu.Item className="menu-item" disabled={busy} onSelect={() => onAction('restart')}>
|
||||
<RotateCw size={14} /> {tr('restart')}
|
||||
</Menu.Item>
|
||||
@@ -644,7 +644,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
startLabel={suspended ? tr('resume') : tr('start')}
|
||||
showLabel={tr('showWindow')}
|
||||
shotLabel={tr('copyScreenshot')}
|
||||
onStart={!busy && (state === 'stopped' || suspended) ? () => onAction(suspended ? 'resume' : 'start') : undefined}
|
||||
onStart={!busy && (state === 'stopped' || (suspended && canSuspend)) ? () => onAction(suspended ? 'resume' : 'start') : undefined}
|
||||
onShow={running && !busy ? () => onAction('focus') : undefined}
|
||||
onScreenshot={running && !busy ? () => onAction('screenshot') : undefined}
|
||||
/>
|
||||
@@ -738,6 +738,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
? tr('suspendedNoticeDescWithTime', { time: suspTime, size: suspSize })
|
||||
: tr('suspendedNoticeDesc', { size: suspSize })}
|
||||
</span>
|
||||
{!canSuspend && <span id={resumeHintId} className="notice-sub">{tr('resumeUnavailable')}</span>}
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
@@ -933,6 +934,10 @@ export const VMPage: React.FC<Props> = ({
|
||||
const needsUpgrade = gtConnected && (detail.guest_tools_agent_version ?? 0) > 0 && (detail.guest_tools_agent_version ?? 0) < 3
|
||||
// Plugin switched off: show the state and hide controls that would only fail.
|
||||
const gtOff = !!detail.guest_tools_disabled
|
||||
const gtAttached = detail.guest_tools_attached
|
||||
const showToolsAction = !gtOff && (gtAttached || !gtConnected || needsUpgrade)
|
||||
const toolsAction = gtAttached ? 'detachGuestTools' : 'attachGuestTools'
|
||||
const toolsActionLabel = gtAttached ? 'detachGuestTools' : needsUpgrade ? 'gtUpdate' : 'gtInstall'
|
||||
|
||||
// One status word per state; how files are shared goes in the tooltip.
|
||||
let gtTone: 'ok' | 'warn' | 'idle' = 'idle'
|
||||
@@ -1045,20 +1050,20 @@ export const VMPage: React.FC<Props> = ({
|
||||
</span>
|
||||
</Tip>
|
||||
</div>
|
||||
{suspended && showToolsAction && (
|
||||
<span id={guestToolsHintId} className="hint">{tr('suspendedGuestToolsHint')}</span>
|
||||
)}
|
||||
<div className="conn-ctrl">
|
||||
{gtOff ? null : detail.guest_tools_attached ? (
|
||||
<Button busy={busyAction === 'detachGuestTools'} disabled={busy} onClick={() => onAction('detachGuestTools')}>
|
||||
{tr('detachGuestTools')}
|
||||
</Button>
|
||||
) : (!gtConnected || needsUpgrade) && (
|
||||
{showToolsAction && (
|
||||
<Button
|
||||
variant={detail.guest_tools_configured ? 'secondary' : 'primary'}
|
||||
icon={<Disc size={13} aria-hidden="true" />}
|
||||
busy={busyAction === 'attachGuestTools'}
|
||||
disabled={busy}
|
||||
onClick={() => onAction('attachGuestTools')}
|
||||
variant={gtAttached || detail.guest_tools_configured || guestToolsLocked ? 'secondary' : 'primary'}
|
||||
icon={gtAttached ? undefined : <Disc size={13} aria-hidden="true" />}
|
||||
busy={busyAction === toolsAction}
|
||||
disabled={busy || guestToolsLocked}
|
||||
aria-describedby={suspended ? guestToolsHintId : undefined}
|
||||
onClick={() => onAction(toolsAction)}
|
||||
>
|
||||
{needsUpgrade ? tr('gtUpdate') : tr('gtInstall')}
|
||||
{tr(toolsActionLabel)}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -119,6 +119,7 @@ export const vmZh: Record<string, string> = {
|
||||
"pickRecoveryTitle": "选择离线镜像(.img / .dmg)",
|
||||
"restartToApply": "重启以应用",
|
||||
"resume": "恢复",
|
||||
"resumeUnavailable": "切换到支持挂起的内核后可恢复",
|
||||
"sendText": "发送文本到虚拟机…",
|
||||
"sendTextConfirm": "发送 (Ctrl+Enter)",
|
||||
"sendTextDesc": "支持中文、Emoji、宿主机输入法与语音输入,按 Ctrl+Enter 发送到 macOS 当前输入框。",
|
||||
@@ -171,6 +172,7 @@ export const vmZh: Record<string, string> = {
|
||||
"state_suspended": "已挂起",
|
||||
"state_suspending": "挂起中",
|
||||
"suspend": "挂起",
|
||||
"suspendedGuestToolsHint": "恢复或放弃挂起状态后可更改",
|
||||
"suspendedNoticeDesc": "恢复后将回到挂起前的桌面与应用状态({size});修改硬件配置或管理磁盘前请先恢复或放弃挂起状态。",
|
||||
"suspendedNoticeDescWithTime": "挂起于 {time}({size})· 恢复后将回到原桌面与应用状态;修改硬件配置或管理磁盘前请先恢复或放弃挂起状态。",
|
||||
"suspendedNoticeTitle": "已保存运行状态",
|
||||
@@ -333,6 +335,7 @@ export const vmEn: Record<string, string> = {
|
||||
"pickRecoveryTitle": "Choose an offline image (.img / .dmg)",
|
||||
"restartToApply": "Restart to apply",
|
||||
"resume": "Resume",
|
||||
"resumeUnavailable": "Switch to a runtime that supports suspend to resume this VM",
|
||||
"sendText": "Send text to VM…",
|
||||
"sendTextConfirm": "Send (Ctrl+Enter)",
|
||||
"sendTextDesc": "Supports Chinese, emoji, host IME, and dictation. Press Ctrl+Enter to inject into the focused macOS field.",
|
||||
@@ -385,6 +388,7 @@ export const vmEn: Record<string, string> = {
|
||||
"state_suspended": "Suspended",
|
||||
"state_suspending": "Suspending",
|
||||
"suspend": "Suspend",
|
||||
"suspendedGuestToolsHint": "Resume or discard saved state to make changes",
|
||||
"suspendedNoticeDesc": "Resuming restores your desktop and running apps ({size}). Resume or discard the saved state before changing settings or managing disks.",
|
||||
"suspendedNoticeDescWithTime": "Suspended {time} ({size}) · Resuming restores your desktop and running apps. Resume or discard before changing settings or disks.",
|
||||
"suspendedNoticeTitle": "Saved state ready",
|
||||
|
||||
@@ -625,6 +625,7 @@ export type I18nKey =
|
||||
| "restart"
|
||||
| "restartToApply"
|
||||
| "resume"
|
||||
| "resumeUnavailable"
|
||||
| "runtimeAlpha"
|
||||
| "runtimeAlphaHint"
|
||||
| "runtimeChannel_alpha"
|
||||
@@ -786,6 +787,7 @@ export type I18nKey =
|
||||
| "summarySSHPort"
|
||||
| "summarySource"
|
||||
| "suspend"
|
||||
| "suspendedGuestToolsHint"
|
||||
| "suspendedNoticeDesc"
|
||||
| "suspendedNoticeDescWithTime"
|
||||
| "suspendedNoticeTitle"
|
||||
|
||||
@@ -909,7 +909,6 @@ button.status-issue + .status-metric { margin-left: 6px; }
|
||||
.dialog-title { font-size: var(--fs-16); font-weight: var(--fw-strong); letter-spacing: -0.01em; text-wrap: balance; }
|
||||
.dialog-desc { font-size: var(--fs-13); color: var(--text-2); margin-top: 2px; }
|
||||
.dialog-body { padding: 20px 22px; overflow-y: auto; overscroll-behavior: contain; flex: 1; display: flex; flex-direction: column; gap: var(--sp-4); }
|
||||
.dialog-body > .dialog-desc:only-child { margin-top: 0; }
|
||||
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); padding: 12px 22px; border-top: 1px solid var(--border); }
|
||||
.dialog.sm .dialog-body { padding: 22px 22px 14px; gap: var(--sp-3); }
|
||||
.dialog.sm .dialog-foot { border-top: none; justify-content: flex-end; padding-top: 0; padding-bottom: 20px; }
|
||||
|
||||
@@ -1,7 +1,37 @@
|
||||
import * as Alert from '@radix-ui/react-alert-dialog'
|
||||
import * as RDialog from '@radix-ui/react-dialog'
|
||||
import { X } from 'lucide-react'
|
||||
import React from 'react'
|
||||
import { IconButton } from './controls'
|
||||
import { Button, IconButton } from './controls'
|
||||
|
||||
interface ConfirmDialogProps {
|
||||
title: string
|
||||
description: string
|
||||
cancelLabel: string
|
||||
confirmLabel: string
|
||||
onCancel: () => void
|
||||
onConfirm: () => void
|
||||
children?: React.ReactNode
|
||||
}
|
||||
|
||||
export const ConfirmDialog: React.FC<ConfirmDialogProps> = ({ title, description, cancelLabel, confirmLabel, onCancel, onConfirm, children }) => (
|
||||
<Alert.Root open onOpenChange={(open) => { if (!open) onCancel() }}>
|
||||
<Alert.Portal>
|
||||
<Alert.Overlay className="overlay" />
|
||||
<Alert.Content className="dialog sm">
|
||||
<div className="dialog-body">
|
||||
<Alert.Title className="dialog-title">{title}</Alert.Title>
|
||||
<Alert.Description className="dialog-desc">{description}</Alert.Description>
|
||||
{children}
|
||||
</div>
|
||||
<div className="dialog-foot">
|
||||
<Alert.Cancel asChild><Button>{cancelLabel}</Button></Alert.Cancel>
|
||||
<Alert.Action asChild><Button variant="danger" onClick={onConfirm}>{confirmLabel}</Button></Alert.Action>
|
||||
</div>
|
||||
</Alert.Content>
|
||||
</Alert.Portal>
|
||||
</Alert.Root>
|
||||
)
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
|
||||
@@ -180,6 +180,7 @@ export const events = {
|
||||
// Tray menu (internal/app/app.go trayVMAction): "Show in Reims-Go" and "New VM…".
|
||||
onTraySelectVM: (cb: (name: string) => void) => eventsOn('reims:tray-select-vm', cb),
|
||||
onTrayNewVM: (cb: () => void) => eventsOn('reims:tray-new-vm', cb),
|
||||
onTrayDiscardSuspend: (cb: (name: string) => void) => eventsOn('reims:tray-discard-suspend', cb),
|
||||
// Renderer health watchdog & crash reporting (internal/app/ui_health.go).
|
||||
onUIPing: (cb: () => void) => eventsOn('reims:ui-ping', cb),
|
||||
emitUIPong: () => eventsEmit('reims:ui-pong'),
|
||||
|
||||
@@ -6,6 +6,7 @@ export namespace app {
|
||||
optimizations: host.Optimization[];
|
||||
runtimes: runtime.Installed[];
|
||||
active_runtime?: runtime.Installed;
|
||||
can_suspend: boolean;
|
||||
vms: reims.VMListItem[];
|
||||
transitions: Record<string, string>;
|
||||
pending_changes: Record<string, Array<PendingChange>>;
|
||||
@@ -30,6 +31,7 @@ export namespace app {
|
||||
this.optimizations = this.convertValues(source["optimizations"], host.Optimization);
|
||||
this.runtimes = this.convertValues(source["runtimes"], runtime.Installed);
|
||||
this.active_runtime = this.convertValues(source["active_runtime"], runtime.Installed);
|
||||
this.can_suspend = source["can_suspend"];
|
||||
this.vms = this.convertValues(source["vms"], reims.VMListItem);
|
||||
this.transitions = source["transitions"];
|
||||
this.pending_changes = this.convertValues(source["pending_changes"], Array<PendingChange>, true);
|
||||
|
||||
+6
-1
@@ -43,6 +43,7 @@ type AppState struct {
|
||||
Optimizations []host.Optimization `json:"optimizations"`
|
||||
Runtimes []rt.Installed `json:"runtimes"`
|
||||
ActiveRuntime *rt.Installed `json:"active_runtime,omitempty"`
|
||||
CanSuspend bool `json:"can_suspend"`
|
||||
VMs []reims.VMListItem `json:"vms"`
|
||||
Transitions map[string]string `json:"transitions"`
|
||||
PendingChanges map[string][]PendingChange `json:"pending_changes"`
|
||||
@@ -658,6 +659,7 @@ func (a *App) GetState() AppState {
|
||||
Optimizations: opts,
|
||||
Runtimes: runtimes,
|
||||
ActiveRuntime: active,
|
||||
CanSuspend: active != nil && active.Manifest.HasCapability("vm-suspend"),
|
||||
VMs: vms,
|
||||
Transitions: trCopy,
|
||||
PendingChanges: pcCopy,
|
||||
@@ -852,7 +854,10 @@ func (a *App) trayVMAction(name string, act tray.Action) {
|
||||
case tray.ActResume:
|
||||
err, failTitle = a.ResumeVM(name), i18n.M(loc, "tray.notify.resume_fail", vars)
|
||||
case tray.ActDiscardSuspend:
|
||||
err, failTitle = a.DiscardSuspend(name), i18n.M(loc, "tray.notify.discard_suspend_fail", vars)
|
||||
a.ShowMainWindow()
|
||||
if a.ctx != nil {
|
||||
wailsRuntime.EventsEmit(a.ctx, "reims:tray-discard-suspend", name)
|
||||
}
|
||||
case tray.ActStop:
|
||||
err, failTitle = a.StopVM(name, false), i18n.M(loc, "tray.notify.stop_fail", vars)
|
||||
case tray.ActForceStop:
|
||||
|
||||
@@ -440,13 +440,14 @@ var catalog = map[Locale]map[string]string{
|
||||
"toastSSHUserSaved": "已保存 SSH 用户名",
|
||||
"toastSaved": "已保存",
|
||||
"toastSavedNextStart": "已保存,下次启动生效",
|
||||
"tray.menu.discard_suspend": "放弃挂起状态(&X)",
|
||||
"tray.menu.discard_suspend": "放弃挂起状态…(&X)",
|
||||
"tray.menu.force_stop": "强制关机(&F)",
|
||||
"tray.menu.new_vm": "新建虚拟机(&N)…",
|
||||
"tray.menu.open_in_app": "在 Reims-Go 中查看(&V)",
|
||||
"tray.menu.quit": "退出 Reims-Go(&Q)",
|
||||
"tray.menu.restart": "重启(&R)",
|
||||
"tray.menu.resume": "恢复(&U)",
|
||||
"tray.menu.resume_unavailable": "恢复(当前内核不支持挂起)",
|
||||
"tray.menu.screenshot": "复制屏幕截图(&C)",
|
||||
"tray.menu.shared_folder": "打开共享文件夹(&H)",
|
||||
"tray.menu.show": "显示 Reims-Go(&O)",
|
||||
@@ -973,13 +974,14 @@ var catalog = map[Locale]map[string]string{
|
||||
"toastSSHUserSaved": "Saved SSH username",
|
||||
"toastSaved": "Saved",
|
||||
"toastSavedNextStart": "Saved — applies on next start",
|
||||
"tray.menu.discard_suspend": "Discard Saved Stat&e",
|
||||
"tray.menu.discard_suspend": "Discard Saved Stat&e…",
|
||||
"tray.menu.force_stop": "&Force Shut Down",
|
||||
"tray.menu.new_vm": "&New Virtual Machine…",
|
||||
"tray.menu.open_in_app": "Show in &Reims-Go",
|
||||
"tray.menu.quit": "&Quit Reims-Go",
|
||||
"tray.menu.restart": "&Restart",
|
||||
"tray.menu.resume": "Res&ume",
|
||||
"tray.menu.resume_unavailable": "Resume (runtime lacks suspend support)",
|
||||
"tray.menu.screenshot": "&Copy Screenshot",
|
||||
"tray.menu.shared_folder": "Open S&hared Folder",
|
||||
"tray.menu.show": "&Show Reims-Go",
|
||||
|
||||
+16
-8
@@ -94,15 +94,17 @@ type menuEntry struct {
|
||||
}
|
||||
|
||||
type texts struct {
|
||||
show, newVM, quit string
|
||||
start, stop, forceStop, restart, showWindow, shot string
|
||||
suspend, resume, discardSuspend string
|
||||
shared, openInApp string
|
||||
running, stopped, suspended string
|
||||
starting, stopping, suspending, resuming string
|
||||
broken, unknown string
|
||||
show, newVM, quit string
|
||||
start, stop, forceStop, restart, showWindow, shot string
|
||||
suspend, resume, discardSuspend string
|
||||
shared, openInApp string
|
||||
running, stopped, suspended string
|
||||
starting, stopping, suspending, resuming string
|
||||
broken, unknown string
|
||||
|
||||
toggleFullscreen string
|
||||
|
||||
resumeUnavailable string
|
||||
}
|
||||
|
||||
func menuTexts(snap Snapshot) texts {
|
||||
@@ -140,6 +142,8 @@ func menuTexts(snap Snapshot) texts {
|
||||
unknown: i18n.T(loc, "tray.state.unknown"),
|
||||
|
||||
toggleFullscreen: i18n.T(loc, "tray.menu.toggle_fullscreen"),
|
||||
|
||||
resumeUnavailable: i18n.T(loc, "tray.menu.resume_unavailable"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +203,11 @@ func buildMenu(snap Snapshot) []menuEntry {
|
||||
case "suspended":
|
||||
dot, state = dotSuspended, t.suspended
|
||||
resume := cmd(ActResume, t.resume)
|
||||
resume.Default = true
|
||||
resume.Default = snap.CanSuspend
|
||||
if !snap.CanSuspend {
|
||||
resume.Label = t.resumeUnavailable
|
||||
resume.Disabled = true
|
||||
}
|
||||
sub = []menuEntry{
|
||||
resume, cmd(ActDiscardSuspend, t.discardSuspend), sep,
|
||||
cmd(ActSharedFolder, t.shared), sep,
|
||||
|
||||
@@ -72,6 +72,21 @@ func TestBuildMenuPerState(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSuspendedVMWithoutCompatibleRuntime(t *testing.T) {
|
||||
menu := buildMenu(Snapshot{LocaleZh: true, VMs: []VMItem{{Name: "macos-sleep", State: "suspended"}}})
|
||||
vm := findEntry(menu, "macos-sleep\t已挂起")
|
||||
if vm == nil {
|
||||
t.Fatal("suspended VM is missing from the tray menu")
|
||||
}
|
||||
resume := vm.Sub[0]
|
||||
if resume.ID != vmCmd(0, ActResume) || !resume.Disabled || resume.Default || resume.Label != "恢复(当前内核不支持挂起)" {
|
||||
t.Fatalf("resume should be disabled and explain why: %+v", resume)
|
||||
}
|
||||
if discard := vm.Sub[1]; discard.ID != vmCmd(0, ActDiscardSuspend) || discard.Disabled {
|
||||
t.Fatalf("discard should remain available: %+v", discard)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDecodeVMCmdRoundTrip(t *testing.T) {
|
||||
for i := 0; i < maxTrayVMs; i++ {
|
||||
for act := ActStart; act <= ActDiscardSuspend; act++ {
|
||||
|
||||
@@ -409,7 +409,8 @@
|
||||
"tray.menu.start": "&Start",
|
||||
"tray.menu.suspend": "Sus&pend",
|
||||
"tray.menu.resume": "Res&ume",
|
||||
"tray.menu.discard_suspend": "Discard Saved Stat&e",
|
||||
"tray.menu.resume_unavailable": "Resume (runtime lacks suspend support)",
|
||||
"tray.menu.discard_suspend": "Discard Saved Stat&e…",
|
||||
"tray.menu.stop": "Shut &Down",
|
||||
"tray.menu.force_stop": "&Force Shut Down",
|
||||
"tray.menu.restart": "&Restart",
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"state_broken": "Error",
|
||||
"suspend": "Suspend",
|
||||
"resume": "Resume",
|
||||
"resumeUnavailable": "Switch to a runtime that supports suspend to resume this VM",
|
||||
"discardSuspend": "Discard saved state",
|
||||
"discardSuspendTitle": "Discard saved state for “{name}”?",
|
||||
"discardSuspendDesc": "Removes the saved memory and device state and returns the VM to powered off. Any unsaved work inside macOS will be lost and can’t be undone.",
|
||||
@@ -59,6 +60,7 @@
|
||||
"suspendedNoticeDesc": "Resuming restores your desktop and running apps ({size}). Resume or discard the saved state before changing settings or managing disks.",
|
||||
"suspendedNoticeDescWithTime": "Suspended {time} ({size}) · Resuming restores your desktop and running apps. Resume or discard before changing settings or disks.",
|
||||
"suspendedSettingsHint": "Resume or discard saved state before changing settings",
|
||||
"suspendedGuestToolsHint": "Resume or discard saved state to make changes",
|
||||
"toastSuspended": "{name} suspended",
|
||||
"toastResumed": "{name} resumed",
|
||||
"toastDiscardSuspend": "Discarded saved state for {name}",
|
||||
|
||||
@@ -409,7 +409,8 @@
|
||||
"tray.menu.start": "启动(&S)",
|
||||
"tray.menu.suspend": "挂起(&P)",
|
||||
"tray.menu.resume": "恢复(&U)",
|
||||
"tray.menu.discard_suspend": "放弃挂起状态(&X)",
|
||||
"tray.menu.resume_unavailable": "恢复(当前内核不支持挂起)",
|
||||
"tray.menu.discard_suspend": "放弃挂起状态…(&X)",
|
||||
"tray.menu.stop": "关机(&D)",
|
||||
"tray.menu.force_stop": "强制关机(&F)",
|
||||
"tray.menu.restart": "重启(&R)",
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
"state_broken": "出错",
|
||||
"suspend": "挂起",
|
||||
"resume": "恢复",
|
||||
"resumeUnavailable": "切换到支持挂起的内核后可恢复",
|
||||
"discardSuspend": "放弃挂起状态",
|
||||
"discardSuspendTitle": "放弃「{name}」的挂起状态?",
|
||||
"discardSuspendDesc": "将删除已保存的内存与设备状态并回到关机状态,macOS 中尚未保存的工作会丢失,且无法撤销。",
|
||||
@@ -59,6 +60,7 @@
|
||||
"suspendedNoticeDesc": "恢复后将回到挂起前的桌面与应用状态({size});修改硬件配置或管理磁盘前请先恢复或放弃挂起状态。",
|
||||
"suspendedNoticeDescWithTime": "挂起于 {time}({size})· 恢复后将回到原桌面与应用状态;修改硬件配置或管理磁盘前请先恢复或放弃挂起状态。",
|
||||
"suspendedSettingsHint": "请先恢复或放弃挂起状态后再修改配置",
|
||||
"suspendedGuestToolsHint": "恢复或放弃挂起状态后可更改",
|
||||
"toastSuspended": "{name} 已挂起",
|
||||
"toastResumed": "{name} 已恢复",
|
||||
"toastDiscardSuspend": "已放弃 {name} 的挂起状态",
|
||||
|
||||
Reference in new issue
Block a user