@skyhook-io/radar-app 1.19.0 → 1.20.1
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 +5 -5
- package/src/App.tsx +37 -9
- 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 +353 -64
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/helmInventory.test.tsx +108 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +42 -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/curl/ServiceCurlAvailability.test.tsx +32 -0
- package/src/components/curl/ServiceCurlButton.tsx +2 -2
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- 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.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -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.test.tsx +50 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +72 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +51 -16
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/adapters/listings.ts +34 -4
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +3 -2
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -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 +5 -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/toolCallLabel.test.ts +10 -4
- 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/helm/HelmDrawerFrame.tsx +101 -0
- package/src/components/helm/HelmDrawerRouting.test.tsx +86 -0
- package/src/components/helm/HelmReleaseDrawer.tsx +23 -86
- package/src/components/helm/HelmView.tsx +213 -71
- package/src/components/helm/ObservedHelmNotice.tsx +146 -0
- package/src/components/helm/ObservedHelmRelease.test.tsx +261 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.test.tsx +80 -0
- package/src/components/helm/ObservedHelmReleaseDrawer.tsx +228 -0
- package/src/components/helm/OwnedResources.tsx +4 -2
- package/src/components/home/ClusterHealthCard.restricted.test.tsx +76 -0
- package/src/components/home/ClusterHealthCard.tsx +28 -5
- package/src/components/home/HelmSummary.tsx +23 -4
- package/src/components/home/HelmSummary.unread.test.ts +16 -0
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +20 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +126 -10
- package/src/components/home/MCPSetupDialog.tsx +33 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- 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 +67 -14
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +22 -1
- package/src/components/issues/uncheckedSources.ts +21 -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/resources/renderers/ServiceRenderer.test.tsx +15 -2
- package/src/components/resources/renderers/ServiceRenderer.tsx +1 -1
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.test.tsx +160 -0
- package/src/components/resources/renderers/ValidatingAdmissionPolicyRenderer.tsx +128 -0
- package/src/components/traffic/TrafficView.tsx +3 -3
- 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 +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -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 +8 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/hooks/useResolvedGitOpsOwner.test.ts +22 -0
- package/src/hooks/useResolvedGitOpsOwner.ts +6 -3
- 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 +17 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -2926,11 +2926,93 @@ describe("failedStepMessage", () => {
|
|
|
2926
2926
|
);
|
|
2927
2927
|
});
|
|
2928
2928
|
it("keeps any other failure text as it came", () => {
|
|
2929
|
-
expect(
|
|
2930
|
-
"user_forbidden: your role cannot list pods",
|
|
2931
|
-
);
|
|
2929
|
+
expect(
|
|
2930
|
+
failedStepMessage("user_forbidden: your role cannot list pods"),
|
|
2931
|
+
).toBe("user_forbidden: your role cannot list pods");
|
|
2932
2932
|
expect(failedStepMessage('{"error":"no code"}')).toBe(
|
|
2933
2933
|
'{"error":"no code"}',
|
|
2934
2934
|
);
|
|
2935
2935
|
});
|
|
2936
2936
|
});
|
|
2937
|
+
|
|
2938
|
+
describe("Kueue diagnosis evidence boundaries", () => {
|
|
2939
|
+
it.each(["get_resource", "diagnose"])(
|
|
2940
|
+
"preserves unchecked Issues in %s",
|
|
2941
|
+
(name) => {
|
|
2942
|
+
const resource = {
|
|
2943
|
+
apiVersion: "kueue.x-k8s.io/v1beta2",
|
|
2944
|
+
kind: "Workload",
|
|
2945
|
+
metadata: { namespace: "shop", name: "run" },
|
|
2946
|
+
};
|
|
2947
|
+
const result = project([
|
|
2948
|
+
tool("batch", name, {
|
|
2949
|
+
resource,
|
|
2950
|
+
resourceContext: {
|
|
2951
|
+
tier: "diagnostic",
|
|
2952
|
+
issueSummary: {
|
|
2953
|
+
count: 0,
|
|
2954
|
+
unchecked: [
|
|
2955
|
+
{
|
|
2956
|
+
source: "kueue",
|
|
2957
|
+
reason: "caller_access_denied",
|
|
2958
|
+
kinds: [{ group: "kueue.x-k8s.io", kind: "ClusterQueue" }],
|
|
2959
|
+
},
|
|
2960
|
+
],
|
|
2961
|
+
},
|
|
2962
|
+
},
|
|
2963
|
+
relatedIssues: [],
|
|
2964
|
+
...(name === "diagnose"
|
|
2965
|
+
? {
|
|
2966
|
+
coverage:
|
|
2967
|
+
"Cached resource only. Pods, runtime logs and metrics were not collected.",
|
|
2968
|
+
}
|
|
2969
|
+
: {}),
|
|
2970
|
+
}),
|
|
2971
|
+
]);
|
|
2972
|
+
expect(
|
|
2973
|
+
result.limitations.some(
|
|
2974
|
+
(limit) =>
|
|
2975
|
+
limit.source === "Issue scan" &&
|
|
2976
|
+
limit.message.includes("can't read ClusterQueues"),
|
|
2977
|
+
),
|
|
2978
|
+
).toBe(true);
|
|
2979
|
+
if (name === "diagnose") {
|
|
2980
|
+
expect(
|
|
2981
|
+
result.limitations.some(
|
|
2982
|
+
(limit) =>
|
|
2983
|
+
limit.source === "Diagnosis coverage" &&
|
|
2984
|
+
limit.message.includes(
|
|
2985
|
+
"runtime logs and metrics were not collected",
|
|
2986
|
+
),
|
|
2987
|
+
),
|
|
2988
|
+
).toBe(true);
|
|
2989
|
+
expect(
|
|
2990
|
+
groupsOf(result.groups, "receipt").some(
|
|
2991
|
+
(group) => group.latest.title === "No warning events",
|
|
2992
|
+
),
|
|
2993
|
+
).toBe(false);
|
|
2994
|
+
}
|
|
2995
|
+
},
|
|
2996
|
+
);
|
|
2997
|
+
});
|
|
2998
|
+
|
|
2999
|
+
it("does not turn unchecked Kueue scans into no-issue receipts", () => {
|
|
3000
|
+
const result = project([
|
|
3001
|
+
tool("partial", "issues", {
|
|
3002
|
+
issues: [],
|
|
3003
|
+
total: 0,
|
|
3004
|
+
total_matched: 0,
|
|
3005
|
+
unchecked_sources: [
|
|
3006
|
+
{
|
|
3007
|
+
source: "kueue",
|
|
3008
|
+
reason: "kind_sync_pending",
|
|
3009
|
+
kinds: [{ kind: "Workload", group: "kueue.x-k8s.io" }],
|
|
3010
|
+
},
|
|
3011
|
+
],
|
|
3012
|
+
}),
|
|
3013
|
+
]);
|
|
3014
|
+
expect(
|
|
3015
|
+
result.limitations.some((limit) => limit.source === "Issue scan"),
|
|
3016
|
+
).toBe(true);
|
|
3017
|
+
expect(groupsOf(result.groups, "receipt")).toHaveLength(0);
|
|
3018
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Issue, type IssueRecentChange } from "@skyhook-io/k8s-ui";
|
|
2
|
+
import { type UncheckedSource } from "../../../api/client";
|
|
2
3
|
import { type TimeSeries } from "@skyhook-io/k8s-ui/components/charts";
|
|
3
4
|
import {
|
|
4
5
|
type DiagnosisChangeContext,
|
|
@@ -103,12 +104,14 @@ export interface InvestigationResourceContext extends DiagnosisResourceContext {
|
|
|
103
104
|
highestSeverity?: string;
|
|
104
105
|
topReason?: string;
|
|
105
106
|
bySource?: Record<string, number>;
|
|
107
|
+
unchecked?: UncheckedSource[];
|
|
106
108
|
};
|
|
107
109
|
auditSummary?: {
|
|
108
110
|
count: number;
|
|
109
111
|
highestSeverity?: string;
|
|
110
112
|
topFinding?: string;
|
|
111
113
|
};
|
|
114
|
+
relatedFindings?: unknown;
|
|
112
115
|
policySummary?: unknown;
|
|
113
116
|
podSummary?: unknown;
|
|
114
117
|
templateDivergence?: {
|
|
@@ -381,6 +384,8 @@ export type InvestigationEvidenceData =
|
|
|
381
384
|
| {
|
|
382
385
|
type: "issue";
|
|
383
386
|
issue: Issue;
|
|
387
|
+
/** Association anchor; parent verification cannot establish recovery of this issue. */
|
|
388
|
+
associatedVia?: DiagnosisResourceRef;
|
|
384
389
|
/**
|
|
385
390
|
* A broad `issues` query can return failures from other resources. Keep
|
|
386
391
|
* those factual observations, but do not let agent selection alone imply
|
|
@@ -800,6 +800,34 @@ export function canStopInvestigation(
|
|
|
800
800
|
);
|
|
801
801
|
}
|
|
802
802
|
|
|
803
|
+
// The hand-off resumes the agent's own session, so it waits until no turn is
|
|
804
|
+
// writing to that session. A finished transcript outranks a run summary that
|
|
805
|
+
// still says running, as for Stop; stopping does not, because Stop writes its
|
|
806
|
+
// terminal frame before the agent process has exited.
|
|
807
|
+
export function canContinueInOwnAgent(input: {
|
|
808
|
+
run: RunSummary;
|
|
809
|
+
busy: boolean;
|
|
810
|
+
requestPending: boolean;
|
|
811
|
+
gone: boolean;
|
|
812
|
+
streamReady: boolean;
|
|
813
|
+
verificationPending: boolean;
|
|
814
|
+
latestTurnStatus?: Turn["status"];
|
|
815
|
+
}): boolean {
|
|
816
|
+
const { run, latestTurnStatus } = input;
|
|
817
|
+
const transcriptTerminal =
|
|
818
|
+
latestTurnStatus === "done" || latestTurnStatus === "error";
|
|
819
|
+
return (
|
|
820
|
+
input.streamReady &&
|
|
821
|
+
!input.busy &&
|
|
822
|
+
!input.requestPending &&
|
|
823
|
+
!input.verificationPending &&
|
|
824
|
+
!input.gone &&
|
|
825
|
+
run.status !== "stopping" &&
|
|
826
|
+
latestTurnStatus !== "running" &&
|
|
827
|
+
(transcriptTerminal || run.status !== "running")
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
|
|
803
831
|
export function canContinueInvestigation(
|
|
804
832
|
run: RunSummary,
|
|
805
833
|
latestTurnStatus?: Turn["status"],
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
|
|
3
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
4
|
+
import {
|
|
5
|
+
LAST_INVESTIGATION_MAX_AGE_MS,
|
|
6
|
+
lastInvestigations,
|
|
7
|
+
sameObject,
|
|
8
|
+
} from "./lastInvestigation";
|
|
9
|
+
import { runTargetKey } from "./target";
|
|
10
|
+
|
|
11
|
+
const now = Date.parse("2026-11-02T12:00:00Z");
|
|
12
|
+
const hoursAgo = (h: number) => new Date(now - h * 3600_000).toISOString();
|
|
13
|
+
const key = runTargetKey("Deployment", "shop", "cart", "apps");
|
|
14
|
+
|
|
15
|
+
function run(over: Partial<RunSummary>): RunSummary {
|
|
16
|
+
return {
|
|
17
|
+
id: "r1",
|
|
18
|
+
kind: "Deployment",
|
|
19
|
+
group: "apps",
|
|
20
|
+
namespace: "shop",
|
|
21
|
+
name: "cart",
|
|
22
|
+
context: "cluster-a",
|
|
23
|
+
status: "done",
|
|
24
|
+
preview: "Pods crash on a bad flag",
|
|
25
|
+
assessedAt: hoursAgo(2),
|
|
26
|
+
createdAt: hoursAgo(3),
|
|
27
|
+
updatedAt: hoursAgo(1),
|
|
28
|
+
...over,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe("lastInvestigations", () => {
|
|
33
|
+
it("picks the newest assessment of the resource on the cluster in use", () => {
|
|
34
|
+
const got = lastInvestigations(
|
|
35
|
+
[
|
|
36
|
+
run({ id: "old", assessedAt: hoursAgo(30) }),
|
|
37
|
+
run({ id: "new", assessedAt: hoursAgo(2), preview: "Healthy" }),
|
|
38
|
+
run({
|
|
39
|
+
id: "other-cluster",
|
|
40
|
+
context: "cluster-b",
|
|
41
|
+
assessedAt: hoursAgo(1),
|
|
42
|
+
}),
|
|
43
|
+
],
|
|
44
|
+
"cluster-a",
|
|
45
|
+
now,
|
|
46
|
+
);
|
|
47
|
+
expect(got.get(key)).toMatchObject({ id: "new", preview: "Healthy" });
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("counts a run made stale by a cluster switch", () => {
|
|
51
|
+
const got = lastInvestigations(
|
|
52
|
+
[run({ status: "stale" })],
|
|
53
|
+
"cluster-a",
|
|
54
|
+
now,
|
|
55
|
+
);
|
|
56
|
+
expect(got.get(key)?.id).toBe("r1");
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
it.each([
|
|
60
|
+
["a live run", { status: "running" as const }],
|
|
61
|
+
[
|
|
62
|
+
"a question about no resource",
|
|
63
|
+
{ name: "", question: "why is checkout slow?" },
|
|
64
|
+
],
|
|
65
|
+
["a run with no dated assessment", { assessedAt: undefined }],
|
|
66
|
+
[
|
|
67
|
+
"an assessment past the cutoff",
|
|
68
|
+
{
|
|
69
|
+
assessedAt: new Date(
|
|
70
|
+
now - LAST_INVESTIGATION_MAX_AGE_MS - 1,
|
|
71
|
+
).toISOString(),
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
])("skips %s", (_, over) => {
|
|
75
|
+
expect(lastInvestigations([run(over)], "cluster-a", now).size).toBe(0);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("matches nothing until the cluster in use is known", () => {
|
|
79
|
+
expect(lastInvestigations([run({})], undefined, now).size).toBe(0);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("sameObject", () => {
|
|
84
|
+
const last = { id: "r1", preview: "x", assessedAt: hoursAgo(2) };
|
|
85
|
+
it("rejects an object created after the assessment", () => {
|
|
86
|
+
expect(sameObject(last, hoursAgo(1))).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
it("accepts an object recreated mid-run that the assessment saw", () => {
|
|
89
|
+
expect(sameObject(last, hoursAgo(2.5))).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
it("accepts an older object, or one whose creation time is unknown", () => {
|
|
92
|
+
expect(sameObject(last, hoursAgo(48))).toBe(true);
|
|
93
|
+
expect(sameObject(last, undefined)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
2
|
+
import { isQuestionOnly, runTargetKey } from "./target";
|
|
3
|
+
|
|
4
|
+
// Past this age a verdict describes the cluster as it was, not as it is, so the
|
|
5
|
+
// resource stops pointing at it. History still lists it.
|
|
6
|
+
export const LAST_INVESTIGATION_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;
|
|
7
|
+
|
|
8
|
+
export interface LastInvestigation {
|
|
9
|
+
id: string;
|
|
10
|
+
preview: string;
|
|
11
|
+
assessedAt: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// The newest assessment of each resource on the cluster in use. Only runs the
|
|
15
|
+
// server dated with assessedAt qualify: their preview is the assessment
|
|
16
|
+
// Findings shows, not a later answer. Stale runs count, since switching
|
|
17
|
+
// clusters marks every run stale.
|
|
18
|
+
export function lastInvestigations(
|
|
19
|
+
runs: readonly RunSummary[],
|
|
20
|
+
context: string | undefined,
|
|
21
|
+
now: number,
|
|
22
|
+
): Map<string, LastInvestigation> {
|
|
23
|
+
const out = new Map<string, LastInvestigation>();
|
|
24
|
+
if (!context) return out;
|
|
25
|
+
for (const r of runs) {
|
|
26
|
+
if (
|
|
27
|
+
isQuestionOnly(r) ||
|
|
28
|
+
r.status === "running" ||
|
|
29
|
+
r.status === "stopping" ||
|
|
30
|
+
r.context !== context ||
|
|
31
|
+
!r.assessedAt ||
|
|
32
|
+
!r.preview
|
|
33
|
+
)
|
|
34
|
+
continue;
|
|
35
|
+
const assessed = Date.parse(r.assessedAt);
|
|
36
|
+
if (!(now - assessed <= LAST_INVESTIGATION_MAX_AGE_MS)) continue;
|
|
37
|
+
const key = runTargetKey(r.kind, r.namespace, r.name, r.group);
|
|
38
|
+
const prev = out.get(key);
|
|
39
|
+
if (prev && Date.parse(prev.assessedAt) >= assessed) continue;
|
|
40
|
+
out.set(key, {
|
|
41
|
+
id: r.id,
|
|
42
|
+
preview: r.preview,
|
|
43
|
+
assessedAt: r.assessedAt,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Whether the object on screen is the one the assessment describes. Without a
|
|
50
|
+
// UID the creation time is the only tell: an object created after the
|
|
51
|
+
// assessment was recreated since. Unknown creation time can't rule it out.
|
|
52
|
+
export function sameObject(
|
|
53
|
+
last: LastInvestigation,
|
|
54
|
+
objectCreatedAt: string | undefined,
|
|
55
|
+
): boolean {
|
|
56
|
+
if (!objectCreatedAt) return true;
|
|
57
|
+
return !(Date.parse(objectCreatedAt) > Date.parse(last.assessedAt));
|
|
58
|
+
}
|
|
@@ -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
|
}
|
|
@@ -15,11 +15,17 @@ describe("describeToolCall", () => {
|
|
|
15
15
|
});
|
|
16
16
|
|
|
17
17
|
it("scopes the runtime inventory to its namespace", () => {
|
|
18
|
-
expect(describeToolCall("get_runtime_versions", JSON.stringify({ runtime: "php" }))).toBe(
|
|
19
|
-
"Reading runtime versions of running images",
|
|
20
|
-
);
|
|
21
18
|
expect(
|
|
22
|
-
describeToolCall(
|
|
19
|
+
describeToolCall(
|
|
20
|
+
"get_runtime_versions",
|
|
21
|
+
JSON.stringify({ runtime: "php" }),
|
|
22
|
+
),
|
|
23
|
+
).toBe("Reading runtime versions of running images");
|
|
24
|
+
expect(
|
|
25
|
+
describeToolCall(
|
|
26
|
+
"get_runtime_versions",
|
|
27
|
+
JSON.stringify({ namespace: "shop", runtime: "php" }),
|
|
28
|
+
),
|
|
23
29
|
).toBe("Reading runtime versions of running images in shop");
|
|
24
30
|
});
|
|
25
31
|
|