refactor: give each VM action one window binding
Every VM action had two bindings: one by name and one by driver and name. The window used only the second, so the first is gone and the WithDriver suffix with it. Unused bindings and frontend exports are removed too. Tests now reject bindings the window never calls, stale generated bindings and unused frontend exports. TypeScript rejects unused locals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b203bde650
commit
565577589a
91 files changed
+606
-930
No files matched your search
@@ -5,7 +5,7 @@
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
"test": "node --test --test-concurrency=2 scripts/test-i18n.mjs scripts/test-keymap.mjs scripts/test-plugins.mjs scripts/test-tasks.mjs scripts/test-display-presets.mjs scripts/test-endpoints.mjs scripts/test-guest-tools.mjs scripts/test-macos-boundary.mjs scripts/test-no-empty-catch.mjs scripts/test-hypervisor.mjs",
|
||||
"test": "node --test --test-concurrency=2 scripts/test-i18n.mjs scripts/test-keymap.mjs scripts/test-plugins.mjs scripts/test-tasks.mjs scripts/test-display-presets.mjs scripts/test-endpoints.mjs scripts/test-guest-tools.mjs scripts/test-macos-boundary.mjs scripts/test-no-empty-catch.mjs scripts/test-unused-exports.mjs scripts/test-hypervisor.mjs",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"bundle": "vite build && node scripts/check-ui-contract.mjs",
|
||||
"build": "tsc --noEmit && pnpm run bundle",
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// Rejects exports in src/ that no other file uses: dead code, or an export
|
||||
// keyword that only widens a module's interface.
|
||||
import test from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import fs from 'node:fs'
|
||||
import path from 'node:path'
|
||||
import ts from 'typescript'
|
||||
|
||||
const root = path.resolve(import.meta.dirname, '..')
|
||||
|
||||
function findUnusedExports() {
|
||||
const { config } = ts.readConfigFile(path.join(root, 'tsconfig.json'), ts.sys.readFile)
|
||||
const { fileNames, options } = ts.parseJsonConfigFileContent(config, ts.sys, root)
|
||||
const service = ts.createLanguageService({
|
||||
...ts.sys,
|
||||
getCompilationSettings: () => options,
|
||||
getScriptFileNames: () => fileNames,
|
||||
getScriptVersion: () => '1',
|
||||
getScriptSnapshot: (file) => (fs.existsSync(file) ? ts.ScriptSnapshot.fromString(fs.readFileSync(file, 'utf8')) : undefined),
|
||||
getCurrentDirectory: () => root,
|
||||
getDefaultLibFileName: ts.getDefaultLibFilePath,
|
||||
})
|
||||
// The test and contract scripts import src modules or read them as text.
|
||||
const scripts = fs.readdirSync(import.meta.dirname)
|
||||
.filter((name) => name !== path.basename(import.meta.filename))
|
||||
.map((name) => fs.readFileSync(path.join(import.meta.dirname, name), 'utf8'))
|
||||
.join('\n')
|
||||
|
||||
const unused = []
|
||||
for (const file of fileNames) {
|
||||
// bridgeContract.ts also documents the message types for plugin authors.
|
||||
if (file.endsWith('.gen.ts') || file.endsWith('/bridgeContract.ts')) continue
|
||||
const source = service.getProgram().getSourceFile(file)
|
||||
for (const statement of source.statements) {
|
||||
if (!ts.canHaveModifiers(statement) || !ts.getModifiers(statement)?.some((m) => m.kind === ts.SyntaxKind.ExportKeyword)) continue
|
||||
const names = ts.isVariableStatement(statement)
|
||||
? statement.declarationList.declarations.map((d) => d.name).filter(ts.isIdentifier)
|
||||
: [statement.name].filter(Boolean)
|
||||
for (const name of names) {
|
||||
if (new RegExp(`\\b${name.text}\\b`).test(scripts)) continue
|
||||
const references = (service.findReferences(file, name.getStart(source)) ?? []).flatMap((r) => r.references)
|
||||
if (references.every((r) => r.fileName === file)) {
|
||||
unused.push(`${path.relative(root, file)}: ${name.text}`)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return { unused, files: fileNames.length }
|
||||
}
|
||||
|
||||
test('every export in src/ has a user outside its own file', () => {
|
||||
const { unused, files } = findUnusedExports()
|
||||
assert.ok(files > 50, `expected to scan src/, found ${files} files`)
|
||||
assert.deepEqual(unused, [])
|
||||
})
|
||||
+26
-26
@@ -24,7 +24,7 @@ import { macOSMajor } from './macos/macosRelease'
|
||||
import { currentTask, finishedTaskTTL, isActiveInstallerTask, pruneFinishedTasks, upsertTask } from './lib/tasks'
|
||||
import { applyActiveLocaleFonts, applyActiveTheme, disposeActiveThemeAndLocaleFonts, emitThemeEvent, notifyInteractiveThemeState, type UIStateSnapshot } from './lib/themeEngine'
|
||||
import { hasVisibleDialog } from './lib/dialogState'
|
||||
import { latestVMStatsWithDriver, refreshSubscribedVMStats, refreshVMStatsWithDriver } from './lib/vmStats'
|
||||
import { latestVMStats, refreshSubscribedVMStats, refreshVMStats } from './lib/vmStats'
|
||||
import { vmRefKey } from './lib/vmRef'
|
||||
import { closePluginDialog, closePluginView, emptyPluginViewState, matchViewCondition, openPluginView, pluginViewKey, prunePluginViews, type PluginViewRoute, type PluginViewState } from './lib/pluginViewRouter'
|
||||
import { publishPluginHostEvent } from './lib/pluginViewEvents'
|
||||
@@ -434,9 +434,9 @@ export const App: React.FC = () => {
|
||||
let live = true
|
||||
for (const vm of vms) {
|
||||
const key = vmRefKey(vm)
|
||||
api.GetVMNoteWithDriver(vm.driver_id ?? '', vm.name)
|
||||
api.GetVMNote(vm.driver_id ?? '', vm.name)
|
||||
.then((n) => { if (live) setDisplayNames((m) => ({ ...m, [key]: (n ?? '').trim() })) })
|
||||
.catch((e) => console.warn('[app] GetVMNoteWithDriver failed:', key, e))
|
||||
.catch((e) => console.warn('[app] GetVMNote failed:', key, e))
|
||||
}
|
||||
return () => { live = false }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
@@ -742,7 +742,7 @@ export const App: React.FC = () => {
|
||||
openSettings: () => setSelected(SETTINGS_ID),
|
||||
focusVMWindow: (vmName) => {
|
||||
const vm = vmsRef.current.find((v) => vmRefKey(v) === vmName) ?? vmsRef.current.find((v) => v.name === vmName)
|
||||
void api.FocusVMWindowWithDriver(vm?.driver_id ?? '', vm?.name ?? vmName).catch((e) => console.warn('[theme] FocusVMWindowWithDriver failed:', vmName, e))
|
||||
void api.FocusVMWindow(vm?.driver_id ?? '', vm?.name ?? vmName).catch((e) => console.warn('[theme] FocusVMWindow failed:', vmName, e))
|
||||
},
|
||||
},
|
||||
)
|
||||
@@ -765,7 +765,7 @@ export const App: React.FC = () => {
|
||||
try {
|
||||
const logVM = name === selectedVM?.name ? selectedVM : vms.find((v) => v.name === name)
|
||||
const logDriverID = logVM?.driver_id ?? ''
|
||||
const text = await api.ReadVMLogsWithDriver(logDriverID, name, serial)
|
||||
const text = await api.ReadVMLogs(logDriverID, name, serial)
|
||||
if (serial) setSerialLog(text)
|
||||
else setQemuLog(text)
|
||||
} catch (e) {
|
||||
@@ -903,7 +903,7 @@ export const App: React.FC = () => {
|
||||
|
||||
// Hosted VMs have no window: the primary action is their best ready endpoint.
|
||||
const openEndpoint = (vm: VMListItem, kind: string) => {
|
||||
api.OpenVMEndpointWithDriver(vm.driver_id ?? '', vm.name, kind, '').catch((e) => fail(tr('failEndpointOpen'), e))
|
||||
api.OpenVMEndpoint(vm.driver_id ?? '', vm.name, kind, '').catch((e) => fail(tr('failEndpointOpen'), e))
|
||||
}
|
||||
const openPrimaryEndpoint = (vm: VMListItem) => {
|
||||
const { primary } = splitEndpoints(vm.endpoints)
|
||||
@@ -941,21 +941,21 @@ export const App: React.FC = () => {
|
||||
return
|
||||
}
|
||||
switch (action) {
|
||||
case 'start': return runVMAction(key, action, () => api.StartVMWithDriver(actionDriverID, name))
|
||||
case 'suspend': return runVMAction(key, action, () => api.SuspendVMWithDriver(actionDriverID, name), tr('toastSuspended', { name }))
|
||||
case 'resume': return runVMAction(key, action, () => api.ResumeVMWithDriver(actionDriverID, name), tr('toastResumed', { name }))
|
||||
case 'start': return runVMAction(key, action, () => api.StartVM(actionDriverID, name))
|
||||
case 'suspend': return runVMAction(key, action, () => api.SuspendVM(actionDriverID, name), tr('toastSuspended', { name }))
|
||||
case 'resume': return runVMAction(key, action, () => api.ResumeVM(actionDriverID, name), tr('toastResumed', { name }))
|
||||
case 'discardSuspend': return setDiscardSuspendTarget(key)
|
||||
case 'focus': return api.FocusVMWindowWithDriver(actionDriverID, name).catch((e) => fail(tr('failFocus'), e))
|
||||
case 'focus': return api.FocusVMWindow(actionDriverID, name).catch((e) => fail(tr('failFocus'), e))
|
||||
case 'fullscreen':
|
||||
return runVMAction(key, action, async () => {
|
||||
const isFullscreen = await api.ToggleVMFullscreenWithDriver(actionDriverID, name)
|
||||
refreshVMStatsWithDriver(actionDriverID, name, { window_fullscreen: isFullscreen })
|
||||
const isFullscreen = await api.ToggleVMFullscreen(actionDriverID, name)
|
||||
refreshVMStats(actionDriverID, name, { window_fullscreen: isFullscreen })
|
||||
})
|
||||
case 'screenshot': return runVMAction(key, action, () => api.CopyVMScreenshotWithDriver(actionDriverID, name), tr('toastScreenshotCopied'))
|
||||
case 'stop': return runVMAction(key, action, () => api.StopVMWithDriver(actionDriverID, name, false), tr('toastStopped', { name }))
|
||||
case 'forceStop': return runVMAction(key, action, () => api.StopVMWithDriver(actionDriverID, name, true), tr('toastStopped', { name }))
|
||||
case 'restart': return runVMAction(key, action, () => api.RestartVMWithDriver(actionDriverID, name))
|
||||
case 'eject': return runVMAction(key, action, () => api.EjectInstallerWithDriver(actionDriverID, name), tr('toastEjected'))
|
||||
case 'screenshot': return runVMAction(key, action, () => api.CopyVMScreenshot(actionDriverID, name), tr('toastScreenshotCopied'))
|
||||
case 'stop': return runVMAction(key, action, () => api.StopVM(actionDriverID, name, false), tr('toastStopped', { name }))
|
||||
case 'forceStop': return runVMAction(key, action, () => api.StopVM(actionDriverID, name, true), tr('toastStopped', { name }))
|
||||
case 'restart': return runVMAction(key, action, () => api.RestartVM(actionDriverID, name))
|
||||
case 'eject': return runVMAction(key, action, () => api.EjectInstaller(actionDriverID, name), tr('toastEjected'))
|
||||
case 'finishInstall': return runVMAction(key, action, () => api.FinishInstall(name), tr(isRunning ? 'toastExitRecoveryNextStart' : 'toastInstallFinished'))
|
||||
case 'enterRecovery': return runVMAction(key, action, () => api.EnterRecovery(name), tr(isRunning ? 'toastEnterRecoveryNextStart' : 'toastEnterRecovery'))
|
||||
case 'attachInstaller': return attachInstaller(key, name, isRunning)
|
||||
@@ -966,11 +966,11 @@ export const App: React.FC = () => {
|
||||
case 'upgradeNVMe':
|
||||
return runVMAction(key, action, () => api.UpgradeDiskToNVMe(name), tr(isRunning ? 'toastNVMeNextStart' : 'toastNVMeReady'))
|
||||
case 'exportDiagnostics':
|
||||
return runVMAction(key, action, async () => { await api.ExportDiagnosticsWithDriver(actionDriverID, name) }, tr('toastDiagExported'))
|
||||
return runVMAction(key, action, async () => { await api.ExportDiagnostics(actionDriverID, name) }, tr('toastDiagExported'))
|
||||
case 'cloneVM':
|
||||
if (!features.clone) return
|
||||
return setCloneSource({ name, driverID: actionDriverID })
|
||||
case 'type': return typeInto(key, () => api.TypeClipboardWithDriver(actionDriverID, name))
|
||||
case 'type': return typeInto(key, () => api.TypeClipboard(actionDriverID, name))
|
||||
case 'sendText': return setSendTextTarget(key)
|
||||
case 'openFolder':
|
||||
return api.OpenVMFolder(name).catch((e) => fail(tr('failOpenFolder'), e))
|
||||
@@ -1018,7 +1018,7 @@ export const App: React.FC = () => {
|
||||
const name = targetVM?.name ?? target
|
||||
const driverID = targetVM?.driver_id ?? ''
|
||||
const key = targetVM ? vmRefKey(targetVM) : (name ?? '')
|
||||
if (name) runVMAction(key, 'delete', () => api.DeleteVMWithDriver(driverID, name, keepFiles), tr('toastDeleted', { name }))
|
||||
if (name) runVMAction(key, 'delete', () => api.DeleteVM(driverID, name, keepFiles), tr('toastDeleted', { name }))
|
||||
}
|
||||
|
||||
const confirmDiscardSuspend = () => {
|
||||
@@ -1028,7 +1028,7 @@ export const App: React.FC = () => {
|
||||
const name = targetVM?.name ?? target
|
||||
const driverID = targetVM?.driver_id ?? ''
|
||||
const key = targetVM ? vmRefKey(targetVM) : (name ?? '')
|
||||
if (name) runVMAction(key, 'discardSuspend', () => api.DiscardSuspendWithDriver(driverID, name), tr('toastDiscardSuspend', { name }))
|
||||
if (name) runVMAction(key, 'discardSuspend', () => api.DiscardSuspend(driverID, name), tr('toastDiscardSuspend', { name }))
|
||||
}
|
||||
|
||||
const confirmOnlineRecovery = () => {
|
||||
@@ -1045,7 +1045,7 @@ export const App: React.FC = () => {
|
||||
setCloneSource(null)
|
||||
if (!src) return
|
||||
runVMAction(vmRefKey({ name: src.name, driver_id: src.driverID }), 'cloneVM', async () => {
|
||||
await api.CloneVMCoWWithDriver(src.driverID, src.name, cloneName)
|
||||
await api.CloneVMCoW(src.driverID, src.name, cloneName)
|
||||
setSelected(vmRefKey({ name: cloneName, driver_id: src.driverID }))
|
||||
}, tr('toastCloned', { name: cloneName }))
|
||||
}
|
||||
@@ -1485,7 +1485,7 @@ export const App: React.FC = () => {
|
||||
onDelete={() => setDeleteTarget(vmRefKey(selectedVM))}
|
||||
onViewLogs={() => { openLogs('serial'); loadSerial() }}
|
||||
onCopy={copy}
|
||||
onTypeText={(text) => typeInto(vmRefKey(selectedVM), () => api.TypeTextWithDriver(selectedVM.driver_id ?? '', selectedVM.name, text))}
|
||||
onTypeText={(text) => typeInto(vmRefKey(selectedVM), () => api.TypeText(selectedVM.driver_id ?? '', selectedVM.name, text))}
|
||||
onToggleBorderless={(enabled) => {
|
||||
api.ToggleBorderless(selectedVM.name, enabled)
|
||||
.then(() => {
|
||||
@@ -1615,7 +1615,7 @@ export const App: React.FC = () => {
|
||||
locale={locale}
|
||||
detail={detail}
|
||||
driverID={selectedVM?.driver_id ?? ''}
|
||||
stats={latestVMStatsWithDriver(selectedVM?.driver_id ?? '', detail.name)}
|
||||
stats={latestVMStats(selectedVM?.driver_id ?? '', detail.name)}
|
||||
host={state.host}
|
||||
fixedModeSupported={fixedModeSupported}
|
||||
optimizations={state.optimizations}
|
||||
@@ -1752,12 +1752,12 @@ export const App: React.FC = () => {
|
||||
<SendTextDialog
|
||||
locale={locale}
|
||||
vmName={sendName}
|
||||
guestToolsConnected={Boolean(latestVMStatsWithDriver(sendVM?.driver_id ?? '', sendName)?.guest_tools_connected ?? (selectedIsMacOS ? detail?.guest_tools_connected : false))}
|
||||
guestToolsConnected={Boolean(latestVMStats(sendVM?.driver_id ?? '', sendName)?.guest_tools_connected ?? (selectedIsMacOS ? detail?.guest_tools_connected : false))}
|
||||
onCancel={() => setSendTextTarget(null)}
|
||||
onConfirm={(text) => {
|
||||
const target = sendTextTarget
|
||||
setSendTextTarget(null)
|
||||
typeInto(sendVM ? vmRefKey(sendVM) : target, () => api.TypeTextWithDriver(sendVM?.driver_id ?? '', sendName, text))
|
||||
typeInto(sendVM ? vmRefKey(sendVM) : target, () => api.TypeText(sendVM?.driver_id ?? '', sendName, text))
|
||||
}}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -15,7 +15,7 @@ import { BrandMark } from '../ui/themeVisuals'
|
||||
const DISCORD_INVITE_URL = 'https://discord.gg/Tj682rW5rS'
|
||||
const QQ_GROUP_ID = '1136042744'
|
||||
|
||||
export type AppUpdateChannel = 'stable' | 'alpha' | 'dev'
|
||||
type AppUpdateChannel = 'stable' | 'alpha' | 'dev'
|
||||
|
||||
interface Props {
|
||||
locale: Locale
|
||||
|
||||
@@ -100,7 +100,7 @@ export const AffinityDialog: React.FC<Props> = ({
|
||||
let live = true
|
||||
setLoading(true)
|
||||
setErr('')
|
||||
api.GetVMAffinityWithDriver(driverID, vmName)
|
||||
api.GetVMAffinity(driverID, vmName)
|
||||
.then((st) => {
|
||||
if (!live) return
|
||||
setStatus(st)
|
||||
@@ -206,7 +206,7 @@ export const AffinityDialog: React.FC<Props> = ({
|
||||
setSaving(true)
|
||||
setErr('')
|
||||
try {
|
||||
const updated = await api.SetVMAffinityWithDriver(driverID, vmName, {
|
||||
const updated = await api.SetVMAffinity(driverID, vmName, {
|
||||
mode,
|
||||
cpus: mode === 'custom' ? selected : [],
|
||||
disable_eco_qos: disableEcoQoS,
|
||||
|
||||
@@ -8,7 +8,6 @@ import '../i18n/domains/wizard.gen'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, locText, parseAppError, t } from '../i18n'
|
||||
import {
|
||||
GUEST_LANG_PRESETS,
|
||||
guestLangOptions,
|
||||
MEMORY_MARKS,
|
||||
controllerLabel,
|
||||
@@ -32,7 +31,6 @@ import {
|
||||
recommendedMemoryGB,
|
||||
recommendedResolution,
|
||||
shortGPUName,
|
||||
splitLangLabel,
|
||||
sshCommand,
|
||||
} from '../lib/format'
|
||||
import { CachedInstaller, CreateOpts, DriverSummary, HostReport, Locale, Release, Task, ValidationIssue, VMNetworkSettings } from '../types'
|
||||
|
||||
@@ -13,7 +13,7 @@ export const hasGuestArt = (family: GuestFamily): boolean => ART_FAMILIES.includ
|
||||
* names. macOS keeps its version artwork (VersionArt), so this returns null
|
||||
* for it and for an unknown family and the caller falls back to that artwork.
|
||||
*/
|
||||
export const GuestIcon: React.FC<{ family: GuestFamily; size?: number }> = ({ family, size = 15 }) => {
|
||||
const GuestIcon: React.FC<{ family: GuestFamily; size?: number }> = ({ family, size = 15 }) => {
|
||||
switch (family) {
|
||||
case 'linux':
|
||||
return <HostIcon name="guest-linux"><Terminal size={size} aria-hidden="true" /></HostIcon>
|
||||
|
||||
@@ -9,7 +9,7 @@ import { PluginPanelFrame } from './PluginPanelFrame'
|
||||
import { locText } from './SchemaForm'
|
||||
import { WordmarkLoader } from './WordmarkLoader'
|
||||
|
||||
export interface NativeImageSourceRenderOpts {
|
||||
interface NativeImageSourceRenderOpts {
|
||||
refreshSignal: number
|
||||
onBusyChange: (busy: boolean) => void
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import React from 'react'
|
||||
import { t } from '../i18n'
|
||||
import type { ParsedAppError } from '../i18n'
|
||||
import type { Locale } from '../types'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react'
|
||||
import { useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { parseAppError, t } from '../i18n'
|
||||
import type { ParsedAppError } from '../i18n'
|
||||
|
||||
@@ -93,7 +93,7 @@ const CUSTOM = '__custom'
|
||||
const PRIMARY_DISPLAY_OPT = '__primary'
|
||||
const RES_RE = /^\s*\d{3,5}\s*[x×]\s*\d{3,5}\s*$/i
|
||||
|
||||
type VMTimezoneStatus = Awaited<ReturnType<typeof api.GetVMTimezoneWithDriver>>
|
||||
type VMTimezoneStatus = Awaited<ReturnType<typeof api.GetVMTimezone>>
|
||||
|
||||
const GUEST_TOOLS_INSTALL_CMD = 'sh /Volumes/REIMSTOOLS/Install-Reims-Tools.command'
|
||||
const GUEST_TIMEZONE_APPLY_CMD = 'sh /Volumes/REIMSTOOLS/Apply-Timezone.command'
|
||||
@@ -387,9 +387,9 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
|
||||
useEffect(() => {
|
||||
let active = true
|
||||
api.GetVMAffinityWithDriver(driverID, detail.name)
|
||||
api.GetVMAffinity(driverID, detail.name)
|
||||
.then((st) => { if (active) setAffinityStatus(st) })
|
||||
.catch((e) => console.warn('[settings] GetVMAffinityWithDriver failed:', e))
|
||||
.catch((e) => console.warn('[settings] GetVMAffinity failed:', e))
|
||||
return () => { active = false }
|
||||
}, [detail.name, running, affinityVersion])
|
||||
|
||||
@@ -409,7 +409,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
let active = true
|
||||
const reqSeq = displayReqSeqRef.current
|
||||
if (displayBusyRef.current) return () => { active = false }
|
||||
api.GetVMDisplayWithDriver(driverID, detail.name)
|
||||
api.GetVMDisplay(driverID, detail.name)
|
||||
.then((st) => {
|
||||
if (active && displayReqSeqRef.current === reqSeq) {
|
||||
setDisplayStatus(st)
|
||||
@@ -430,7 +430,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
|
||||
useEffect(() => {
|
||||
if (cat !== 'general') return
|
||||
const { refresh, stop } = tzRequests.watch(vmSettingsKey, () => api.GetVMTimezoneWithDriver(driverID, detail.name))
|
||||
const { refresh, stop } = tzRequests.watch(vmSettingsKey, () => api.GetVMTimezone(driverID, detail.name))
|
||||
void refresh()
|
||||
const timer = window.setInterval(refresh, 3000)
|
||||
return () => { stop(); window.clearInterval(timer) }
|
||||
@@ -440,7 +440,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
if (busy || displayBusyRef.current || !tzStatus) return
|
||||
const currentSetting = tzStatus.mode === 'off' ? 'off' : tzStatus.mode === 'custom' ? tzStatus.timezone : 'host'
|
||||
if (nextSetting === currentSetting) return
|
||||
if (await tzRequests.write(vmSettingsKey, () => api.SetVMTimezoneWithDriver(driverID, detail.name, nextSetting))) {
|
||||
if (await tzRequests.write(vmSettingsKey, () => api.SetVMTimezone(driverID, detail.name, nextSetting))) {
|
||||
onToast({ kind: 'ok', title: tr('guestTimezoneSaved') })
|
||||
}
|
||||
}
|
||||
@@ -624,7 +624,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
setDisplayBusy(true)
|
||||
setDisplayErr('')
|
||||
try {
|
||||
const next = await api.SetVMDisplayWithDriver(driverID, vmName, nextTarget)
|
||||
const next = await api.SetVMDisplay(driverID, vmName, nextTarget)
|
||||
if (activeVMNameRef.current !== vmName || displayReqSeqRef.current !== opSeq) return
|
||||
setDisplayStatus(next)
|
||||
const chosenLabel = displayOptions.find((o) => o.value === nextValue)?.label
|
||||
@@ -1213,7 +1213,7 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
setErr('')
|
||||
setDiskOpBusy('resize')
|
||||
try {
|
||||
const res = await api.ResizeVMDiskWithDriver(driverID, vmName, resizeInput.trim())
|
||||
const res = await api.ResizeVMDisk(driverID, vmName, resizeInput.trim())
|
||||
if (activeVMNameRef.current === vmName) {
|
||||
setResizeResult(res)
|
||||
}
|
||||
@@ -1243,13 +1243,13 @@ export const SettingsModal: React.FC<Props> = ({ locale, detail, driverID, stats
|
||||
setDiskOpBusy(optimize ? 'optimize' : 'compact')
|
||||
try {
|
||||
if (optimize) {
|
||||
const res = await api.OptimizeVMDiskWithDriver(driverID, vmName)
|
||||
const res = await api.OptimizeVMDisk(driverID, vmName)
|
||||
if (activeVMNameRef.current === vmName) {
|
||||
setOptimizeResult(res)
|
||||
setCompactResult(null)
|
||||
}
|
||||
} else {
|
||||
const res = await api.CompactVMDiskWithDriver(driverID, vmName)
|
||||
const res = await api.CompactVMDisk(driverID, vmName)
|
||||
if (activeVMNameRef.current === vmName) {
|
||||
setCompactResult(res)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useState } from 'react'
|
||||
import { useEffect, useState } from 'react'
|
||||
import '../i18n/domains/settings.gen'
|
||||
import { parseAppError, t } from '../i18n'
|
||||
import type { I18nKey, ParsedAppError } from '../i18n'
|
||||
|
||||
@@ -97,7 +97,7 @@ const OFFLINE_INSTALL_CMD = 'sh /Volumes/REIMSHELP/install.sh'
|
||||
const GUEST_TOOLS_INSTALL_CMD = 'sh /Volumes/REIMSTOOLS/Install-Reims-Tools.command'
|
||||
const HOST_DNS_APPLY_CMD = 'sh /Volumes/REIMSTOOLS/Apply-Host-DNS.command'
|
||||
const HOST_DNS_DISABLE_CMD = 'sh /Volumes/REIMSTOOLS/Disable-Host-DNS.command'
|
||||
export const PRIMARY_SHORTCUT = 'Ctrl+Enter'
|
||||
const PRIMARY_SHORTCUT = 'Ctrl+Enter'
|
||||
|
||||
const GUEST_FAMILY_LABEL: Record<string, string> = { macos: 'macOS', linux: 'Linux', windows: 'Windows', android: 'Android' }
|
||||
|
||||
@@ -346,9 +346,9 @@ export const VMPage: React.FC<Props> = ({
|
||||
let live = true
|
||||
const pull = () => {
|
||||
if (document.hidden) return
|
||||
api.GetVMThumbnailWithDriver(driverID, name)
|
||||
api.GetVMThumbnail(driverID, name)
|
||||
.then((t) => { if (live && t?.data_url) setThumb(t) })
|
||||
.catch((e) => console.warn('[vm] GetVMThumbnailWithDriver failed:', e))
|
||||
.catch((e) => console.warn('[vm] GetVMThumbnail failed:', e))
|
||||
}
|
||||
pull()
|
||||
const timer = running ? window.setInterval(pull, 15000) : undefined
|
||||
@@ -377,7 +377,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
if (next === name) next = ''
|
||||
if (next === displayName) return
|
||||
try {
|
||||
await api.SetVMNoteWithDriver(driverID, name, next)
|
||||
await api.SetVMNote(driverID, name, next)
|
||||
onDisplayNameSaved(next)
|
||||
} catch (e) {
|
||||
onError(tr('failGeneric'), e)
|
||||
@@ -399,7 +399,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
// The remembered SSH user belongs to the macOS connection row; other drivers keep theirs in their endpoints.
|
||||
if (!isMacOSDriver) { setSshUser(''); return }
|
||||
let live = true
|
||||
api.GetVMSSHUserWithDriver(driverID, name).then((u) => { if (live) setSshUser(u ?? '') }).catch(() => { if (live) setSshUser('') })
|
||||
api.GetVMSSHUser(driverID, name).then((u) => { if (live) setSshUser(u ?? '') }).catch(() => { if (live) setSshUser('') })
|
||||
return () => { live = false }
|
||||
}, [driverID, name, isMacOSDriver])
|
||||
|
||||
@@ -408,13 +408,13 @@ export const VMPage: React.FC<Props> = ({
|
||||
setEndpointBusy(busyKey)
|
||||
const done = () => setEndpointBusy((cur) => (cur === busyKey ? '' : cur))
|
||||
if (action === 'copy') {
|
||||
api.GetVMEndpointCommandWithDriver(driverID, name, ep.kind)
|
||||
api.GetVMEndpointCommand(driverID, name, ep.kind)
|
||||
.then((cmd) => onCopy(cmd))
|
||||
.catch((e) => onError(tr('failEndpointCommand'), e))
|
||||
.finally(done)
|
||||
return
|
||||
}
|
||||
api.OpenVMEndpointWithDriver(driverID, name, ep.kind, action)
|
||||
api.OpenVMEndpoint(driverID, name, ep.kind, action)
|
||||
.catch((e) => onError(tr('failEndpointOpen'), e))
|
||||
.finally(done)
|
||||
}
|
||||
@@ -441,21 +441,21 @@ export const VMPage: React.FC<Props> = ({
|
||||
}
|
||||
|
||||
const openSSHTerminal = () => {
|
||||
api.OpenSSHTerminalWithDriver(driverID, name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
api.OpenSSHTerminal(driverID, name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
}
|
||||
const writeSSHConfig = () => {
|
||||
api.WriteSSHConfigWithDriver(driverID, name, sshUser)
|
||||
api.WriteSSHConfig(driverID, name, sshUser)
|
||||
.then((alias) => onToast(tr('toastSSHConfigWritten', { alias })))
|
||||
.catch((e) => onError(tr('failSSH'), e))
|
||||
}
|
||||
const openVSCodeSSH = () => {
|
||||
api.OpenVSCodeSSHWithDriver(driverID, name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
api.OpenVSCodeSSH(driverID, name, sshUser).catch((e) => onError(tr('failSSH'), e))
|
||||
}
|
||||
const saveSSHUser = async () => {
|
||||
const next = sshUserDraft.trim()
|
||||
setSshUserDialog(false)
|
||||
try {
|
||||
await api.SetVMSSHUserWithDriver(driverID, name, next)
|
||||
await api.SetVMSSHUser(driverID, name, next)
|
||||
setSshUser(next)
|
||||
onToast(tr('toastSSHUserSaved'))
|
||||
} catch (e) {
|
||||
@@ -495,7 +495,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
|
||||
const loadSnapshots = () => {
|
||||
if (!showSnapshots) { setSnapshots([]); return }
|
||||
api.ListSnapshotsWithDriver(driverID, name).then((list) => setSnapshots(list ?? [])).catch(() => setSnapshots([]))
|
||||
api.ListSnapshots(driverID, name).then((list) => setSnapshots(list ?? [])).catch(() => setSnapshots([]))
|
||||
}
|
||||
useEffect(() => {
|
||||
setCreatingSnap(false)
|
||||
@@ -510,7 +510,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
if (!label) return
|
||||
setSnapBusy('create')
|
||||
try {
|
||||
await api.CreateSnapshotWithDriver(driverID, name, label)
|
||||
await api.CreateSnapshot(driverID, name, label)
|
||||
setSnapDraft('')
|
||||
setCreatingSnap(false)
|
||||
onToast(tr('toastSnapshotCreated', { name: label }))
|
||||
@@ -525,7 +525,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
setRestoreTarget(null)
|
||||
setSnapBusy(`restore:${snapName}`)
|
||||
try {
|
||||
await api.RestoreSnapshotWithDriver(driverID, name, snapName)
|
||||
await api.RestoreSnapshot(driverID, name, snapName)
|
||||
onToast(tr('toastSnapshotRestored', { name: snapName }))
|
||||
loadSnapshots()
|
||||
} catch (e) {
|
||||
@@ -537,7 +537,7 @@ export const VMPage: React.FC<Props> = ({
|
||||
const handleDeleteSnapshot = async (snapName: string) => {
|
||||
setSnapBusy(`delete:${snapName}`)
|
||||
try {
|
||||
await api.DeleteSnapshotWithDriver(driverID, name, snapName)
|
||||
await api.DeleteSnapshot(driverID, name, snapName)
|
||||
onToast(tr('toastSnapshotDeleted', { name: snapName }))
|
||||
loadSnapshots()
|
||||
} catch (e) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { builtinDict, registerBuiltinDomain } from './i18n/runtime'
|
||||
export type { I18nKey }
|
||||
export { registerBuiltinDomain }
|
||||
|
||||
export interface LocaleOption {
|
||||
interface LocaleOption {
|
||||
value: Locale
|
||||
label: string
|
||||
detail?: string
|
||||
@@ -65,11 +65,11 @@ function primarySubtag(tag: string): string {
|
||||
return idx >= 0 ? s.slice(0, idx) : s
|
||||
}
|
||||
|
||||
export function isZhLocale(locale: Locale): boolean {
|
||||
function isZhLocale(locale: Locale): boolean {
|
||||
return primarySubtag(locale) === 'zh'
|
||||
}
|
||||
|
||||
export function isCJKLocale(locale: Locale): boolean {
|
||||
function isCJKLocale(locale: Locale): boolean {
|
||||
const p = primarySubtag(locale)
|
||||
return p === 'zh' || p === 'ja' || p === 'ko'
|
||||
}
|
||||
@@ -87,7 +87,7 @@ function isBuiltinLocale(locale: string): locale is BuiltinLocale {
|
||||
return locale === 'zh-CN' || locale === 'en-US'
|
||||
}
|
||||
|
||||
export function canonicalizeTag(raw: string | undefined): string {
|
||||
function canonicalizeTag(raw: string | undefined): string {
|
||||
if (!raw) return ''
|
||||
const clean = raw.trim().split(/[.@]/)[0].replaceAll('_', '-')
|
||||
const low = clean.toLowerCase()
|
||||
|
||||
@@ -51,7 +51,7 @@ export function formatLocaleNumber(locale: string, value: number, precision = -1
|
||||
const MAX_ICU_DEPTH = 16
|
||||
const MAX_ICU_TEMPLATE_LEN = 16384
|
||||
|
||||
export function parseICU(tmpl: string): ICUNode[] | null {
|
||||
function parseICU(tmpl: string): ICUNode[] | null {
|
||||
if (tmpl.length > MAX_ICU_TEMPLATE_LEN) return null
|
||||
if (astCache.has(tmpl)) {
|
||||
return astCache.get(tmpl) ?? null
|
||||
|
||||
@@ -3,13 +3,13 @@
|
||||
// visibility:hidden/collapse, [hidden], [inert], aria-hidden="true",
|
||||
// data-state="closed") must not block global shortcuts or menu focus return.
|
||||
|
||||
export interface DialogLikeElement {
|
||||
interface DialogLikeElement {
|
||||
getAttribute(name: string): string | null
|
||||
closest?(selector: string): unknown
|
||||
parentElement?: DialogLikeElement | null
|
||||
}
|
||||
|
||||
export interface ComputedVisibility {
|
||||
interface ComputedVisibility {
|
||||
display: string
|
||||
visibility: string
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { VMEndpoint, VMInfo, VMListItem } from '../types'
|
||||
// Guest family, driver capabilities and endpoint ordering for non-macOS guests.
|
||||
// Everything here is pure so node:test can load it (scripts/test-endpoints.mjs).
|
||||
|
||||
export const BUILTIN_MACOS_DRIVER = 'builtin.driver.reims-macos'
|
||||
const BUILTIN_MACOS_DRIVER = 'builtin.driver.reims-macos'
|
||||
|
||||
export type GuestFamily = 'macos' | 'linux' | 'windows' | 'android' | ''
|
||||
|
||||
@@ -85,7 +85,7 @@ export function vmFeatures(vm?: { driver_id?: string; capabilities?: readonly st
|
||||
/** Highest priority first: the first ready endpoint in this order is the primary hosted action. */
|
||||
export const ENDPOINT_PRIORITY = ['vmconnect', 'rdp', 'wsl', 'ssh', 'adb'] as const
|
||||
|
||||
export type EndpointKind = (typeof ENDPOINT_PRIORITY)[number]
|
||||
type EndpointKind = (typeof ENDPOINT_PRIORITY)[number]
|
||||
|
||||
export type EndpointAction = 'open' | 'terminal' | 'vscode' | 'config' | 'edit' | 'shell' | 'copy'
|
||||
|
||||
@@ -102,7 +102,7 @@ function rank(kind: string): number {
|
||||
return i < 0 ? ENDPOINT_PRIORITY.length : i
|
||||
}
|
||||
|
||||
export function isEndpointKind(kind: string): kind is EndpointKind {
|
||||
function isEndpointKind(kind: string): kind is EndpointKind {
|
||||
return rank(kind) < ENDPOINT_PRIORITY.length
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ export function secondaryEndpointActions(kind: string): EndpointAction[] {
|
||||
return endpointActions(kind).slice(1)
|
||||
}
|
||||
|
||||
export interface EndpointSplit {
|
||||
interface EndpointSplit {
|
||||
/** The highest-priority ready endpoint; absent when none is ready. */
|
||||
primary?: VMEndpoint
|
||||
/** All other endpoints in priority order, never the primary one. */
|
||||
|
||||
@@ -10,10 +10,6 @@ function currentDocLocale(): string {
|
||||
// Human-readable values for the main view (see docs/design-guidelines.md).
|
||||
// Raw values stay available under "Technical details".
|
||||
|
||||
export function formatNameList(locale: Locale, names: string[]): string {
|
||||
return new Intl.ListFormat(locale === 'auto' ? currentDocLocale() : locale, { style: 'long', type: 'conjunction' }).format(names)
|
||||
}
|
||||
|
||||
const MEMORY_CHOICES = [4, 6, 8, 12, 16, 24, 32, 48, 64]
|
||||
|
||||
/**
|
||||
@@ -143,7 +139,7 @@ export function shortGPUName(name: string): string {
|
||||
}
|
||||
|
||||
/** "1920x1080" → "1080p"; non-16:9 sizes keep "W×H". */
|
||||
export function resolutionLabel(raw: string): string {
|
||||
function resolutionLabel(raw: string): string {
|
||||
const m = /^(\d+)\s*[x×]\s*(\d+)$/i.exec(raw ?? '')
|
||||
if (!m) return raw
|
||||
const w = Number(m[1]), h = Number(m[2])
|
||||
@@ -426,7 +422,7 @@ export function recommendedResolution(host: HostReport): string {
|
||||
return rec?.resolution ?? '1920x1080'
|
||||
}
|
||||
|
||||
export interface GuestLangPreset {
|
||||
interface GuestLangPreset {
|
||||
value: string
|
||||
labelKey: I18nKey
|
||||
detailKey?: I18nKey
|
||||
@@ -472,15 +468,6 @@ export function guestLangLabel(locale: Locale, code: string | undefined): string
|
||||
return detail ? `${label} (${detail})` : label
|
||||
}
|
||||
|
||||
/**
|
||||
* Split "简体中文(美式键盘,推荐)" / "Simplified Chinese (US Keyboard)" into a
|
||||
* pop-up label and its grey detail, so the menu reads like macOS.
|
||||
*/
|
||||
export function splitLangLabel(value: string, text: string): { value: string; label: string; detail?: string } {
|
||||
const m = /^(.*?)\s*[((](.*)[))]\s*$/.exec(text)
|
||||
return m ? { value, label: m[1], detail: m[2] } : { value, label: text }
|
||||
}
|
||||
|
||||
/**
|
||||
* A change saved while the VM runs, as the user would say it:
|
||||
* `memory 8G→16G` becomes "内存 8 GB → 16 GB". Field names come from
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
export const DEFAULT_FULLSCREEN_HOTKEY = 'Ctrl+Shift+F'
|
||||
|
||||
export interface HotkeyModifiers {
|
||||
interface HotkeyModifiers {
|
||||
ctrl: boolean
|
||||
shift: boolean
|
||||
alt: boolean
|
||||
win: boolean
|
||||
}
|
||||
|
||||
export interface HotkeyKeyEventLike {
|
||||
interface HotkeyKeyEventLike {
|
||||
code?: string
|
||||
key?: string
|
||||
ctrlKey?: boolean
|
||||
@@ -17,15 +17,15 @@ export interface HotkeyKeyEventLike {
|
||||
repeat?: boolean
|
||||
}
|
||||
|
||||
export type FullscreenHotkeyErrorReason = 'unsupported' | 'needs_modifier' | 'reserved'
|
||||
type FullscreenHotkeyErrorReason = 'unsupported' | 'needs_modifier' | 'reserved'
|
||||
|
||||
export type FullscreenHotkeyCaptureResult =
|
||||
type FullscreenHotkeyCaptureResult =
|
||||
| { kind: 'cancel' }
|
||||
| { kind: 'ignore' }
|
||||
| { kind: 'ok'; hotkey: string }
|
||||
| { kind: 'error'; reason: FullscreenHotkeyErrorReason; hotkey?: string }
|
||||
|
||||
export type FullscreenHotkeyParseResult =
|
||||
type FullscreenHotkeyParseResult =
|
||||
| { ok: true; hotkey: string }
|
||||
| { ok: false; reason: FullscreenHotkeyErrorReason | 'invalid'; hotkey?: string }
|
||||
|
||||
@@ -100,11 +100,11 @@ const CODE_TO_KEY: Record<string, string> = {
|
||||
ArrowRight: 'Right',
|
||||
}
|
||||
|
||||
export function isFunctionKey(key: string): boolean {
|
||||
function isFunctionKey(key: string): boolean {
|
||||
return /^F(?:[1-9]|1[0-2])$/.test(key)
|
||||
}
|
||||
|
||||
export function isReservedFullscreenHotkey(mods: HotkeyModifiers, key: string): boolean {
|
||||
function isReservedFullscreenHotkey(mods: HotkeyModifiers, key: string): boolean {
|
||||
return (
|
||||
(mods.ctrl && mods.alt && key === 'Delete') ||
|
||||
(mods.alt && (key === 'F4' || key === 'Tab')) ||
|
||||
@@ -158,7 +158,7 @@ function mapEventPrimaryKey(e: HotkeyKeyEventLike): string | null {
|
||||
return normalizePrimaryToken(key, EVENT_KEY_ALIASES)
|
||||
}
|
||||
|
||||
export function parseFullscreenHotkey(raw: string): FullscreenHotkeyParseResult {
|
||||
function parseFullscreenHotkey(raw: string): FullscreenHotkeyParseResult {
|
||||
const input = trimGoSpace(raw) || DEFAULT_FULLSCREEN_HOTKEY
|
||||
const mods: HotkeyModifiers = { ctrl: false, shift: false, alt: false, win: false }
|
||||
let primary = ''
|
||||
|
||||
@@ -3,7 +3,7 @@ import { I18nKey, t } from '../i18n'
|
||||
import { vmRefKey } from './vmRef'
|
||||
import type { Config, HostReport, Locale, Task, VMListItem } from '../types'
|
||||
|
||||
export interface HypervisorSettingsView {
|
||||
interface HypervisorSettingsView {
|
||||
supported: boolean
|
||||
gateEnabled: boolean
|
||||
expanded: boolean
|
||||
@@ -18,7 +18,7 @@ export interface HypervisorSettingsView {
|
||||
showHVCINotice: boolean
|
||||
}
|
||||
|
||||
export interface HostWHPXSummary {
|
||||
interface HostWHPXSummary {
|
||||
short: string
|
||||
hint: string
|
||||
tone: 'ok' | 'warn'
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import { LogEntry } from '../types'
|
||||
|
||||
export type LogLevel = 'info' | 'warn' | 'error'
|
||||
type LogLevel = 'info' | 'warn' | 'error'
|
||||
|
||||
export interface LogLine extends LogEntry {
|
||||
id: number
|
||||
level: LogLevel
|
||||
}
|
||||
|
||||
export const MAX_LOG_LINES = 2000
|
||||
const MAX_LOG_LINES = 2000
|
||||
|
||||
// Progress no longer reaches the log: the backend turns it into tasks
|
||||
// (tasks.go, "reims:task"). Levels are still guessed from the text until the
|
||||
@@ -17,7 +17,7 @@ const WARN_RE = /\bwarn(ing)?\b/i
|
||||
|
||||
let nextId = 1
|
||||
|
||||
export function classify(entry: LogEntry): LogLine {
|
||||
function classify(entry: LogEntry): LogLine {
|
||||
const ts = typeof entry?.ts === 'string' ? entry.ts : ''
|
||||
const source = typeof entry?.source === 'string' ? entry.source : ''
|
||||
const line = typeof entry?.line === 'string' ? entry.line : String(entry?.line ?? '')
|
||||
|
||||
@@ -2,7 +2,7 @@ import '../i18n/domains/settings.gen'
|
||||
import { I18nKey, t } from '../i18n'
|
||||
import { Locale, Optimization, OptimizationStatus } from '../types'
|
||||
|
||||
export type KernelIrqchipMode = 'auto' | 'on' | 'off'
|
||||
type KernelIrqchipMode = 'auto' | 'on' | 'off'
|
||||
|
||||
export function findOptimization(list: Optimization[] | undefined, id: string): Optimization | undefined {
|
||||
return (list ?? []).find((o) => o.id === id)
|
||||
|
||||
@@ -19,7 +19,7 @@ export interface PluginFormResult {
|
||||
values?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface PluginViewActionHandlers {
|
||||
interface PluginViewActionHandlers {
|
||||
invoke(method: string, params: Record<string, unknown>): Promise<unknown>
|
||||
confirm(request: PluginConfirmRequest): Promise<boolean>
|
||||
showForm(request: PluginFormRequest): Promise<PluginFormResult>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export type PluginHostEvent = 'vm.stateChanged' | 'task.updated'
|
||||
export type PluginHostEventListener = (event: PluginHostEvent, data: unknown) => void
|
||||
type PluginHostEvent = 'vm.stateChanged' | 'task.updated'
|
||||
type PluginHostEventListener = (event: PluginHostEvent, data: unknown) => void
|
||||
|
||||
const listeners = new Set<PluginHostEventListener>()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export type PluginViewLocation = 'sidebar' | 'vm.tab' | 'settings' | 'dialog'
|
||||
type PluginViewLocation = 'sidebar' | 'vm.tab' | 'settings' | 'dialog'
|
||||
|
||||
export interface PluginViewRoute {
|
||||
pluginId: string
|
||||
|
||||
@@ -93,14 +93,14 @@ export function taskInstallerKey(task: Task): string {
|
||||
return `${kind}:${v}`
|
||||
}
|
||||
|
||||
export function matchesOnlineInstallerTitle(title: string | undefined, target: string): boolean {
|
||||
function matchesOnlineInstallerTitle(title: string | undefined, target: string): boolean {
|
||||
const want = target.trim().toLowerCase()
|
||||
if (!want) return false
|
||||
const norm = (title ?? '').trim().toLowerCase().replace(/^macos\s+/, '')
|
||||
return norm === want || norm.replace(/\s+/g, '-') === want
|
||||
}
|
||||
|
||||
export function matchesCachedInstaller(item: CachedInstaller, task: Task): boolean {
|
||||
function matchesCachedInstaller(item: CachedInstaller, task: Task): boolean {
|
||||
if (!isActiveInstallerTask(task)) return false
|
||||
const kind = taskInstallerKind(task)
|
||||
if (!kind || kind !== item.kind) return false
|
||||
|
||||
@@ -86,7 +86,7 @@ function decodeCSSEscapes(s: string): string {
|
||||
}
|
||||
|
||||
/** Validates a token key+value against the UI Contract whitelist and CSS injection rules. */
|
||||
export function sanitizeTokenValue(key: string, value: string): string | null {
|
||||
function sanitizeTokenValue(key: string, value: string): string | null {
|
||||
if (!ALLOWED_CONTRACT_TOKENS.has(key)) return null
|
||||
if (typeof value !== 'string') return null
|
||||
const trimmed = value.trim()
|
||||
@@ -133,7 +133,7 @@ const LAYOUT_ATTRS: Record<string, string> = {
|
||||
const ALLOWED_LAYOUT = new Set<string>(UI_CONTRACT_LAYOUT_OPTIONS)
|
||||
|
||||
/** Writes the active theme's layout options as data-layout-* attributes; null clears them. */
|
||||
export function applyThemeLayout(layout: Record<string, unknown> | null | undefined): void {
|
||||
function applyThemeLayout(layout: Record<string, unknown> | null | undefined): void {
|
||||
const el = document.documentElement
|
||||
for (const [option, attr] of Object.entries(LAYOUT_ATTRS)) {
|
||||
const value = layout?.[option]
|
||||
@@ -143,7 +143,7 @@ export function applyThemeLayout(layout: Record<string, unknown> | null | undefi
|
||||
}
|
||||
|
||||
/** Verifies stylesheet has balanced braces and no unclosed strings/comments so it cannot escape `@layer theme`. */
|
||||
export function isBalancedThemeCSS(css: string): boolean {
|
||||
function isBalancedThemeCSS(css: string): boolean {
|
||||
if (css.toLowerCase().includes('</style')) return false
|
||||
let depth = 0
|
||||
const n = css.length
|
||||
@@ -655,18 +655,3 @@ export function disposeActiveThemeAndLocaleFonts(): void {
|
||||
export function notifyInteractiveThemeState(snap: UIStateSnapshot): void {
|
||||
activeUIScriptNotifier?.(snap)
|
||||
}
|
||||
|
||||
/** Plays a theme-configured sound for an event if present (fail-silent). */
|
||||
export function playThemeSound(payload: ActiveThemePayload | null, eventName: string): void {
|
||||
const file = payload?.theme?.sounds?.[eventName]
|
||||
if (!file || !payload?.asset_base_url) return
|
||||
const safe = sanitizeRelativeAssetPath(file)
|
||||
if (!safe) return
|
||||
try {
|
||||
const audio = new Audio(payload.asset_base_url + safe)
|
||||
audio.volume = 0.35
|
||||
void audio.play().catch((e) => console.warn('[theme] sound playback failed:', eventName, e))
|
||||
} catch (e) {
|
||||
console.warn('[theme] sound init failed:', eventName, e)
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
import { hideWailsGlobals } from '../wails'
|
||||
import type { ThemeSDKHostActions, UIStateSnapshot } from './themeEngine'
|
||||
|
||||
export interface ReimsUISDK {
|
||||
interface ReimsUISDK {
|
||||
readonly uiApi: string
|
||||
/** Stable host features (e.g. `slot.sidebar.footer`); feature-detect instead of comparing versions. */
|
||||
readonly features: readonly string[]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export interface VMRefLike {
|
||||
interface VMRefLike {
|
||||
name: string
|
||||
driver_id?: string
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ const statsKey = (driverID: string, name: string) => `${driverID}:${name}`
|
||||
function sample(key: string, driverID: string, name: string, entryRef: Entry) {
|
||||
if (entries.get(key) !== entryRef) return
|
||||
const reqSeq = ++entryRef.seq
|
||||
api.GetVMStatsWithDriver(driverID, name)
|
||||
api.GetVMStats(driverID, name)
|
||||
.then((s) => {
|
||||
if (entries.get(key) !== entryRef || reqSeq <= entryRef.appliedSeq) return
|
||||
entryRef.appliedSeq = reqSeq
|
||||
entryRef.last = s
|
||||
entryRef.subs.forEach((f) => f(s))
|
||||
})
|
||||
.catch((e) => console.warn('[vmStats] GetVMStatsWithDriver failed:', key, e))
|
||||
.catch((e) => console.warn('[vmStats] GetVMStats failed:', key, e))
|
||||
}
|
||||
|
||||
function schedule(key: string, driverID: string, name: string, e: Entry) {
|
||||
@@ -51,13 +51,12 @@ if (typeof document !== 'undefined') {
|
||||
}
|
||||
|
||||
/** Latest stats seen for a VM, without subscribing (e.g. when a dialog opens). */
|
||||
export function latestVMStatsWithDriver(driverID: string, name: string | undefined | null): VMStats | null {
|
||||
export function latestVMStats(driverID: string, name: string | undefined | null): VMStats | null {
|
||||
return name ? entries.get(statsKey(driverID, name))?.last ?? null : null
|
||||
}
|
||||
export function latestVMStats(name: string | undefined | null): VMStats | null { return latestVMStatsWithDriver('', name) }
|
||||
|
||||
/** Immediately patch cached stats (if any) and re-sample a VM's stats. */
|
||||
export function refreshVMStatsWithDriver(driverID: string, name: string, patch?: Partial<VMStats>) {
|
||||
export function refreshVMStats(driverID: string, name: string, patch?: Partial<VMStats>) {
|
||||
const key = statsKey(driverID, name)
|
||||
const e = entries.get(key)
|
||||
if (!e) return
|
||||
@@ -68,7 +67,6 @@ export function refreshVMStatsWithDriver(driverID: string, name: string, patch?:
|
||||
}
|
||||
sample(key, driverID, name, e)
|
||||
}
|
||||
export function refreshVMStats(name: string, patch?: Partial<VMStats>) { refreshVMStatsWithDriver('', name, patch) }
|
||||
|
||||
/** Re-sample all currently subscribed VMs (e.g. after a tray-triggered state change). */
|
||||
export function refreshSubscribedVMStats() {
|
||||
@@ -82,7 +80,7 @@ export function refreshSubscribedVMStats() {
|
||||
|
||||
/** Live stats for one VM; `running` picks the sampling rate. Null name: none. */
|
||||
export function useVMStats(driverID: string, name: string | null, running: boolean): VMStats | null {
|
||||
const [stats, setStats] = useState<VMStats | null>(() => latestVMStatsWithDriver(driverID, name))
|
||||
const [stats, setStats] = useState<VMStats | null>(() => latestVMStats(driverID, name))
|
||||
useEffect(() => {
|
||||
if (!name) { setStats(null); return }
|
||||
const key = statsKey(driverID, name)
|
||||
|
||||
@@ -238,31 +238,6 @@ export const UI_CONTRACT_TOKENS = [
|
||||
'--titlebar-h', '--logbar-h', '--sidebar-w', '--page-max',
|
||||
] as const
|
||||
|
||||
export const UI_CONTRACT = {
|
||||
uiApi: UI_API_VERSION,
|
||||
parts: [...UI_CONTRACT_PARTS],
|
||||
stateAttrs: [...UI_CONTRACT_STATE_ATTRS],
|
||||
itemStates: [...UI_CONTRACT_ITEM_STATES],
|
||||
slots: [...UI_CONTRACT_SLOTS],
|
||||
layers: [...UI_CONTRACT_LAYERS],
|
||||
layoutOptions: [...UI_CONTRACT_LAYOUT_OPTIONS],
|
||||
icons: [...UI_CONTRACT_ICONS],
|
||||
viewLocations: [...UI_CONTRACT_VIEW_LOCATIONS],
|
||||
sdkEvents: [...UI_CONTRACT_SDK_EVENTS],
|
||||
tokens: [...UI_CONTRACT_TOKENS],
|
||||
experimental: {
|
||||
parts: [...UI_CONTRACT_PARTS_EXPERIMENTAL],
|
||||
stateAttrs: [...UI_CONTRACT_STATE_ATTRS_EXPERIMENTAL],
|
||||
itemStates: [...UI_CONTRACT_ITEM_STATES_EXPERIMENTAL],
|
||||
slots: [...UI_CONTRACT_SLOTS_EXPERIMENTAL],
|
||||
layers: [...UI_CONTRACT_LAYERS_EXPERIMENTAL],
|
||||
layoutOptions: [...UI_CONTRACT_LAYOUT_OPTIONS_EXPERIMENTAL],
|
||||
icons: [...UI_CONTRACT_ICONS_EXPERIMENTAL],
|
||||
viewLocations: [...UI_CONTRACT_VIEW_LOCATIONS_EXPERIMENTAL],
|
||||
sdkEvents: [...UI_CONTRACT_SDK_EVENTS_EXPERIMENTAL],
|
||||
},
|
||||
}
|
||||
|
||||
// Stable host features advertised to themes through the UI SDK.
|
||||
export const UI_CONTRACT_FEATURES: readonly string[] = [
|
||||
...UI_CONTRACT_SLOTS.map((s) => `slot.${s}`),
|
||||
|
||||
+6
-22
@@ -16,11 +16,9 @@ export type Config = Model<config.Config> & {
|
||||
|
||||
export type DisplayInfo = host.DisplayInfo
|
||||
export type DisplayPreset = host.DisplayPreset
|
||||
export type AudioInfo = host.AudioInfo
|
||||
export type WHPXCapabilities = host.WHPXCapabilities
|
||||
export type LogicalCPUInfo = host.LogicalCPUInfo
|
||||
|
||||
export type GPUCompat = 'supported' | 'warn' | 'unsupported' | 'unknown'
|
||||
type GPUCompat = 'supported' | 'warn' | 'unsupported' | 'unknown'
|
||||
|
||||
export type GPUInfo = Omit<Model<host.GPUInfo>, 'compat'> & {
|
||||
kind: 'discrete' | 'integrated' | 'virtual' | 'unknown'
|
||||
@@ -41,16 +39,15 @@ export type HostReport = Omit<Model<host.Report>, 'gpus' | 'recommended_gpu'> &
|
||||
recommended_gpu?: GPUInfo
|
||||
}
|
||||
|
||||
export type RuntimeManifest = Model<runtime.Manifest>
|
||||
export type InstalledRuntime = Model<runtime.Installed>
|
||||
|
||||
export type RemoteRuntime = Model<runtime.Remote> & {
|
||||
channel: 'stable' | 'alpha'
|
||||
}
|
||||
|
||||
export type VMState = 'running' | 'stopped' | 'suspended' | 'broken' | 'driver_unavailable'
|
||||
export type VMPhase = 'normal' | 'installer' | 'recovery'
|
||||
export type GuestOSInfo = Model<driver.GuestOSInfo>
|
||||
type VMState = 'running' | 'stopped' | 'suspended' | 'broken' | 'driver_unavailable'
|
||||
type VMPhase = 'normal' | 'installer' | 'recovery'
|
||||
type GuestOSInfo = Model<driver.GuestOSInfo>
|
||||
export type VMEndpoint = Model<driver.VMEndpoint> & {
|
||||
kind: 'ssh' | 'wsl' | 'rdp' | 'vmconnect' | 'adb' | (string & {})
|
||||
}
|
||||
@@ -83,7 +80,6 @@ export type AppState = Omit<Model<app.AppState>, 'config' | 'host' | 'optimizati
|
||||
}
|
||||
|
||||
export type AppUpdateInfo = version.UpdateInfo
|
||||
export type SuspendInfo = reims.SuspendInfo
|
||||
export type VMDetail = reims.VMDetail
|
||||
export type SMBIOSIdentity = opencore.SMBIOSIdentity
|
||||
export type VMStats = app.VMStats
|
||||
@@ -126,7 +122,7 @@ export type CreateOpts = Model<reims.CreateOpts> & {
|
||||
displays: number
|
||||
}
|
||||
|
||||
export type TaskStatus = 'running' | 'done' | 'failed' | 'canceled'
|
||||
type TaskStatus = 'running' | 'done' | 'failed' | 'canceled'
|
||||
|
||||
export type InstallerKind = 'offline' | 'online'
|
||||
export type InstallerPhase = 'queued' | 'downloading'
|
||||
@@ -155,23 +151,15 @@ export type PermissionSpec = plugin.PermissionSpec
|
||||
export type SettingProperty = plugin.SettingProperty
|
||||
export type SettingsSchema = plugin.SettingsSchema
|
||||
export type PluginInfo = plugin.PluginInfo
|
||||
export type DoctorFinding = plugin.DoctorFinding
|
||||
export type ScanFinding = plugin.ScanFinding
|
||||
export type ExecutableFile = plugin.ExecutableFile
|
||||
export type CapabilityItem = plugin.CapabilityItem
|
||||
export type ScanReport = plugin.ScanReport
|
||||
export type MarketEntry = plugin.MarketEntry
|
||||
export type MarketWithdrawal = plugin.MarketWithdrawal
|
||||
export type MarketCatalogItem = plugin.MarketCatalogItem
|
||||
export type MarketBrowseResult = plugin.MarketBrowseResult
|
||||
export type TokenDeriveRule = plugin.TokenDeriveRule
|
||||
export type ThemeScheme = plugin.ThemeScheme
|
||||
export type ThemeDecoration = plugin.ThemeDecoration
|
||||
export type ThemeDecorationState = plugin.ThemeDecorationState
|
||||
export type ThemeContribution = plugin.ThemeContribution
|
||||
export type CustomThemeScheme = plugin.CustomThemeScheme
|
||||
export type ActiveThemePayload = plugin.ActiveThemePayload
|
||||
export interface ResolvedLocaleFont {
|
||||
interface ResolvedLocaleFont {
|
||||
family: string
|
||||
url: string
|
||||
weight?: string
|
||||
@@ -184,15 +172,11 @@ export type ResolvedLocalePack = Model<plugin.ResolvedLocalePack> & {
|
||||
plugin_messages?: Record<string, Record<string, string>>
|
||||
fonts?: ResolvedLocaleFont[]
|
||||
}
|
||||
export type MenuContribution = plugin.MenuContribution
|
||||
export type VMCardContribution = plugin.VMCardContribution
|
||||
export type PanelContribution = plugin.PanelContribution
|
||||
export type ViewContribution = plugin.ViewContribution
|
||||
export type ImageSourceContribution = plugin.ImageSourceContribution
|
||||
export type StatusItemContribution = plugin.StatusItemContribution
|
||||
export type PluginUIContributions = app.PluginUIContributions
|
||||
export type DriverSummary = driver.DriverSummary
|
||||
export type DriverCreateRequest = driver.CreateRequest
|
||||
export type RuntimeKindSpec = runtime.KindSpec
|
||||
|
||||
/** A "reims:log" event (internal/app/app.go emitLog); not a Go struct, so not generated. */
|
||||
|
||||
@@ -92,7 +92,7 @@ export const IconButton = React.forwardRef<HTMLButtonElement, IconButtonProps>(
|
||||
)
|
||||
IconButton.displayName = 'IconButton'
|
||||
|
||||
export type StatusKind = 'running' | 'stopped' | 'suspended' | 'busy' | 'broken' | 'warn'
|
||||
type StatusKind = 'running' | 'stopped' | 'suspended' | 'busy' | 'broken' | 'warn'
|
||||
|
||||
export function statusKind(state: string): StatusKind {
|
||||
if (state === 'running') return 'running'
|
||||
|
||||
@@ -89,7 +89,7 @@ export const Switch: React.FC<{ checked: boolean; onChange: (v: boolean) => void
|
||||
</label>
|
||||
)
|
||||
|
||||
export interface SegOption<V> {
|
||||
interface SegOption<V> {
|
||||
value: V
|
||||
label: string
|
||||
disabled?: boolean
|
||||
@@ -247,7 +247,7 @@ function thinMarks(marks: RangeMark[], min: number, max: number, gap = 9): Range
|
||||
return out
|
||||
}
|
||||
|
||||
export interface RangeMark {
|
||||
interface RangeMark {
|
||||
value: number
|
||||
label: string
|
||||
}
|
||||
@@ -326,7 +326,7 @@ export const RangeField: React.FC<RangeProps> = ({ value, min, max, step = 1, un
|
||||
)
|
||||
}
|
||||
|
||||
export interface CardOption<V> {
|
||||
interface CardOption<V> {
|
||||
value: V
|
||||
title: string
|
||||
sub?: string
|
||||
@@ -362,7 +362,7 @@ export function OptionCards<V extends string>({ options, value, onChange, label,
|
||||
)
|
||||
}
|
||||
|
||||
export interface PopupOption<V> {
|
||||
interface PopupOption<V> {
|
||||
value: V
|
||||
label: string
|
||||
/** Secondary text drawn after the label in grey, e.g. a build number. */
|
||||
|
||||
@@ -13,7 +13,7 @@ const DEFAULT_BRAND_MARK = '/logo.svg'
|
||||
const KNOWN_ICONS = new Set<string>(UI_CONTRACT_ICONS)
|
||||
const KNOWN_TARGETS = new Set<string>([...UI_CONTRACT_SLOTS, ...UI_CONTRACT_LAYERS])
|
||||
|
||||
export interface ThemeVisuals {
|
||||
interface ThemeVisuals {
|
||||
brandMarkURL: string
|
||||
icons: Partial<Record<UIContractIcon, string>>
|
||||
}
|
||||
@@ -25,7 +25,7 @@ function isBuiltin(payload: ActiveThemePayload | null): boolean {
|
||||
return !payload?.theme || payload.theme_id === 'builtin.theme.default'
|
||||
}
|
||||
|
||||
export function resolveThemeVisuals(payload: ActiveThemePayload | null): ThemeVisuals {
|
||||
function resolveThemeVisuals(payload: ActiveThemePayload | null): ThemeVisuals {
|
||||
if (isBuiltin(payload)) return EMPTY
|
||||
const th = payload!.theme!
|
||||
const icons: Partial<Record<UIContractIcon, string>> = {}
|
||||
@@ -41,7 +41,7 @@ export const ThemeVisualsProvider: React.FC<{ payload: ActiveThemePayload | null
|
||||
return <ThemeVisualsContext.Provider value={value}>{children}</ThemeVisualsContext.Provider>
|
||||
}
|
||||
|
||||
export function useThemeVisuals(): ThemeVisuals {
|
||||
function useThemeVisuals(): ThemeVisuals {
|
||||
return useContext(ThemeVisualsContext)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ export interface ToastInput {
|
||||
action?: { label: string; onClick: () => void }
|
||||
}
|
||||
|
||||
export interface ToastItem extends ToastInput {
|
||||
interface ToastItem extends ToastInput {
|
||||
id: number
|
||||
}
|
||||
|
||||
|
||||
@@ -155,10 +155,8 @@ export const api = {
|
||||
InstallNpcap: boundGo.InstallNpcap as () => Promise<void>,
|
||||
GetState: boundGo.GetState as () => Promise<AppState>,
|
||||
GetTasks: boundGo.GetTasks as () => Promise<Task[]>,
|
||||
GetVMAffinity: boundGo.GetVMAffinity as (name: string) => Promise<VMAffinityStatus>,
|
||||
SetVMAffinity: boundGo.SetVMAffinity as (name: string, req: VMAffinityUpdate) => Promise<VMAffinityStatus>,
|
||||
GetVMAffinityWithDriver: boundGo.GetVMAffinityWithDriver as (driverID: string, name: string) => Promise<VMAffinityStatus>,
|
||||
SetVMAffinityWithDriver: boundGo.SetVMAffinityWithDriver as (driverID: string, name: string, req: VMAffinityUpdate) => Promise<VMAffinityStatus>,
|
||||
GetVMAffinity: boundGo.GetVMAffinity as (driverID: string, name: string) => Promise<VMAffinityStatus>,
|
||||
SetVMAffinity: boundGo.SetVMAffinity as (driverID: string, name: string, req: VMAffinityUpdate) => Promise<VMAffinityStatus>,
|
||||
GetVMKeymap: boundGo.GetVMKeymap as (name: string) => Promise<VMKeymapStatus>,
|
||||
GetVMInfo: boundGo.GetVMInfo as (driverID: string, name: string) => Promise<VMInfo>,
|
||||
SetVMKeymap: boundGo.SetVMKeymap as (name: string, req: VMKeymapUpdate) => Promise<VMKeymapStatus>,
|
||||
|
||||
@@ -11,7 +11,9 @@
|
||||
"moduleDetection": "force",
|
||||
"noEmit": true,
|
||||
"jsx": "react-jsx",
|
||||
"strict": true
|
||||
"strict": true,
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true
|
||||
},
|
||||
"include": ["src"]
|
||||
}
|
||||
Vendored
+42
-118
@@ -34,23 +34,15 @@ export function CheckAppUpdate(arg1:boolean):Promise<version.UpdateInfo>;
|
||||
|
||||
export function CheckDataRoot(arg1:string):Promise<app.DataRootCheck>;
|
||||
|
||||
export function CloneVMCoW(arg1:string,arg2:string):Promise<void>;
|
||||
export function CloneVMCoW(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function CloneVMCoWWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function CompactVMDisk(arg1:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function CompactVMDiskWithDriver(arg1:string,arg2:string):Promise<driver.DiskCompactResult>;
|
||||
export function CompactVMDisk(arg1:string,arg2:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function CompleteSetup(arg1:string):Promise<void>;
|
||||
|
||||
export function CopyVMScreenshot(arg1:string):Promise<void>;
|
||||
export function CopyVMScreenshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CopyVMScreenshotWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CreateSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function CreateSnapshotWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
export function CreateSnapshot(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function CreateVM(arg1:reims.CreateOpts):Promise<void>;
|
||||
|
||||
@@ -60,13 +52,9 @@ export function DeleteCustomThemeScheme(arg1:string):Promise<void>;
|
||||
|
||||
export function DeleteInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function DeleteSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
export function DeleteSnapshot(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function DeleteSnapshotWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function DeleteVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function DeleteVMWithDriver(arg1:string,arg2:string,arg3:boolean):Promise<void>;
|
||||
export function DeleteVM(arg1:string,arg2:string,arg3:boolean):Promise<void>;
|
||||
|
||||
export function DeliverFileToGuest(arg1:string):Promise<string>;
|
||||
|
||||
@@ -76,13 +64,7 @@ export function DetachGuestTools(arg1:string):Promise<void>;
|
||||
|
||||
export function DisablePlugin(arg1:string):Promise<void>;
|
||||
|
||||
export function DiscardSuspend(arg1:string):Promise<void>;
|
||||
|
||||
export function DiscardSuspendWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function DismissTask(arg1:string):Promise<void>;
|
||||
|
||||
export function DoctorPlugin(arg1:string):Promise<Array<plugin.DoctorFinding>>;
|
||||
export function DiscardSuspend(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function DownloadAndAttachOnlineRecovery(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
@@ -90,25 +72,17 @@ export function DownloadAppUpdate():Promise<string>;
|
||||
|
||||
export function DownloadInstaller(arg1:string):Promise<string>;
|
||||
|
||||
export function EjectInstaller(arg1:string):Promise<void>;
|
||||
|
||||
export function EjectInstallerWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
export function EjectInstaller(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function EnablePlugin(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function EnableWHPX():Promise<void>;
|
||||
|
||||
export function EnterRecovery(arg1:string):Promise<void>;
|
||||
|
||||
export function ExportDiagnostics(arg1:string):Promise<string>;
|
||||
|
||||
export function ExportDiagnosticsWithDriver(arg1:string,arg2:string):Promise<string>;
|
||||
export function ExportDiagnostics(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function FinishInstall(arg1:string):Promise<void>;
|
||||
|
||||
export function FocusVMWindow(arg1:string):Promise<void>;
|
||||
|
||||
export function FocusVMWindowWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
export function FocusVMWindow(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function ForceQuitApp():Promise<void>;
|
||||
|
||||
@@ -136,17 +110,16 @@ export function GetStorageBreakdown():Promise<app.StorageBreakdown>;
|
||||
|
||||
export function GetTasks():Promise<Array<app.Task>>;
|
||||
|
||||
export function GetVMAffinity(arg1:string):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function GetVMAffinityWithDriver(arg1:string,arg2:string):Promise<app.VMAffinityStatus>;
|
||||
export function GetVMAffinity(arg1:string,arg2:string):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function GetVMDetail(arg1:string):Promise<reims.VMDetail>;
|
||||
|
||||
export function GetVMDisplayWithDriver(arg1:string,arg2:string):Promise<app.VMDisplayStatus>;
|
||||
export function GetVMDisplay(arg1:string,arg2:string):Promise<app.VMDisplayStatus>;
|
||||
|
||||
export function GetVMDriveShareSettings(arg1:string):Promise<app.DriveShareSettings>;
|
||||
|
||||
export function GetVMEndpointCommandWithDriver(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||
export function GetVMEndpointCommand(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||
|
||||
export function GetVMInfo(arg1:string,arg2:string):Promise<driver.VMInfo>;
|
||||
|
||||
export function GetVMKeymap(arg1:string):Promise<app.VMKeymapStatus>;
|
||||
@@ -157,30 +130,21 @@ export function GetVMNetworkPlan(arg1:string,arg2:string,arg3:string):Promise<ap
|
||||
|
||||
export function GetVMNetworkSettings(arg1:string):Promise<app.VMNetworkSettings>;
|
||||
|
||||
export function GetVMNote(arg1:string):Promise<string>;
|
||||
export function GetVMNoteWithDriver(arg1:string,arg2:string):Promise<string>;
|
||||
export function GetVMNote(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function GetVMPluginSettings(arg1:string):Promise<Record<string, Record<string, any>>>;
|
||||
|
||||
export function GetVMSMBIOS(arg1:string):Promise<opencore.SMBIOSIdentity>;
|
||||
|
||||
export function GetVMSSHUser(arg1:string):Promise<string>;
|
||||
|
||||
export function GetVMSSHUserWithDriver(arg1:string,arg2:string):Promise<string>;
|
||||
export function GetVMSSHUser(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function GetVMSharedFolderSettings(arg1:string):Promise<app.SharedFolderSettings>;
|
||||
|
||||
export function GetVMStats(arg1:string):Promise<app.VMStats>;
|
||||
export function GetVMStats(arg1:string,arg2:string):Promise<app.VMStats>;
|
||||
|
||||
export function GetVMStatsWithDriver(arg1:string,arg2:string):Promise<app.VMStats>;
|
||||
export function GetVMThumbnail(arg1:string,arg2:string):Promise<app.VMThumbnail>;
|
||||
|
||||
export function GetVMThumbnail(arg1:string):Promise<app.VMThumbnail>;
|
||||
|
||||
export function GetVMThumbnailWithDriver(arg1:string,arg2:string):Promise<app.VMThumbnail>;
|
||||
|
||||
export function GetVMTimezone(arg1:string):Promise<app.VMTimezoneStatus>;
|
||||
|
||||
export function GetVMTimezoneWithDriver(arg1:string,arg2:string):Promise<app.VMTimezoneStatus>;
|
||||
export function GetVMTimezone(arg1:string,arg2:string):Promise<app.VMTimezoneStatus>;
|
||||
|
||||
export function InspectPluginArchive(arg1:string):Promise<plugin.ScanReport>;
|
||||
|
||||
@@ -214,36 +178,29 @@ export function ListRemoteRuntimes():Promise<Array<runtime.Remote>>;
|
||||
|
||||
export function ListRuntimeKinds():Promise<Array<runtime.KindSpec>>;
|
||||
|
||||
export function ListSnapshots(arg1:string):Promise<Array<driver.DiskSnapshot>>;
|
||||
|
||||
export function ListSnapshotsWithDriver(arg1:string,arg2:string):Promise<Array<driver.DiskSnapshot>>;
|
||||
export function ListSnapshots(arg1:string,arg2:string):Promise<Array<driver.DiskSnapshot>>;
|
||||
|
||||
export function OpenProcessorScheduling():Promise<void>;
|
||||
|
||||
export function OpenQQGroup():Promise<void>;
|
||||
|
||||
export function OpenSSHTerminal(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function OpenSSHTerminalWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
export function OpenSSHTerminal(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function OpenSharedFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenURL(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenVMEndpointWithDriver(arg1:string,arg2:string,arg3:string,arg4:string):Promise<void>;
|
||||
export function OpenVMEndpoint(arg1:string,arg2:string,arg3:string,arg4:string):Promise<void>;
|
||||
|
||||
export function OpenVMFolder(arg1:string):Promise<void>;
|
||||
|
||||
export function OpenVSCodeSSH(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function OpenVSCodeSSHWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
export function OpenVSCodeSSH(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function OpenWindowsCoreIsolation():Promise<void>;
|
||||
|
||||
export function OpenWindowsSecurityExclusions():Promise<void>;
|
||||
|
||||
export function OptimizeVMDisk(arg1:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function OptimizeVMDiskWithDriver(arg1:string,arg2:string):Promise<driver.DiskCompactResult>;
|
||||
export function OptimizeVMDisk(arg1:string,arg2:string):Promise<driver.DiskCompactResult>;
|
||||
|
||||
export function PanelBridgeCall(arg1:string,arg2:string,arg3:Record<string, any>):Promise<any>;
|
||||
|
||||
@@ -261,9 +218,7 @@ export function QuitApp():Promise<void>;
|
||||
|
||||
export function ReadPluginLog(arg1:string):Promise<string>;
|
||||
|
||||
export function ReadVMLogs(arg1:string,arg2:boolean):Promise<string>;
|
||||
|
||||
export function ReadVMLogsWithDriver(arg1:string,arg2:string,arg3:boolean):Promise<string>;
|
||||
export function ReadVMLogs(arg1:string,arg2:string,arg3:boolean):Promise<string>;
|
||||
|
||||
export function RemovePlugin(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
@@ -275,23 +230,15 @@ export function ReopenDataRoot(arg1:boolean):Promise<dataroot.Status>;
|
||||
|
||||
export function RequestClose():Promise<void>;
|
||||
|
||||
export function ResizeVMDisk(arg1:string,arg2:string):Promise<driver.DiskResizeResult>;
|
||||
|
||||
export function ResizeVMDiskWithDriver(arg1:string,arg2:string,arg3:string):Promise<driver.DiskResizeResult>;
|
||||
export function ResizeVMDisk(arg1:string,arg2:string,arg3:string):Promise<driver.DiskResizeResult>;
|
||||
|
||||
export function ResolveElevationRequest(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function RestartVM(arg1:string):Promise<void>;
|
||||
export function RestartVM(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function RestartVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
export function RestoreSnapshot(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function RestoreSnapshot(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function RestoreSnapshotWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function ResumeVM(arg1:string):Promise<void>;
|
||||
|
||||
export function ResumeVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
export function ResumeVM(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SaveCustomThemeScheme(arg1:plugin.CustomThemeScheme):Promise<void>;
|
||||
|
||||
@@ -327,62 +274,41 @@ export function SetRuntimeChannel(arg1:string):Promise<void>;
|
||||
|
||||
export function SetSyncHostMemorySMBIOS(arg1:boolean):Promise<void>;
|
||||
|
||||
export function SetVMAffinity(arg1:string,arg2:app.VMAffinityUpdate):Promise<app.VMAffinityStatus>;
|
||||
export function SetVMAffinity(arg1:string,arg2:string,arg3:app.VMAffinityUpdate):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function SetVMAffinityWithDriver(arg1:string,arg2:string,arg3:app.VMAffinityUpdate):Promise<app.VMAffinityStatus>;
|
||||
|
||||
export function SetVMDisplayWithDriver(arg1:string,arg2:string,arg3:string):Promise<app.VMDisplayStatus>;
|
||||
export function SetVMDisplay(arg1:string,arg2:string,arg3:string):Promise<app.VMDisplayStatus>;
|
||||
|
||||
export function SetVMDriveShareSettings(arg1:string,arg2:boolean,arg3:Array<string>):Promise<app.DriveShareSettings>;
|
||||
|
||||
export function SetVMKeymap(arg1:string,arg2:app.VMKeymapUpdate):Promise<app.VMKeymapStatus>;
|
||||
|
||||
export function SetVMNote(arg1:string,arg2:string):Promise<void>;
|
||||
export function SetVMNoteWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
export function SetVMNote(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function SetVMSSHUser(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function SetVMSSHUserWithDriver(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
export function SetVMSSHUser(arg1:string,arg2:string,arg3:string):Promise<void>;
|
||||
|
||||
export function SetVMSharedFolderMode(arg1:string,arg2:string,arg3:string):Promise<app.SharedFolderSettings>;
|
||||
|
||||
export function SetVMTimezone(arg1:string,arg2:string):Promise<app.VMTimezoneStatus>;
|
||||
export function SetVMTimezone(arg1:string,arg2:string,arg3:string):Promise<app.VMTimezoneStatus>;
|
||||
|
||||
export function SetVMTimezoneWithDriver(arg1:string,arg2:string,arg3:string):Promise<app.VMTimezoneStatus>;
|
||||
export function StartVM(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function ShowMainWindow():Promise<void>;
|
||||
|
||||
export function StartVM(arg1:string):Promise<void>;
|
||||
|
||||
export function StartVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function StopVM(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function StopVMWithDriver(arg1:string,arg2:string,arg3:boolean):Promise<void>;
|
||||
export function StopVM(arg1:string,arg2:string,arg3:boolean):Promise<void>;
|
||||
|
||||
export function SuggestDataRoots():Promise<Array<app.DataRootChoice>>;
|
||||
|
||||
export function SuggestLanguagePack():Promise<plugin.MarketCatalogItem>;
|
||||
|
||||
export function SuspendVM(arg1:string):Promise<void>;
|
||||
|
||||
export function SuspendVMWithDriver(arg1:string,arg2:string):Promise<void>;
|
||||
export function SuspendVM(arg1:string,arg2:string):Promise<void>;
|
||||
|
||||
export function TestHostDNS(arg1:guesttools.HostDNSConfig):Promise<guesttools.HostDNSTestResult>;
|
||||
|
||||
export function ToggleBorderless(arg1:string,arg2:boolean):Promise<void>;
|
||||
|
||||
export function ToggleVMFullscreen(arg1:string):Promise<boolean>;
|
||||
export function ToggleVMFullscreen(arg1:string,arg2:string):Promise<boolean>;
|
||||
|
||||
export function ToggleVMFullscreenWithDriver(arg1:string,arg2:string):Promise<boolean>;
|
||||
export function TypeClipboard(arg1:string,arg2:string):Promise<number>;
|
||||
|
||||
export function TypeClipboard(arg1:string):Promise<number>;
|
||||
|
||||
export function TypeClipboardWithDriver(arg1:string,arg2:string):Promise<number>;
|
||||
|
||||
export function TypeText(arg1:string,arg2:string):Promise<number>;
|
||||
|
||||
export function TypeTextWithDriver(arg1:string,arg2:string,arg3:string):Promise<number>;
|
||||
export function TypeText(arg1:string,arg2:string,arg3:string):Promise<number>;
|
||||
|
||||
export function UpgradeDiskToNVMe(arg1:string):Promise<void>;
|
||||
|
||||
@@ -392,6 +318,4 @@ export function ValidateCreate(arg1:reims.CreateOpts):Promise<Array<reims.Valida
|
||||
|
||||
export function ValidateSet(arg1:reims.SetOpts):Promise<Array<reims.ValidationIssue>>;
|
||||
|
||||
export function WriteSSHConfig(arg1:string,arg2:string):Promise<string>;
|
||||
|
||||
export function WriteSSHConfigWithDriver(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||
export function WriteSSHConfig(arg1:string,arg2:string,arg3:string):Promise<string>;
|
||||
+80
-240
@@ -46,40 +46,24 @@ export function CheckDataRoot(arg1) {
|
||||
return window['go']['app']['App']['CheckDataRoot'](arg1);
|
||||
}
|
||||
|
||||
export function CloneVMCoW(arg1, arg2) {
|
||||
return window['go']['app']['App']['CloneVMCoW'](arg1, arg2);
|
||||
export function CloneVMCoW(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['CloneVMCoW'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function CloneVMCoWWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['CloneVMCoWWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function CompactVMDisk(arg1) {
|
||||
return window['go']['app']['App']['CompactVMDisk'](arg1);
|
||||
}
|
||||
|
||||
export function CompactVMDiskWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['CompactVMDiskWithDriver'](arg1, arg2);
|
||||
export function CompactVMDisk(arg1, arg2) {
|
||||
return window['go']['app']['App']['CompactVMDisk'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CompleteSetup(arg1) {
|
||||
return window['go']['app']['App']['CompleteSetup'](arg1);
|
||||
}
|
||||
|
||||
export function CopyVMScreenshot(arg1) {
|
||||
return window['go']['app']['App']['CopyVMScreenshot'](arg1);
|
||||
export function CopyVMScreenshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['CopyVMScreenshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CopyVMScreenshotWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['CopyVMScreenshotWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CreateSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['CreateSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function CreateSnapshotWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['CreateSnapshotWithDriver'](arg1, arg2, arg3);
|
||||
export function CreateSnapshot(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['CreateSnapshot'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function CreateVM(arg1) {
|
||||
@@ -98,20 +82,12 @@ export function DeleteInstaller(arg1) {
|
||||
return window['go']['app']['App']['DeleteInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function DeleteSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeleteSnapshot'](arg1, arg2);
|
||||
export function DeleteSnapshot(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['DeleteSnapshot'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function DeleteSnapshotWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['DeleteSnapshotWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function DeleteVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['DeleteVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DeleteVMWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['DeleteVMWithDriver'](arg1, arg2, arg3);
|
||||
export function DeleteVM(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['DeleteVM'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function DeliverFileToGuest(arg1) {
|
||||
@@ -130,20 +106,8 @@ export function DisablePlugin(arg1) {
|
||||
return window['go']['app']['App']['DisablePlugin'](arg1);
|
||||
}
|
||||
|
||||
export function DiscardSuspend(arg1) {
|
||||
return window['go']['app']['App']['DiscardSuspend'](arg1);
|
||||
}
|
||||
|
||||
export function DiscardSuspendWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['DiscardSuspendWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DismissTask(arg1) {
|
||||
return window['go']['app']['App']['DismissTask'](arg1);
|
||||
}
|
||||
|
||||
export function DoctorPlugin(arg1) {
|
||||
return window['go']['app']['App']['DoctorPlugin'](arg1);
|
||||
export function DiscardSuspend(arg1, arg2) {
|
||||
return window['go']['app']['App']['DiscardSuspend'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function DownloadAndAttachOnlineRecovery(arg1, arg2) {
|
||||
@@ -158,44 +122,28 @@ export function DownloadInstaller(arg1) {
|
||||
return window['go']['app']['App']['DownloadInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function EjectInstaller(arg1) {
|
||||
return window['go']['app']['App']['EjectInstaller'](arg1);
|
||||
}
|
||||
|
||||
export function EjectInstallerWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['EjectInstallerWithDriver'](arg1, arg2);
|
||||
export function EjectInstaller(arg1, arg2) {
|
||||
return window['go']['app']['App']['EjectInstaller'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function EnablePlugin(arg1, arg2) {
|
||||
return window['go']['app']['App']['EnablePlugin'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function EnableWHPX() {
|
||||
return window['go']['app']['App']['EnableWHPX']();
|
||||
}
|
||||
|
||||
export function EnterRecovery(arg1) {
|
||||
return window['go']['app']['App']['EnterRecovery'](arg1);
|
||||
}
|
||||
|
||||
export function ExportDiagnostics(arg1) {
|
||||
return window['go']['app']['App']['ExportDiagnostics'](arg1);
|
||||
}
|
||||
|
||||
export function ExportDiagnosticsWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ExportDiagnosticsWithDriver'](arg1, arg2);
|
||||
export function ExportDiagnostics(arg1, arg2) {
|
||||
return window['go']['app']['App']['ExportDiagnostics'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function FinishInstall(arg1) {
|
||||
return window['go']['app']['App']['FinishInstall'](arg1);
|
||||
}
|
||||
|
||||
export function FocusVMWindow(arg1) {
|
||||
return window['go']['app']['App']['FocusVMWindow'](arg1);
|
||||
}
|
||||
|
||||
export function FocusVMWindowWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['FocusVMWindowWithDriver'](arg1, arg2);
|
||||
export function FocusVMWindow(arg1, arg2) {
|
||||
return window['go']['app']['App']['FocusVMWindow'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ForceQuitApp() {
|
||||
@@ -250,28 +198,24 @@ export function GetTasks() {
|
||||
return window['go']['app']['App']['GetTasks']();
|
||||
}
|
||||
|
||||
export function GetVMAffinity(arg1) {
|
||||
return window['go']['app']['App']['GetVMAffinity'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMAffinityWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMAffinityWithDriver'](arg1, arg2);
|
||||
export function GetVMAffinity(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMAffinity'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMDetail(arg1) {
|
||||
return window['go']['app']['App']['GetVMDetail'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMDisplayWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMDisplayWithDriver'](arg1, arg2);
|
||||
export function GetVMDisplay(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMDisplay'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMDriveShareSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMDriveShareSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMEndpointCommandWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['GetVMEndpointCommandWithDriver'](arg1, arg2, arg3);
|
||||
export function GetVMEndpointCommand(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['GetVMEndpointCommand'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function GetVMInfo(arg1, arg2) {
|
||||
@@ -294,8 +238,8 @@ export function GetVMNetworkSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMNetworkSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMNote(arg1) {
|
||||
return window['go']['app']['App']['GetVMNote'](arg1);
|
||||
export function GetVMNote(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMNote'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMPluginSettings(arg1) {
|
||||
@@ -306,44 +250,24 @@ export function GetVMSMBIOS(arg1) {
|
||||
return window['go']['app']['App']['GetVMSMBIOS'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMNoteWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMNoteWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMSSHUser(arg1) {
|
||||
return window['go']['app']['App']['GetVMSSHUser'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMSSHUserWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMSSHUserWithDriver'](arg1, arg2);
|
||||
export function GetVMSSHUser(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMSSHUser'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMSharedFolderSettings(arg1) {
|
||||
return window['go']['app']['App']['GetVMSharedFolderSettings'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMStats(arg1) {
|
||||
return window['go']['app']['App']['GetVMStats'](arg1);
|
||||
export function GetVMStats(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMStats'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMStatsWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMStatsWithDriver'](arg1, arg2);
|
||||
export function GetVMThumbnail(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMThumbnail'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMThumbnail(arg1) {
|
||||
return window['go']['app']['App']['GetVMThumbnail'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMThumbnailWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMThumbnailWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetVMTimezone(arg1) {
|
||||
return window['go']['app']['App']['GetVMTimezone'](arg1);
|
||||
}
|
||||
|
||||
export function GetVMTimezoneWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMTimezoneWithDriver'](arg1, arg2);
|
||||
export function GetVMTimezone(arg1, arg2) {
|
||||
return window['go']['app']['App']['GetVMTimezone'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function InspectPluginArchive(arg1) {
|
||||
@@ -410,12 +334,8 @@ export function ListRuntimeKinds() {
|
||||
return window['go']['app']['App']['ListRuntimeKinds']();
|
||||
}
|
||||
|
||||
export function ListSnapshots(arg1) {
|
||||
return window['go']['app']['App']['ListSnapshots'](arg1);
|
||||
}
|
||||
|
||||
export function ListSnapshotsWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ListSnapshotsWithDriver'](arg1, arg2);
|
||||
export function ListSnapshots(arg1, arg2) {
|
||||
return window['go']['app']['App']['ListSnapshots'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenProcessorScheduling() {
|
||||
@@ -426,12 +346,8 @@ export function OpenQQGroup() {
|
||||
return window['go']['app']['App']['OpenQQGroup']();
|
||||
}
|
||||
|
||||
export function OpenSSHTerminal(arg1, arg2) {
|
||||
return window['go']['app']['App']['OpenSSHTerminal'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenSSHTerminalWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['OpenSSHTerminalWithDriver'](arg1, arg2, arg3);
|
||||
export function OpenSSHTerminal(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['OpenSSHTerminal'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function OpenSharedFolder(arg1) {
|
||||
@@ -442,20 +358,16 @@ export function OpenURL(arg1) {
|
||||
return window['go']['app']['App']['OpenURL'](arg1);
|
||||
}
|
||||
|
||||
export function OpenVMEndpointWithDriver(arg1, arg2, arg3, arg4) {
|
||||
return window['go']['app']['App']['OpenVMEndpointWithDriver'](arg1, arg2, arg3, arg4);
|
||||
export function OpenVMEndpoint(arg1, arg2, arg3, arg4) {
|
||||
return window['go']['app']['App']['OpenVMEndpoint'](arg1, arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
export function OpenVMFolder(arg1) {
|
||||
return window['go']['app']['App']['OpenVMFolder'](arg1);
|
||||
}
|
||||
|
||||
export function OpenVSCodeSSH(arg1, arg2) {
|
||||
return window['go']['app']['App']['OpenVSCodeSSH'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function OpenVSCodeSSHWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['OpenVSCodeSSHWithDriver'](arg1, arg2, arg3);
|
||||
export function OpenVSCodeSSH(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['OpenVSCodeSSH'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function OpenWindowsCoreIsolation() {
|
||||
@@ -466,12 +378,8 @@ export function OpenWindowsSecurityExclusions() {
|
||||
return window['go']['app']['App']['OpenWindowsSecurityExclusions']();
|
||||
}
|
||||
|
||||
export function OptimizeVMDisk(arg1) {
|
||||
return window['go']['app']['App']['OptimizeVMDisk'](arg1);
|
||||
}
|
||||
|
||||
export function OptimizeVMDiskWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['OptimizeVMDiskWithDriver'](arg1, arg2);
|
||||
export function OptimizeVMDisk(arg1, arg2) {
|
||||
return window['go']['app']['App']['OptimizeVMDisk'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function PanelBridgeCall(arg1, arg2, arg3) {
|
||||
@@ -506,12 +414,8 @@ export function ReadPluginLog(arg1) {
|
||||
return window['go']['app']['App']['ReadPluginLog'](arg1);
|
||||
}
|
||||
|
||||
export function ReadVMLogs(arg1, arg2) {
|
||||
return window['go']['app']['App']['ReadVMLogs'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ReadVMLogsWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['ReadVMLogsWithDriver'](arg1, arg2, arg3);
|
||||
export function ReadVMLogs(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['ReadVMLogs'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function RemovePlugin(arg1, arg2) {
|
||||
@@ -534,40 +438,24 @@ export function RequestClose() {
|
||||
return window['go']['app']['App']['RequestClose']();
|
||||
}
|
||||
|
||||
export function ResizeVMDisk(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResizeVMDisk'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ResizeVMDiskWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['ResizeVMDiskWithDriver'](arg1, arg2, arg3);
|
||||
export function ResizeVMDisk(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['ResizeVMDisk'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function ResolveElevationRequest(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResolveElevationRequest'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestartVM(arg1) {
|
||||
return window['go']['app']['App']['RestartVM'](arg1);
|
||||
export function RestartVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['RestartVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestartVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['RestartVMWithDriver'](arg1, arg2);
|
||||
export function RestoreSnapshot(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['RestoreSnapshot'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function RestoreSnapshot(arg1, arg2) {
|
||||
return window['go']['app']['App']['RestoreSnapshot'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function RestoreSnapshotWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['RestoreSnapshotWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function ResumeVM(arg1) {
|
||||
return window['go']['app']['App']['ResumeVM'](arg1);
|
||||
}
|
||||
|
||||
export function ResumeVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResumeVMWithDriver'](arg1, arg2);
|
||||
export function ResumeVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['ResumeVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SaveCustomThemeScheme(arg1) {
|
||||
@@ -638,16 +526,12 @@ export function SetSyncHostMemorySMBIOS(arg1) {
|
||||
return window['go']['app']['App']['SetSyncHostMemorySMBIOS'](arg1);
|
||||
}
|
||||
|
||||
export function SetVMAffinity(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMAffinity'](arg1, arg2);
|
||||
export function SetVMAffinity(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMAffinity'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMAffinityWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMAffinityWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMDisplayWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMDisplayWithDriver'](arg1, arg2, arg3);
|
||||
export function SetVMDisplay(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMDisplay'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMDriveShareSettings(arg1, arg2, arg3) {
|
||||
@@ -658,52 +542,28 @@ export function SetVMKeymap(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMKeymap'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMNote(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMNote'](arg1, arg2);
|
||||
export function SetVMNote(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMNote'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMNoteWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMNoteWithDriver'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMSSHUser(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMSSHUser'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function SetVMSSHUserWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMSSHUserWithDriver'](arg1, arg2, arg3);
|
||||
export function SetVMSSHUser(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMSSHUser'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMSharedFolderMode(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMSharedFolderMode'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMTimezone(arg1, arg2) {
|
||||
return window['go']['app']['App']['SetVMTimezone'](arg1, arg2);
|
||||
export function SetVMTimezone(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMTimezone'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SetVMTimezoneWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['SetVMTimezoneWithDriver'](arg1, arg2, arg3);
|
||||
export function StartVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['StartVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ShowMainWindow() {
|
||||
return window['go']['app']['App']['ShowMainWindow']();
|
||||
}
|
||||
|
||||
export function StartVM(arg1) {
|
||||
return window['go']['app']['App']['StartVM'](arg1);
|
||||
}
|
||||
|
||||
export function StartVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['StartVMWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function StopVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['StopVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function StopVMWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['StopVMWithDriver'](arg1, arg2, arg3);
|
||||
export function StopVM(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['StopVM'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function SuggestDataRoots() {
|
||||
@@ -714,12 +574,8 @@ export function SuggestLanguagePack() {
|
||||
return window['go']['app']['App']['SuggestLanguagePack']();
|
||||
}
|
||||
|
||||
export function SuspendVM(arg1) {
|
||||
return window['go']['app']['App']['SuspendVM'](arg1);
|
||||
}
|
||||
|
||||
export function SuspendVMWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['SuspendVMWithDriver'](arg1, arg2);
|
||||
export function SuspendVM(arg1, arg2) {
|
||||
return window['go']['app']['App']['SuspendVM'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function TestHostDNS(arg1) {
|
||||
@@ -730,28 +586,16 @@ export function ToggleBorderless(arg1, arg2) {
|
||||
return window['go']['app']['App']['ToggleBorderless'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ToggleVMFullscreen(arg1) {
|
||||
return window['go']['app']['App']['ToggleVMFullscreen'](arg1);
|
||||
export function ToggleVMFullscreen(arg1, arg2) {
|
||||
return window['go']['app']['App']['ToggleVMFullscreen'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ToggleVMFullscreenWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['ToggleVMFullscreenWithDriver'](arg1, arg2);
|
||||
export function TypeClipboard(arg1, arg2) {
|
||||
return window['go']['app']['App']['TypeClipboard'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function TypeClipboard(arg1) {
|
||||
return window['go']['app']['App']['TypeClipboard'](arg1);
|
||||
}
|
||||
|
||||
export function TypeClipboardWithDriver(arg1, arg2) {
|
||||
return window['go']['app']['App']['TypeClipboardWithDriver'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function TypeText(arg1, arg2) {
|
||||
return window['go']['app']['App']['TypeText'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function TypeTextWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['TypeTextWithDriver'](arg1, arg2, arg3);
|
||||
export function TypeText(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['TypeText'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function UpgradeDiskToNVMe(arg1) {
|
||||
@@ -770,10 +614,6 @@ export function ValidateSet(arg1) {
|
||||
return window['go']['app']['App']['ValidateSet'](arg1);
|
||||
}
|
||||
|
||||
export function WriteSSHConfig(arg1, arg2) {
|
||||
return window['go']['app']['App']['WriteSSHConfig'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function WriteSSHConfigWithDriver(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['WriteSSHConfigWithDriver'](arg1, arg2, arg3);
|
||||
export function WriteSSHConfig(arg1, arg2, arg3) {
|
||||
return window['go']['app']['App']['WriteSSHConfig'](arg1, arg2, arg3);
|
||||
}
|
||||
@@ -96,10 +96,7 @@ func buildVMAffinityStatus(detail driver.VMInfo, rep host.Report, globalAutoPin
|
||||
|
||||
// GetVMAffinity returns the per-VM processor affinity configuration, resolved
|
||||
// effective CPU set, and live QEMU process affinity mask when running.
|
||||
func (a *App) GetVMAffinity(name string) (VMAffinityStatus, error) {
|
||||
return a.GetVMAffinityWithDriver("", name)
|
||||
}
|
||||
func (a *App) GetVMAffinityWithDriver(driverID, name string) (VMAffinityStatus, error) {
|
||||
func (a *App) GetVMAffinity(driverID, name string) (VMAffinityStatus, error) {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return VMAffinityStatus{}, err
|
||||
@@ -127,10 +124,7 @@ func (a *App) GetVMAffinityWithDriver(driverID, name string) (VMAffinityStatus,
|
||||
|
||||
// SetVMAffinity saves a VM's processor affinity mapping and immediately applies
|
||||
// it (plus EcoQoS power-throttling control) to the running QEMU process if active.
|
||||
func (a *App) SetVMAffinity(name string, req VMAffinityUpdate) (VMAffinityStatus, error) {
|
||||
return a.SetVMAffinityWithDriver("", name, req)
|
||||
}
|
||||
func (a *App) SetVMAffinityWithDriver(driverID, name string, req VMAffinityUpdate) (VMAffinityStatus, error) {
|
||||
func (a *App) SetVMAffinity(driverID, name string, req VMAffinityUpdate) (VMAffinityStatus, error) {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return VMAffinityStatus{}, err
|
||||
|
||||
+15
-15
@@ -924,8 +924,8 @@ func (a *App) SetSyncHostMemorySMBIOS(enabled bool) error {
|
||||
return a.saveConfigLocked()
|
||||
}
|
||||
|
||||
// ShowMainWindow restores and focuses the Wails window from the system tray.
|
||||
func (a *App) ShowMainWindow() {
|
||||
// showMainWindow restores and focuses the Wails window from the system tray.
|
||||
func (a *App) showMainWindow() {
|
||||
if a.ctx == nil {
|
||||
return
|
||||
}
|
||||
@@ -946,10 +946,10 @@ func (a *App) RequestClose() {
|
||||
func (a *App) startTray() {
|
||||
mgr, err := tray.Start(a.trayIcon, "Reims-Go", tray.Callbacks{
|
||||
OnShow: func() {
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
},
|
||||
OnNewVM: func() {
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
a.emit("reims:tray-new-vm")
|
||||
},
|
||||
OnVMAction: a.trayVMAction,
|
||||
@@ -1021,34 +1021,34 @@ func (a *App) trayVMAction(driverID, name string, act tray.Action) {
|
||||
var failTitle string
|
||||
switch act {
|
||||
case tray.ActStart:
|
||||
err, failTitle = a.StartVMWithDriver(driverID, name), i18n.M(loc, "tray.notify.start_fail", vars)
|
||||
err, failTitle = a.StartVM(driverID, name), i18n.M(loc, "tray.notify.start_fail", vars)
|
||||
case tray.ActSuspend:
|
||||
err, failTitle = a.SuspendVMWithDriver(driverID, name), i18n.M(loc, "tray.notify.suspend_fail", vars)
|
||||
err, failTitle = a.SuspendVM(driverID, name), i18n.M(loc, "tray.notify.suspend_fail", vars)
|
||||
case tray.ActResume:
|
||||
err, failTitle = a.ResumeVMWithDriver(driverID, name), i18n.M(loc, "tray.notify.resume_fail", vars)
|
||||
err, failTitle = a.ResumeVM(driverID, name), i18n.M(loc, "tray.notify.resume_fail", vars)
|
||||
case tray.ActDiscardSuspend:
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
a.emit("reims:tray-discard-suspend", name)
|
||||
case tray.ActStop:
|
||||
err, failTitle = a.StopVMWithDriver(driverID, name, false), i18n.M(loc, "tray.notify.stop_fail", vars)
|
||||
err, failTitle = a.StopVM(driverID, name, false), i18n.M(loc, "tray.notify.stop_fail", vars)
|
||||
case tray.ActForceStop:
|
||||
err, failTitle = a.StopVMWithDriver(driverID, name, true), i18n.M(loc, "tray.notify.force_stop_fail", vars)
|
||||
err, failTitle = a.StopVM(driverID, name, true), i18n.M(loc, "tray.notify.force_stop_fail", vars)
|
||||
case tray.ActRestart:
|
||||
err, failTitle = a.RestartVMWithDriver(driverID, name), i18n.M(loc, "tray.notify.restart_fail", vars)
|
||||
err, failTitle = a.RestartVM(driverID, name), i18n.M(loc, "tray.notify.restart_fail", vars)
|
||||
case tray.ActShowWindow:
|
||||
err, failTitle = a.FocusVMWindowWithDriver(driverID, name), i18n.M(loc, "tray.notify.focus_fail", vars)
|
||||
err, failTitle = a.FocusVMWindow(driverID, name), i18n.M(loc, "tray.notify.focus_fail", vars)
|
||||
case tray.ActToggleFullscreen:
|
||||
_, err = a.ToggleVMFullscreenWithDriver(driverID, name)
|
||||
_, err = a.ToggleVMFullscreen(driverID, name)
|
||||
failTitle = i18n.M(loc, "tray.notify.fullscreen_fail", vars)
|
||||
case tray.ActScreenshot:
|
||||
if err = a.CopyVMScreenshotWithDriver(driverID, name); err == nil && tm != nil {
|
||||
if err = a.CopyVMScreenshot(driverID, name); err == nil && tm != nil {
|
||||
tm.Notify(i18n.T(loc, "tray.notify.screenshot_ok"), name, false)
|
||||
}
|
||||
failTitle = i18n.M(loc, "tray.notify.screenshot_fail", vars)
|
||||
case tray.ActSharedFolder:
|
||||
err, failTitle = a.OpenSharedFolder(name), i18n.T(loc, "tray.notify.shared_fail")
|
||||
case tray.ActOpenInApp:
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
a.emit("reims:tray-select-vm", name)
|
||||
}
|
||||
if err != nil {
|
||||
|
||||
@@ -8,16 +8,12 @@ import (
|
||||
)
|
||||
|
||||
// CloneVMCoW derives a VM through the source VM's owning driver.
|
||||
func (a *App) CloneVMCoW(sourceName, cloneName string) error {
|
||||
return a.CloneVMCoWWithDriver("", sourceName, cloneName)
|
||||
}
|
||||
|
||||
func (a *App) CloneVMCoWWithDriver(driverID, sourceName, cloneName string) error {
|
||||
_, err := a.cloneVMCoWWithDriverInfo(driverID, sourceName, cloneName)
|
||||
func (a *App) CloneVMCoW(driverID, sourceName, cloneName string) error {
|
||||
_, err := a.cloneVM(driverID, sourceName, cloneName)
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) cloneVMCoWWithDriverInfo(driverID, sourceName, cloneName string) (driver.VMInfo, error) {
|
||||
func (a *App) cloneVM(driverID, sourceName, cloneName string) (driver.VMInfo, error) {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
|
||||
@@ -46,8 +46,8 @@ func (a *App) computerUseHostHandlers(mgr *plugin.Manager, pluginID string) map[
|
||||
"host/vm.get": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:read", "host/vm.get", a.handleComputerUseVMGet),
|
||||
"host/vm.start": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.start", a.handleComputerUseVMStart),
|
||||
"host/vm.shutdown": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.shutdown", a.handleComputerUseVMShutdown),
|
||||
"host/vm.suspend": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.suspend", a.handleComputerUseVMStateChange(a.SuspendVMWithDriver)),
|
||||
"host/vm.resume": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.resume", a.handleComputerUseVMStateChange(a.ResumeVMWithDriver)),
|
||||
"host/vm.suspend": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.suspend", a.handleComputerUseVMStateChange(a.SuspendVM)),
|
||||
"host/vm.resume": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.resume", a.handleComputerUseVMStateChange(a.ResumeVM)),
|
||||
"host/vm.clone": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.clone", a.handleComputerUseVMClone),
|
||||
"host/vm.delete": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.delete", a.handleComputerUseVMDelete),
|
||||
"host/vm.snapshot.list": a.authorizedComputerUseVMHandler(mgr, pluginID, "vm:control", "host/vm.snapshot.list", a.handleComputerUseVMSnapshotList),
|
||||
@@ -175,7 +175,7 @@ func (a *App) computerUseVMView(vm driver.VMInfo, mgr *plugin.Manager, pluginID
|
||||
view["capabilities"] = append([]string(nil), vm.Capabilities...)
|
||||
}
|
||||
if accessEnabled {
|
||||
username := a.GetVMSSHUserWithDriver(vm.DriverID, vm.Name)
|
||||
username := a.GetVMSSHUser(vm.DriverID, vm.Name)
|
||||
if mgr != nil {
|
||||
settings := mgr.GetSettings(pluginID, vm.Ref().Key(), false)
|
||||
if configured, ok := settings["username"].(string); ok && strings.TrimSpace(configured) != "" {
|
||||
@@ -200,7 +200,7 @@ func (a *App) handleComputerUseVMStart(_ context.Context, raw json.RawMessage, m
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := a.StartVMWithDriver(vm.DriverID, vm.Name); err != nil {
|
||||
if err := a.StartVM(vm.DriverID, vm.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]any{"ok": true}, nil
|
||||
@@ -217,7 +217,7 @@ func (a *App) handleComputerUseVMShutdown(_ context.Context, raw json.RawMessage
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := a.StopVMWithDriver(vm.DriverID, vm.Name, false); err != nil {
|
||||
if err := a.StopVM(vm.DriverID, vm.Name, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]any{"ok": true}, nil
|
||||
@@ -273,14 +273,14 @@ func (a *App) handleComputerUseVMClone(ctx context.Context, raw json.RawMessage,
|
||||
}) {
|
||||
return nil, fmt.Errorf("VM name %q is already taken", cloneName)
|
||||
}
|
||||
cloned, err := a.cloneVMCoWWithDriverInfo(vm.DriverID, vm.Name, cloneName)
|
||||
cloned, err := a.cloneVM(vm.DriverID, vm.Name, cloneName)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
cloneRef := cloned.Ref()
|
||||
err = persistComputerUseOwnership(cloned, pluginID, cloneRef.Key())
|
||||
if err != nil {
|
||||
if cleanupErr := a.DeleteVMWithDriver(vm.DriverID, cloneName, false); cleanupErr != nil {
|
||||
if cleanupErr := a.DeleteVM(vm.DriverID, cloneName, false); cleanupErr != nil {
|
||||
return nil, errors.Join(err, fmt.Errorf("clean up unregistered clone %q: %w", cloneName, cleanupErr))
|
||||
}
|
||||
return nil, err
|
||||
@@ -307,13 +307,13 @@ func (a *App) handleComputerUseVMDelete(ctx context.Context, raw json.RawMessage
|
||||
return nil, a.computerUseHostError("not_authorized", "err.computer_use.not_owned", i18n.Vars{"name": vm.Name})
|
||||
}
|
||||
if vm.State == "running" {
|
||||
if err := a.stopVMWithDriverCtx(ctx, vm.DriverID, vm.Name, false); err != nil {
|
||||
if forceErr := a.stopVMWithDriverCtx(ctx, vm.DriverID, vm.Name, true); forceErr != nil {
|
||||
if err := a.stopVM(ctx, vm.DriverID, vm.Name, false); err != nil {
|
||||
if forceErr := a.stopVM(ctx, vm.DriverID, vm.Name, true); forceErr != nil {
|
||||
return nil, errors.Join(err, fmt.Errorf("force stop temporary VM %q: %w", vm.Name, forceErr))
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := a.DeleteVMWithDriver(vm.DriverID, vm.Name, false); err != nil {
|
||||
if err := a.DeleteVM(vm.DriverID, vm.Name, false); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
removeComputerUseOwnership(vm.Directory)
|
||||
@@ -332,7 +332,7 @@ func (a *App) handleComputerUseVMSnapshotList(ctx context.Context, raw json.RawM
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
snapshots, err := a.ListSnapshotsWithDriver(vm.DriverID, vm.Name)
|
||||
snapshots, err := a.ListSnapshots(vm.DriverID, vm.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -351,7 +351,7 @@ func (a *App) handleComputerUseVMSnapshotCreate(_ context.Context, raw json.RawM
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := a.CreateSnapshotWithDriver(vm.DriverID, vm.Name, req.Name); err != nil {
|
||||
if err := a.CreateSnapshot(vm.DriverID, vm.Name, req.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]any{"ok": true, "name": strings.TrimSpace(req.Name)}, nil
|
||||
@@ -372,7 +372,7 @@ func (a *App) handleComputerUseVMSnapshotRestore(_ context.Context, raw json.Raw
|
||||
if !a.computerUseOwned(pluginID, vm.Ref().Key()) {
|
||||
return nil, a.computerUseHostError("confirmation_required", "err.computer_use.restore_confirmation", i18n.Vars{"name": vm.Name})
|
||||
}
|
||||
if err := a.RestoreSnapshotWithDriver(vm.DriverID, vm.Name, req.Name); err != nil {
|
||||
if err := a.RestoreSnapshot(vm.DriverID, vm.Name, req.Name); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return map[string]any{"ok": true, "name": strings.TrimSpace(req.Name)}, nil
|
||||
@@ -588,11 +588,11 @@ func (a *App) restoreComputerUseOwnedVMs(ctx context.Context) error {
|
||||
}
|
||||
if item.State == "running" {
|
||||
stopCtx, stopCancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
|
||||
err := a.stopVMWithDriverCtx(stopCtx, item.DriverID, item.Name, false)
|
||||
err := a.stopVM(stopCtx, item.DriverID, item.Name, false)
|
||||
stopCancel()
|
||||
if err != nil {
|
||||
forceCtx, forceCancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
|
||||
forceErr := a.stopVMWithDriverCtx(forceCtx, item.DriverID, item.Name, true)
|
||||
forceErr := a.stopVM(forceCtx, item.DriverID, item.Name, true)
|
||||
forceCancel()
|
||||
if forceErr != nil {
|
||||
cleanupErrors = append(cleanupErrors, errors.Join(
|
||||
@@ -603,7 +603,7 @@ func (a *App) restoreComputerUseOwnedVMs(ctx context.Context) error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := a.DeleteVMWithDriver(item.DriverID, item.Name, false); err != nil {
|
||||
if err := a.DeleteVM(item.DriverID, item.Name, false); err != nil {
|
||||
cleanupErrors = append(cleanupErrors, fmt.Errorf("delete orphaned temporary VM %q: %w", item.Name, err))
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -93,14 +93,14 @@ func TestDriverConsoleServesGUIThumbnailAndTyping(t *testing.T) {
|
||||
ct := newConsoleTestApp(t)
|
||||
a := ct.app
|
||||
|
||||
thumb, err := a.GetVMThumbnailWithDriver(ct.drv.ID(), "dev")
|
||||
thumb, err := a.GetVMThumbnail(ct.drv.ID(), "dev")
|
||||
if err != nil || !thumb.Live || !strings.HasPrefix(thumb.DataURL, "data:image/jpeg;base64,") {
|
||||
t.Fatalf("thumbnail = live %v, %.30q, %v; want a live frame from the driver console", thumb.Live, thumb.DataURL, err)
|
||||
}
|
||||
|
||||
n, err := a.TypeTextWithDriver(ct.drv.ID(), "dev", "hello")
|
||||
n, err := a.TypeText(ct.drv.ID(), "dev", "hello")
|
||||
if err != nil || n != 5 {
|
||||
t.Fatalf("TypeTextWithDriver = %d, %v", n, err)
|
||||
t.Fatalf("TypeText = %d, %v", n, err)
|
||||
}
|
||||
if got := ct.log(t); !strings.Contains(got, "type dev hello") {
|
||||
t.Fatalf("the driver never received the text; its log is %q", got)
|
||||
|
||||
@@ -227,7 +227,7 @@ func (a *App) createVMFlow(opts reims.CreateOpts) (err error) {
|
||||
a.emitVMLog(opts.Name, "VM "+opts.Name+" ready.")
|
||||
a.emitStateChanged()
|
||||
if startAfterCreate && ctx.Err() == nil {
|
||||
return a.StartVMWithDriver(driver.BuiltinReimsMacOSDriverID, opts.Name)
|
||||
return a.StartVM(driver.BuiltinReimsMacOSDriverID, opts.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func TestNothingWrittenBeforeSetup(t *testing.T) {
|
||||
if got := dirEntries(t, dir); len(got) != 0 {
|
||||
t.Fatalf("suggested folder written before setup: %v", got)
|
||||
}
|
||||
if err := a.StartVM("mac"); err == nil {
|
||||
if err := a.StartVM("", "mac"); err == nil {
|
||||
t.Fatal("StartVM before setup must be refused")
|
||||
}
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func TestReadOnlyFolderRefusesWrites(t *testing.T) {
|
||||
if raw, _ := os.ReadFile(cfgPath); string(raw) != `{"data_root": "x", "locale": "zh-CN"}` {
|
||||
t.Fatalf("config rewritten: %s", raw)
|
||||
}
|
||||
if err := a.StartVM("mac"); err == nil {
|
||||
if err := a.StartVM("", "mac"); err == nil {
|
||||
t.Fatal("StartVM on a read-only folder must be refused")
|
||||
}
|
||||
a.initPlugins()
|
||||
|
||||
@@ -126,10 +126,7 @@ func writeDiagnosticsZip(zipPath string, b diagnosticsBundle) error {
|
||||
}
|
||||
|
||||
// ExportDiagnostics collects a redacted troubleshooting zip bundle through the owning driver.
|
||||
func (a *App) ExportDiagnostics(name string) (string, error) {
|
||||
return a.ExportDiagnosticsWithDriver("", name)
|
||||
}
|
||||
func (a *App) ExportDiagnosticsWithDriver(driverID, name string) (string, error) {
|
||||
func (a *App) ExportDiagnostics(driverID, name string) (string, error) {
|
||||
var vm driver.VMInfo
|
||||
var err error
|
||||
if strings.TrimSpace(name) != "" {
|
||||
@@ -154,12 +151,12 @@ func (a *App) ExportDiagnosticsWithDriver(driverID, name string) (string, error)
|
||||
ref := vm.Ref()
|
||||
pluginKey = ref.Key()
|
||||
if ref.DriverID != driver.BuiltinReimsMacOSDriverID {
|
||||
label = sshHostAliasForDriver(ref.DriverID, vm.Name)
|
||||
label = sshHostAlias(ref.DriverID, vm.Name)
|
||||
}
|
||||
if serial, err := a.ReadVMLogsWithDriver(ref.DriverID, vm.Name, true); err == nil {
|
||||
if serial, err := a.ReadVMLogs(ref.DriverID, vm.Name, true); err == nil {
|
||||
bundle.SerialLog = serial
|
||||
}
|
||||
if qemuLog, err := a.ReadVMLogsWithDriver(ref.DriverID, vm.Name, false); err == nil {
|
||||
if qemuLog, err := a.ReadVMLogs(ref.DriverID, vm.Name, false); err == nil {
|
||||
bundle.QEMULog = qemuLog
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,10 +10,7 @@ import (
|
||||
)
|
||||
|
||||
// ResizeVMDisk expands a stopped VM's virtual disk through its owning driver.
|
||||
func (a *App) ResizeVMDisk(name, newSize string) (driver.DiskResizeResult, error) {
|
||||
return a.ResizeVMDiskWithDriver("", name, newSize)
|
||||
}
|
||||
func (a *App) ResizeVMDiskWithDriver(driverID, name, newSize string) (driver.DiskResizeResult, error) {
|
||||
func (a *App) ResizeVMDisk(driverID, name, newSize string) (driver.DiskResizeResult, error) {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
@@ -39,18 +36,12 @@ func (a *App) ResizeVMDiskWithDriver(driverID, name, newSize string) (driver.Dis
|
||||
}
|
||||
|
||||
// CompactVMDisk reclaims unused host space through the owning driver.
|
||||
func (a *App) CompactVMDisk(name string) (driver.DiskCompactResult, error) {
|
||||
return a.CompactVMDiskWithDriver("", name)
|
||||
}
|
||||
func (a *App) CompactVMDiskWithDriver(driverID, name string) (driver.DiskCompactResult, error) {
|
||||
func (a *App) CompactVMDisk(driverID, name string) (driver.DiskCompactResult, error) {
|
||||
return a.runCompactVMDisk(driverID, name, false)
|
||||
}
|
||||
|
||||
// OptimizeVMDisk rewrites a stopped VM's qcow2 disk with extended L2 subclusters.
|
||||
func (a *App) OptimizeVMDisk(name string) (driver.DiskCompactResult, error) {
|
||||
return a.OptimizeVMDiskWithDriver("", name)
|
||||
}
|
||||
func (a *App) OptimizeVMDiskWithDriver(driverID, name string) (driver.DiskCompactResult, error) {
|
||||
func (a *App) OptimizeVMDisk(driverID, name string) (driver.DiskCompactResult, error) {
|
||||
return a.runCompactVMDisk(driverID, name, true)
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ func TestVMStatsDiskHeaderMeta(t *testing.T) {
|
||||
lastVMsAt: time.Now(),
|
||||
lifecycleSvc: vmlifecycle.New(reg, router, nil),
|
||||
}
|
||||
stats, err := a.GetVMStats("test")
|
||||
stats, err := a.GetVMStats("", "test")
|
||||
if err != nil || !stats.DiskExtendedL2 || stats.DiskSnapshotCount != 2 {
|
||||
t.Fatalf("GetVMStats = %+v, %v", stats, err)
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ func buildVMDisplayStatus(vm driver.VMInfo, cfg vmstart.VMDisplayConfig, display
|
||||
return status
|
||||
}
|
||||
|
||||
func (a *App) GetVMDisplayWithDriver(driverID, name string) (VMDisplayStatus, error) {
|
||||
func (a *App) GetVMDisplay(driverID, name string) (VMDisplayStatus, error) {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return VMDisplayStatus{}, err
|
||||
@@ -82,7 +82,7 @@ func (a *App) GetVMDisplayWithDriver(driverID, name string) (VMDisplayStatus, er
|
||||
return buildVMDisplayStatus(vm, vmstart.ReadVMDisplay(vm.Directory), a.displayHost.displays()), nil
|
||||
}
|
||||
|
||||
func (a *App) SetVMDisplayWithDriver(driverID, name, targetDisplay string) (VMDisplayStatus, error) {
|
||||
func (a *App) SetVMDisplay(driverID, name, targetDisplay string) (VMDisplayStatus, error) {
|
||||
if err := a.requireWritableDataRoot(); err != nil {
|
||||
return VMDisplayStatus{}, err
|
||||
}
|
||||
|
||||
@@ -72,15 +72,15 @@ func TestGetAndSetVMDisplay(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
status, err := a.GetVMDisplayWithDriver(driverID, name)
|
||||
status, err := a.GetVMDisplay(driverID, name)
|
||||
if err != nil || status.TargetDisplay != "" || status.EffectiveDisplay != "DISPLAY1" ||
|
||||
!status.Connected || status.FallbackToPrimary || status.Running || len(status.Displays) != 2 {
|
||||
t.Fatalf("get default = %+v, %v", status, err)
|
||||
}
|
||||
if _, err := a.SetVMDisplayWithDriver(driverID, name, "DISCONNECTED"); !errors.Is(err, host.ErrDisplayNotFound) {
|
||||
if _, err := a.SetVMDisplay(driverID, name, "DISCONNECTED"); !errors.Is(err, host.ErrDisplayNotFound) {
|
||||
t.Fatalf("new offline display error = %v", err)
|
||||
}
|
||||
status, err = a.SetVMDisplayWithDriver(driverID, name, " DISPLAY2 ")
|
||||
status, err = a.SetVMDisplay(driverID, name, " DISPLAY2 ")
|
||||
if err != nil || status.TargetDisplay != "DISPLAY2" || status.EffectiveDisplay != "DISPLAY2" || moveCalls != 0 {
|
||||
t.Fatalf("set while stopped = %+v, %v, %d moves", status, err, moveCalls)
|
||||
}
|
||||
@@ -89,14 +89,14 @@ func TestGetAndSetVMDisplay(t *testing.T) {
|
||||
t.Fatalf("display recommendations = %+v", status)
|
||||
}
|
||||
displays = displays[:1]
|
||||
status, err = a.GetVMDisplayWithDriver(driverID, name)
|
||||
status, err = a.GetVMDisplay(driverID, name)
|
||||
if err != nil || status.TargetDisplay != "DISPLAY2" || status.EffectiveDisplay != "DISPLAY1" || status.Connected || !status.FallbackToPrimary {
|
||||
t.Fatalf("get offline display = %+v, %v", status, err)
|
||||
}
|
||||
if status, err := a.SetVMDisplayWithDriver(driverID, name, "display2"); err != nil || !status.FallbackToPrimary {
|
||||
if status, err := a.SetVMDisplay(driverID, name, "display2"); err != nil || !status.FallbackToPrimary {
|
||||
t.Fatalf("keep offline display = %+v, %v", status, err)
|
||||
}
|
||||
if status, err := a.SetVMDisplayWithDriver(driverID, name, " PRIMARY "); err != nil || status.TargetDisplay != "" ||
|
||||
if status, err := a.SetVMDisplay(driverID, name, " PRIMARY "); err != nil || status.TargetDisplay != "" ||
|
||||
status.FallbackToPrimary || vmstart.ReadVMDisplay(vm.Directory).TargetDisplay != "" {
|
||||
t.Fatalf("clear offline display = %+v, %v", status, err)
|
||||
}
|
||||
@@ -106,13 +106,13 @@ func TestGetAndSetVMDisplay(t *testing.T) {
|
||||
// The detail view for the built-in driver gets its PID from the list.
|
||||
a.lastVMsAt = time.Now()
|
||||
a.lastVMs = []driver.VMListItem{{Name: name, DriverID: driverID, State: "running", PID: &pid}}
|
||||
status, err = a.SetVMDisplayWithDriver(driverID, name, "display2")
|
||||
status, err = a.SetVMDisplay(driverID, name, "display2")
|
||||
if err != nil || !status.Running || !status.Connected || status.EffectiveDisplay != "DISPLAY2" ||
|
||||
!status.AppliedLive || status.MoveError != "" || moveCalls != 1 {
|
||||
t.Fatalf("set while running = %+v, %v, %d moves", status, err, moveCalls)
|
||||
}
|
||||
moveErr = host.ErrDisplayWindowNotFound
|
||||
if status, err := a.SetVMDisplayWithDriver(driverID, name, "display2"); err != nil || status.AppliedLive || status.MoveError != "" || moveCalls != 2 {
|
||||
if status, err := a.SetVMDisplay(driverID, name, "display2"); err != nil || status.AppliedLive || status.MoveError != "" || moveCalls != 2 {
|
||||
t.Fatalf("set before window creation = %+v, %v, %d moves", status, err, moveCalls)
|
||||
}
|
||||
if logs := strings.Join(a.recentLogs, "\n"); !strings.Contains(logs, "Moved VM window") || !strings.Contains(logs, "Display window not ready") {
|
||||
@@ -122,7 +122,7 @@ func TestGetAndSetVMDisplay(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
moveErr = errors.New("move failed")
|
||||
status, err = a.SetVMDisplayWithDriver(driverID, name, "display2")
|
||||
status, err = a.SetVMDisplay(driverID, name, "display2")
|
||||
if err != nil || status.AppliedLive || !strings.Contains(status.MoveError, moveErr.Error()) || moveCalls != 3 {
|
||||
t.Fatalf("set with move failure = %+v, %v, %d moves", status, err, moveCalls)
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func TestSetVMDisplayReadOnly(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, target := range []string{"DISPLAY2", ""} {
|
||||
_, err := a.SetVMDisplayWithDriver(driverID, vm.Name, target)
|
||||
_, err := a.SetVMDisplay(driverID, vm.Name, target)
|
||||
var coded *i18n.CodedError
|
||||
if !errors.As(err, &coded) || coded.Code != "E_DATAROOT_NEWER" {
|
||||
t.Fatalf("set %q on read-only data root: %v", target, err)
|
||||
@@ -160,8 +160,8 @@ func TestSetVMDisplayReadOnly(t *testing.T) {
|
||||
func TestVMDisplayRejectsUnknownDriverWithoutLifecycleService(t *testing.T) {
|
||||
a := &App{cfg: config.Default()}
|
||||
const driverID = "test.driver.other"
|
||||
_, getErr := a.GetVMDisplayWithDriver(driverID, "test-vm")
|
||||
_, setErr := a.SetVMDisplayWithDriver(driverID, "test-vm", "")
|
||||
_, getErr := a.GetVMDisplay(driverID, "test-vm")
|
||||
_, setErr := a.SetVMDisplay(driverID, "test-vm", "")
|
||||
for _, err := range []error{getErr, setErr} {
|
||||
if err == nil || err.Error() != `driver "test.driver.other" is unavailable without the plugin manager` {
|
||||
t.Fatalf("unknown driver error = %v", err)
|
||||
@@ -200,13 +200,13 @@ func TestSetVMDisplayRefreshesStoppedPIDCache(t *testing.T) {
|
||||
return true, nil
|
||||
},
|
||||
}
|
||||
status, err := a.SetVMDisplayWithDriver(driverID, vm.Name, "DISPLAY1")
|
||||
status, err := a.SetVMDisplay(driverID, vm.Name, "DISPLAY1")
|
||||
if err != nil || !status.Running || !status.AppliedLive || status.MoveError != "" || moveCalls != 1 {
|
||||
t.Fatalf("set with stale cache = %+v, %v, %d moves", status, err, moveCalls)
|
||||
}
|
||||
|
||||
d.listErr = errors.New("PID lookup failed")
|
||||
status, err = a.SetVMDisplayWithDriver(driverID, vm.Name, "DISPLAY2")
|
||||
status, err = a.SetVMDisplay(driverID, vm.Name, "DISPLAY2")
|
||||
if err != nil || status.AppliedLive || !strings.Contains(status.MoveError, d.listErr.Error()) || moveCalls != 1 {
|
||||
t.Fatalf("set with PID lookup failure = %+v, %v, %d moves", status, err, moveCalls)
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func TestSetVMDisplayDoesNotBlockOtherVMs(t *testing.T) {
|
||||
}()
|
||||
aResult := make(chan error, 1)
|
||||
pending.Go(func() {
|
||||
_, err := a.SetVMDisplayWithDriver(driverID, vmA.Name, "DISPLAY2")
|
||||
_, err := a.SetVMDisplay(driverID, vmA.Name, "DISPLAY2")
|
||||
aResult <- err
|
||||
})
|
||||
select {
|
||||
@@ -250,7 +250,7 @@ func TestSetVMDisplayDoesNotBlockOtherVMs(t *testing.T) {
|
||||
}
|
||||
bResult := make(chan error, 1)
|
||||
pending.Go(func() {
|
||||
_, err := a.SetVMDisplayWithDriver(driverID, vmB.Name, "DISPLAY2")
|
||||
_, err := a.SetVMDisplay(driverID, vmB.Name, "DISPLAY2")
|
||||
bResult <- err
|
||||
})
|
||||
select {
|
||||
@@ -261,7 +261,7 @@ func TestSetVMDisplayDoesNotBlockOtherVMs(t *testing.T) {
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatal("VM-B could not save while VM-A was moving")
|
||||
}
|
||||
if status, err := a.GetVMDisplayWithDriver(driverID, vmB.Name); err != nil || status.TargetDisplay != "DISPLAY2" {
|
||||
if status, err := a.GetVMDisplay(driverID, vmB.Name); err != nil || status.TargetDisplay != "DISPLAY2" {
|
||||
t.Fatalf("get VM-B while VM-A is moving = %+v, %v", status, err)
|
||||
}
|
||||
}
|
||||
@@ -303,7 +303,7 @@ func TestPositionVMDisplayOnStartAfterManualSelection(t *testing.T) {
|
||||
ticks <- time.Time{}
|
||||
close(ticks)
|
||||
a.positionVMDisplayOnStart(context.Background(), vm, ticks, func(context.Context) (int, error) {
|
||||
status, err := a.SetVMDisplayWithDriver(driverID, vm.Name, "DISPLAY2")
|
||||
status, err := a.SetVMDisplay(driverID, vm.Name, "DISPLAY2")
|
||||
if err != nil || status.AppliedLive != manualMoved || status.MoveError != "" {
|
||||
t.Fatalf("manual move = %+v, %v", status, err)
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ func (a *App) requestElevation(ctx context.Context, broker *plugin.Broker, reg *
|
||||
if emit != nil {
|
||||
emit(prompt)
|
||||
} else {
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
a.emit("reims:elevate-request", prompt)
|
||||
}
|
||||
|
||||
|
||||
@@ -141,10 +141,10 @@ func findEndpoint(vm driver.VMInfo, kind string) (driver.VMEndpoint, error) {
|
||||
return driver.VMEndpoint{}, fmt.Errorf("%s has no %s endpoint", vm.Name, kind)
|
||||
}
|
||||
|
||||
// OpenVMEndpointWithDriver opens one way into a running guest: a terminal, a
|
||||
// OpenVMEndpoint opens one way into a running guest: a terminal, a
|
||||
// remote desktop, VMConnect or an adb shell. kind picks the endpoint and action
|
||||
// one of its fixed actions ("" is its default).
|
||||
func (a *App) OpenVMEndpointWithDriver(driverID, name, kind, action string) error {
|
||||
func (a *App) OpenVMEndpoint(driverID, name, kind, action string) error {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -175,11 +175,11 @@ func (a *App) OpenVMEndpointWithDriver(driverID, name, kind, action string) erro
|
||||
if kind == driver.EndpointSSH {
|
||||
switch action {
|
||||
case endpointActionDefault, endpointActionTerminal:
|
||||
return a.OpenSSHTerminalWithDriver(vm.DriverID, vm.Name, "")
|
||||
return a.OpenSSHTerminal(vm.DriverID, vm.Name, "")
|
||||
case endpointActionVSCode:
|
||||
return a.OpenVSCodeSSHWithDriver(vm.DriverID, vm.Name, "")
|
||||
return a.OpenVSCodeSSH(vm.DriverID, vm.Name, "")
|
||||
case endpointActionConfig:
|
||||
_, err := a.WriteSSHConfigWithDriver(vm.DriverID, vm.Name, "")
|
||||
_, err := a.WriteSSHConfig(vm.DriverID, vm.Name, "")
|
||||
return err
|
||||
}
|
||||
return fmt.Errorf("the ssh endpoint has no %q action", action)
|
||||
@@ -195,9 +195,9 @@ func (a *App) OpenVMEndpointWithDriver(driverID, name, kind, action string) erro
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetVMEndpointCommandWithDriver returns the command line that reaches an
|
||||
// GetVMEndpointCommand returns the command line that reaches an
|
||||
// endpoint, for the user to copy.
|
||||
func (a *App) GetVMEndpointCommandWithDriver(driverID, name, kind string) (string, error) {
|
||||
func (a *App) GetVMEndpointCommand(driverID, name, kind string) (string, error) {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
@@ -153,9 +153,9 @@ func TestSSHTargetPrefersTheEndpoint(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestSSHHostAliasSeparatesDrivers(t *testing.T) {
|
||||
mac := sshHostAliasForDriver("", "dev")
|
||||
other := sshHostAliasForDriver("vendor.driver.linux", "dev")
|
||||
another := sshHostAliasForDriver("vendor.driver.windows", "dev")
|
||||
mac := sshHostAlias("", "dev")
|
||||
other := sshHostAlias("vendor.driver.linux", "dev")
|
||||
another := sshHostAlias("vendor.driver.windows", "dev")
|
||||
if mac == other || other == another || mac == another {
|
||||
t.Fatalf("aliases collide: %q %q %q", mac, other, another)
|
||||
}
|
||||
|
||||
@@ -47,10 +47,7 @@ func (a *App) vmDirectoryForDriver(driverID, name string) string {
|
||||
}
|
||||
|
||||
// GetVMNote returns the optional single-line note saved for a VM.
|
||||
func (a *App) GetVMNote(name string) string { return a.GetVMNoteWithDriver("", name) }
|
||||
|
||||
// GetVMNoteWithDriver returns the note of the VM that driverID owns.
|
||||
func (a *App) GetVMNoteWithDriver(driverID, name string) string {
|
||||
func (a *App) GetVMNote(driverID, name string) string {
|
||||
dir := a.vmDirectoryForDriver(driverID, name)
|
||||
if dir == "" {
|
||||
return ""
|
||||
@@ -63,10 +60,7 @@ func (a *App) GetVMNoteWithDriver(driverID, name string) string {
|
||||
}
|
||||
|
||||
// SetVMNote stores a short single-line note next to the VM directory.
|
||||
func (a *App) SetVMNote(name, note string) error { return a.SetVMNoteWithDriver("", name, note) }
|
||||
|
||||
// SetVMNoteWithDriver stores the note of the VM that driverID owns.
|
||||
func (a *App) SetVMNoteWithDriver(driverID, name, note string) error {
|
||||
func (a *App) SetVMNote(driverID, name, note string) error {
|
||||
note = sanitizeVMNote(note)
|
||||
dir := a.vmDirectoryForDriver(driverID, name)
|
||||
if dir == "" {
|
||||
|
||||
@@ -153,7 +153,7 @@ func (a *App) onFullscreenHotkey(target host.IMETarget, hwnd uintptr) {
|
||||
if !host.IsForegroundDisplayWindow(hwnd, target.PID) {
|
||||
return
|
||||
}
|
||||
if _, err := a.ToggleVMFullscreenWithDriver(vm.DriverID, target.VMName); err != nil {
|
||||
if _, err := a.ToggleVMFullscreen(vm.DriverID, target.VMName); err != nil {
|
||||
a.emitVMLogForDriver(vm.DriverID, target.VMName, err.Error())
|
||||
}
|
||||
return
|
||||
|
||||
@@ -140,16 +140,16 @@ func TestSameNameVMsOfTwoDriversStayIsolatedInTheApp(t *testing.T) {
|
||||
tw := newTwoDriverApp(t)
|
||||
a := tw.app
|
||||
|
||||
if err := a.SetVMNoteWithDriver(tw.hosted.ID(), "dev", "hosted note"); err != nil {
|
||||
if err := a.SetVMNote(tw.hosted.ID(), "dev", "hosted note"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.SetVMNoteWithDriver(tw.process.ID(), "dev", "process note"); err != nil {
|
||||
if err := a.SetVMNote(tw.process.ID(), "dev", "process note"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if got := a.GetVMNoteWithDriver(tw.hosted.ID(), "dev"); got != "hosted note" {
|
||||
if got := a.GetVMNote(tw.hosted.ID(), "dev"); got != "hosted note" {
|
||||
t.Fatalf("hosted note = %q", got)
|
||||
}
|
||||
if got := a.GetVMNoteWithDriver(tw.process.ID(), "dev"); got != "process note" {
|
||||
if got := a.GetVMNote(tw.process.ID(), "dev"); got != "process note" {
|
||||
t.Fatalf("process note = %q", got)
|
||||
}
|
||||
for dir, want := range map[string]string{tw.hostedDir: "hosted note", tw.processDir: "process note"} {
|
||||
@@ -158,15 +158,15 @@ func TestSameNameVMsOfTwoDriversStayIsolatedInTheApp(t *testing.T) {
|
||||
t.Fatalf("note file in %s = %q, %v; want %q", dir, raw, err, want)
|
||||
}
|
||||
}
|
||||
if err := a.SetVMNoteWithDriver(tw.hosted.ID(), "dev", ""); err != nil {
|
||||
if err := a.SetVMNote(tw.hosted.ID(), "dev", ""); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if a.GetVMNoteWithDriver(tw.hosted.ID(), "dev") != "" || a.GetVMNoteWithDriver(tw.process.ID(), "dev") != "process note" {
|
||||
if a.GetVMNote(tw.hosted.ID(), "dev") != "" || a.GetVMNote(tw.process.ID(), "dev") != "process note" {
|
||||
t.Fatal("clearing one VM's note touched the other")
|
||||
}
|
||||
|
||||
if logs, err := a.ReadVMLogsWithDriver(tw.hosted.ID(), "dev", false); err != nil || logs == "" {
|
||||
t.Fatalf("ReadVMLogsWithDriver = %q, %v", logs, err)
|
||||
if logs, err := a.ReadVMLogs(tw.hosted.ID(), "dev", false); err != nil || logs == "" {
|
||||
t.Fatalf("ReadVMLogs = %q, %v", logs, err)
|
||||
}
|
||||
if _, err := a.GetVMInfo("", "dev"); err == nil {
|
||||
t.Fatal("a bare same-name lookup was not rejected as ambiguous")
|
||||
@@ -180,21 +180,21 @@ func TestHostedVMIsGatedFromWindowAndProcessFeatures(t *testing.T) {
|
||||
id := tw.hosted.ID()
|
||||
|
||||
// Not running and not ready: nothing to open.
|
||||
if err := a.FocusVMWindowWithDriver(id, "dev"); err == nil || !strings.Contains(err.Error(), "no ready endpoint") {
|
||||
t.Fatalf("FocusVMWindowWithDriver on a stopped hosted VM = %v", err)
|
||||
if err := a.FocusVMWindow(id, "dev"); err == nil || !strings.Contains(err.Error(), "no ready endpoint") {
|
||||
t.Fatalf("FocusVMWindow on a stopped hosted VM = %v", err)
|
||||
}
|
||||
|
||||
if _, err := tw.svc.Start(ctx, tw.hostedRef, io.Discard, io.Discard); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
waitFor(t, "the hosted VM to run", func() bool { return tw.listed(t, tw.hostedRef).State == "running" })
|
||||
if cmd, err := a.GetVMEndpointCommandWithDriver(id, "dev", driver.EndpointWSL); err != nil || cmd != "wsl.exe -d dev" {
|
||||
if cmd, err := a.GetVMEndpointCommand(id, "dev", driver.EndpointWSL); err != nil || cmd != "wsl.exe -d dev" {
|
||||
t.Fatalf("endpoint command = %q, %v", cmd, err)
|
||||
}
|
||||
if _, err := a.GetVMEndpointCommandWithDriver(tw.process.ID(), "dev", driver.EndpointWSL); err == nil {
|
||||
if _, err := a.GetVMEndpointCommand(tw.process.ID(), "dev", driver.EndpointWSL); err == nil {
|
||||
t.Fatal("the stopped same-name process VM exposed the hosted VM's endpoint")
|
||||
}
|
||||
stats, err := a.GetVMStatsWithDriver(id, "dev")
|
||||
stats, err := a.GetVMStats(id, "dev")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -202,22 +202,22 @@ func TestHostedVMIsGatedFromWindowAndProcessFeatures(t *testing.T) {
|
||||
t.Fatalf("hosted stats = %+v, want running with no process telemetry", stats)
|
||||
}
|
||||
|
||||
_, err = a.ToggleVMFullscreenWithDriver(id, "dev")
|
||||
_, err = a.ToggleVMFullscreen(id, "dev")
|
||||
var coded *i18n.CodedError
|
||||
if !errors.As(err, &coded) || coded.Code != "E_VM_WINDOW_NOT_FOUND" {
|
||||
t.Fatalf("ToggleVMFullscreenWithDriver = %v, want E_VM_WINDOW_NOT_FOUND", err)
|
||||
t.Fatalf("ToggleVMFullscreen = %v, want E_VM_WINDOW_NOT_FOUND", err)
|
||||
}
|
||||
if err := a.CopyVMScreenshotWithDriver(id, "dev"); err == nil {
|
||||
if err := a.CopyVMScreenshot(id, "dev"); err == nil {
|
||||
t.Fatal("a hosted VM must not offer screenshots")
|
||||
}
|
||||
if _, err := a.SetVMAffinityWithDriver(id, "dev", VMAffinityUpdate{}); err == nil {
|
||||
if _, err := a.SetVMAffinity(id, "dev", VMAffinityUpdate{}); err == nil {
|
||||
t.Fatal("a hosted VM must not accept CPU affinity")
|
||||
}
|
||||
if _, err := a.TypeTextWithDriver(id, "dev", "hello"); err == nil {
|
||||
if _, err := a.TypeText(id, "dev", "hello"); err == nil {
|
||||
t.Fatal("a hosted VM must not accept QMP typing")
|
||||
}
|
||||
if thumb, err := a.GetVMThumbnailWithDriver(id, "dev"); err != nil || thumb.Live {
|
||||
t.Fatalf("GetVMThumbnailWithDriver = %+v, %v; want no live frame", thumb, err)
|
||||
if thumb, err := a.GetVMThumbnail(id, "dev"); err != nil || thumb.Live {
|
||||
t.Fatalf("GetVMThumbnail = %+v, %v; want no live frame", thumb, err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,14 +239,14 @@ func TestProcessVMStatsFollowTheSpawnedJob(t *testing.T) {
|
||||
waitFor(t, "the broker to track the spawned VM", func() bool {
|
||||
return tw.harness.Broker.IsManagedVMRunning(tw.process.ID(), "dev")
|
||||
})
|
||||
stats, err := a.GetVMStatsWithDriver(tw.process.ID(), "dev")
|
||||
stats, err := a.GetVMStats(tw.process.ID(), "dev")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !stats.Running || stats.PID <= 0 {
|
||||
t.Fatalf("process VM stats = %+v, want running with a PID", stats)
|
||||
}
|
||||
if hostedStats, err := a.GetVMStatsWithDriver(tw.hosted.ID(), "dev"); err != nil || hostedStats.Running || hostedStats.PID != 0 {
|
||||
if hostedStats, err := a.GetVMStats(tw.hosted.ID(), "dev"); err != nil || hostedStats.Running || hostedStats.PID != 0 {
|
||||
t.Fatalf("same-name hosted VM stats = %+v, %v; want stopped", hostedStats, err)
|
||||
}
|
||||
}
|
||||
@@ -34,21 +34,10 @@ func (a *App) SetEnableHypervisorSwitch(enabled bool) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// EnableWHPX enables Windows Hypervisor Platform (if missing) and sets Windows
|
||||
// hypervisor boot launch to auto via UAC. Declining UAC is a no-op.
|
||||
func (a *App) EnableWHPX() error {
|
||||
_, err := a.setHypervisorBootInternal(true)
|
||||
return err
|
||||
}
|
||||
|
||||
// SetHypervisorBoot prompts for UAC and updates Windows hypervisor boot launch
|
||||
// (`auto` when enable is true, `off` when false). It returns changed=false with
|
||||
// err=nil when the person declines the UAC prompt, and never restarts Windows.
|
||||
func (a *App) SetHypervisorBoot(enable bool) (bool, error) {
|
||||
return a.setHypervisorBootInternal(enable)
|
||||
}
|
||||
|
||||
func (a *App) setHypervisorBootInternal(enable bool) (bool, error) {
|
||||
a.mu.Lock()
|
||||
loc := i18n.EffectiveLocale(a.cfg.Locale)
|
||||
dataRoot := a.cfg.DataRoot
|
||||
|
||||
@@ -116,8 +116,8 @@ func TestHypervisorSwitchGateAndBootGuards(t *testing.T) {
|
||||
if changed, err := a.SetHypervisorBoot(false); err != nil || changed {
|
||||
t.Fatalf("UAC decline should return (false, nil), got (%v, %v)", changed, err)
|
||||
}
|
||||
if err := a.EnableWHPX(); err != nil {
|
||||
t.Fatalf("EnableWHPX on UAC decline should return nil, got %v", err)
|
||||
if _, err := a.SetHypervisorBoot(true); err != nil {
|
||||
t.Fatalf("SetHypervisorBoot(true) on UAC decline should return nil, got %v", err)
|
||||
}
|
||||
if recordedPending != "" {
|
||||
t.Fatalf("UAC decline must not record pending boot, got %q", recordedPending)
|
||||
@@ -149,13 +149,13 @@ func TestHypervisorSwitchGateAndBootGuards(t *testing.T) {
|
||||
t.Fatalf("after undo: lastEnable=%v pending=%q", lastEnable, recordedPending)
|
||||
}
|
||||
|
||||
// 7. EnableWHPX when hypervisor_off sets pending="auto".
|
||||
// 7. SetHypervisorBoot(true) when hypervisor_off sets pending="auto".
|
||||
liveWHPX = host.WHPXHypervisorOff
|
||||
if err := a.EnableWHPX(); err != nil {
|
||||
t.Fatalf("EnableWHPX from hypervisor_off: %v", err)
|
||||
if _, err := a.SetHypervisorBoot(true); err != nil {
|
||||
t.Fatalf("SetHypervisorBoot(true) from hypervisor_off: %v", err)
|
||||
}
|
||||
if lastEnable != true || recordedPending != host.HypervisorBootAuto {
|
||||
t.Fatalf("after EnableWHPX: lastEnable=%v pending=%q", lastEnable, recordedPending)
|
||||
t.Fatalf("after SetHypervisorBoot(true): lastEnable=%v pending=%q", lastEnable, recordedPending)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ func TestHypervisorReadOnlyAndFirstRunIsolation(t *testing.T) {
|
||||
t.Fatal("read-only mode must never write hypervisor-boot-pending.json")
|
||||
}
|
||||
|
||||
// Case B: First-run setup (needsSetup=true) allows EnableWHPX in memory,
|
||||
// Case B: First-run setup (needsSetup=true) allows SetHypervisorBoot(true) in memory,
|
||||
// but must never write to the unconfirmed default candidate folder on disk.
|
||||
firstCfg := config.Default()
|
||||
firstCfg.DataRoot = dir
|
||||
@@ -225,16 +225,15 @@ func TestHypervisorReadOnlyAndFirstRunIsolation(t *testing.T) {
|
||||
transitions: make(map[string]string),
|
||||
pendingChanges: make(map[string][]PendingChange),
|
||||
}
|
||||
if err := firstApp.EnableWHPX(); err != nil {
|
||||
t.Fatalf("EnableWHPX during first-run setup: %v", err)
|
||||
if _, err := firstApp.SetHypervisorBoot(true); err != nil {
|
||||
t.Fatalf("SetHypervisorBoot(true) during first-run setup: %v", err)
|
||||
}
|
||||
if elevatedCalls != 1 {
|
||||
t.Fatalf("expected 1 elevated call during first-run EnableWHPX, got %d", elevatedCalls)
|
||||
t.Fatalf("expected 1 elevated call during first-run SetHypervisorBoot(true), got %d", elevatedCalls)
|
||||
}
|
||||
if fileExistsForTest(filepath.Join(tmpSub, "hypervisor-boot-pending.json")) {
|
||||
t.Fatal("first-run EnableWHPX must not write to unconfirmed candidate dataRoot/tmp")
|
||||
t.Fatal("first-run SetHypervisorBoot(true) must not write to unconfirmed candidate dataRoot/tmp")
|
||||
}
|
||||
// Clean up in-memory pending state.
|
||||
_ = host.RecordPendingHypervisorBoot("", host.WHPXReady, true)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ func (a *App) buildInstallGuide(ctx context.Context, g installguide.Guide, d rei
|
||||
if err := checkBoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
_, err := a.TypeText(name, text)
|
||||
_, err := a.TypeText("", name, text)
|
||||
return err
|
||||
}
|
||||
g.FinishRecovery = func() error {
|
||||
|
||||
@@ -89,9 +89,7 @@ func (a *App) GetVMInfo(driverID, name string) (driver.VMInfo, error) {
|
||||
return vm, err
|
||||
}
|
||||
|
||||
func (a *App) StartVM(name string) error { return a.StartVMWithDriver("", name) }
|
||||
|
||||
func (a *App) StartVMWithDriver(driverID, name string) error {
|
||||
func (a *App) StartVM(driverID, name string) error {
|
||||
if err := a.beginVMStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -119,7 +117,7 @@ func (a *App) StartVMWithDriver(driverID, name string) error {
|
||||
return err
|
||||
}
|
||||
if vm.State == "suspended" {
|
||||
return a.ResumeVMWithDriver(vm.DriverID, vm.Name)
|
||||
return a.ResumeVM(vm.DriverID, vm.Name)
|
||||
}
|
||||
return a.withComputerUseVM(context.Background(), vm.Directory, func(ctx context.Context) error {
|
||||
return a.startResolvedVMLocked(ctx, svc, vm)
|
||||
@@ -172,13 +170,11 @@ func (a *App) startResolvedVMLocked(ctx context.Context, svc interface {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) StopVM(name string, force bool) error { return a.StopVMWithDriver("", name, force) }
|
||||
|
||||
func (a *App) StopVMWithDriver(driverID, name string, force bool) error {
|
||||
return a.stopVMWithDriverCtx(context.Background(), driverID, name, force)
|
||||
func (a *App) StopVM(driverID, name string, force bool) error {
|
||||
return a.stopVM(context.Background(), driverID, name, force)
|
||||
}
|
||||
|
||||
func (a *App) stopVMWithDriverCtx(ctx context.Context, driverID, name string, force bool) error {
|
||||
func (a *App) stopVM(ctx context.Context, driverID, name string, force bool) error {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
@@ -221,9 +217,7 @@ func (a *App) stopVMWithDriverCtx(ctx context.Context, driverID, name string, fo
|
||||
return nil
|
||||
})
|
||||
}
|
||||
func (a *App) EjectInstaller(name string) error { return a.EjectInstallerWithDriver("", name) }
|
||||
|
||||
func (a *App) EjectInstallerWithDriver(driverID, name string) error {
|
||||
func (a *App) EjectInstaller(driverID, name string) error {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
@@ -248,7 +242,7 @@ func (a *App) EjectInstallerWithDriver(driverID, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) ReadVMLogsWithDriver(driverID, name string, serial bool) (string, error) {
|
||||
func (a *App) ReadVMLogs(driverID, name string, serial bool) (string, error) {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
@@ -258,7 +252,7 @@ func (a *App) ReadVMLogsWithDriver(driverID, name string, serial bool) (string,
|
||||
return svc.ReadLogs(context.Background(), driver.VMRef{DriverID: driverID, Name: name}, serial)
|
||||
}
|
||||
|
||||
func (a *App) RestartVMWithDriver(driverID, name string) error {
|
||||
func (a *App) RestartVM(driverID, name string) error {
|
||||
if err := a.beginVMStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -289,7 +283,7 @@ func (a *App) RestartVMWithDriver(driverID, name string) error {
|
||||
return err
|
||||
}
|
||||
return a.withComputerUseVM(a.baseCtx(), vm.Directory, func(ctx context.Context) error {
|
||||
if err := a.stopVMWithDriverCtx(ctx, ref.DriverID, ref.Name, false); err != nil {
|
||||
if err := a.stopVM(ctx, ref.DriverID, ref.Name, false); err != nil {
|
||||
return err
|
||||
}
|
||||
return a.startResolvedVMLocked(ctx, svc, vm)
|
||||
@@ -299,11 +293,7 @@ func (a *App) RestartVMWithDriver(driverID, name string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (a *App) DeleteVM(name string, keepFiles bool) error {
|
||||
return a.DeleteVMWithDriver("", name, keepFiles)
|
||||
}
|
||||
|
||||
func (a *App) DeleteVMWithDriver(driverID, name string, keepFiles bool) error {
|
||||
func (a *App) DeleteVM(driverID, name string, keepFiles bool) error {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
|
||||
@@ -92,10 +92,10 @@ func TestAppSecondDriverUserEntry(t *testing.T) {
|
||||
if err != nil || len(vms) != 1 || vms[0].DriverID != driverID {
|
||||
t.Fatalf("list = %+v, %v", vms, err)
|
||||
}
|
||||
if err := a.StartVMWithDriver(driverID, "ubuntu"); err != nil {
|
||||
if err := a.StartVM(driverID, "ubuntu"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.StopVMWithDriver(driverID, "ubuntu", false); err != nil {
|
||||
if err := a.StopVM(driverID, "ubuntu", false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.startHandedVM(driverID, "ubuntu"); err != nil {
|
||||
@@ -104,10 +104,10 @@ func TestAppSecondDriverUserEntry(t *testing.T) {
|
||||
if err := a.lifecycleSvc.Set(context.Background(), driver.NewVMRef(driverID, "ubuntu"), map[string]any{"memory": "8G"}, io.Discard, io.Discard); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.RestartVMWithDriver(driverID, "ubuntu"); err != nil {
|
||||
if err := a.RestartVM(driverID, "ubuntu"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := a.DeleteVMWithDriver(driverID, "ubuntu", false); err != nil {
|
||||
if err := a.DeleteVM(driverID, "ubuntu", false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if drv.starts != 3 || drv.stops != 2 || drv.deletes != 1 || drv.sets != 1 {
|
||||
@@ -190,14 +190,14 @@ func TestSameNameVMsAcrossDriversStayIndependent(t *testing.T) {
|
||||
a := &App{cfg: &config.Config{DataRoot: t.TempDir()}, lifecycleSvc: vmlifecycle.New(reg, driver.NewRouter(reg, nil), nil),
|
||||
transitions: map[string]string{}, pendingChanges: map[string][]PendingChange{}}
|
||||
|
||||
if err := a.StopVM("dup", false); err == nil {
|
||||
if err := a.StopVM("", "dup", false); err == nil {
|
||||
t.Fatal("bare-name stop must stay ambiguous")
|
||||
}
|
||||
d, err := a.GetVMDetail("dup")
|
||||
if err != nil || d.Directory != mac.vms[0].Directory {
|
||||
t.Fatalf("GetVMDetail = %+v, %v", d, err)
|
||||
}
|
||||
if err := a.RestartVMWithDriver(driver.BuiltinReimsMacOSDriverID, "dup"); err != nil {
|
||||
if err := a.RestartVM(driver.BuiltinReimsMacOSDriverID, "dup"); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if mac.stops != 1 || mac.starts != 1 || lin.stops != 0 || lin.starts != 0 {
|
||||
|
||||
@@ -173,7 +173,7 @@ func (a *App) watchWin10ColdReboot(name, qmpAddr string) {
|
||||
if watchCtx.Err() != nil {
|
||||
return
|
||||
}
|
||||
if err := a.StartVMWithDriver(driver.BuiltinReimsMacOSDriverID, name); err != nil {
|
||||
if err := a.StartVM(driver.BuiltinReimsMacOSDriverID, name); err != nil {
|
||||
a.emitVMLog(name, "Win10 WHPX cold-reboot start failed: "+err.Error())
|
||||
}
|
||||
}()
|
||||
@@ -491,8 +491,6 @@ func (a *App) stopMacOSVMLocked(ctx context.Context, name string, force bool, c
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RestartVM(name string) error { return a.RestartVMWithDriver("", name) }
|
||||
|
||||
// restartMacOSVM restarts a built-in macOS VM, waiting for the old QEMU
|
||||
// process and its committed memory to go away before starting again.
|
||||
func (a *App) restartMacOSVM(ctx context.Context, name string) (stopped bool, err error) {
|
||||
@@ -509,7 +507,7 @@ func (a *App) restartMacOSVM(ctx context.Context, name string) (stopped bool, er
|
||||
|
||||
func (a *App) restartMacOSVMLocked(ctx context.Context, name string) (stopped bool, err error) {
|
||||
oldPID := a.cachedVMPID(name)
|
||||
if err := a.stopVMWithDriverCtx(ctx, driver.BuiltinReimsMacOSDriverID, name, false); err != nil {
|
||||
if err := a.stopVM(ctx, driver.BuiltinReimsMacOSDriverID, name, false); err != nil {
|
||||
return false, err
|
||||
}
|
||||
a.waitForVMProcessExit(ctx, oldPID, vmExitWaitTimeout)
|
||||
@@ -619,10 +617,6 @@ func (a *App) OpenVMFolder(name string) error {
|
||||
return host.OpenFolder(d.Directory)
|
||||
}
|
||||
|
||||
func (a *App) ReadVMLogs(name string, serial bool) (string, error) {
|
||||
return a.ReadVMLogsWithDriver("", name, serial)
|
||||
}
|
||||
|
||||
func (a *App) readMacOSVMLogs(name string, serial bool) (string, error) {
|
||||
c, err := a.client()
|
||||
if err != nil {
|
||||
|
||||
@@ -955,31 +955,6 @@ func (a *App) ReadPluginLog(pluginID string) (string, error) {
|
||||
return host.RedactText(string(raw)), nil
|
||||
}
|
||||
|
||||
func (a *App) DoctorPlugin(pluginID string) []plugin.DoctorFinding {
|
||||
a.mu.Lock()
|
||||
mgr := a.pluginMgr
|
||||
a.mu.Unlock()
|
||||
if mgr == nil {
|
||||
return nil
|
||||
}
|
||||
info, ok := mgr.Registry().Info(pluginID)
|
||||
if !ok {
|
||||
return []plugin.DoctorFinding{{
|
||||
Severity: "error",
|
||||
Check: "lookup",
|
||||
Message: fmt.Sprintf("plugin %q not found", pluginID),
|
||||
}}
|
||||
}
|
||||
if info.InstallDir == "" {
|
||||
return []plugin.DoctorFinding{{
|
||||
Severity: "ok",
|
||||
Check: "builtin",
|
||||
Message: fmt.Sprintf("%s@%s (%s)", info.ID, info.Version, info.State),
|
||||
}}
|
||||
}
|
||||
return plugin.DoctorDirectory(info.InstallDir, version.Version, nil)
|
||||
}
|
||||
|
||||
// InspectPluginArchive runs the unified static security scanner on a local .zip
|
||||
// package before installing it so the UI can display hard blockers, capabilities,
|
||||
// and L3 native execution notices.
|
||||
|
||||
@@ -79,7 +79,7 @@ func (a *App) forceStopRunningVMs(ctx context.Context) error {
|
||||
return vms, err
|
||||
}
|
||||
return stopListedVMs(ctx, loc, list, func(ctx context.Context, vm driver.VMListItem) error {
|
||||
return a.stopVMWithDriverCtx(ctx, vm.DriverID, vm.Name, true)
|
||||
return a.stopVM(ctx, vm.DriverID, vm.Name, true)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ func TestForceQuitAppWaitsForStartsAndCanRetry(t *testing.T) {
|
||||
}
|
||||
time.Sleep(time.Millisecond)
|
||||
}
|
||||
for _, launch := range []func(string) error{a.StartVM, a.ResumeVM} {
|
||||
if err := launch("new"); err == nil || err.Error() != i18n.T(i18n.EnUS, "quitInProgress") {
|
||||
for _, launch := range []func(driverID, name string) error{a.StartVM, a.ResumeVM} {
|
||||
if err := launch("", "new"); err == nil || err.Error() != i18n.T(i18n.EnUS, "quitInProgress") {
|
||||
t.Fatalf("launch during shutdown: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// ListSnapshots returns all driver-owned restore points for a VM, newest first.
|
||||
func (a *App) ListSnapshots(name string) ([]driver.DiskSnapshot, error) {
|
||||
return a.ListSnapshotsWithDriver("", name)
|
||||
}
|
||||
func (a *App) ListSnapshotsWithDriver(driverID, name string) ([]driver.DiskSnapshot, error) {
|
||||
func (a *App) ListSnapshots(driverID, name string) ([]driver.DiskSnapshot, error) {
|
||||
a.mu.Lock()
|
||||
svc := a.lifecycleSvc
|
||||
a.mu.Unlock()
|
||||
@@ -24,26 +21,17 @@ func (a *App) ListSnapshotsWithDriver(driverID, name string) ([]driver.DiskSnaps
|
||||
return svc.ListSnapshots(a.baseCtx(), driver.VMRef{DriverID: driverID, Name: name})
|
||||
}
|
||||
|
||||
func (a *App) CreateSnapshot(name, snapName string) error {
|
||||
return a.CreateSnapshotWithDriver("", name, snapName)
|
||||
func (a *App) CreateSnapshot(driverID, name, snapName string) error {
|
||||
return a.runSnapshotOp(driverID, name, "create", snapName, "Created restore point")
|
||||
}
|
||||
func (a *App) CreateSnapshotWithDriver(driverID, name, snapName string) error {
|
||||
return a.runSnapshotOpWithDriver(driverID, name, "create", snapName, "Created restore point")
|
||||
func (a *App) RestoreSnapshot(driverID, name, snapName string) error {
|
||||
return a.runSnapshotOp(driverID, name, "restore", snapName, "Restored restore point")
|
||||
}
|
||||
func (a *App) RestoreSnapshot(name, snapName string) error {
|
||||
return a.RestoreSnapshotWithDriver("", name, snapName)
|
||||
}
|
||||
func (a *App) RestoreSnapshotWithDriver(driverID, name, snapName string) error {
|
||||
return a.runSnapshotOpWithDriver(driverID, name, "restore", snapName, "Restored restore point")
|
||||
}
|
||||
func (a *App) DeleteSnapshot(name, snapName string) error {
|
||||
return a.DeleteSnapshotWithDriver("", name, snapName)
|
||||
}
|
||||
func (a *App) DeleteSnapshotWithDriver(driverID, name, snapName string) error {
|
||||
return a.runSnapshotOpWithDriver(driverID, name, "delete", snapName, "Deleted restore point")
|
||||
func (a *App) DeleteSnapshot(driverID, name, snapName string) error {
|
||||
return a.runSnapshotOp(driverID, name, "delete", snapName, "Deleted restore point")
|
||||
}
|
||||
|
||||
func (a *App) runSnapshotOpWithDriver(driverID, name, operation, snapName, verb string) error {
|
||||
func (a *App) runSnapshotOp(driverID, name, operation, snapName, verb string) error {
|
||||
loc := a.locale()
|
||||
cleanSnap := strings.TrimSpace(snapName)
|
||||
if cleanSnap == "" {
|
||||
|
||||
+14
-26
@@ -15,7 +15,7 @@ const sshUserFileName = ".reims-go-ssh-user"
|
||||
|
||||
var safeSSHUserRe = regexp.MustCompile(`^[A-Za-z0-9._-]+$`)
|
||||
|
||||
func sshHostAliasForDriver(driverID, vmName string) string {
|
||||
func sshHostAlias(driverID, vmName string) string {
|
||||
var b strings.Builder
|
||||
b.WriteString("reims-")
|
||||
if id := driver.CanonicalDriverID(driverID); id != "" && id != driver.BuiltinReimsMacOSDriverID {
|
||||
@@ -46,8 +46,7 @@ func sshConfigKey(driverID, name string) string {
|
||||
}
|
||||
|
||||
// GetVMSSHUser returns the remembered SSH login user for a VM (empty if unset).
|
||||
func (a *App) GetVMSSHUser(name string) string { return a.GetVMSSHUserWithDriver("", name) }
|
||||
func (a *App) GetVMSSHUserWithDriver(driverID, name string) string {
|
||||
func (a *App) GetVMSSHUser(driverID, name string) string {
|
||||
d, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil || d.Directory == "" {
|
||||
return ""
|
||||
@@ -60,8 +59,7 @@ func (a *App) GetVMSSHUserWithDriver(driverID, name string) string {
|
||||
}
|
||||
|
||||
// SetVMSSHUser persists the preferred SSH login user for a VM.
|
||||
func (a *App) SetVMSSHUser(name, user string) error { return a.SetVMSSHUserWithDriver("", name, user) }
|
||||
func (a *App) SetVMSSHUserWithDriver(driverID, name, user string) error {
|
||||
func (a *App) SetVMSSHUser(driverID, name, user string) error {
|
||||
user = strings.TrimSpace(user)
|
||||
if user != "" && !safeSSHUserRe.MatchString(user) {
|
||||
return fmt.Errorf("invalid SSH username %q", user)
|
||||
@@ -81,12 +79,6 @@ func (a *App) SetVMSSHUserWithDriver(driverID, name, user string) error {
|
||||
return os.WriteFile(p, []byte(user+"\n"), 0o644)
|
||||
}
|
||||
|
||||
// OpenSSHTerminal launches an interactive Windows Terminal (falling back to
|
||||
// PowerShell) connected to the VM's forwarded SSH port.
|
||||
func (a *App) OpenSSHTerminal(name, user string) error {
|
||||
return a.OpenSSHTerminalWithDriver("", name, user)
|
||||
}
|
||||
|
||||
// sshTarget is where a VM's SSH server answers: the ssh endpoint the driver
|
||||
// reports (a hosted VM may sit on its own address), else the forwarded port.
|
||||
func sshTarget(vm driver.VMInfo) (host string, port int, user string, ok bool) {
|
||||
@@ -105,7 +97,9 @@ func sshTarget(vm driver.VMInfo) (host string, port int, user string, ok bool) {
|
||||
return "", 0, "", false
|
||||
}
|
||||
|
||||
func (a *App) OpenSSHTerminalWithDriver(driverID, name, user string) error {
|
||||
// OpenSSHTerminal launches an interactive Windows Terminal (falling back to
|
||||
// PowerShell) connected to the VM's forwarded SSH port.
|
||||
func (a *App) OpenSSHTerminal(driverID, name, user string) error {
|
||||
d, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -116,11 +110,11 @@ func (a *App) OpenSSHTerminalWithDriver(driverID, name, user string) error {
|
||||
}
|
||||
user = strings.TrimSpace(user)
|
||||
if user == "" {
|
||||
user = a.GetVMSSHUserWithDriver(driverID, name)
|
||||
user = a.GetVMSSHUser(driverID, name)
|
||||
} else if !safeSSHUserRe.MatchString(user) {
|
||||
return fmt.Errorf("invalid SSH username %q", user)
|
||||
} else {
|
||||
_ = a.SetVMSSHUserWithDriver(driverID, name, user)
|
||||
_ = a.SetVMSSHUser(driverID, name, user)
|
||||
}
|
||||
if user == "" {
|
||||
user = endpointUser
|
||||
@@ -147,10 +141,7 @@ func (a *App) OpenSSHTerminalWithDriver(driverID, name, user string) error {
|
||||
|
||||
// WriteSSHConfig idempotently writes or updates a Host block for the VM in
|
||||
// ~/.ssh/config and returns the configured Host alias (e.g. "reims-macos-tahoe").
|
||||
func (a *App) WriteSSHConfig(name, user string) (string, error) {
|
||||
return a.WriteSSHConfigWithDriver("", name, user)
|
||||
}
|
||||
func (a *App) WriteSSHConfigWithDriver(driverID, name, user string) (string, error) {
|
||||
func (a *App) WriteSSHConfig(driverID, name, user string) (string, error) {
|
||||
d, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return "", err
|
||||
@@ -161,11 +152,11 @@ func (a *App) WriteSSHConfigWithDriver(driverID, name, user string) (string, err
|
||||
}
|
||||
user = strings.TrimSpace(user)
|
||||
if user == "" {
|
||||
user = a.GetVMSSHUserWithDriver(driverID, name)
|
||||
user = a.GetVMSSHUser(driverID, name)
|
||||
} else if !safeSSHUserRe.MatchString(user) {
|
||||
return "", fmt.Errorf("invalid SSH username %q", user)
|
||||
} else {
|
||||
_ = a.SetVMSSHUserWithDriver(driverID, name, user)
|
||||
_ = a.SetVMSSHUser(driverID, name, user)
|
||||
}
|
||||
if user == "" {
|
||||
user = endpointUser
|
||||
@@ -179,7 +170,7 @@ func (a *App) WriteSSHConfigWithDriver(driverID, name, user string) (string, err
|
||||
return "", fmt.Errorf("create ~/.ssh: %w", err)
|
||||
}
|
||||
cfgPath := filepath.Join(sshDir, "config")
|
||||
alias := sshHostAliasForDriver(driverID, name)
|
||||
alias := sshHostAlias(driverID, name)
|
||||
if err := upsertSSHConfigBlock(cfgPath, sshConfigKey(driverID, name), alias, sshHost, sshPort, user); err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -189,11 +180,8 @@ func (a *App) WriteSSHConfigWithDriver(driverID, name, user string) (string, err
|
||||
|
||||
// OpenVSCodeSSH ensures the VM's Host block is present in ~/.ssh/config and
|
||||
// launches VS Code (falling back to Cursor) in Remote-SSH mode.
|
||||
func (a *App) OpenVSCodeSSH(name, user string) error {
|
||||
return a.OpenVSCodeSSHWithDriver("", name, user)
|
||||
}
|
||||
func (a *App) OpenVSCodeSSHWithDriver(driverID, name, user string) error {
|
||||
alias, err := a.WriteSSHConfigWithDriver(driverID, name, user)
|
||||
func (a *App) OpenVSCodeSSH(driverID, name, user string) error {
|
||||
alias, err := a.WriteSSHConfig(driverID, name, user)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import (
|
||||
)
|
||||
|
||||
func TestSSHHostAlias(t *testing.T) {
|
||||
if sshHostAliasForDriver("test.driver.linux", "dev") == sshHostAliasForDriver("", "dev") {
|
||||
if sshHostAlias("test.driver.linux", "dev") == sshHostAlias("", "dev") {
|
||||
t.Fatal("same-name drivers share an SSH alias")
|
||||
}
|
||||
if got := sshHostAliasForDriver("", "macos-tahoe"); got != "reims-macos-tahoe" {
|
||||
if got := sshHostAlias("", "macos-tahoe"); got != "reims-macos-tahoe" {
|
||||
t.Fatalf("alias = %q", got)
|
||||
}
|
||||
if got := sshHostAliasForDriver("", "My Mac 26"); got != "reims-my-mac-26" {
|
||||
if got := sshHostAlias("", "My Mac 26"); got != "reims-my-mac-26" {
|
||||
t.Fatalf("alias = %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,8 +34,7 @@ type VMStats struct {
|
||||
}
|
||||
|
||||
// GetVMStats samples host-side process and disk telemetry through the owning driver.
|
||||
func (a *App) GetVMStats(name string) (VMStats, error) { return a.GetVMStatsWithDriver("", name) }
|
||||
func (a *App) GetVMStatsWithDriver(driverID, name string) (VMStats, error) {
|
||||
func (a *App) GetVMStats(driverID, name string) (VMStats, error) {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return VMStats{Name: name}, err
|
||||
|
||||
@@ -62,7 +62,7 @@ func TestVMStatsReportsLiveGuestToolsAgentVersion(t *testing.T) {
|
||||
if res.StatusCode != http.StatusOK {
|
||||
t.Fatalf("agent status: %s", res.Status)
|
||||
}
|
||||
stats, err := a.GetVMStats(name)
|
||||
stats, err := a.GetVMStats("", name)
|
||||
if err != nil || !stats.GuestToolsConnected || stats.GuestToolsAgentVersion != version {
|
||||
t.Fatalf("VM stats: %+v, %v", stats, err)
|
||||
}
|
||||
|
||||
@@ -14,11 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// SuspendVM saves a VM's running state and closes its QEMU process.
|
||||
func (a *App) SuspendVM(name string) error {
|
||||
return a.SuspendVMWithDriver("", name)
|
||||
}
|
||||
|
||||
func (a *App) SuspendVMWithDriver(driverID, name string) error {
|
||||
func (a *App) SuspendVM(driverID, name string) error {
|
||||
if err := a.requireWritableDataRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -73,11 +69,7 @@ func (a *App) SuspendVMWithDriver(driverID, name string) error {
|
||||
}
|
||||
|
||||
// ResumeVM restores a suspended VM with its original media and devices.
|
||||
func (a *App) ResumeVM(name string) error {
|
||||
return a.ResumeVMWithDriver("", name)
|
||||
}
|
||||
|
||||
func (a *App) ResumeVMWithDriver(driverID, name string) error {
|
||||
func (a *App) ResumeVM(driverID, name string) error {
|
||||
if err := a.beginVMStart(); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -225,11 +217,7 @@ func (a *App) registerResumeGuestTools(vm driver.VMInfo, epoch uint64, unicodeIn
|
||||
}
|
||||
|
||||
// DiscardSuspend deletes a stopped VM's saved execution state.
|
||||
func (a *App) DiscardSuspend(name string) error {
|
||||
return a.DiscardSuspendWithDriver("", name)
|
||||
}
|
||||
|
||||
func (a *App) DiscardSuspendWithDriver(driverID, name string) error {
|
||||
func (a *App) DiscardSuspend(driverID, name string) error {
|
||||
if err := a.requireWritableDataRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -187,7 +187,7 @@ func TestResumeVMRegistersSavedGuestToolsWithoutUnicodeInput(t *testing.T) {
|
||||
}
|
||||
}
|
||||
})
|
||||
if err := a.ResumeVM(name); !errors.Is(err, tc.resumeErr) {
|
||||
if err := a.ResumeVM("", name); !errors.Is(err, tc.resumeErr) {
|
||||
t.Fatalf("ResumeVM error = %v, want %v", err, tc.resumeErr)
|
||||
}
|
||||
if !tc.savedConfig {
|
||||
|
||||
@@ -294,14 +294,6 @@ func (m *taskManager) cancelAll() {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *taskManager) dismiss(id string) {
|
||||
m.mu.Lock()
|
||||
if e, ok := m.tasks[id]; ok && e.task.Status != TaskRunning {
|
||||
delete(m.tasks, id)
|
||||
}
|
||||
m.mu.Unlock()
|
||||
}
|
||||
|
||||
func (m *taskManager) get(id string) (Task, bool) {
|
||||
m.mu.Lock()
|
||||
defer m.mu.Unlock()
|
||||
@@ -379,9 +371,6 @@ func (a *App) GetTasks() []Task {
|
||||
// CancelTask stops a cancelable task (a download pauses; rerunning resumes it).
|
||||
func (a *App) CancelTask(id string) error { return tasks.cancel(id) }
|
||||
|
||||
// DismissTask forgets a finished task.
|
||||
func (a *App) DismissTask(id string) { tasks.dismiss(id) }
|
||||
|
||||
func (a *App) ensureTaskEmitter() {
|
||||
tasks.mu.Lock()
|
||||
if tasks.emit == nil {
|
||||
|
||||
@@ -97,3 +97,12 @@ func TestCtlTaskWriterRoutesProgressToTheTask(t *testing.T) {
|
||||
t.Fatalf("final = %+v", final)
|
||||
}
|
||||
}
|
||||
|
||||
// dismiss drops a finished task, so one test does not see another's.
|
||||
func (m *taskManager) dismiss(id string) {
|
||||
m.mu.Lock()
|
||||
if e, ok := m.tasks[id]; ok && e.task.Status != TaskRunning {
|
||||
delete(m.tasks, id)
|
||||
}
|
||||
m.mu.Unlock()
|
||||
}
|
||||
@@ -42,7 +42,7 @@ var thumbLocks = struct {
|
||||
locks map[string]*sync.Mutex
|
||||
}{locks: make(map[string]*sync.Mutex)}
|
||||
|
||||
func (a *App) thumbPathForDriver(driverID, name string) string {
|
||||
func (a *App) thumbPath(driverID, name string) string {
|
||||
a.mu.Lock()
|
||||
dir := a.cfg.XDGCacheDir()
|
||||
a.mu.Unlock()
|
||||
@@ -58,7 +58,7 @@ func (a *App) thumbPathForDriver(driverID, name string) string {
|
||||
return filepath.Join(dir, "thumbs", prefix+name+".jpg")
|
||||
}
|
||||
|
||||
func vmThumbLockForDriver(driverID, name string) *sync.Mutex {
|
||||
func vmThumbLock(driverID, name string) *sync.Mutex {
|
||||
key := vmKeyForDriver(driverID, name)
|
||||
thumbLocks.mu.Lock()
|
||||
defer thumbLocks.mu.Unlock()
|
||||
@@ -76,7 +76,7 @@ func releaseVMThumbnail(name string) { releaseVMThumbnailForDriver("", name) }
|
||||
|
||||
func releaseVMThumbnailForDriver(driverID, name string) {
|
||||
key := vmKeyForDriver(driverID, name)
|
||||
mu := vmThumbLockForDriver(driverID, name)
|
||||
mu := vmThumbLock(driverID, name)
|
||||
mu.Lock()
|
||||
thumbLocks.mu.Lock()
|
||||
if thumbLocks.locks[key] == mu {
|
||||
@@ -88,15 +88,12 @@ func releaseVMThumbnailForDriver(driverID, name string) {
|
||||
|
||||
// GetVMThumbnail returns the VM's screen: a fresh frame while it runs, else
|
||||
// the last one saved. An empty DataURL means there is no frame to show.
|
||||
func (a *App) GetVMThumbnail(name string) (VMThumbnail, error) {
|
||||
return a.GetVMThumbnailWithDriver("", name)
|
||||
}
|
||||
func (a *App) GetVMThumbnailWithDriver(driverID, name string) (VMThumbnail, error) {
|
||||
path := a.thumbPathForDriver(driverID, name)
|
||||
mu := vmThumbLockForDriver(driverID, name)
|
||||
func (a *App) GetVMThumbnail(driverID, name string) (VMThumbnail, error) {
|
||||
path := a.thumbPath(driverID, name)
|
||||
mu := vmThumbLock(driverID, name)
|
||||
if mu.TryLock() {
|
||||
defer mu.Unlock()
|
||||
if t, ok := a.captureThumbWithDriver(driverID, name, path); ok {
|
||||
if t, ok := a.captureThumb(driverID, name, path); ok {
|
||||
return t, nil
|
||||
}
|
||||
}
|
||||
@@ -105,8 +102,7 @@ func (a *App) GetVMThumbnailWithDriver(driverID, name string) (VMThumbnail, erro
|
||||
|
||||
// FocusVMWindow brings a running VM's QEMU display window to the foreground,
|
||||
// restoring it first if minimized.
|
||||
func (a *App) FocusVMWindow(name string) error { return a.FocusVMWindowWithDriver("", name) }
|
||||
func (a *App) FocusVMWindowWithDriver(driverID, name string) error {
|
||||
func (a *App) FocusVMWindow(driverID, name string) error {
|
||||
info, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -117,7 +113,7 @@ func (a *App) FocusVMWindowWithDriver(driverID, name string) error {
|
||||
if !ok {
|
||||
return fmt.Errorf("%s has no ready endpoint to open", name)
|
||||
}
|
||||
return a.OpenVMEndpointWithDriver(info.DriverID, info.Name, ep.Kind, "")
|
||||
return a.OpenVMEndpoint(info.DriverID, info.Name, ep.Kind, "")
|
||||
}
|
||||
vm, ok := a.polledVMForDriver(info.DriverID, name)
|
||||
if !ok || vm.State != "running" {
|
||||
@@ -141,10 +137,7 @@ func (a *App) FocusVMWindowWithDriver(driverID, name string) error {
|
||||
}
|
||||
|
||||
// ToggleVMFullscreen switches the running VM's display through its owning driver.
|
||||
func (a *App) ToggleVMFullscreen(name string) (bool, error) {
|
||||
return a.ToggleVMFullscreenWithDriver("", name)
|
||||
}
|
||||
func (a *App) ToggleVMFullscreenWithDriver(driverID, name string) (bool, error) {
|
||||
func (a *App) ToggleVMFullscreen(driverID, name string) (bool, error) {
|
||||
a.mu.Lock()
|
||||
preference := a.cfg.Locale
|
||||
a.mu.Unlock()
|
||||
@@ -190,8 +183,7 @@ func (a *App) ToggleVMFullscreenWithDriver(driverID, name string) (bool, error)
|
||||
|
||||
// CopyVMScreenshot captures a full-resolution frame from a running VM over QMP
|
||||
// and writes it as a PNG/DIB image to the Windows clipboard.
|
||||
func (a *App) CopyVMScreenshot(name string) error { return a.CopyVMScreenshotWithDriver("", name) }
|
||||
func (a *App) CopyVMScreenshotWithDriver(driverID, name string) error {
|
||||
func (a *App) CopyVMScreenshot(driverID, name string) error {
|
||||
info, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -210,7 +202,7 @@ func (a *App) CopyVMScreenshotWithDriver(driverID, name string) error {
|
||||
if route.kind == consoleRouteQMP && route.vm.Directory == "" {
|
||||
return fmt.Errorf("VM %s is not running", name)
|
||||
}
|
||||
mu := vmThumbLockForDriver(driverID, name)
|
||||
mu := vmThumbLock(driverID, name)
|
||||
mu.Lock()
|
||||
defer mu.Unlock()
|
||||
|
||||
@@ -236,7 +228,7 @@ func (a *App) CopyVMScreenshotWithDriver(driverID, name string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) captureThumbWithDriver(driverID, name, path string) (VMThumbnail, bool) {
|
||||
func (a *App) captureThumb(driverID, name, path string) (VMThumbnail, bool) {
|
||||
typing.mu.Lock()
|
||||
busy := typing.busy[vmKeyForDriver(driverID, name)]
|
||||
typing.mu.Unlock()
|
||||
|
||||
@@ -17,8 +17,8 @@ import (
|
||||
func TestReleaseVMThumbnailRemovesLock(t *testing.T) {
|
||||
const name = "thumbnail-release-test"
|
||||
t.Cleanup(func() { releaseVMThumbnail(name) })
|
||||
first := vmThumbLockForDriver("", name)
|
||||
if got := vmThumbLockForDriver("", name); got != first {
|
||||
first := vmThumbLock("", name)
|
||||
if got := vmThumbLock("", name); got != first {
|
||||
t.Fatal("same VM should share a thumbnail lock")
|
||||
}
|
||||
releaseVMThumbnail(name)
|
||||
@@ -28,7 +28,7 @@ func TestReleaseVMThumbnailRemovesLock(t *testing.T) {
|
||||
if remaining != 0 {
|
||||
t.Fatalf("thumbnail locks remain after release: %d", remaining)
|
||||
}
|
||||
if got := vmThumbLockForDriver("", name); got == first {
|
||||
if got := vmThumbLock("", name); got == first {
|
||||
t.Fatal("released lock was reused")
|
||||
}
|
||||
}
|
||||
@@ -74,7 +74,7 @@ func TestToggleVMFullscreenLocalizesErrors(t *testing.T) {
|
||||
a := &App{cfg: &config.Config{DataRoot: t.TempDir(), Locale: i18n.Locale(locale)},
|
||||
lifecycleSvc: vmlifecycle.New(reg, driver.NewRouter(reg, nil), nil),
|
||||
transitions: map[string]string{}, pendingChanges: map[string][]PendingChange{}}
|
||||
got, err := a.ToggleVMFullscreen("Tahoe")
|
||||
got, err := a.ToggleVMFullscreen("", "Tahoe")
|
||||
if got || err == nil {
|
||||
t.Fatalf("toggle = (%v, %v), want an error", got, err)
|
||||
}
|
||||
|
||||
@@ -24,11 +24,7 @@ type VMTimezoneStatus struct {
|
||||
Running bool `json:"running"`
|
||||
}
|
||||
|
||||
func (a *App) GetVMTimezone(name string) (VMTimezoneStatus, error) {
|
||||
return a.GetVMTimezoneWithDriver("", name)
|
||||
}
|
||||
|
||||
func (a *App) GetVMTimezoneWithDriver(driverID, name string) (VMTimezoneStatus, error) {
|
||||
func (a *App) GetVMTimezone(driverID, name string) (VMTimezoneStatus, error) {
|
||||
vm, err := a.resolveVMInfo(driverID, name)
|
||||
if err != nil {
|
||||
return VMTimezoneStatus{}, err
|
||||
@@ -42,11 +38,7 @@ func (a *App) GetVMTimezoneWithDriver(driverID, name string) (VMTimezoneStatus,
|
||||
return a.timezoneStatus(vm, cfg.GuestTimezone), nil
|
||||
}
|
||||
|
||||
func (a *App) SetVMTimezone(name, setting string) (VMTimezoneStatus, error) {
|
||||
return a.SetVMTimezoneWithDriver("", name, setting)
|
||||
}
|
||||
|
||||
func (a *App) SetVMTimezoneWithDriver(driverID, name, setting string) (VMTimezoneStatus, error) {
|
||||
func (a *App) SetVMTimezone(driverID, name, setting string) (VMTimezoneStatus, error) {
|
||||
if err := a.requireWritableDataRoot(); err != nil {
|
||||
return VMTimezoneStatus{}, err
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ func TestVMTimezone(t *testing.T) {
|
||||
lifecycleSvc: vmlifecycle.New(reg, driver.NewRouter(reg, nil), nil),
|
||||
}
|
||||
|
||||
initial, err := a.GetVMTimezone(vm.Name)
|
||||
initial, err := a.GetVMTimezone("", vm.Name)
|
||||
if err != nil || initial.Mode != "host" || initial.EffectiveTimezone != initial.HostTimezone ||
|
||||
!initial.Running || initial.RequiredAgentVersion != 11 || initial.GuestConnected {
|
||||
t.Fatalf("initial timezone = %+v, %v", initial, err)
|
||||
@@ -87,7 +87,7 @@ func TestVMTimezone(t *testing.T) {
|
||||
{"America/Argentina/Buenos_Aires", "custom", "America/Argentina/Buenos_Aires", "America/Argentina/Buenos_Aires"},
|
||||
{"", "host", "", initial.HostTimezone},
|
||||
} {
|
||||
got, err := a.SetVMTimezone(vm.Name, tc.setting)
|
||||
got, err := a.SetVMTimezone("", vm.Name, tc.setting)
|
||||
if err != nil || got.Mode != tc.mode || got.Timezone != tc.custom || got.EffectiveTimezone != tc.effective {
|
||||
t.Fatalf("set %q = %+v, %v", tc.setting, got, err)
|
||||
}
|
||||
@@ -97,13 +97,13 @@ func TestVMTimezone(t *testing.T) {
|
||||
t.Fatalf("stored timezone = %q, other settings preserved = %v, %v",
|
||||
stored.GuestTimezone, stored.Token == cfg.Token && stored.Port == cfg.Port && stored.SharedDir == cfg.SharedDir && stored.PreventSleep, err)
|
||||
}
|
||||
persisted, err := a.GetVMTimezoneWithDriver(driverID, vm.Name)
|
||||
persisted, err := a.GetVMTimezone(driverID, vm.Name)
|
||||
if err != nil || persisted.Mode != tc.mode || persisted.EffectiveTimezone != tc.effective {
|
||||
t.Fatalf("get after set = %+v, %v", persisted, err)
|
||||
}
|
||||
checkLiveTimezone(t, tc.effective)
|
||||
}
|
||||
if _, err := a.SetVMTimezoneWithDriver(driverID, vm.Name, "../Asia/Shanghai"); err == nil {
|
||||
if _, err := a.SetVMTimezone(driverID, vm.Name, "../Asia/Shanghai"); err == nil {
|
||||
t.Fatal("accepted invalid timezone")
|
||||
}
|
||||
stored, _, err := guesttools.ReadVMConfigStrict(vm.Directory)
|
||||
@@ -122,7 +122,7 @@ func TestVMTimezone(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
res.Body.Close()
|
||||
status, err := a.GetVMTimezoneWithDriver(driverID, vm.Name)
|
||||
status, err := a.GetVMTimezone(driverID, vm.Name)
|
||||
if err != nil || res.StatusCode != http.StatusOK || !status.GuestConnected ||
|
||||
!status.HelperReady || status.TimezoneError != "apply_failed" {
|
||||
t.Fatalf("guest timezone status = %+v, HTTP %d, %v", status, res.StatusCode, err)
|
||||
@@ -135,7 +135,7 @@ func TestVMTimezone(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
a.root = dataroot.Status{ReadOnly: true, Reason: dataroot.ReasonNewer}
|
||||
if got, err := a.SetVMTimezoneWithDriver(driverID, vm.Name, "off"); err == nil || got != (VMTimezoneStatus{}) {
|
||||
if got, err := a.SetVMTimezone(driverID, vm.Name, "off"); err == nil || got != (VMTimezoneStatus{}) {
|
||||
t.Fatalf("set on read-only root = %+v, %v", got, err)
|
||||
}
|
||||
after, err := os.ReadFile(path)
|
||||
|
||||
@@ -71,14 +71,9 @@ func hasNonASCII(s string) bool {
|
||||
// sent. When Guest Tools is connected, arbitrary UTF-8 (including Chinese and
|
||||
// emoji) is injected via the Guest Tools bridge + QMP Command+V; otherwise pure
|
||||
// US-ASCII falls back to direct QMP USB keyboard strokes (works in Recovery and
|
||||
// at the Login Window).
|
||||
func (a *App) TypeText(name, text string) (int, error) {
|
||||
return a.TypeTextWithDriver("", name, text)
|
||||
}
|
||||
|
||||
// TypeTextWithDriver types into the VM that driverID owns, so two VMs with the
|
||||
// same name under different drivers never share a typing job.
|
||||
func (a *App) TypeTextWithDriver(driverID, name, text string) (int, error) {
|
||||
// at the Login Window). Two VMs with the same name under different drivers never
|
||||
// share a typing job.
|
||||
func (a *App) TypeText(driverID, name, text string) (int, error) {
|
||||
return a.injectTextIntoVMForDriver(driverID, name, "", text, false, false)
|
||||
}
|
||||
|
||||
@@ -332,10 +327,7 @@ func (a *App) runRemoteTextQueue(key, vmName string, ch <-chan remoteTextItem) {
|
||||
}
|
||||
|
||||
// TypeClipboard types or injects the host clipboard's text into a running VM.
|
||||
func (a *App) TypeClipboard(name string) (int, error) { return a.TypeClipboardWithDriver("", name) }
|
||||
|
||||
// TypeClipboardWithDriver types the clipboard into the VM that driverID owns.
|
||||
func (a *App) TypeClipboardWithDriver(driverID, name string) (int, error) {
|
||||
func (a *App) TypeClipboard(driverID, name string) (int, error) {
|
||||
if a.ctx == nil {
|
||||
return 0, errors.New("no window")
|
||||
}
|
||||
@@ -346,5 +338,5 @@ func (a *App) TypeClipboardWithDriver(driverID, name string) (int, error) {
|
||||
if text == "" {
|
||||
return 0, errors.New("the clipboard has no text")
|
||||
}
|
||||
return a.TypeTextWithDriver(driverID, name, text)
|
||||
return a.TypeText(driverID, name, text)
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (a *App) confirmVMWindowClose(name string) {
|
||||
ref = vm.Ref()
|
||||
canSuspend = slices.Contains(vm.Capabilities, driver.CapSuspend)
|
||||
}
|
||||
label := strings.TrimSpace(a.GetVMNote(ref.Name))
|
||||
label := strings.TrimSpace(a.GetVMNote(ref.DriverID, ref.Name))
|
||||
if label == "" {
|
||||
label = ref.Name
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ func TestSameNamedVMMemoryStatesUseDriverQualifiedKeys(t *testing.T) {
|
||||
t.Fatal("driver-qualified cache keys collided")
|
||||
}
|
||||
a.cfg = &config.Config{DataRoot: t.TempDir()}
|
||||
if a.thumbPathForDriver("test.driver.a", "shared") == a.thumbPathForDriver("test.driver.b", "shared") {
|
||||
if a.thumbPath("test.driver.a", "shared") == a.thumbPath("test.driver.b", "shared") {
|
||||
t.Fatal("same-named VMs share a thumbnail path")
|
||||
}
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func (a *App) afterStartup() {
|
||||
noTray := a.trayMgr == nil
|
||||
a.mu.Unlock()
|
||||
if launch.Background && noTray {
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
}
|
||||
a.handleWindowArgs(launch, false)
|
||||
}
|
||||
@@ -47,7 +47,7 @@ func (a *App) handleWindowArgs(w cli.WindowArgs, secondLaunch bool) {
|
||||
}
|
||||
if w.StartVM == "" && w.ResumeVM == "" {
|
||||
if secondLaunch && !w.Background {
|
||||
a.ShowMainWindow()
|
||||
a.showMainWindow()
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -65,7 +65,7 @@ func (a *App) handleWindowArgs(w cli.WindowArgs, secondLaunch bool) {
|
||||
capture := a.captureLogs(key)
|
||||
var err error
|
||||
if w.ResumeVM != "" {
|
||||
err = a.ResumeVMWithDriver(w.StartDriver, name)
|
||||
err = a.ResumeVM(w.StartDriver, name)
|
||||
} else {
|
||||
err = a.startHandedVM(w.StartDriver, name)
|
||||
}
|
||||
@@ -84,7 +84,7 @@ func (a *App) handleWindowArgs(w cli.WindowArgs, secondLaunch bool) {
|
||||
}
|
||||
|
||||
func (a *App) startHandedVM(driverID, name string) error {
|
||||
return a.StartVMWithDriver(driverID, name)
|
||||
return a.StartVM(driverID, name)
|
||||
}
|
||||
|
||||
// logCapture keeps the last few log lines one source emits while it is
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package archtest
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
"io/fs"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// TestWindowBindingsMatch keeps the methods App exposes to the window in step
|
||||
// with the frontend: Wails exposes every exported method, so each one needs a
|
||||
// caller, and frontend/wailsjs must be regenerated after a change
|
||||
// (wails generate module).
|
||||
func TestWindowBindingsMatch(t *testing.T) {
|
||||
generated := map[string]bool{}
|
||||
raw, err := os.ReadFile("../../frontend/wailsjs/go/app/App.d.ts")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, m := range regexp.MustCompile(`export function (\w+)\(`).FindAllStringSubmatch(string(raw), -1) {
|
||||
generated[m[1]] = true
|
||||
}
|
||||
|
||||
used := map[string]bool{}
|
||||
call := regexp.MustCompile(`\b(?:api|boundGo)\.(\w+)`)
|
||||
err = filepath.WalkDir("../../frontend/src", func(p string, d fs.DirEntry, err error) error {
|
||||
if err != nil || d.IsDir() || !strings.Contains(filepath.Ext(p), ".ts") {
|
||||
return err
|
||||
}
|
||||
src, err := os.ReadFile(p)
|
||||
for _, m := range call.FindAllStringSubmatch(string(src), -1) {
|
||||
used[m[1]] = true
|
||||
}
|
||||
return err
|
||||
})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
exported := map[string]bool{}
|
||||
for _, s := range sources(t) {
|
||||
if s.rel == "main.go" {
|
||||
ast.Inspect(s.file, func(n ast.Node) bool {
|
||||
if sel, ok := n.(*ast.SelectorExpr); ok {
|
||||
used[sel.Sel.Name] = true
|
||||
}
|
||||
return true
|
||||
})
|
||||
}
|
||||
if s.isTest() || s.dir() != "internal/app" {
|
||||
continue
|
||||
}
|
||||
for _, decl := range s.file.Decls {
|
||||
fn, ok := decl.(*ast.FuncDecl)
|
||||
if !ok || fn.Recv == nil || !fn.Name.IsExported() {
|
||||
continue
|
||||
}
|
||||
star, ok := fn.Recv.List[0].Type.(*ast.StarExpr)
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
if id, ok := star.X.(*ast.Ident); ok && id.Name == "App" {
|
||||
exported[fn.Name.Name] = true
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(exported) < 100 || len(generated) < 100 {
|
||||
t.Fatalf("found only %d App methods and %d generated bindings", len(exported), len(generated))
|
||||
}
|
||||
for name := range exported {
|
||||
if !used[name] {
|
||||
t.Errorf("the window never calls App.%s: delete or unexport it", name)
|
||||
}
|
||||
if !generated[name] {
|
||||
t.Errorf("App.%s is missing from frontend/wailsjs: run wails generate module", name)
|
||||
}
|
||||
}
|
||||
for name := range generated {
|
||||
if !exported[name] {
|
||||
t.Errorf("frontend/wailsjs still has App.%s: run wails generate module", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -508,7 +508,7 @@ func cmdVM(cfg *config.Config, loc i18n.Locale, args []string, viaWindow bool) e
|
||||
if fs.NArg() < 1 {
|
||||
return fmt.Errorf("usage: reims-go vm start [--driver <id>] <name>")
|
||||
}
|
||||
return startVMWithDriver(ctx, cfg, *driverID, fs.Arg(0), viaWindow)
|
||||
return startVM(ctx, cfg, *driverID, fs.Arg(0), viaWindow)
|
||||
case "stop":
|
||||
fs := flag.NewFlagSet("vm stop", flag.ContinueOnError)
|
||||
driverID := fs.String("driver", "", "Owning driver ID when VM names are ambiguous")
|
||||
|
||||
@@ -119,7 +119,7 @@ func createMacOSVM(ctx context.Context, cfg *config.Config, loc i18n.Locale, in
|
||||
}
|
||||
}
|
||||
if startAfterCreate {
|
||||
if err := startVMWithDriver(ctx, cfg, driver.BuiltinReimsMacOSDriverID, in.Name, viaWindow); err != nil {
|
||||
if err := startVM(ctx, cfg, driver.BuiltinReimsMacOSDriverID, in.Name, viaWindow); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ import (
|
||||
// report back. Preparation can rebuild the OpenCore image before QEMU starts.
|
||||
const startHandoffTimeout = 5 * time.Minute
|
||||
|
||||
// startVMWithDriver resolves the VM, then hands it to the desktop window: the
|
||||
// startVM resolves the VM, then hands it to the desktop window: the
|
||||
// one already running, or a new one in the tray (`--background`). The window
|
||||
// runs the GUI's StartVM, so a VM started from the command line gets Guest
|
||||
// Tools and the Win10 cold-reboot watcher too; both need a process that stays
|
||||
// up after this command exits.
|
||||
//
|
||||
// 显式传入管理器当前数据目录仍交给管理器;其他目录的桥接禁止直接启动。
|
||||
func startVMWithDriver(ctx context.Context, cfg *config.Config, driverID, name string, viaWindow bool) error {
|
||||
func startVM(ctx context.Context, cfg *config.Config, driverID, name string, viaWindow bool) error {
|
||||
mgr, router, err := openCLIPluginManager(cfg, false)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -222,7 +222,7 @@ func TestTransactionalInstallSigningRedlinesAndThemeDoctor(t *testing.T) {
|
||||
Parts: []string{"rg-p-sidebar"},
|
||||
Tokens: []string{"--surface-sidebar"},
|
||||
}
|
||||
findings := plugin.DoctorDirectory(info.InstallDir, "0.2.6", contract)
|
||||
findings := plugin.ScanDirectory(info.InstallDir, "0.2.6", plugin.ScanOptions{Contract: contract}).ToDoctorFindings()
|
||||
for _, f := range findings {
|
||||
if f.Severity == "error" || f.Severity == "warn" {
|
||||
t.Fatalf("unexpected doctor finding on valid theme: %+v", f)
|
||||
|
||||
@@ -684,16 +684,6 @@ func InstallArchive(layout PluginsLayout, archivePath string, opts PackageInstal
|
||||
}, nil
|
||||
}
|
||||
|
||||
// DoctorDirectory validates a plugin directory (installed or local dev link),
|
||||
// checking manifest, SHA256SUMS (if present), static risk rules, CSS safety,
|
||||
// and UI contract compliance (§5.1, §10).
|
||||
func DoctorDirectory(dir string, hostVersion string, contract *UIContract) []DoctorFinding {
|
||||
return ScanDirectory(dir, hostVersion, ScanOptions{
|
||||
Contract: contract,
|
||||
RequireChecksums: false,
|
||||
}).ToDoctorFindings()
|
||||
}
|
||||
|
||||
var (
|
||||
reCSSClass = regexp.MustCompile(`\.([a-zA-Z_-][a-zA-Z0-9_-]*)`)
|
||||
reCSSVar = regexp.MustCompile(`var\(\s*(--[a-zA-Z0-9_-]+)`)
|
||||
|
||||
@@ -561,8 +561,7 @@ func finalizeScanReport(rep *ScanReport) {
|
||||
}
|
||||
}
|
||||
|
||||
// ToDoctorFindings converts a ScanReport into backward-compatible DoctorFinding
|
||||
// entries so `DoctorDirectory` and existing callers/tests share one engine.
|
||||
// ToDoctorFindings lists a ScanReport's results the way `plugin doctor` prints them.
|
||||
func (r ScanReport) ToDoctorFindings() []DoctorFinding {
|
||||
var out []DoctorFinding
|
||||
hasManifestErr := false
|
||||
|
||||
Reference in new issue
Block a user