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
+19 -1
View File
@@ -23,6 +23,7 @@ import {
writePrivateFileAtomic
} from './managed-paths'
import type { AttachWelcome } from '../shared/agent-protocol'
import { AgentDiagnosticLog } from './diagnostic-log'
const DEFAULT_READINESS_TIMEOUT_MS = 15_000
const DEFAULT_STOP_TIMEOUT_MS = 5_000
@@ -140,6 +141,7 @@ export class DetachedAgentLifecycle {
readonly #retireLegacyInstallation?: (
verified: VerifiedInstalledAgentBundle
) => void | Promise<void>
readonly #diagnostics: AgentDiagnosticLog
constructor(options: DetachedAgentLifecycleOptions) {
this.#installationId = validateInstallationId(options.installationId)
@@ -156,6 +158,10 @@ export class DetachedAgentLifecycle {
this.#spawnDetached = options.spawnDetached ?? spawnDetachedProcess
this.#currentPid = positivePid(options.currentPid ?? process.pid)
this.#now = options.now ?? Date.now
this.#diagnostics = new AgentDiagnosticLog(this.#stateDirectory, {
now: this.#now,
pid: this.#currentPid
})
this.#sleep =
options.sleep ??
(async (milliseconds) =>
@@ -215,6 +221,7 @@ export class DetachedAgentLifecycle {
const launchArgv = ['daemon', '--installation-id', this.#installationId]
const runtimePath = expectedRuntimePath(verified)
this.#diagnostics.tryRecord('detached.launching')
const child = this.#spawnDetached(this.#executablePath, launchArgv, {
env: detachedEnvironment(this.#environment),
detached: true,
@@ -226,6 +233,7 @@ export class DetachedAgentLifecycle {
throw new Error('Detached Agent spawn did not return a process ID')
}
child.unref()
this.#diagnostics.tryRecord('detached.spawned')
const processIdentity = await this.#waitForProcessIdentity(
child.pid,
runtimePath
@@ -246,8 +254,18 @@ export class DetachedAgentLifecycle {
throw new Error('Detached Agent readiness timed out')
}
return ready
} catch (error) {
this.#diagnostics.tryRecord('recovery.failed', {
reason: 'bootstrap',
error
})
throw error
} finally {
releaseLock()
try {
releaseLock()
} finally {
await this.#diagnostics.flush()
}
}
}