feat: add bounded diagnostics and improve UX feedback

Ask and Execute guidance, Runtime state, live announcements, loading states,
retry paths, settings focus, and update failures now provide consistent and
accessible feedback across the desktop experience.

Add bounded redacted Desktop and Agent diagnostic logs, a read-only Agent
diagnostics command, and an explicit opt-in for attaching a small Desktop
diagnostic summary to in-app feedback. Diagnostics stay local by default and
the existing feedback v1 service contract remains compatible.

Release note: 新增可选桌面诊断反馈与 Agent 诊断导出,并统一 Ask/Execute 状态、错误恢复和无障碍反馈;诊断默认保留在本地,仅在用户明确勾选时附加桌面摘要。
This commit is contained in:
mesalogo
2026-08-31 15:35:13 +08:00
parent b1729125e1
commit 2833a27f83
60 changed files with 4679 additions and 216 deletions
+34 -2
View File
@@ -13,6 +13,9 @@ import type {
} from './runtime'
import { AgentRuntimeController } from './runtime-controller'
import type { ExecutionSpaceDescriptor } from '../execution-space'
import type {
DesktopDiagnosticFailureObserver
} from '../desktop-diagnostics'
export type SelectedRuntimeResolver = {
getRuntime(
@@ -70,7 +73,9 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
private readonly maximumCachedRuntimes =
DEFAULT_MAXIMUM_CACHED_RUNTIMES,
private readonly maximumRetainedRuntimes =
DEFAULT_MAXIMUM_RETAINED_RUNTIMES
DEFAULT_MAXIMUM_RETAINED_RUNTIMES,
private readonly observeFailure?:
DesktopDiagnosticFailureObserver
) {
if (
!Number.isSafeInteger(maximumCachedRuntimes) ||
@@ -129,7 +134,11 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
await runtime.dispose()
throw new Error('Runtime 设置已更改,请重新选择')
}
const controller = new AgentRuntimeController(runtime)
const controller = new AgentRuntimeController(
runtime,
undefined,
this.observeFailure
)
entry.controller = controller
return controller
}
@@ -148,6 +157,7 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
if (this.entries.get(key) === entry) {
this.entries.delete(key)
}
this.reportFailure('create', error)
throw error
}
}
@@ -162,6 +172,9 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
this.tests.add(operation)
try {
return await operation
} catch (error) {
this.reportFailure('status', error)
throw error
} finally {
this.tests.delete(operation)
}
@@ -177,6 +190,9 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
this.tests.add(operation)
try {
return await operation
} catch (error) {
this.reportFailure('connection-test', error)
throw error
} finally {
this.tests.delete(operation)
}
@@ -196,6 +212,9 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
this.snapshots.add(operation)
try {
return await operation
} catch (error) {
this.reportFailure('native-snapshot', error)
throw error
} finally {
this.snapshots.delete(operation)
}
@@ -421,4 +440,17 @@ export class SelectedRuntimeManager implements SelectedRuntimeResolver {
void this.startRetiring(entry, false)
}
}
private reportFailure(stage: string, error: unknown): void {
try {
this.observeFailure?.({
component: 'runtime',
stage,
code: 'runtime.operation.failed',
error
})
} catch {
// Diagnostics must not alter Runtime behavior.
}
}
}