vtcode_desktop_protocol/diagnostics.rs
1//! Setup diagnostics: shared repair model for the Desktop self-solve entry.
2//!
3//! Mirrors the CLI `/doctor` repairs computed by the service from the same
4//!core: [`DiagnosticsCheckupResult`] lists applicable repairs, and
5//!`diagnostics/apply` executes the directly-appliable ones. Picker and
6//!secret kinds are routed client-side to native UI instead.
7use serde::{Deserialize, Serialize};
8
9/// One applicable setup repair.
10#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
11#[serde(rename_all = "camelCase")]
12pub struct DiagnosticsRepair {
13 /// Stable repair id, echoed back to `diagnostics/apply`.
14 pub id: String,
15 /// Short user-facing title.
16 pub title: String,
17 /// One-line explanation of what is wrong and what happens.
18 pub subtitle: String,
19 /// How the client carries the repair out.
20 pub kind: DiagnosticsRepairKind,
21 /// Destructive repairs render danger styling and preselect cancel.
22 pub destructive: bool,
23 /// What applying would change. Empty for routed repairs; absent on older services.
24 #[serde(default)]
25 pub preview: DiagnosticsPreview,
26}
27
28/// Preview of a repair's config changes, shown for confirmation before apply.
29#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize)]
30#[serde(rename_all = "camelCase")]
31pub struct DiagnosticsPreview {
32 /// Where the change lands, human-readable.
33 #[serde(default)]
34 pub target_display: String,
35 /// Per-key old → new values.
36 #[serde(default)]
37 pub changes: Vec<DiagnosticsPreviewChange>,
38 /// Files a scaffold would create (missing files only).
39 #[serde(default)]
40 pub creates: Vec<String>,
41 /// Extra context (backups, reversibility).
42 #[serde(default, skip_serializing_if = "Option::is_none")]
43 pub note: Option<String>,
44}
45
46/// One key change inside a preview.
47#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
48#[serde(rename_all = "camelCase")]
49pub struct DiagnosticsPreviewChange {
50 /// Dotted setting path.
51 pub path: String,
52 /// Current effective value, or `(unset)`.
53 pub old: String,
54 /// Value that would be written.
55 pub new: String,
56}
57
58/// How the client carries a repair out.
59#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
60#[serde(rename_all = "snake_case")]
61pub enum DiagnosticsRepairKind {
62 /// Applied server-side via `diagnostics/apply`.
63 Apply,
64 /// Client opens its native provider/model picker.
65 ModelPicker,
66 /// Client routes to its secret store UI.
67 SecretStore,
68}
69
70/// Result of a `diagnostics/checkup` call.
71#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
72#[serde(rename_all = "camelCase")]
73pub struct DiagnosticsCheckupResult {
74 /// Currently applicable repairs, empty when the setup is healthy.
75 pub repairs: Vec<DiagnosticsRepair>,
76}
77
78/// Params for a `diagnostics/apply` call.
79#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
80#[serde(rename_all = "camelCase")]
81pub struct DiagnosticsApplyParams {
82 /// Repair id from a previous checkup result.
83 pub repair_id: String,
84}
85
86/// Result of a `diagnostics/apply` call.
87#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
88#[serde(rename_all = "camelCase")]
89pub struct DiagnosticsApplyResult {
90 /// Whether anything changed. False for client-routed repairs.
91 pub applied: bool,
92 /// Human-readable outcome or next step.
93 pub message: String,
94}