@skyhook-io/radar-app 1.13.5 → 1.14.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/package.json +9 -9
- package/src/App.tsx +66 -28
- package/src/api/client.authRedirect.test.ts +12 -1
- package/src/api/client.prometheusStatus.test.ts +24 -0
- package/src/api/client.ts +324 -16
- package/src/api/diagnose.ts +32 -1
- package/src/api/drain-plan.test.ts +86 -0
- package/src/api/quotas.test.ts +26 -0
- package/src/api/quotas.ts +20 -0
- package/src/api/workloadMetrics.test.ts +40 -0
- package/src/api/workloadMetrics.ts +68 -0
- package/src/components/CloudConnectFlow.tsx +343 -46
- package/src/components/CloudFunnelButton.tsx +110 -37
- package/src/components/ConnectionErrorView.tsx +9 -10
- package/src/components/DebugOverlay.tsx +10 -6
- package/src/components/SyncProgressPanel.tsx +73 -0
- package/src/components/audit/AuditView.tsx +2 -0
- package/src/components/cloudConnectHandoff.test.ts +245 -0
- package/src/components/cloudConnectHandoff.ts +276 -0
- package/src/components/curl/ServiceCurlButton.tsx +19 -26
- package/src/components/diagnose/AgentCase.tsx +18 -5
- package/src/components/diagnose/AnalysisStory.test.tsx +308 -0
- package/src/components/diagnose/AnalysisStory.tsx +564 -0
- package/src/components/diagnose/DiagnoseContext.test.ts +10 -0
- package/src/components/diagnose/DiagnoseContext.tsx +26 -8
- package/src/components/diagnose/DiagnoseSurface.tsx +20 -14
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +771 -0
- package/src/components/diagnose/InvestigationEvidencePane.test.tsx +8 -33
- package/src/components/diagnose/InvestigationEvidencePane.tsx +809 -168
- package/src/components/diagnose/InvestigationResourceEvidence.test.tsx +30 -0
- package/src/components/diagnose/InvestigationResourceEvidence.tsx +20 -0
- package/src/components/diagnose/InvestigationView.tsx +493 -529
- package/src/components/diagnose/investigationCase.test.tsx +267 -129
- package/src/components/diagnose/investigationCase.ts +122 -77
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +60 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +573 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +935 -0
- package/src/components/diagnose/investigationEvidence/adapters/events.ts +96 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.test.ts +242 -0
- package/src/components/diagnose/investigationEvidence/adapters/helm.ts +208 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +172 -0
- package/src/components/diagnose/investigationEvidence/adapters/logs.test.ts +283 -0
- package/src/components/diagnose/investigationEvidence/adapters/logs.ts +183 -0
- package/src/components/diagnose/investigationEvidence/adapters/permissions.test.ts +528 -0
- package/src/components/diagnose/investigationEvidence/adapters/permissions.ts +292 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +1641 -0
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +769 -0
- package/src/components/diagnose/investigationEvidence/adapters/resource.test.ts +81 -0
- package/src/components/diagnose/investigationEvidence/adapters/resource.ts +285 -0
- package/src/components/diagnose/investigationEvidence/adapters/topology.ts +207 -0
- package/src/components/diagnose/investigationEvidence/builder.ts +427 -0
- package/src/components/diagnose/investigationEvidence/evidenceFixtures.ts +179 -0
- package/src/components/diagnose/investigationEvidence/identity.test.ts +632 -0
- package/src/components/diagnose/investigationEvidence/identity.ts +261 -0
- package/src/components/diagnose/investigationEvidence/index.ts +55 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +978 -0
- package/src/components/diagnose/investigationEvidence/parse.ts +467 -0
- package/src/components/diagnose/investigationEvidence/projection.test.ts +2736 -0
- package/src/components/diagnose/investigationEvidence/types.ts +514 -0
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +2 -0
- package/src/components/diagnose/investigationEvidencePresentation.ts +3 -0
- package/src/components/diagnose/investigationState.test.ts +316 -58
- package/src/components/diagnose/investigationState.ts +257 -44
- package/src/components/diagnose/investigationStory.test.ts +161 -0
- package/src/components/diagnose/investigationStory.ts +207 -0
- package/src/components/diagnose/parts.test.tsx +9 -6
- package/src/components/diagnose/parts.tsx +977 -193
- package/src/components/diagnose/storyParts.test.tsx +426 -0
- package/src/components/diagnose/target.test.ts +19 -0
- package/src/components/diagnose/target.ts +3 -2
- package/src/components/diagnose/toolCallLabel.test.ts +51 -0
- package/src/components/diagnose/toolCallLabel.ts +135 -0
- package/src/components/diagnose/useDisclosureReveal.ts +10 -11
- package/src/components/gitops/GitOpsView.tsx +7 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +26 -0
- package/src/components/helm/HelmCompareRoute.tsx +18 -4
- package/src/components/helm/HelmReleaseDrawer.tsx +11 -26
- package/src/components/helm/InstallWizard.tsx +8 -3
- package/src/components/home/MCPSetupDialog.tsx +15 -9
- package/src/components/portforward/PortForwardManager.tsx +6 -13
- package/src/components/resource/PrometheusCharts.overlays.test.ts +22 -0
- package/src/components/resource/PrometheusCharts.tsx +4 -3
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +99 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +75 -35
- package/src/components/resource/RightsizingStrip.test.ts +38 -0
- package/src/components/resource/RightsizingStrip.tsx +15 -3
- package/src/components/resource/WorkloadMetricsHelpDialog.test.tsx +79 -0
- package/src/components/resource/WorkloadMetricsHelpDialog.tsx +145 -0
- package/src/components/resource/WorkloadMetricsSection.render.test.tsx +351 -0
- package/src/components/resource/WorkloadMetricsSection.tsx +480 -0
- package/src/components/resource/workloadMetricValues.test.ts +65 -0
- package/src/components/resource/workloadMetricValues.ts +30 -0
- package/src/components/resources/PodFilePreview.tsx +3 -3
- package/src/components/resources/ResourcesView.tsx +44 -6
- package/src/components/resources/renderers/NamespaceRenderer.tsx +7 -1
- package/src/components/resources/renderers/PodRenderer.tsx +4 -0
- package/src/components/resources/renderers/RolloutRenderer.tsx +15 -1
- package/src/components/resources/renderers/ServiceRenderer.tsx +2 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +3 -0
- package/src/components/rightsizing/RightsizingScanView.tsx +21 -0
- package/src/components/settings/SettingsDialog.tsx +98 -16
- package/src/components/traffic/TrafficFlowList.tsx +229 -70
- package/src/components/traffic/TrafficGraph.tsx +6 -6
- package/src/components/traffic/TrafficView.tsx +10 -9
- package/src/components/traffic/trafficFilters.test.ts +28 -1
- package/src/components/traffic/trafficFilters.ts +31 -0
- package/src/components/ui/CommandPalette.tsx +10 -6
- package/src/components/ui/DiagnosticsOverlay.tsx +10 -6
- package/src/components/ui/Disclosure.tsx +47 -0
- package/src/components/ui/Markdown.tsx +23 -11
- package/src/components/ui/ShortcutHelpOverlay.tsx +3 -1
- package/src/components/ui/UpdateNotification.tsx +18 -2
- package/src/components/workload/WorkloadView.tsx +19 -8
- package/src/context/ConnectionContext.tsx +48 -3
- package/src/context/DiagnoseCustomization.tsx +1 -0
- package/src/index.css +36 -6
- package/src/utils/navigation.ts +1 -1
- package/src/utils/topology-namespace.test.ts +64 -0
- package/src/utils/topology-namespace.ts +18 -0
- package/src/components/diagnose/investigationEvidence.test.ts +0 -6617
- package/src/components/diagnose/investigationEvidence.ts +0 -5572
- package/src/components/gitops/GitOpsActions.tsx +0 -1
- package/src/components/gitops/GitOpsStatusBadge.tsx +0 -1
- package/src/components/gitops/ManagedResourcesList.tsx +0 -1
- package/src/components/gitops/SyncCountdown.tsx +0 -1
- package/src/components/gitops/index.ts +0 -4
- package/src/components/helm/ManifestDiffViewer.tsx +0 -69
- package/src/components/logs/JsonLogLine.tsx +0 -1
- package/src/components/logs/LogCore.tsx +0 -2
- package/src/components/logs/useLogBuffer.ts +0 -2
- package/src/components/logs/useLogSearch.ts +0 -1
- package/src/components/resource-drawer/ResourceDrawer.tsx +0 -216
- package/src/components/resources/drawer-components.tsx +0 -1
- package/src/components/resources/renderers/AlertRenderer.tsx +0 -1
- package/src/components/resources/renderers/CNPGBackupRenderer.tsx +0 -1
- package/src/components/resources/renderers/CNPGPoolerRenderer.tsx +0 -1
- package/src/components/resources/renderers/CNPGScheduledBackupRenderer.tsx +0 -1
- package/src/components/resources/renderers/CertificateRenderer.tsx +0 -1
- package/src/components/resources/renderers/CertificateRequestRenderer.tsx +0 -1
- package/src/components/resources/renderers/ChallengeRenderer.tsx +0 -1
- package/src/components/resources/renderers/ClusterComplianceReportRenderer.tsx +0 -1
- package/src/components/resources/renderers/ClusterExternalSecretRenderer.tsx +0 -1
- package/src/components/resources/renderers/ClusterIssuerRenderer.tsx +0 -1
- package/src/components/resources/renderers/ConfigAuditReportRenderer.tsx +0 -1
- package/src/components/resources/renderers/ConfigMapRenderer.tsx +0 -1
- package/src/components/resources/renderers/CronJobRenderer.tsx +0 -1
- package/src/components/resources/renderers/CronWorkflowRenderer.tsx +0 -1
- package/src/components/resources/renderers/EventRenderer.tsx +0 -1
- package/src/components/resources/renderers/ExposedSecretReportRenderer.tsx +0 -1
- package/src/components/resources/renderers/ExternalSecretRenderer.tsx +0 -1
- package/src/components/resources/renderers/FluxHelmReleaseRenderer.tsx +0 -1
- package/src/components/resources/renderers/GRPCRouteRenderer.tsx +0 -1
- package/src/components/resources/renderers/GatewayClassRenderer.tsx +0 -1
- package/src/components/resources/renderers/GatewayRenderer.tsx +0 -1
- package/src/components/resources/renderers/GenericRenderer.tsx +0 -1
- package/src/components/resources/renderers/GitRepositoryRenderer.tsx +0 -1
- package/src/components/resources/renderers/HTTPRouteRenderer.tsx +0 -1
- package/src/components/resources/renderers/HelmRepositoryRenderer.tsx +0 -1
- package/src/components/resources/renderers/IngressClassRenderer.tsx +0 -1
- package/src/components/resources/renderers/IngressRenderer.tsx +0 -1
- package/src/components/resources/renderers/IstioAuthorizationPolicyRenderer.tsx +0 -1
- package/src/components/resources/renderers/IstioDestinationRuleRenderer.tsx +0 -1
- package/src/components/resources/renderers/IstioGatewayRenderer.tsx +0 -1
- package/src/components/resources/renderers/IstioPeerAuthenticationRenderer.tsx +0 -1
- package/src/components/resources/renderers/IstioServiceEntryRenderer.tsx +0 -1
- package/src/components/resources/renderers/IstioVirtualServiceRenderer.tsx +0 -1
- package/src/components/resources/renderers/JobRenderer.tsx +0 -1
- package/src/components/resources/renderers/KarpenterEC2NodeClassRenderer.tsx +0 -1
- package/src/components/resources/renderers/KarpenterNodeClaimRenderer.tsx +0 -1
- package/src/components/resources/renderers/KedaScaledJobRenderer.tsx +0 -1
- package/src/components/resources/renderers/KedaScaledObjectRenderer.tsx +0 -1
- package/src/components/resources/renderers/KedaTriggerAuthRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeConfigurationRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeEventingRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeFlowRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeNetworkingRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeRevisionRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeRouteRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeServiceRenderer.tsx +0 -1
- package/src/components/resources/renderers/KnativeSourceRenderer.tsx +0 -1
- package/src/components/resources/renderers/KustomizationRenderer.tsx +0 -1
- package/src/components/resources/renderers/KyvernoPolicyReportRenderer.tsx +0 -1
- package/src/components/resources/renderers/LeaseRenderer.tsx +0 -1
- package/src/components/resources/renderers/NetworkPolicyRenderer.tsx +0 -1
- package/src/components/resources/renderers/OCIRepositoryRenderer.tsx +0 -1
- package/src/components/resources/renderers/OrderRenderer.tsx +0 -1
- package/src/components/resources/renderers/PersistentVolumeRenderer.tsx +0 -1
- package/src/components/resources/renderers/PodDisruptionBudgetRenderer.tsx +0 -1
- package/src/components/resources/renderers/PodMonitorRenderer.tsx +0 -1
- package/src/components/resources/renderers/PriorityClassRenderer.tsx +0 -1
- package/src/components/resources/renderers/PrometheusRuleRenderer.tsx +0 -1
- package/src/components/resources/renderers/ReplicaSetRenderer.tsx +0 -1
- package/src/components/resources/renderers/RuntimeClassRenderer.tsx +0 -1
- package/src/components/resources/renderers/SbomReportRenderer.tsx +0 -1
- package/src/components/resources/renderers/SealedSecretRenderer.tsx +0 -1
- package/src/components/resources/renderers/SecretRenderer.tsx +0 -1
- package/src/components/resources/renderers/SecretStoreRenderer.tsx +0 -1
- package/src/components/resources/renderers/ServiceMonitorRenderer.tsx +0 -1
- package/src/components/resources/renderers/SimpleRouteRenderer.tsx +0 -1
- package/src/components/resources/renderers/StorageClassRenderer.tsx +0 -1
- package/src/components/resources/renderers/TraefikIngressRouteRenderer.tsx +0 -1
- package/src/components/resources/renderers/VPARenderer.tsx +0 -1
- package/src/components/resources/renderers/VeleroScheduleRenderer.tsx +0 -1
- package/src/components/resources/renderers/VeleroVSLRenderer.tsx +0 -1
- package/src/components/resources/renderers/VulnerabilityReportRenderer.tsx +0 -1
- package/src/components/resources/renderers/WebhookConfigRenderer.tsx +0 -1
- package/src/components/resources/renderers/WorkflowRenderer.tsx +0 -1
- package/src/components/resources/renderers/WorkflowTemplateRenderer.tsx +0 -1
- package/src/components/resources/renderers/argo-cells.tsx +0 -1
- package/src/components/resources/renderers/certmanager-cells.tsx +0 -1
- package/src/components/resources/renderers/cnpg-cells.tsx +0 -1
- package/src/components/resources/renderers/eso-cells.tsx +0 -1
- package/src/components/resources/renderers/flux-cells.tsx +0 -1
- package/src/components/resources/renderers/index.ts +0 -94
- package/src/components/resources/renderers/istio-cells.tsx +0 -1
- package/src/components/resources/renderers/karpenter-cells.tsx +0 -1
- package/src/components/resources/renderers/keda-cells.tsx +0 -1
- package/src/components/resources/renderers/knative-cells.tsx +0 -1
- package/src/components/resources/renderers/kyverno-cells.tsx +0 -1
- package/src/components/resources/renderers/prometheus-cells.tsx +0 -1
- package/src/components/resources/renderers/traefik-cells.tsx +0 -1
- package/src/components/resources/renderers/trivy-cells.tsx +0 -1
- package/src/components/resources/renderers/trivy-shared.tsx +0 -1
- package/src/components/resources/renderers/velero-cells.tsx +0 -1
- package/src/components/resources/resource-utils-argo.ts +0 -2
- package/src/components/resources/resource-utils-certmanager.ts +0 -2
- package/src/components/resources/resource-utils-eso.ts +0 -2
- package/src/components/resources/resource-utils-flux.ts +0 -2
- package/src/components/resources/resource-utils-istio.ts +0 -2
- package/src/components/resources/resource-utils-karpenter.ts +0 -2
- package/src/components/resources/resource-utils-knative.ts +0 -2
- package/src/components/resources/resource-utils-kyverno.ts +0 -2
- package/src/components/resources/resource-utils-prometheus.ts +0 -2
- package/src/components/resources/resource-utils-traefik.ts +0 -1
- package/src/components/resources/resource-utils-trivy.ts +0 -2
- package/src/components/resources/resource-utils-velero.ts +0 -2
- package/src/components/shared/EditableYamlView.tsx +0 -24
- package/src/components/timeline/DiffViewer.tsx +0 -1
- package/src/components/traffic/index.ts +0 -3
- package/src/components/ui/ForceDeleteConfirmDialog.tsx +0 -1
- package/src/components/ui/MetricsChart.tsx +0 -1
- package/src/components/ui/ResourceBar.tsx +0 -1
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
|
-
import { Sparkles } from "lucide-react";
|
|
3
2
|
import { Badge } from "@skyhook-io/k8s-ui";
|
|
4
3
|
|
|
5
4
|
import type { DiagnosisEvidenceRole } from "../../api/diagnose";
|
|
@@ -11,7 +10,7 @@ export const AGENT_ROLE_LABELS: Readonly<
|
|
|
11
10
|
cause: "Cause",
|
|
12
11
|
symptom: "Symptom",
|
|
13
12
|
context: "Context",
|
|
14
|
-
benign: "Not a problem",
|
|
13
|
+
benign: "Not a live problem",
|
|
15
14
|
demoted: "Less relevant",
|
|
16
15
|
rules_out: "Rules out",
|
|
17
16
|
};
|
|
@@ -29,8 +28,11 @@ export function AgentRoleChip({ role }: { role: DiagnosisEvidenceRole }) {
|
|
|
29
28
|
// and the badge's own baseline comes from the sparkle, landing 1px high.
|
|
30
29
|
wrapperClassName="shrink-0 align-[-1px]"
|
|
31
30
|
>
|
|
32
|
-
<Badge
|
|
33
|
-
|
|
31
|
+
<Badge
|
|
32
|
+
tone="structural"
|
|
33
|
+
size="sm"
|
|
34
|
+
className="border-theme-border-light font-medium text-theme-text-primary"
|
|
35
|
+
>
|
|
34
36
|
{AGENT_ROLE_LABELS[role]}
|
|
35
37
|
</Badge>
|
|
36
38
|
</Tooltip>
|
|
@@ -55,10 +57,13 @@ export function AgentClaimNote({
|
|
|
55
57
|
role,
|
|
56
58
|
excludes,
|
|
57
59
|
subject,
|
|
60
|
+
gap,
|
|
58
61
|
className,
|
|
59
62
|
}: {
|
|
60
63
|
claim: string;
|
|
61
64
|
role?: DiagnosisEvidenceRole;
|
|
65
|
+
/** What the agent says this result does not cover; shown beside its reading of it. */
|
|
66
|
+
gap?: string;
|
|
62
67
|
/**
|
|
63
68
|
* The hypothesis this item excludes. Rendered only for `rules_out`, where
|
|
64
69
|
* the chip frames it as rejected: a hypothesis is a claim the agent
|
|
@@ -69,7 +74,7 @@ export function AgentClaimNote({
|
|
|
69
74
|
subject?: string;
|
|
70
75
|
className?: string;
|
|
71
76
|
}) {
|
|
72
|
-
if (!claim && !role) return null;
|
|
77
|
+
if (!claim && !role && !gap) return null;
|
|
73
78
|
return (
|
|
74
79
|
<p
|
|
75
80
|
data-agent-claim
|
|
@@ -102,6 +107,14 @@ export function AgentClaimNote({
|
|
|
102
107
|
{renderClaim(claim)}
|
|
103
108
|
</>
|
|
104
109
|
) : null}
|
|
110
|
+
{gap ? (
|
|
111
|
+
<span
|
|
112
|
+
data-agent-gap
|
|
113
|
+
className="block text-[11px] text-theme-text-tertiary"
|
|
114
|
+
>
|
|
115
|
+
Not shown: {gap}
|
|
116
|
+
</span>
|
|
117
|
+
) : null}
|
|
105
118
|
</span>
|
|
106
119
|
</p>
|
|
107
120
|
);
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
AnalysisStory,
|
|
6
|
+
resolveStoryPlacements,
|
|
7
|
+
type StoryPlacementLoss,
|
|
8
|
+
type StoryPlacementTarget,
|
|
9
|
+
} from "./AnalysisStory";
|
|
10
|
+
import type { InvestigationCaseItem } from "./investigationCase";
|
|
11
|
+
|
|
12
|
+
function target(index: number, observationId: string): StoryPlacementTarget {
|
|
13
|
+
return {
|
|
14
|
+
item: {
|
|
15
|
+
index,
|
|
16
|
+
role: "cause",
|
|
17
|
+
claim: "",
|
|
18
|
+
placement: "card",
|
|
19
|
+
groupId: `group-${observationId}`,
|
|
20
|
+
source: { id: `src-${observationId}` },
|
|
21
|
+
observation: {
|
|
22
|
+
source: { id: `src-${observationId}` },
|
|
23
|
+
revision: 1,
|
|
24
|
+
title: `Card ${observationId}`,
|
|
25
|
+
},
|
|
26
|
+
} as unknown as InvestigationCaseItem,
|
|
27
|
+
domId: `story-group-${observationId}`,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const resolver =
|
|
32
|
+
(table: Record<number, StoryPlacementTarget | StoryPlacementLoss>) =>
|
|
33
|
+
(index: number) =>
|
|
34
|
+
table[index] ?? ("invalid" as const);
|
|
35
|
+
|
|
36
|
+
describe("resolveStoryPlacements", () => {
|
|
37
|
+
it("places the first block marker per observation and references the rest", () => {
|
|
38
|
+
const story = resolveStoryPlacements(
|
|
39
|
+
"A.\n\n[[radar:evidence=0]]\n\nAgain [[radar:evidence=0]] and [[radar:evidence=1]].\n\n[[radar:evidence=1]]\n\n[[radar:evidence=0]]",
|
|
40
|
+
resolver({ 0: target(0, "a"), 1: target(1, "a") }),
|
|
41
|
+
);
|
|
42
|
+
// Item 1 resolves to the same observation as item 0: one card, not two.
|
|
43
|
+
expect(story.byIndex.get(0)?.kind).toBe("placed");
|
|
44
|
+
expect(story.byIndex.get(1)?.kind).toBe("reference");
|
|
45
|
+
expect(story.placedCount).toBe(1);
|
|
46
|
+
expect(story.lostItems).toBe(0);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("renders one card for a repeated block marker and keeps the paragraph when nothing places", () => {
|
|
50
|
+
const repeated = resolveStoryPlacements(
|
|
51
|
+
"[[radar:evidence=0]]\n\nAgain:\n\n[[radar:evidence=0]]",
|
|
52
|
+
resolver({ 0: target(0, "a") }),
|
|
53
|
+
);
|
|
54
|
+
expect(repeated.placedAt.get(0)).toBe(0);
|
|
55
|
+
const html = renderToStaticMarkup(
|
|
56
|
+
<AnalysisStory
|
|
57
|
+
report={"Opening paragraph.\n\n[[radar:evidence=2]]\n\nMore."}
|
|
58
|
+
resolveItem={resolver({ 2: "unlinked" })}
|
|
59
|
+
renderPlacement={() => null}
|
|
60
|
+
onReveal={vi.fn()}
|
|
61
|
+
/>,
|
|
62
|
+
);
|
|
63
|
+
expect(html).toContain("Opening paragraph.");
|
|
64
|
+
expect(html).toContain('data-story-lost-support="unlinked"');
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("places a card under the paragraph that first mentions it inline, and drops that marker from the sentence", () => {
|
|
68
|
+
const story = resolveStoryPlacements(
|
|
69
|
+
"Envoy boots [[radar:evidence=0]] then hangs on xDS.\n\nLater, see [[radar:evidence=0]] again.",
|
|
70
|
+
resolver({ 0: target(0, "a") }),
|
|
71
|
+
);
|
|
72
|
+
expect(story.segments.map((segment) => segment.kind)).toEqual([
|
|
73
|
+
"prose",
|
|
74
|
+
"placement",
|
|
75
|
+
"prose",
|
|
76
|
+
]);
|
|
77
|
+
expect(story.segments[1]).toEqual({
|
|
78
|
+
kind: "placement",
|
|
79
|
+
index: 0,
|
|
80
|
+
auto: true,
|
|
81
|
+
});
|
|
82
|
+
expect(story.placedAt.get(0)).toBe(1);
|
|
83
|
+
expect((story.segments[0] as { markdown: string }).markdown).toBe(
|
|
84
|
+
"Envoy boots then hangs on xDS.",
|
|
85
|
+
);
|
|
86
|
+
expect((story.segments[2] as { markdown: string }).markdown).toContain(
|
|
87
|
+
"#radar-evidence-0",
|
|
88
|
+
);
|
|
89
|
+
const html = renderToStaticMarkup(
|
|
90
|
+
<AnalysisStory
|
|
91
|
+
report={
|
|
92
|
+
"Envoy boots [[radar:evidence=0]] then hangs on xDS.\n\nLater, see [[radar:evidence=0]] again."
|
|
93
|
+
}
|
|
94
|
+
resolveItem={resolver({ 0: target(0, "a") })}
|
|
95
|
+
renderPlacement={() => <div data-card>card</div>}
|
|
96
|
+
onReveal={vi.fn()}
|
|
97
|
+
openRequest={1}
|
|
98
|
+
/>,
|
|
99
|
+
);
|
|
100
|
+
expect(html).toContain("data-card");
|
|
101
|
+
expect(html).toContain("↑");
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("keeps an inline mention a reference when the agent places that card on its own line later, pointing down", () => {
|
|
105
|
+
const html = renderToStaticMarkup(
|
|
106
|
+
<AnalysisStory
|
|
107
|
+
report={
|
|
108
|
+
"First [[radar:evidence=0]] here.\n\nThen:\n\n[[radar:evidence=0]]"
|
|
109
|
+
}
|
|
110
|
+
resolveItem={resolver({ 0: target(0, "a") })}
|
|
111
|
+
renderPlacement={() => <div data-card>card</div>}
|
|
112
|
+
onReveal={vi.fn()}
|
|
113
|
+
openRequest={1}
|
|
114
|
+
/>,
|
|
115
|
+
);
|
|
116
|
+
expect(html).toContain("↓");
|
|
117
|
+
expect(html.match(/data-card/g)).toHaveLength(1);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("places two cards that share one source and revision when they are different groups", () => {
|
|
121
|
+
const shared = (index: number, group: string): StoryPlacementTarget => ({
|
|
122
|
+
item: {
|
|
123
|
+
index,
|
|
124
|
+
role: "context",
|
|
125
|
+
claim: "",
|
|
126
|
+
placement: "card",
|
|
127
|
+
groupId: group,
|
|
128
|
+
source: { id: "src-bundle" },
|
|
129
|
+
observation: {
|
|
130
|
+
source: { id: "src-bundle" },
|
|
131
|
+
revision: 1,
|
|
132
|
+
title: group,
|
|
133
|
+
},
|
|
134
|
+
} as unknown as InvestigationCaseItem,
|
|
135
|
+
domId: `story-${group}`,
|
|
136
|
+
});
|
|
137
|
+
const story = resolveStoryPlacements(
|
|
138
|
+
"[[radar:evidence=0]]\n\n[[radar:evidence=1]]",
|
|
139
|
+
resolver({ 0: shared(0, "logs"), 1: shared(1, "events") }),
|
|
140
|
+
);
|
|
141
|
+
expect(story.placedCount).toBe(2);
|
|
142
|
+
expect(story.byIndex.get(1)?.kind).toBe("placed");
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it("keeps the compact flag of an inline marker it auto-places, and tidies only the marker's hole", () => {
|
|
146
|
+
const story = resolveStoryPlacements(
|
|
147
|
+
"Line one \nline two says [[radar:evidence=0|compact]], then more.",
|
|
148
|
+
resolver({ 0: target(0, "a") }),
|
|
149
|
+
);
|
|
150
|
+
expect(story.segments).toEqual([
|
|
151
|
+
{
|
|
152
|
+
kind: "prose",
|
|
153
|
+
markdown: "Line one \nline two says, then more.",
|
|
154
|
+
},
|
|
155
|
+
{ kind: "placement", index: 0, auto: true, compact: true },
|
|
156
|
+
]);
|
|
157
|
+
const breaks = (report: string) =>
|
|
158
|
+
(
|
|
159
|
+
resolveStoryPlacements(report, resolver({ 0: target(0, "a") }))
|
|
160
|
+
.segments[0] as { markdown: string }
|
|
161
|
+
).markdown;
|
|
162
|
+
expect(breaks("Says [[radar:evidence=0]] \nnext")).toBe("Says \nnext");
|
|
163
|
+
expect(breaks("Says \n[[radar:evidence=0]] next")).toBe("Says \nnext");
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("keeps the agent's own-line placement when a twin item on the same card was mentioned inline first", () => {
|
|
167
|
+
const story = resolveStoryPlacements(
|
|
168
|
+
"Inline [[radar:evidence=1]] first.\n\nLater:\n\n[[radar:evidence=0]]",
|
|
169
|
+
resolver({ 0: target(0, "a"), 1: target(1, "a") }),
|
|
170
|
+
);
|
|
171
|
+
expect(story.segments.map((segment) => segment.kind)).toEqual([
|
|
172
|
+
"prose",
|
|
173
|
+
"prose",
|
|
174
|
+
"placement",
|
|
175
|
+
]);
|
|
176
|
+
expect(story.byIndex.get(1)?.kind).toBe("reference");
|
|
177
|
+
expect(story.placedAt.get(1)).toBe(2);
|
|
178
|
+
expect(story.placedCount).toBe(1);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
it("points a chip past the placement cap down, to Captured results", () => {
|
|
182
|
+
const table: Record<number, StoryPlacementTarget | StoryPlacementLoss> = {};
|
|
183
|
+
for (let i = 0; i < 8; i += 1) table[i] = target(i, `o${i}`);
|
|
184
|
+
const markers = Array.from(
|
|
185
|
+
{ length: 6 },
|
|
186
|
+
(_, i) => `[[radar:evidence=${i}]]`,
|
|
187
|
+
).join("\n\n");
|
|
188
|
+
const html = renderToStaticMarkup(
|
|
189
|
+
<AnalysisStory
|
|
190
|
+
report={`${markers}\n\nSee [[radar:evidence=7]] here.`}
|
|
191
|
+
resolveItem={resolver(table)}
|
|
192
|
+
renderPlacement={() => <div data-card>card</div>}
|
|
193
|
+
onReveal={vi.fn()}
|
|
194
|
+
openRequest={1}
|
|
195
|
+
/>,
|
|
196
|
+
);
|
|
197
|
+
expect(html.match(/data-card/g)).toHaveLength(6);
|
|
198
|
+
expect(html).toContain('data-story-ref-direction="down"');
|
|
199
|
+
|
|
200
|
+
const ownLine = renderToStaticMarkup(
|
|
201
|
+
<AnalysisStory
|
|
202
|
+
report={Array.from(
|
|
203
|
+
{ length: 7 },
|
|
204
|
+
(_, i) => `[[radar:evidence=${i}]]`,
|
|
205
|
+
).join("\n\n")}
|
|
206
|
+
resolveItem={resolver(table)}
|
|
207
|
+
renderPlacement={() => <div data-card>card</div>}
|
|
208
|
+
onReveal={vi.fn()}
|
|
209
|
+
openRequest={1}
|
|
210
|
+
/>,
|
|
211
|
+
);
|
|
212
|
+
expect(ownLine.match(/data-card/g)).toHaveLength(6);
|
|
213
|
+
expect(ownLine).toContain('data-story-ref-direction="down"');
|
|
214
|
+
expect(ownLine).not.toContain('data-story-ref-direction="up"');
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
it("caps placed cards and reports every distinct lost item once", () => {
|
|
218
|
+
const markers = Array.from(
|
|
219
|
+
{ length: 8 },
|
|
220
|
+
(_, i) => `[[radar:evidence=${i}]]`,
|
|
221
|
+
).join("\n\n");
|
|
222
|
+
const table: Record<number, StoryPlacementTarget | StoryPlacementLoss> = {};
|
|
223
|
+
for (let i = 0; i < 8; i += 1) table[i] = target(i, `o${i}`);
|
|
224
|
+
const story = resolveStoryPlacements(markers, resolver(table));
|
|
225
|
+
expect(story.placedCount).toBe(6);
|
|
226
|
+
expect(story.byIndex.get(7)?.kind).toBe("reference");
|
|
227
|
+
|
|
228
|
+
const lost = resolveStoryPlacements(
|
|
229
|
+
"[[radar:evidence=3]]\n\nx [[radar:evidence=3]] [[radar:evidence=4]]",
|
|
230
|
+
resolver({ 3: "unlinked", 4: "unplaced" }),
|
|
231
|
+
);
|
|
232
|
+
expect(lost.lostItems).toBe(2);
|
|
233
|
+
expect(lost.byIndex.get(3)).toEqual({ kind: "lost", reason: "unlinked" });
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
describe("AnalysisStory", () => {
|
|
238
|
+
const render = (report: string, open = false) =>
|
|
239
|
+
renderToStaticMarkup(
|
|
240
|
+
<AnalysisStory
|
|
241
|
+
report={report}
|
|
242
|
+
resolveItem={resolver({
|
|
243
|
+
0: target(0, "crash"),
|
|
244
|
+
1: target(1, "chart"),
|
|
245
|
+
2: "unlinked",
|
|
246
|
+
})}
|
|
247
|
+
renderPlacement={(t, { compact }) => (
|
|
248
|
+
<div data-placed={t.domId} data-compact={compact ? "1" : "0"}>
|
|
249
|
+
{t.item.observation?.title}
|
|
250
|
+
</div>
|
|
251
|
+
)}
|
|
252
|
+
onReveal={vi.fn()}
|
|
253
|
+
openRequest={open ? 1 : 0}
|
|
254
|
+
/>,
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
it("previews the paragraph before the first placed card plus that card, compact, and nothing after", () => {
|
|
258
|
+
const html = render(
|
|
259
|
+
"Intro paragraph.\n\nThe container dies on start.\n\n[[radar:evidence=0]]\n\nThen a second thought.\n\n[[radar:evidence=1]]",
|
|
260
|
+
);
|
|
261
|
+
expect(html).toContain("The container dies on start.");
|
|
262
|
+
expect(html).toContain('data-placed="story-group-crash"');
|
|
263
|
+
expect(html).toContain('data-compact="1"');
|
|
264
|
+
expect(html).not.toContain("Intro paragraph.");
|
|
265
|
+
// The paragraph behind the fold shows only as the faded, aria-hidden teaser.
|
|
266
|
+
expect(html).toContain("data-story-teaser");
|
|
267
|
+
expect(html.split("Then a second thought.").length).toBe(2);
|
|
268
|
+
expect(html).not.toContain("story-group-chart");
|
|
269
|
+
expect(html).toContain("Expand");
|
|
270
|
+
expect(html).toContain('data-story-open="false"');
|
|
271
|
+
});
|
|
272
|
+
|
|
273
|
+
it("opens to the whole story with full cards, reference chips and visible lost support", () => {
|
|
274
|
+
const html = render(
|
|
275
|
+
"Intro.\n\n[[radar:evidence=0]]\n\nSee [[radar:evidence=0]] and [[radar:evidence=2]].",
|
|
276
|
+
true,
|
|
277
|
+
);
|
|
278
|
+
expect(html).toContain("Intro.");
|
|
279
|
+
expect(html).toContain('data-compact="0"');
|
|
280
|
+
expect(html).toContain("Show Card crash");
|
|
281
|
+
expect(html).toContain('data-story-lost-support="unlinked"');
|
|
282
|
+
expect(html).toContain("1 cited result could not be shown here.");
|
|
283
|
+
expect(html).toContain("Collapse");
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
it("keeps trailing content behind the fold and folds for it alone", () => {
|
|
287
|
+
const collapsed = render("One paragraph only.");
|
|
288
|
+
expect(collapsed).not.toContain("Expand");
|
|
289
|
+
const withTrailing = renderToStaticMarkup(
|
|
290
|
+
<AnalysisStory
|
|
291
|
+
report="One paragraph only."
|
|
292
|
+
resolveItem={resolver({})}
|
|
293
|
+
renderPlacement={() => null}
|
|
294
|
+
onReveal={vi.fn()}
|
|
295
|
+
trailing={<p data-trailing>Also checked: nothing else.</p>}
|
|
296
|
+
/>,
|
|
297
|
+
);
|
|
298
|
+
expect(withTrailing).toContain("Expand");
|
|
299
|
+
expect(withTrailing).not.toContain("data-trailing");
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
it("does not offer a fold when everything already fits the preview", () => {
|
|
303
|
+
const html = render("One paragraph only.");
|
|
304
|
+
expect(html).toContain("One paragraph only.");
|
|
305
|
+
expect(html).not.toContain("Expand");
|
|
306
|
+
expect(html).toContain('data-story-open="true"');
|
|
307
|
+
});
|
|
308
|
+
});
|