@skyhook-io/radar-app 1.18.2 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +7 -7
- package/src/App.tsx +31 -6
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +97 -3
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +41 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/diagnose/AIMarkdown.tsx +4 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +22 -4
- package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
- package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
- package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
- package/src/components/diagnose/AnalysisStory.tsx +17 -4
- package/src/components/diagnose/AssessmentCard.tsx +39 -8
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
- package/src/components/diagnose/DiagnoseContext.tsx +272 -10
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +151 -134
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +208 -5
- package/src/components/diagnose/Home.tsx +187 -36
- package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
- package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +50 -23
- package/src/components/diagnose/InvestigationView.tsx +249 -54
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +365 -39
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +495 -0
- package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
- package/src/components/diagnose/QuestionFocus.tsx +123 -0
- package/src/components/diagnose/ResourcePicker.tsx +206 -0
- package/src/components/diagnose/StoryExcerpt.tsx +12 -3
- package/src/components/diagnose/assessmentCopy.ts +5 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +58 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
- package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
- package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/index.ts +1 -1
- package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +7 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/parts.test.tsx +20 -0
- package/src/components/diagnose/questionSuggestions.test.ts +111 -0
- package/src/components/diagnose/questionSuggestions.ts +150 -0
- package/src/components/diagnose/storyParts.test.tsx +13 -0
- package/src/components/diagnose/target.test.ts +143 -2
- package/src/components/diagnose/target.ts +109 -7
- package/src/components/diagnose/testdata/story-runs.json +474 -0
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/diagnose/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/home/ClusterHealthCard.tsx +13 -39
- package/src/components/home/HomeAgentBlock.test.tsx +141 -0
- package/src/components/home/HomeAgentBlock.tsx +103 -0
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +86 -47
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
- package/src/components/ui/Omnibar.tsx +47 -3
- package/src/components/ui/RadarOmnibar.test.tsx +1 -0
- package/src/components/ui/RadarOmnibar.tsx +11 -0
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +18 -4
- package/src/components/whats-new/releaseNotes.ts +136 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +6 -4
- package/src/hooks/useAgentSignin.test.tsx +190 -0
- package/src/hooks/useAgentSignin.ts +160 -0
- package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
- package/src/hooks/useElementSize.ts +30 -0
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +12 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
import type { RunSummary } from "../../api/diagnose";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
buildLaunchCommand,
|
|
5
|
+
launchAgentLabel,
|
|
6
|
+
launchTrustHint,
|
|
7
|
+
} from "./launch";
|
|
4
8
|
|
|
5
9
|
describe("OpenCode terminal handoff", () => {
|
|
6
10
|
it("uses the correct label without launching a different agent", () => {
|
|
@@ -21,3 +25,123 @@ describe("OpenCode terminal handoff", () => {
|
|
|
21
25
|
expect(buildLaunchCommand(run, "http://localhost:9280/mcp")).toBeNull();
|
|
22
26
|
});
|
|
23
27
|
});
|
|
28
|
+
|
|
29
|
+
describe("launchTrustHint", () => {
|
|
30
|
+
const base: RunSummary = {
|
|
31
|
+
id: "run-test",
|
|
32
|
+
kind: "Deployment",
|
|
33
|
+
group: "apps",
|
|
34
|
+
namespace: "default",
|
|
35
|
+
name: "demo",
|
|
36
|
+
context: "test",
|
|
37
|
+
agent: "claude",
|
|
38
|
+
status: "done",
|
|
39
|
+
sessionId: "ses_1",
|
|
40
|
+
createdAt: "2026-09-21T00:00:00Z",
|
|
41
|
+
updatedAt: "2026-09-21T00:00:00Z",
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
it("warns about Claude Code's folder trust prompt", () => {
|
|
45
|
+
expect(launchTrustHint(base)).toMatch(/trust Radar's agent folder/);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("stays quiet for agents without that prompt", () => {
|
|
49
|
+
expect(launchTrustHint({ ...base, agent: "codex" })).toBeNull();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe("Claude Code resume command", () => {
|
|
54
|
+
const run: RunSummary = {
|
|
55
|
+
id: "run-test",
|
|
56
|
+
kind: "Deployment",
|
|
57
|
+
group: "apps",
|
|
58
|
+
namespace: "default",
|
|
59
|
+
name: "demo",
|
|
60
|
+
context: "test",
|
|
61
|
+
agent: "claude",
|
|
62
|
+
status: "done",
|
|
63
|
+
sessionId: "ses_1",
|
|
64
|
+
createdAt: "2026-09-21T00:00:00Z",
|
|
65
|
+
updatedAt: "2026-09-21T00:00:00Z",
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
it("resumes from the folder Radar runs Claude in", () => {
|
|
69
|
+
expect(buildLaunchCommand(run, "http://localhost:9280/mcp", "posix")).toBe(
|
|
70
|
+
'mkdir -p -m 700 ~/.radar/agent && cd ~/.radar/agent && claude --resume \'ses_1\' --mcp-config \'{"mcpServers":{"radar":{"type":"http","url":"http://localhost:9280/mcp"}}}\'',
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
// Windows PowerShell 5.1 has no && and strips the quotes inside a native
|
|
75
|
+
// argument; --% passes the JSON through with C-runtime escaping instead.
|
|
76
|
+
it("uses a form Windows PowerShell 5.1 runs", () => {
|
|
77
|
+
expect(
|
|
78
|
+
buildLaunchCommand(run, "http://localhost:9280/mcp", "powershell"),
|
|
79
|
+
).toBe(
|
|
80
|
+
'New-Item -ItemType Directory -Force -Path "$HOME\\.radar\\agent" -ErrorAction Stop | Out-Null; ' +
|
|
81
|
+
'Set-Location -LiteralPath "$HOME\\.radar\\agent" -ErrorAction Stop; ' +
|
|
82
|
+
"& (Get-Command claude -CommandType Application -ErrorAction Stop)[0].Source --% " +
|
|
83
|
+
'--resume ses_1 --mcp-config "{\\"mcpServers\\":{\\"radar\\":{\\"type\\":\\"http\\",\\"url\\":\\"http://localhost:9280/mcp\\"}}}"',
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it("gives Codex the same pass-through under PowerShell", () => {
|
|
88
|
+
expect(
|
|
89
|
+
buildLaunchCommand(
|
|
90
|
+
{ ...run, agent: "codex", sessionId: "019a-b2" },
|
|
91
|
+
"http://localhost:9280/mcp",
|
|
92
|
+
"powershell",
|
|
93
|
+
),
|
|
94
|
+
).toBe(
|
|
95
|
+
"& (Get-Command codex -CommandType Application -ErrorAction Stop)[0].Source --% " +
|
|
96
|
+
'resume 019a-b2 -c "mcp_servers.radar.url=\\"http://localhost:9280/mcp\\""',
|
|
97
|
+
);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("offers no PowerShell command it can't pass through intact", () => {
|
|
101
|
+
expect(
|
|
102
|
+
buildLaunchCommand(
|
|
103
|
+
{ ...run, sessionId: 'a"b' },
|
|
104
|
+
"http://localhost:9280/mcp",
|
|
105
|
+
"powershell",
|
|
106
|
+
),
|
|
107
|
+
).toBeNull();
|
|
108
|
+
expect(
|
|
109
|
+
buildLaunchCommand(run, "http://localhost:9280/%41/mcp", "powershell"),
|
|
110
|
+
).toBeNull();
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
describe("an agent the hand-off doesn't know", () => {
|
|
115
|
+
const base: RunSummary = {
|
|
116
|
+
id: "run-x",
|
|
117
|
+
kind: "Deployment",
|
|
118
|
+
group: "apps",
|
|
119
|
+
namespace: "default",
|
|
120
|
+
name: "demo",
|
|
121
|
+
context: "test",
|
|
122
|
+
status: "done",
|
|
123
|
+
sessionId: "ses_1",
|
|
124
|
+
createdAt: "2026-09-21T00:00:00Z",
|
|
125
|
+
updatedAt: "2026-09-21T00:00:00Z",
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
it("is named by its own label, with no Claude warning and no command", () => {
|
|
129
|
+
const run = { ...base, agent: "gemini" };
|
|
130
|
+
expect(launchAgentLabel(run)).toBe("Gemini CLI");
|
|
131
|
+
expect(launchTrustHint(run)).toBeNull();
|
|
132
|
+
expect(
|
|
133
|
+
buildLaunchCommand(run, "http://localhost:9280/mcp", "posix"),
|
|
134
|
+
).toBeNull();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("falls back to the agent's own name when Radar has no label for it", () => {
|
|
138
|
+
expect(launchAgentLabel({ ...base, agent: "newagent" })).toBe("newagent");
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it("still resumes a run from before Radar recorded the agent as Claude Code", () => {
|
|
142
|
+
expect(launchAgentLabel(base)).toBe("Claude Code");
|
|
143
|
+
expect(
|
|
144
|
+
buildLaunchCommand(base, "http://localhost:9280/mcp", "posix"),
|
|
145
|
+
).toMatch(/claude --resume 'ses_1'/);
|
|
146
|
+
});
|
|
147
|
+
});
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
// from the contained in-panel engine. The endpoint follows the server MCP mode.
|
|
5
5
|
// In full mode, the client approval prompts gate changes.
|
|
6
6
|
import { type RunSummary } from "../../api/diagnose";
|
|
7
|
+
import { agentLabelFor } from "./DiagnoseContext";
|
|
7
8
|
|
|
8
9
|
// sq POSIX-single-quotes a string so it's a safe single shell argument regardless
|
|
9
10
|
// of content. Findings carry backticks, quotes, and newlines — inside single
|
|
@@ -13,11 +14,26 @@ function sq(s: string): string {
|
|
|
13
14
|
return "'" + s.replace(/'/g, "'\\''") + "'";
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
// Radar also creates it before each Claude turn, but a run from before Radar
|
|
18
|
+
// used it can be continued first. Unquoted so the shell expands ~.
|
|
19
|
+
const AGENT_DIR = "~/.radar/agent";
|
|
20
|
+
|
|
21
|
+
// A run with no recorded agent predates recording it, when Claude Code was
|
|
22
|
+
// the only one. Any other agent is named by its own label, with no Claude
|
|
23
|
+
// specifics, and gets no resume command it hasn't been taught.
|
|
24
|
+
function isClaudeRun(run: RunSummary): boolean {
|
|
25
|
+
return !run.agent || run.agent === "claude";
|
|
26
|
+
}
|
|
27
|
+
|
|
16
28
|
export function launchAgentLabel(run: RunSummary): string {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
return isClaudeRun(run) ? "Claude Code" : agentLabelFor(run.agent ?? "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Claude Code asks once whether to trust the folder the resume runs in, and
|
|
33
|
+
// its default answer exits, so a user who presses Enter loses the session.
|
|
34
|
+
export function launchTrustHint(run: RunSummary): string | null {
|
|
35
|
+
if (!isClaudeRun(run)) return null;
|
|
36
|
+
return "The first time, Claude Code may ask to trust Radar's agent folder. Select Yes before pressing Enter; the default exits.";
|
|
21
37
|
}
|
|
22
38
|
|
|
23
39
|
// openInTerminal asks App (which owns the DockProvider) to open Radar's local
|
|
@@ -40,6 +56,7 @@ export function openInTerminal(command: string, title: string) {
|
|
|
40
56
|
export function buildLaunchCommand(
|
|
41
57
|
run: RunSummary,
|
|
42
58
|
mcpUrl: string,
|
|
59
|
+
shell: "posix" | "powershell" = "posix",
|
|
43
60
|
): string | null {
|
|
44
61
|
if (!run.sessionId || run.status === "stale") return null;
|
|
45
62
|
|
|
@@ -55,15 +72,45 @@ export function buildLaunchCommand(
|
|
|
55
72
|
}
|
|
56
73
|
if (run.agent === "codex") {
|
|
57
74
|
// Codex threads are stored globally by id (cwd-independent); -c re-attaches MCP.
|
|
75
|
+
if (shell === "powershell") {
|
|
76
|
+
if (!psSafe(run.sessionId, mcpUrl)) return null;
|
|
77
|
+
return psNative(
|
|
78
|
+
"codex",
|
|
79
|
+
`resume ${run.sessionId} -c "mcp_servers.radar.url=\\"${mcpUrl}\\""`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
58
82
|
return `codex resume ${sq(run.sessionId)} -c ${sq(`mcp_servers.radar.url="${mcpUrl}"`)}`;
|
|
59
83
|
}
|
|
60
|
-
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
// --mcp-config MERGES radar alongside
|
|
84
|
+
if (!isClaudeRun(run)) return null;
|
|
85
|
+
// Claude Code: resume from the folder Radar runs Claude turns in (claudeWorkDir
|
|
86
|
+
// in agent_claude.go). Older versions find a session only from the folder it
|
|
87
|
+
// was created in, and Claude Code remembers the folder-trust answer there,
|
|
88
|
+
// which it never does for the home dir. --mcp-config MERGES radar alongside
|
|
89
|
+
// the user's own servers.
|
|
65
90
|
const cfg = JSON.stringify({
|
|
66
91
|
mcpServers: { radar: { type: "http", url: mcpUrl } },
|
|
67
92
|
});
|
|
68
|
-
|
|
93
|
+
if (shell === "powershell") {
|
|
94
|
+
if (!psSafe(run.sessionId, mcpUrl)) return null;
|
|
95
|
+
const dir = '"$HOME\\.radar\\agent"';
|
|
96
|
+
return `New-Item -ItemType Directory -Force -Path ${dir} -ErrorAction Stop | Out-Null; Set-Location -LiteralPath ${dir} -ErrorAction Stop; ${psNative("claude", `--resume ${run.sessionId} --mcp-config "${cfg.replace(/"/g, '\\"')}"`)}`;
|
|
97
|
+
}
|
|
98
|
+
return `mkdir -p -m 700 ${AGENT_DIR} && cd ${AGENT_DIR} && claude --resume ${sq(run.sessionId)} --mcp-config ${sq(cfg)}`;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Radar's terminal on Windows is Windows PowerShell 5.1, which has no `&&`
|
|
102
|
+
// or `mkdir -p`, and drops the double quotes inside an argument it passes to a
|
|
103
|
+
// program. `--%` hands the rest of the line to the program unparsed, where the
|
|
104
|
+
// C runtime turns \" back into ". It applies to programs, not to npm's .ps1
|
|
105
|
+
// shims, so the program is found as an application (.exe or .cmd). A failing
|
|
106
|
+
// step stops the line (-ErrorAction Stop), so the agent never starts in the
|
|
107
|
+
// wrong folder.
|
|
108
|
+
function psNative(program: string, rawArgs: string): string {
|
|
109
|
+
return `& (Get-Command ${program} -CommandType Application -ErrorAction Stop)[0].Source --% ${rawArgs}`;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// The --% text can't carry a quote, a % or a backslash, so a session id or URL
|
|
113
|
+
// holding one gets no command rather than a broken one.
|
|
114
|
+
function psSafe(sessionId: string, mcpUrl: string): boolean {
|
|
115
|
+
return /^[\w-]+$/.test(sessionId) && !/["%\\]/.test(mcpUrl);
|
|
69
116
|
}
|
|
@@ -1741,3 +1741,23 @@ describe("assessment provenance disclosure", () => {
|
|
|
1741
1741
|
).toBe("");
|
|
1742
1742
|
});
|
|
1743
1743
|
});
|
|
1744
|
+
|
|
1745
|
+
describe("TurnView opening question", () => {
|
|
1746
|
+
const opening: Turn = {
|
|
1747
|
+
timeline: [],
|
|
1748
|
+
diagnosis: null,
|
|
1749
|
+
error: null,
|
|
1750
|
+
status: "running",
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1753
|
+
it("shows the question a run opened with as the engineer's message", () => {
|
|
1754
|
+
const html = renderToStaticMarkup(
|
|
1755
|
+
<TurnView
|
|
1756
|
+
turn={opening}
|
|
1757
|
+
openingQuestion={"checkout 502s\nsince lunch"}
|
|
1758
|
+
/>,
|
|
1759
|
+
);
|
|
1760
|
+
expect(html).toContain("checkout 502s\nsince lunch");
|
|
1761
|
+
expect(html).toContain("whitespace-pre-wrap");
|
|
1762
|
+
});
|
|
1763
|
+
});
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import type { Issue } from "@skyhook-io/k8s-ui";
|
|
3
|
+
|
|
4
|
+
import { suggestionsFromIssues } from "./questionSuggestions";
|
|
5
|
+
|
|
6
|
+
function issue(patch: Partial<Issue>): Issue {
|
|
7
|
+
return {
|
|
8
|
+
id: patch.name ?? "x",
|
|
9
|
+
severity: "warning",
|
|
10
|
+
source: "problem",
|
|
11
|
+
category: "crashloop",
|
|
12
|
+
category_group: "runtime",
|
|
13
|
+
grouping_scope: "workload",
|
|
14
|
+
kind: "Deployment",
|
|
15
|
+
group: "apps",
|
|
16
|
+
namespace: "shop",
|
|
17
|
+
name: "checkout",
|
|
18
|
+
reason: "CrashLoopBackOff",
|
|
19
|
+
...patch,
|
|
20
|
+
} as Issue;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe("suggestionsFromIssues", () => {
|
|
24
|
+
it("offers nothing when Radar sees nothing", () => {
|
|
25
|
+
expect(suggestionsFromIssues([])).toEqual([]);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("pins a problem on one resource and scopes a shared one to its namespace", () => {
|
|
29
|
+
const suggestions = suggestionsFromIssues([
|
|
30
|
+
issue({ name: "checkout" }),
|
|
31
|
+
issue({ category: "image_pull_failed", namespace: "web", name: "a" }),
|
|
32
|
+
issue({ category: "image_pull_failed", namespace: "web", name: "b" }),
|
|
33
|
+
]);
|
|
34
|
+
const one = suggestions.find((s) => s.pin);
|
|
35
|
+
expect(one?.pin).toEqual({
|
|
36
|
+
kind: "Deployment",
|
|
37
|
+
group: "apps",
|
|
38
|
+
namespace: "shop",
|
|
39
|
+
name: "checkout",
|
|
40
|
+
});
|
|
41
|
+
expect(one?.title).toBe("Crash loop");
|
|
42
|
+
expect(one?.where).toBe("Deployment shop/checkout");
|
|
43
|
+
expect(one?.question).toBe("What's causing “Crash loop”?");
|
|
44
|
+
const shared = suggestions.find((s) => !s.pin);
|
|
45
|
+
expect(shared?.namespaces).toEqual(["web"]);
|
|
46
|
+
expect(shared?.question).toContain("on 2 resources in web");
|
|
47
|
+
expect(shared?.where).toBe("2 resources · web");
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("counts resources, not issues, and keeps different problems apart", () => {
|
|
51
|
+
const suggestions = suggestionsFromIssues([
|
|
52
|
+
issue({
|
|
53
|
+
id: "a",
|
|
54
|
+
name: "pg",
|
|
55
|
+
kind: "Cluster",
|
|
56
|
+
group: "postgresql.cnpg.io",
|
|
57
|
+
reason: "WALArchivingFailing",
|
|
58
|
+
}),
|
|
59
|
+
issue({
|
|
60
|
+
id: "b",
|
|
61
|
+
name: "pg",
|
|
62
|
+
kind: "Cluster",
|
|
63
|
+
group: "postgresql.cnpg.io",
|
|
64
|
+
reason: "WALArchivingFailing",
|
|
65
|
+
}),
|
|
66
|
+
issue({
|
|
67
|
+
id: "c",
|
|
68
|
+
name: "pg",
|
|
69
|
+
kind: "Cluster",
|
|
70
|
+
group: "postgresql.cnpg.io",
|
|
71
|
+
reason: "BackupFailed",
|
|
72
|
+
}),
|
|
73
|
+
]);
|
|
74
|
+
expect(suggestions.length).toBeGreaterThan(0);
|
|
75
|
+
for (const suggestion of suggestions) {
|
|
76
|
+
expect(suggestion.pin).toMatchObject({ kind: "Cluster", name: "pg" });
|
|
77
|
+
expect(suggestion.where).not.toMatch(/resources/);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it("offers different kinds of problem before more of the same", () => {
|
|
82
|
+
const suggestions = suggestionsFromIssues(
|
|
83
|
+
[
|
|
84
|
+
issue({ category: "crashloop", namespace: "a", name: "a" }),
|
|
85
|
+
issue({ category: "crashloop", namespace: "b", name: "b" }),
|
|
86
|
+
issue({ category: "image_pull_failed", namespace: "c", name: "c" }),
|
|
87
|
+
],
|
|
88
|
+
2,
|
|
89
|
+
);
|
|
90
|
+
expect(suggestions.map((s) => s.pin?.name)).toEqual(["a", "c"]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("puts the most severe problem first and stops at the cap", () => {
|
|
94
|
+
const suggestions = suggestionsFromIssues(
|
|
95
|
+
[
|
|
96
|
+
issue({ category: "a", name: "a" }),
|
|
97
|
+
issue({ category: "b", name: "b", severity: "critical" }),
|
|
98
|
+
issue({ category: "c", name: "c" }),
|
|
99
|
+
issue({ category: "d", name: "d" }),
|
|
100
|
+
],
|
|
101
|
+
3,
|
|
102
|
+
);
|
|
103
|
+
expect(suggestions).toHaveLength(3);
|
|
104
|
+
expect(suggestions[0].pin?.name).toBe("b");
|
|
105
|
+
expect(suggestions.map((s) => s.severity)).toEqual([
|
|
106
|
+
"critical",
|
|
107
|
+
"warning",
|
|
108
|
+
"warning",
|
|
109
|
+
]);
|
|
110
|
+
});
|
|
111
|
+
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import {
|
|
2
|
+
compareIssues,
|
|
3
|
+
issueTitle,
|
|
4
|
+
type Issue,
|
|
5
|
+
type IssueSeverity,
|
|
6
|
+
} from "@skyhook-io/k8s-ui";
|
|
7
|
+
|
|
8
|
+
import { formatInvestigationTarget } from "./target";
|
|
9
|
+
|
|
10
|
+
export interface QuestionPin {
|
|
11
|
+
kind: string;
|
|
12
|
+
group: string;
|
|
13
|
+
namespace: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface QuestionSuggestion {
|
|
18
|
+
key: string;
|
|
19
|
+
/** The problem as the Issues page names it, so the row is recognizable. */
|
|
20
|
+
title: string;
|
|
21
|
+
/** Where it is: one resource, or how many resources in which namespace. */
|
|
22
|
+
where: string;
|
|
23
|
+
severity: IssueSeverity;
|
|
24
|
+
/** What goes in the box. A pinned resource is named by its chip instead. */
|
|
25
|
+
question: string;
|
|
26
|
+
namespaces: string[];
|
|
27
|
+
/** Set when the suggestion is about one resource, so the run can start
|
|
28
|
+
* there instead of searching for it. */
|
|
29
|
+
pin?: QuestionPin;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Questions an engineer would plausibly ask about what Radar sees right now,
|
|
33
|
+
// most severe first: one per problem per namespace. A problem on one
|
|
34
|
+
// resource becomes a question about that resource; the same problem on
|
|
35
|
+
// several becomes a question about the namespace. A resource with two issues
|
|
36
|
+
// of the same name is still one resource. A cluster with no issues
|
|
37
|
+
// gets no suggestions — a stock prompt would only be noise.
|
|
38
|
+
export function suggestionsFromIssues(
|
|
39
|
+
issues: readonly Issue[],
|
|
40
|
+
max = 3,
|
|
41
|
+
): QuestionSuggestion[] {
|
|
42
|
+
const groups = new Map<string, Issue[]>();
|
|
43
|
+
for (const issue of [...issues].sort(compareIssues)) {
|
|
44
|
+
const key = `${issueTitle(issue)}\u0000${issue.namespace ?? ""}`;
|
|
45
|
+
const members = groups.get(key);
|
|
46
|
+
if (members) members.push(issue);
|
|
47
|
+
else groups.set(key, [issue]);
|
|
48
|
+
}
|
|
49
|
+
// One kind of problem per suggestion first, so three namespaces with the
|
|
50
|
+
// same symptom don't crowd out a different one; then fill by severity.
|
|
51
|
+
const seen = new Set<string>();
|
|
52
|
+
const firstOfKind: [string, Issue[]][] = [];
|
|
53
|
+
const rest: [string, Issue[]][] = [];
|
|
54
|
+
for (const entry of groups) {
|
|
55
|
+
const category = entry[1][0].category;
|
|
56
|
+
if (seen.has(category)) rest.push(entry);
|
|
57
|
+
else {
|
|
58
|
+
seen.add(category);
|
|
59
|
+
firstOfKind.push(entry);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const suggestions: QuestionSuggestion[] = [];
|
|
63
|
+
for (const [key, members] of [...firstOfKind, ...rest]) {
|
|
64
|
+
if (suggestions.length >= max) break;
|
|
65
|
+
const first = members[0];
|
|
66
|
+
const title = issueTitle(first);
|
|
67
|
+
const namespaces = first.namespace ? [first.namespace] : [];
|
|
68
|
+
const resources = new Set(
|
|
69
|
+
members.map((m) => `${m.kind}\u0000${m.group ?? ""}\u0000${m.name}`),
|
|
70
|
+
).size;
|
|
71
|
+
if (resources === 1) {
|
|
72
|
+
const pin = {
|
|
73
|
+
kind: first.kind,
|
|
74
|
+
group: first.group ?? "",
|
|
75
|
+
namespace: first.namespace ?? "",
|
|
76
|
+
name: first.name,
|
|
77
|
+
};
|
|
78
|
+
suggestions.push({
|
|
79
|
+
key,
|
|
80
|
+
title,
|
|
81
|
+
where: formatInvestigationTarget(pin),
|
|
82
|
+
severity: severityOf(first),
|
|
83
|
+
question: `What's causing “${title}”?`,
|
|
84
|
+
namespaces,
|
|
85
|
+
pin,
|
|
86
|
+
});
|
|
87
|
+
continue;
|
|
88
|
+
}
|
|
89
|
+
const scope = first.namespace
|
|
90
|
+
? `in ${first.namespace}`
|
|
91
|
+
: "across the cluster";
|
|
92
|
+
suggestions.push({
|
|
93
|
+
key,
|
|
94
|
+
title,
|
|
95
|
+
where: first.namespace
|
|
96
|
+
? `${resources} resources · ${first.namespace}`
|
|
97
|
+
: `${resources} resources across the cluster`,
|
|
98
|
+
severity: severityOf(first),
|
|
99
|
+
question: `What's causing “${title}” on ${resources} resources ${scope}?`,
|
|
100
|
+
namespaces,
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return suggestions;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Questions about a pinned resource, from the issues Radar reports for it
|
|
107
|
+
// (its own, and ones on related objects that name it). The resource stays
|
|
108
|
+
// pinned; the question names the problem, and the object it is on when that
|
|
109
|
+
// is not the pinned resource.
|
|
110
|
+
export function suggestionsForPin(
|
|
111
|
+
issues: readonly Issue[],
|
|
112
|
+
pin: QuestionPin,
|
|
113
|
+
max = 3,
|
|
114
|
+
): QuestionSuggestion[] {
|
|
115
|
+
const pinned = formatInvestigationTarget(pin);
|
|
116
|
+
const seen = new Set<string>();
|
|
117
|
+
const suggestions: QuestionSuggestion[] = [];
|
|
118
|
+
for (const issue of [...issues].sort(compareIssues)) {
|
|
119
|
+
if (suggestions.length >= max) break;
|
|
120
|
+
const title = issueTitle(issue);
|
|
121
|
+
const on = formatInvestigationTarget({
|
|
122
|
+
kind: issue.kind,
|
|
123
|
+
group: issue.group ?? "",
|
|
124
|
+
namespace: issue.namespace ?? "",
|
|
125
|
+
name: issue.name,
|
|
126
|
+
});
|
|
127
|
+
const key = `${title}\u0000${on}`;
|
|
128
|
+
if (seen.has(key)) continue;
|
|
129
|
+
seen.add(key);
|
|
130
|
+
const question =
|
|
131
|
+
on === pinned
|
|
132
|
+
? `What's causing “${title}”?`
|
|
133
|
+
: `What's causing “${title}” on ${on}?`;
|
|
134
|
+
suggestions.push({
|
|
135
|
+
key,
|
|
136
|
+
title,
|
|
137
|
+
where: on,
|
|
138
|
+
severity: severityOf(issue),
|
|
139
|
+
question,
|
|
140
|
+
namespaces: [],
|
|
141
|
+
pin,
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
return suggestions;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
// The Issues page coerces an unknown severity to warning; so does this list.
|
|
148
|
+
function severityOf(issue: Issue): IssueSeverity {
|
|
149
|
+
return issue.severity === "critical" ? "critical" : "warning";
|
|
150
|
+
}
|
|
@@ -350,6 +350,19 @@ describe("assessmentCopyText", () => {
|
|
|
350
350
|
expect(text).toContain("2 more steps in Radar.");
|
|
351
351
|
});
|
|
352
352
|
|
|
353
|
+
it("says what was asked about the resource, right under where", () => {
|
|
354
|
+
const text = assessmentCopyText(storyDiagnosis, {
|
|
355
|
+
context: {
|
|
356
|
+
target: "Deployment shop/api",
|
|
357
|
+
asked: "users saw errors\n yesterday",
|
|
358
|
+
},
|
|
359
|
+
});
|
|
360
|
+
expect(text.split("\n\n").slice(0, 2)).toEqual([
|
|
361
|
+
"**Deployment shop/api**",
|
|
362
|
+
"Asked: “users saw errors yesterday”",
|
|
363
|
+
]);
|
|
364
|
+
});
|
|
365
|
+
|
|
353
366
|
it("puts the healthy word on the headline and the flags before Still open", () => {
|
|
354
367
|
const text = assessmentCopyText(
|
|
355
368
|
{
|