fix(logs): classify successful Metal precision notes as info

Ignore the Metal selector when a QEMU message reports a successful precision note. Reuse the same severity for log rows and the unread-error badge.
This commit is contained in:
YXC0915 committed 2026-12-04 21:23:18 +08:00
1 parent 8b467563c7
commit 2e480d99b7
3 files changed
+42 -8

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
import assert from 'node:assert/strict'
import test from 'node:test'
import { loadTestModule } from './load-test-module.mjs'
const { createLogLine } = await loadTestModule(`export * from './lib/logs'`)
const renderSelector = 'newRenderPipelineStateWithDescriptor:error:'
const computeSelector = 'newComputePipelineStateWithDescriptor:options:reflection:error:'
const precisionNote = (selector, code) =>
`[QEMU] reims-vgpu: ${selector}: metal2vulkan-runtime made it with a precision note (metal2vulkan-degrade-${code}): its answers there can differ from Metal's on this device; the first of its kind, each make that carries it counted`
test('successful render and compute precision notes keep their text as informational logs', () => {
for (const line of [
precisionNote(renderSelector, 'device-denormals'),
precisionNote(computeSelector, 'simdgroup-access-order'),
]) {
const row = createLogLine({ line })
assert.equal(row.level, 'info')
assert.equal(row.line, line)
}
})
test('pipeline refusals and fatal errors retain their error level', () => {
for (const line of [
`[QEMU] reims-vgpu: platform call ${renderSelector}: the runtime refused it`,
'[QEMU] reims-vgpu: fatal: Vulkan device was lost',
`${precisionNote(renderSelector, 'device-denormals')}; error: failed to submit the command buffer`,
]) {
assert.equal(createLogLine({ line }).level, 'error')
}
})
+4 -4
View File
@@ -16,7 +16,7 @@ import { buildFallbackChain, I18nKey, localeDir, locText, parseAppError, resolve
import { defaultGuestLang, recommendedMemoryGB, recommendedResolution } from './lib/format'
import { isMacOSDriver, liveVMInfo, splitEndpoints, vmFeatures } from './lib/endpoints'
import { resolveFullscreenHotkey } from './lib/fullscreenHotkey'
import { LogLine, appendLog } from './lib/logs'
import { LogLine, appendLog, createLogLine } from './lib/logs'
import { macOSMajor } from './macos/macosRelease'
import { currentTask, finishedTaskTTL, isActiveInstallerTask, pruneFinishedTasks, upsertTask } from './lib/tasks'
import { applyActiveLocaleFonts, applyActiveTheme, disposeActiveThemeAndLocaleFonts, notifyInteractiveThemeState } from './lib/themeEngine'
@@ -200,11 +200,11 @@ export const App: React.FC = () => {
// Logs never pop the panel open (see docs/design-guidelines.md); errors only bump a badge.
const offLog = events.onLog((entry) => {
if (!entry || typeof entry !== 'object') return
const lineText = typeof entry.line === 'string' ? entry.line : String(entry.line ?? '')
if (!logsOpenRef.current && /\b(error|failed|fatal|panic)\b/i.test(lineText)) {
const line = createLogLine(entry)
if (!logsOpenRef.current && line.level === 'error') {
setUnseenErrors((n) => n + 1)
}
setLogLines((prev) => appendLog(prev, entry))
setLogLines((prev) => appendLog(prev, line))
})
// Tasks: seed from the backend, then follow events.
api.GetTasks().then((list) => {
+7 -4
View File
@@ -14,18 +14,21 @@ const MAX_LOG_LINES = 2000
// backend tags them explicitly.
const ERROR_RE = /\b(error|failed|fatal|panic)\b/i
const WARN_RE = /\bwarn(ing)?\b/i
// Successful vGPU precision notes include the Metal selector's error: argument.
const PRECISION_NOTE_PREFIX = /^(?:\[QEMU\] )?reims-vgpu: [\w:]+: metal2vulkan-runtime made it with a precision note \(metal2vulkan-degrade-[a-z0-9-]+\): /
let nextId = 1
function classify(entry: LogEntry): LogLine {
export function createLogLine(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 ?? '')
const level: LogLevel = ERROR_RE.test(line) ? 'error' : WARN_RE.test(line) ? 'warn' : 'info'
const message = line.replace(PRECISION_NOTE_PREFIX, '')
const level: LogLevel = ERROR_RE.test(message) ? 'error' : WARN_RE.test(message) ? 'warn' : 'info'
return { ts, source, line, id: nextId++, level }
}
export function appendLog(prev: LogLine[], entry: LogEntry): LogLine[] {
const next = [...prev, classify(entry)]
export function appendLog(prev: LogLine[], line: LogLine): LogLine[] {
const next = [...prev, line]
return next.length > MAX_LOG_LINES ? next.slice(next.length - MAX_LOG_LINES) : next
}