@skyhook-io/radar-app 1.18.1 → 1.19.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/package.json +4 -4
- package/src/App.tsx +23 -9
- package/src/api/client.deleteResource.test.tsx +111 -0
- package/src/api/client.resourceAudit.test.tsx +57 -0
- package/src/api/client.resourcePath.test.ts +107 -0
- package/src/api/client.ts +136 -37
- package/src/api/diagnose.test.ts +33 -2
- package/src/api/diagnose.ts +93 -3
- package/src/api/radarFeatures.ts +1 -0
- package/src/components/capacity/CapacityDemand.tsx +6 -3
- package/src/components/capacity/CapacityOverview.tsx +14 -7
- package/src/components/capacity/CapacityPoolDetail.tsx +7 -5
- package/src/components/capacity/ClusterSchedulingCard.tsx +3 -3
- package/src/components/capacity/shared.tsx +9 -5
- package/src/components/cnpg/CNPGOverview.tsx +4 -1
- package/src/components/cnpg/actions/useCNPGWriteGuard.tsx +1 -0
- package/src/components/diagnose/AIMarkdown.tsx +1 -1
- package/src/components/diagnose/ActivityTurn.tsx +34 -14
- package/src/components/diagnose/AgentControls.tsx +53 -6
- package/src/components/diagnose/AgentSetupNotice.tsx +1 -1
- 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/ApplyDialog.test.tsx +10 -0
- package/src/components/diagnose/ApplyDialog.tsx +8 -1
- package/src/components/diagnose/AssessmentCard.tsx +99 -8
- 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 +205 -9
- package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +98 -21
- package/src/components/diagnose/EvidenceCard.tsx +67 -14
- package/src/components/diagnose/Home.test.tsx +182 -5
- package/src/components/diagnose/Home.tsx +168 -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 +119 -2
- package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +11 -6
- package/src/components/diagnose/InvestigationView.tsx +203 -42
- package/src/components/diagnose/LocalDiagnoseAction.tsx +23 -16
- package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
- package/src/components/diagnose/QuestionComposer.tsx +487 -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 +16 -0
- package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
- package/src/components/diagnose/investigationCase.ts +33 -1
- package/src/components/diagnose/investigationEvidence/adapters/changes.ts +36 -1
- package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
- package/src/components/diagnose/investigationEvidence/adapters/crossplane.test.tsx +85 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -0
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +1 -0
- package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +42 -1
- package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +29 -2
- package/src/components/diagnose/investigationEvidence/adapters/testdata/crossplane-paused-get-resource.json +28 -0
- package/src/components/diagnose/investigationEvidence/bodies/index.tsx +2 -0
- 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/bodies/workload.tsx +5 -1
- package/src/components/diagnose/investigationEvidence/builder.ts +3 -1
- package/src/components/diagnose/investigationEvidence/cardParts.tsx +7 -2
- package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
- package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- 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 +7 -3
- package/src/components/diagnose/investigationEvidence/projection.test.ts +57 -3
- package/src/components/diagnose/investigationEvidence/types.ts +2 -0
- package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
- package/src/components/diagnose/investigationEvidencePresentation.test.ts +36 -2
- package/src/components/diagnose/investigationEvidencePresentation.ts +33 -8
- package/src/components/diagnose/investigationFocus.test.ts +271 -0
- package/src/components/diagnose/investigationFocus.ts +132 -0
- 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 +66 -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/verdictText.test.tsx +87 -0
- package/src/components/diagnose/verdictText.ts +68 -0
- package/src/components/helm/ChartBrowser.tsx +4 -4
- package/src/components/helm/HelmReleaseDrawer.tsx +6 -2
- package/src/components/helm/HelmView.tsx +34 -23
- package/src/components/helm/InstallWizard.tsx +6 -2
- package/src/components/helm/ValuesViewer.test.tsx +1 -0
- package/src/components/helm/ValuesViewer.tsx +4 -2
- package/src/components/home/ClusterHealthCard.tsx +40 -59
- package/src/components/home/HomeAgentBlock.test.tsx +113 -0
- package/src/components/home/HomeAgentBlock.tsx +94 -0
- package/src/components/home/HomeView.tsx +5 -6
- package/src/components/home/MCPSetupDialog.test.tsx +27 -2
- package/src/components/home/MCPSetupDialog.tsx +14 -2
- package/src/components/home/RadarVersionLine.test.tsx +0 -14
- package/src/components/home/RadarVersionLine.tsx +3 -28
- package/src/components/home/mcpToolCatalog.ts +29 -2
- package/src/components/issues/IssuesPane.render.test.tsx +5 -5
- package/src/components/nav/PrimaryNavRail.tsx +34 -2
- package/src/components/product-hunt/ProductHuntNotice.render.test.tsx +120 -0
- package/src/components/product-hunt/ProductHuntNotice.test.ts +121 -0
- package/src/components/product-hunt/ProductHuntNotice.tsx +202 -0
- package/src/components/product-hunt/launchWindow.ts +78 -0
- package/src/components/product-hunt/useProductHuntRailEntry.test.tsx +76 -0
- package/src/components/product-hunt/useProductHuntRailEntry.ts +27 -0
- package/src/components/resources/CompositeRenderer.tsx +4 -0
- package/src/components/resources/ResourcesView.tsx +1 -1
- package/src/components/settings/LocalConnectionSettings.tsx +1 -0
- 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 +19 -0
- package/src/components/ui/RadarOmnibar.tsx +12 -0
- package/src/components/ui/SearchSyntaxHelp.test.tsx +39 -0
- package/src/components/ui/SearchSyntaxHelp.tsx +23 -2
- package/src/components/ui/UpdateNotification.test.tsx +2 -0
- package/src/components/ui/UpdateNotification.tsx +32 -5
- package/src/components/usage-data/UsageDataPrompt.tsx +19 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +3 -3
- package/src/components/whats-new/releaseNotes.ts +60 -1
- package/src/components/workload/WorkloadView.tsx +10 -4
- package/src/components/workspace/layout.tsx +2 -1
- package/src/contexts/CapabilitiesContext.tsx +1 -0
- 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/useGitOpsWriteGuard.test.tsx +126 -2
- package/src/hooks/useGitOpsWriteGuard.ts +25 -3
- package/src/hooks/useResolvedGitOpsOwner.ts +14 -9
- package/src/index.css +85 -0
|
@@ -36,9 +36,11 @@ import {
|
|
|
36
36
|
agentLabelFor,
|
|
37
37
|
openDiagnoseSettings,
|
|
38
38
|
type DiagnoseView,
|
|
39
|
+
type Target,
|
|
39
40
|
} from "./DiagnoseContext";
|
|
40
41
|
import { useDiagnoseCustomization } from "../../context/DiagnoseCustomization";
|
|
41
42
|
import { InvestigationRefusalAction } from "./InvestigationRefusalAction";
|
|
43
|
+
import { InvestigationCapacityRecovery } from "./InvestigationCapacityNotice";
|
|
42
44
|
import { useNavCustomization } from "../../context/NavCustomization";
|
|
43
45
|
import { InvestigationView } from "./InvestigationView";
|
|
44
46
|
import type { InvestigationTimelineScope } from "./InvestigationEvidencePane";
|
|
@@ -49,13 +51,25 @@ import {
|
|
|
49
51
|
statusWord,
|
|
50
52
|
} from "./Home";
|
|
51
53
|
import { AgentSetupNotice } from "./AgentSetupNotice";
|
|
54
|
+
import { AgentSigninNotice } from "./AgentSigninNotice";
|
|
55
|
+
import {
|
|
56
|
+
useAgentSignin,
|
|
57
|
+
useApproveAfterSignin,
|
|
58
|
+
} from "../../hooks/useAgentSignin";
|
|
52
59
|
import { ConsentCard } from "./parts";
|
|
60
|
+
import type { ConsentSubject } from "./AgentControls";
|
|
53
61
|
import { buildLaunchCommand, launchAgentLabel, openInTerminal } from "./launch";
|
|
54
62
|
import { type RunSummary, type ExecutionProfile } from "../../api/diagnose";
|
|
55
63
|
import { mcpEndpointUrl } from "../../api/config";
|
|
56
64
|
import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
|
|
57
65
|
import { useContexts } from "../../api/client";
|
|
58
|
-
import {
|
|
66
|
+
import {
|
|
67
|
+
formatInvestigationTarget,
|
|
68
|
+
formatInvestigationTitle,
|
|
69
|
+
formatQuestionScope,
|
|
70
|
+
isQuestionOnly,
|
|
71
|
+
rerunOpening,
|
|
72
|
+
} from "./target";
|
|
59
73
|
import type { DiagnosisResourceRef } from "./diagnoseEvidenceTypes";
|
|
60
74
|
|
|
61
75
|
function capWord(s: string): string {
|
|
@@ -194,7 +208,7 @@ function InvestigationMenu({ run }: { run: RunSummary }) {
|
|
|
194
208
|
// Every clause is a failure this button actually had:
|
|
195
209
|
//
|
|
196
210
|
// view Home is the fresh-entry surface, never a re-run action.
|
|
197
|
-
// run nothing to take a resource from.
|
|
211
|
+
// run nothing to take a resource or question from.
|
|
198
212
|
// running/stopping human starts reuse the live run. Automatic investigations
|
|
199
213
|
// are immutable, so they retain a separate fresh human start.
|
|
200
214
|
// stale the original session is closed after a cluster switch;
|
|
@@ -209,8 +223,7 @@ export function canRerunInvestigation(
|
|
|
209
223
|
return (
|
|
210
224
|
view === "investigation" &&
|
|
211
225
|
!!run &&
|
|
212
|
-
!!run.kind &&
|
|
213
|
-
!!run.name &&
|
|
226
|
+
((!!run.kind && !!run.name) || isQuestionOnly(run)) &&
|
|
214
227
|
((run.status !== "running" && run.status !== "stopping") ||
|
|
215
228
|
run.trigger === "background") &&
|
|
216
229
|
run.status !== "stale" &&
|
|
@@ -232,6 +245,25 @@ export const MAXIMIZED_RUN_META_VISIBILITY_CLASS =
|
|
|
232
245
|
export const DIAGNOSE_SURFACE_FRAME_CLASS =
|
|
233
246
|
"@container/diagnose-surface absolute z-40 flex min-h-0 flex-col overflow-hidden border-l border-theme-border bg-theme-surface shadow-drawer";
|
|
234
247
|
|
|
248
|
+
// The consent card names what it is about to investigate, so approving it is
|
|
249
|
+
// approving that run.
|
|
250
|
+
export function consentSubject(
|
|
251
|
+
target: Target | null,
|
|
252
|
+
): ConsentSubject | undefined {
|
|
253
|
+
if (!target) return undefined;
|
|
254
|
+
if (isQuestionOnly(target)) {
|
|
255
|
+
return {
|
|
256
|
+
title: `“${formatInvestigationTitle(target)}”`,
|
|
257
|
+
detail: formatQuestionScope(target),
|
|
258
|
+
question: true,
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
return {
|
|
262
|
+
title: formatInvestigationTarget(target),
|
|
263
|
+
detail: target.question ? `Asked: ${target.question}` : undefined,
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
|
|
235
267
|
export function unavailableInvestigationMessage(embedded: boolean): string {
|
|
236
268
|
return embedded
|
|
237
269
|
? "This investigation is unavailable. It may be private, your access may have changed, or its history may have been cleared. Check your account and organization, or ask the creator for access."
|
|
@@ -381,6 +413,28 @@ export function DiagnoseSurface({
|
|
|
381
413
|
onBrowseIssues?: () => void;
|
|
382
414
|
}) {
|
|
383
415
|
const d = useDiagnose();
|
|
416
|
+
// A hosted agent runs on the host's backend, where a local CLI's sign-in
|
|
417
|
+
// says nothing.
|
|
418
|
+
const signin = useAgentSignin(
|
|
419
|
+
d.selectedAgent,
|
|
420
|
+
d.profile,
|
|
421
|
+
d.needsConsent && !d.hosted,
|
|
422
|
+
);
|
|
423
|
+
const consentActions = useApproveAfterSignin({
|
|
424
|
+
approve: d.approveConsent,
|
|
425
|
+
cancel: d.cancelConsent,
|
|
426
|
+
signin,
|
|
427
|
+
attemptKey: `${d.selectedAgent}\u0000${d.profile}\u0000${d.needsConsent}`,
|
|
428
|
+
});
|
|
429
|
+
const signinNotice =
|
|
430
|
+
signin.status?.state === "signed-out" && signin.status.signinCmd ? (
|
|
431
|
+
<AgentSigninNotice
|
|
432
|
+
agentName={d.agentLabel}
|
|
433
|
+
signinCmd={signin.status.signinCmd}
|
|
434
|
+
rechecking={signin.rechecking}
|
|
435
|
+
onRecheck={signin.recheck}
|
|
436
|
+
/>
|
|
437
|
+
) : null;
|
|
384
438
|
const { data: contexts } = useContexts();
|
|
385
439
|
const currentContext = contexts?.find((context) => context.isCurrent)?.name;
|
|
386
440
|
const [historyCollapsed, setHistoryCollapsed] = useState(false);
|
|
@@ -466,6 +520,10 @@ export function DiagnoseSurface({
|
|
|
466
520
|
setMaximized,
|
|
467
521
|
],
|
|
468
522
|
);
|
|
523
|
+
const revealDestination = useCallback(
|
|
524
|
+
() => revealInvestigationDestination(setMaximized, d.dismissForNavigation, narrow),
|
|
525
|
+
[d.dismissForNavigation, narrow, setMaximized],
|
|
526
|
+
);
|
|
469
527
|
const openEvidenceTimeline = useCallback(
|
|
470
528
|
(scope: InvestigationTimelineScope) => {
|
|
471
529
|
if (!onOpenTimeline) return;
|
|
@@ -510,7 +568,8 @@ export function DiagnoseSurface({
|
|
|
510
568
|
const activeRun = d.runs.find((r) => r.id === d.activeRunId) ?? null;
|
|
511
569
|
// Consent replaces the detail pane even if goHome retained an older run id.
|
|
512
570
|
// Header identity and actions must describe what is actually visible.
|
|
513
|
-
const visibleRunDetail =
|
|
571
|
+
const visibleRunDetail =
|
|
572
|
+
d.needsConsent || d.startCapacity ? null : activeRun;
|
|
514
573
|
// A focused run shows the agent it actually ran with; Home reflects the current pick.
|
|
515
574
|
const activeAgentLabel = visibleRunDetail?.agent
|
|
516
575
|
? agentLabelFor(visibleRunDetail.agent)
|
|
@@ -526,7 +585,7 @@ export function DiagnoseSurface({
|
|
|
526
585
|
visibleRunDetail ?? defaultHeaderConfig,
|
|
527
586
|
);
|
|
528
587
|
const focusedTitle = visibleRunDetail
|
|
529
|
-
?
|
|
588
|
+
? formatInvestigationTitle(visibleRunDetail)
|
|
530
589
|
: "AI investigations";
|
|
531
590
|
const headerPresentation = investigationHeaderPresentation({
|
|
532
591
|
view: d.view,
|
|
@@ -563,13 +622,20 @@ export function DiagnoseSurface({
|
|
|
563
622
|
agent={d.selectedAgent}
|
|
564
623
|
profile={d.profile}
|
|
565
624
|
copy={consentCopy}
|
|
625
|
+
subject={consentSubject(d.pendingTarget)}
|
|
566
626
|
onOpenSettings={openSettings ?? undefined}
|
|
567
627
|
error={d.consentError}
|
|
568
|
-
|
|
569
|
-
|
|
628
|
+
notice={signinNotice}
|
|
629
|
+
approveBusy={consentActions.waiting}
|
|
630
|
+
onApprove={consentActions.approve}
|
|
631
|
+
onCancel={consentActions.cancel}
|
|
570
632
|
/>
|
|
571
633
|
</div>
|
|
572
634
|
</div>
|
|
635
|
+
) : d.startCapacity ? (
|
|
636
|
+
// Before the focused run: the start the user just asked for is what this
|
|
637
|
+
// pane is about, and a focused run's view would bury the way out.
|
|
638
|
+
<InvestigationCapacityRecovery capacity={d.startCapacity} />
|
|
573
639
|
) : activeRun ? (
|
|
574
640
|
<InvestigationView
|
|
575
641
|
key={activeRun.id}
|
|
@@ -578,6 +644,7 @@ export function DiagnoseSurface({
|
|
|
578
644
|
maximized={maximized}
|
|
579
645
|
onOpenResource={onOpenResource ? openEvidenceResource : undefined}
|
|
580
646
|
onOpenTimeline={onOpenTimeline ? openEvidenceTimeline : undefined}
|
|
647
|
+
onRevealDestination={revealDestination}
|
|
581
648
|
/>
|
|
582
649
|
) : d.activeRunId && !d.runsLoaded ? (
|
|
583
650
|
// Deep-linked to a run before the list has ever loaded: show the load
|
|
@@ -608,6 +675,14 @@ export function DiagnoseSurface({
|
|
|
608
675
|
<p className="text-sm text-theme-text-secondary">{d.startError}</p>
|
|
609
676
|
<div className="flex flex-wrap items-center justify-center gap-2">
|
|
610
677
|
<InvestigationRefusalAction refusal={d.startRefusal} />
|
|
678
|
+
{d.questionDraft?.text && (
|
|
679
|
+
<button
|
|
680
|
+
onClick={d.openHome}
|
|
681
|
+
className="rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover"
|
|
682
|
+
>
|
|
683
|
+
Back to your question
|
|
684
|
+
</button>
|
|
685
|
+
)}
|
|
611
686
|
<button
|
|
612
687
|
onClick={d.dismissError}
|
|
613
688
|
className="rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover"
|
|
@@ -638,10 +713,13 @@ export function DiagnoseSurface({
|
|
|
638
713
|
agent={d.selectedAgent}
|
|
639
714
|
profile={d.profile}
|
|
640
715
|
copy={consentCopy}
|
|
716
|
+
subject={consentSubject(d.pendingTarget)}
|
|
641
717
|
onOpenSettings={openSettings ?? undefined}
|
|
642
718
|
error={d.consentError}
|
|
643
|
-
|
|
644
|
-
|
|
719
|
+
notice={signinNotice}
|
|
720
|
+
approveBusy={consentActions.waiting}
|
|
721
|
+
onApprove={consentActions.approve}
|
|
722
|
+
onCancel={consentActions.cancel}
|
|
645
723
|
/>
|
|
646
724
|
</div>
|
|
647
725
|
) : setupPending ? (
|
|
@@ -657,8 +735,11 @@ export function DiagnoseSurface({
|
|
|
657
735
|
) : (
|
|
658
736
|
<InvestigationHome
|
|
659
737
|
agentLabel={d.agentLabel}
|
|
738
|
+
questions={d.questions}
|
|
660
739
|
onBrowseIssues={
|
|
661
|
-
d.runsLoaded && d.runs.length === 0
|
|
740
|
+
d.questions || (d.runsLoaded && d.runs.length === 0)
|
|
741
|
+
? onBrowseIssues
|
|
742
|
+
: undefined
|
|
662
743
|
}
|
|
663
744
|
/>
|
|
664
745
|
);
|
|
@@ -765,22 +846,14 @@ export function DiagnoseSurface({
|
|
|
765
846
|
</div>
|
|
766
847
|
<div className="flex shrink-0 items-center gap-1">
|
|
767
848
|
{activeRun &&
|
|
849
|
+
visibleRunDetail &&
|
|
768
850
|
canRerunInvestigation(d.view, activeRun, d.needsConsent) && (
|
|
769
851
|
<Tooltip
|
|
770
852
|
content="Re-run this investigation from scratch"
|
|
771
853
|
position="bottom"
|
|
772
854
|
>
|
|
773
855
|
<button
|
|
774
|
-
onClick={() =>
|
|
775
|
-
d.openInvestigation({
|
|
776
|
-
kind: activeRun.kind,
|
|
777
|
-
group: activeRun.group,
|
|
778
|
-
namespace: activeRun.namespace,
|
|
779
|
-
name: activeRun.name,
|
|
780
|
-
issueId: activeRun.issueId,
|
|
781
|
-
fresh: true,
|
|
782
|
-
})
|
|
783
|
-
}
|
|
856
|
+
onClick={() => d.openInvestigation(rerunOpening(activeRun))}
|
|
784
857
|
className="rounded-md p-1 text-theme-text-tertiary hover:bg-theme-hover hover:text-theme-text-primary"
|
|
785
858
|
aria-label="Re-run this investigation from scratch"
|
|
786
859
|
>
|
|
@@ -869,6 +942,10 @@ export function DiagnoseSurface({
|
|
|
869
942
|
if (historyOverlay) dismissHistory();
|
|
870
943
|
}}
|
|
871
944
|
historyDegraded={d.historyDegraded}
|
|
945
|
+
loaded={d.runsLoaded}
|
|
946
|
+
loadFailed={d.runsLoadFailed}
|
|
947
|
+
onRetry={d.refreshRuns}
|
|
948
|
+
questions={d.questions}
|
|
872
949
|
/>
|
|
873
950
|
</aside>
|
|
874
951
|
)}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StoryExcerpt } from "./StoryExcerpt";
|
|
2
2
|
import { storyExcerpt } from "./investigationEvidence/excerpt";
|
|
3
|
+
import { metricsReading } from "./investigationEvidence/bodies/metrics";
|
|
3
4
|
import {
|
|
4
5
|
type InvestigationCaseItem,
|
|
5
6
|
investigationCaseObservationKey,
|
|
@@ -61,6 +62,7 @@ export function EvidenceCard({
|
|
|
61
62
|
spanFullRow = false,
|
|
62
63
|
prominence = "primary",
|
|
63
64
|
compact = false,
|
|
65
|
+
storyPreview = false,
|
|
64
66
|
placedInStory = false,
|
|
65
67
|
gapRoles,
|
|
66
68
|
noteMode = "full",
|
|
@@ -87,6 +89,11 @@ export function EvidenceCard({
|
|
|
87
89
|
* card. A story log card keeps its cited lines: they are the card.
|
|
88
90
|
*/
|
|
89
91
|
compact?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* The card sits in the story's collapsed preview, which bounds its height;
|
|
94
|
+
* a compact card outside it still shows a placed chart.
|
|
95
|
+
*/
|
|
96
|
+
storyPreview?: boolean;
|
|
90
97
|
/** This card also appears inside the story above. */
|
|
91
98
|
placedInStory?: boolean;
|
|
92
99
|
/** Roles whose "does not cover" line is shown; undefined shows every gap. */
|
|
@@ -109,6 +116,7 @@ export function EvidenceCard({
|
|
|
109
116
|
metricsMarkersBySource,
|
|
110
117
|
caseByGroup,
|
|
111
118
|
excludedByItem,
|
|
119
|
+
storyReveal,
|
|
112
120
|
} = useContext(EvidenceNavigationContext);
|
|
113
121
|
const open = expandedGroupIds?.has(group.id) ?? false;
|
|
114
122
|
const setOpen = useCallback(
|
|
@@ -176,6 +184,7 @@ export function EvidenceCard({
|
|
|
176
184
|
evidenceDisplaySnapshot(citedObservation) !==
|
|
177
185
|
evidenceDisplaySnapshot(observation);
|
|
178
186
|
const bodyId = `${domId}-body`;
|
|
187
|
+
const chartId = `${domId}-chart`;
|
|
179
188
|
const hasEvidenceDetails = evidenceHasDetails(
|
|
180
189
|
observation.data,
|
|
181
190
|
observation.summary,
|
|
@@ -183,6 +192,7 @@ export function EvidenceCard({
|
|
|
183
192
|
const excerpt = storyCard
|
|
184
193
|
? storyExcerpt(observation, cardItems, {
|
|
185
194
|
compact,
|
|
195
|
+
preview: storyPreview,
|
|
186
196
|
scopeNamespace: listingScopeNamespace(observation.source),
|
|
187
197
|
})
|
|
188
198
|
: undefined;
|
|
@@ -201,7 +211,37 @@ export function EvidenceCard({
|
|
|
201
211
|
const storyLogRest = excerpt?.kind === "lines" ? excerpt.rest : [];
|
|
202
212
|
const hasExpandableBody =
|
|
203
213
|
(hasEvidenceDetails && !inlineLogs && !inlineMetrics) || meaningfulHistory;
|
|
204
|
-
const
|
|
214
|
+
const bodyExpandable =
|
|
215
|
+
!compact && (hasExpandableBody || storyLogRest.length > 0);
|
|
216
|
+
// A placed chart folds behind the card's chevron, compact or not, starting
|
|
217
|
+
// as the excerpt says until the reader toggles it. Its fold is the card's
|
|
218
|
+
// own: the body behind it (earlier reads) opens and closes with the chart,
|
|
219
|
+
// and the same result's card under Captured results keeps its own state.
|
|
220
|
+
// Keyed by the result so a different chart in this slot starts as its own
|
|
221
|
+
// excerpt says rather than as the reader left the last one.
|
|
222
|
+
const [chartChoice, setChartChoice] = useState<{
|
|
223
|
+
sourceId: string;
|
|
224
|
+
open: boolean;
|
|
225
|
+
}>();
|
|
226
|
+
const chooseChart = (open: boolean) =>
|
|
227
|
+
setChartChoice({ sourceId: observation.source.id, open });
|
|
228
|
+
const chartOpen =
|
|
229
|
+
excerpt?.kind === "chart"
|
|
230
|
+
? chartChoice?.sourceId === observation.source.id
|
|
231
|
+
? chartChoice.open
|
|
232
|
+
: !excerpt.folded
|
|
233
|
+
: false;
|
|
234
|
+
const canExpand = inlineMetrics || bodyExpandable;
|
|
235
|
+
const expanded = inlineMetrics ? chartOpen : open;
|
|
236
|
+
const chartReading =
|
|
237
|
+
inlineMetrics && !chartOpen && observation.data.type === "metrics"
|
|
238
|
+
? metricsReading(observation.data)
|
|
239
|
+
: undefined;
|
|
240
|
+
const toggle = (opening: boolean) => {
|
|
241
|
+
if (inlineMetrics) chooseChart(opening);
|
|
242
|
+
else setOpen(opening);
|
|
243
|
+
revealAfterToggle(opening);
|
|
244
|
+
};
|
|
205
245
|
const revealHistory = investigationEvidenceShouldRevealHistory(
|
|
206
246
|
group,
|
|
207
247
|
revealSourceId,
|
|
@@ -216,9 +256,17 @@ export function EvidenceCard({
|
|
|
216
256
|
if (
|
|
217
257
|
revealHistory ||
|
|
218
258
|
(destination && elementRef.current?.contains(destination))
|
|
219
|
-
)
|
|
259
|
+
) {
|
|
220
260
|
setOpen(true);
|
|
261
|
+
chooseChart(true);
|
|
262
|
+
}
|
|
263
|
+
// chooseChart is rebuilt per render from the observation on screen.
|
|
264
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
221
265
|
}, [revealHistory, revealSourceId, revealRequestId, elementRef, setOpen]);
|
|
266
|
+
useLayoutEffect(() => {
|
|
267
|
+
if (storyReveal?.domId === domId) chooseChart(true);
|
|
268
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
269
|
+
}, [storyReveal?.requestId]);
|
|
222
270
|
const wide = spanFullRow || evidenceTypePrefersFullRow(observation.data.type);
|
|
223
271
|
const resourceRef = investigationEvidenceSubjectRef(observation.data);
|
|
224
272
|
const resourceIdentity = resourceRef
|
|
@@ -268,13 +316,21 @@ export function EvidenceCard({
|
|
|
268
316
|
<span
|
|
269
317
|
className={clsx(
|
|
270
318
|
"mt-0.5 block text-xs leading-relaxed text-theme-text-secondary",
|
|
271
|
-
!
|
|
319
|
+
!expanded && !inlineSecretKeys && "line-clamp-2",
|
|
272
320
|
"[overflow-wrap:anywhere]",
|
|
273
321
|
)}
|
|
274
322
|
>
|
|
275
323
|
{displaySummary}
|
|
276
324
|
</span>
|
|
277
325
|
) : null}
|
|
326
|
+
{chartReading ? (
|
|
327
|
+
<span
|
|
328
|
+
data-chart-reading
|
|
329
|
+
className="mt-0.5 block font-mono text-xs tabular-nums text-theme-text-secondary"
|
|
330
|
+
>
|
|
331
|
+
{chartReading}
|
|
332
|
+
</span>
|
|
333
|
+
) : null}
|
|
278
334
|
{supersededRead ? (
|
|
279
335
|
<span className="mt-0.5 block text-xs text-theme-text-tertiary">
|
|
280
336
|
Captured in turn {observation.source.turnIndex + 1} · a newer read
|
|
@@ -299,7 +355,7 @@ export function EvidenceCard({
|
|
|
299
355
|
) : null}
|
|
300
356
|
</span>
|
|
301
357
|
{canExpand ? (
|
|
302
|
-
<CollapseChevron open={
|
|
358
|
+
<CollapseChevron open={expanded} className="h-4 w-4 self-center" />
|
|
303
359
|
) : null}
|
|
304
360
|
</>
|
|
305
361
|
);
|
|
@@ -338,13 +394,9 @@ export function EvidenceCard({
|
|
|
338
394
|
{canExpand ? (
|
|
339
395
|
<button
|
|
340
396
|
type="button"
|
|
341
|
-
aria-expanded={
|
|
342
|
-
aria-controls={bodyId}
|
|
343
|
-
onClick={() =>
|
|
344
|
-
const opening = !open;
|
|
345
|
-
setOpen(opening);
|
|
346
|
-
revealAfterToggle(opening);
|
|
347
|
-
}}
|
|
397
|
+
aria-expanded={expanded}
|
|
398
|
+
aria-controls={inlineMetrics ? chartId : bodyId}
|
|
399
|
+
onClick={() => toggle(!expanded)}
|
|
348
400
|
className={clsx(
|
|
349
401
|
"flex min-w-0 flex-1 items-start text-left hover:bg-theme-hover/60",
|
|
350
402
|
prominence === "primary"
|
|
@@ -419,8 +471,9 @@ export function EvidenceCard({
|
|
|
419
471
|
excerpt={excerpt}
|
|
420
472
|
data={observation.data}
|
|
421
473
|
prominence={prominence}
|
|
422
|
-
open={
|
|
474
|
+
open={expanded}
|
|
423
475
|
canExpand={canExpand}
|
|
476
|
+
chartId={chartId}
|
|
424
477
|
changeCoverage={metricsMarkersBySource?.get(
|
|
425
478
|
observation.source.id,
|
|
426
479
|
)}
|
|
@@ -450,9 +503,9 @@ export function EvidenceCard({
|
|
|
450
503
|
))}
|
|
451
504
|
</div>
|
|
452
505
|
) : null}
|
|
453
|
-
{
|
|
506
|
+
{bodyExpandable && hasExpandableBody ? (
|
|
454
507
|
<div id={bodyId}>
|
|
455
|
-
<Collapse open={
|
|
508
|
+
<Collapse open={expanded}>
|
|
456
509
|
<div
|
|
457
510
|
className={clsx(
|
|
458
511
|
"space-y-3 border-t border-theme-border/60",
|
|
@@ -81,7 +81,7 @@ describe("RecentList", () => {
|
|
|
81
81
|
const html = render([run()]);
|
|
82
82
|
expect(html.match(/<button\b/g)).toHaveLength(1);
|
|
83
83
|
expect(html).not.toContain('title="');
|
|
84
|
-
expect(html).toContain('aria-label="Deployment
|
|
84
|
+
expect(html).toContain('aria-label="Deployment shop/checkout');
|
|
85
85
|
expect(html).toContain('aria-label="Cluster: nonprod"');
|
|
86
86
|
});
|
|
87
87
|
it("uses cluster identity instead of lifecycle locks and deterministic initial-issue text", () => {
|
|
@@ -103,7 +103,45 @@ describe("RecentList", () => {
|
|
|
103
103
|
expect(html).not.toContain("lucide-lock");
|
|
104
104
|
expect(html).not.toContain("lucide-check");
|
|
105
105
|
});
|
|
106
|
-
it("
|
|
106
|
+
it("groups older history into this week and earlier, dating each older row", () => {
|
|
107
|
+
const html = render([
|
|
108
|
+
run({ id: "today", name: "today", createdAt: time(2, 9) }),
|
|
109
|
+
run({ id: "week", name: "week", createdAt: time(1 - 3, 9) }),
|
|
110
|
+
run({
|
|
111
|
+
id: "old",
|
|
112
|
+
name: "old",
|
|
113
|
+
createdAt: new Date(2026, 6, 4, 18, 5).toISOString(),
|
|
114
|
+
}),
|
|
115
|
+
]);
|
|
116
|
+
const text = visible(html);
|
|
117
|
+
expect(
|
|
118
|
+
html.match(/<h3 [^>]*>(Today|Yesterday|Previous 7 days|Earlier)<\/h3>/g),
|
|
119
|
+
).toHaveLength(3);
|
|
120
|
+
expect(html).toContain(">Previous 7 days</h3>");
|
|
121
|
+
expect(html).toContain(">Earlier</h3>");
|
|
122
|
+
const day = (d: Date) =>
|
|
123
|
+
d.toLocaleDateString(undefined, { month: "short", day: "numeric" });
|
|
124
|
+
expect(text).toContain(`${day(new Date(2026, 6, 4))} · `);
|
|
125
|
+
expect(text).not.toContain(`${day(NOW)} · `);
|
|
126
|
+
});
|
|
127
|
+
it("shows the issue a run started with only until it has a finding", () => {
|
|
128
|
+
const html = render([
|
|
129
|
+
run({
|
|
130
|
+
id: "a",
|
|
131
|
+
name: "found",
|
|
132
|
+
health: { topReason: "ErrImagePull" },
|
|
133
|
+
preview: "A direct edit set a bad tag.",
|
|
134
|
+
}),
|
|
135
|
+
run({
|
|
136
|
+
id: "b",
|
|
137
|
+
name: "pending",
|
|
138
|
+
health: { topReason: "CrashLoopBackOff" },
|
|
139
|
+
}),
|
|
140
|
+
]);
|
|
141
|
+
expect(html).not.toContain("Started with ErrImagePull");
|
|
142
|
+
expect(html).toContain("Started with CrashLoopBackOff");
|
|
143
|
+
});
|
|
144
|
+
it("uses one stable start time per run, sorted into local date groups, with what each found", () => {
|
|
107
145
|
const recentTime = time(2, 13);
|
|
108
146
|
const olderTime = time(1, 12);
|
|
109
147
|
const html = render([
|
|
@@ -112,7 +150,8 @@ describe("RecentList", () => {
|
|
|
112
150
|
id: "recent",
|
|
113
151
|
name: "recent",
|
|
114
152
|
createdAt: recentTime,
|
|
115
|
-
preview:
|
|
153
|
+
preview:
|
|
154
|
+
"MONGO_PASSWORD **broken**, see [the runbook](https://example.com/rb) and _why_",
|
|
116
155
|
}),
|
|
117
156
|
]);
|
|
118
157
|
expect(html.match(/<time /g)).toHaveLength(2);
|
|
@@ -120,7 +159,10 @@ describe("RecentList", () => {
|
|
|
120
159
|
expect(html).toContain(`dateTime="${olderTime}"`);
|
|
121
160
|
expect(html).not.toContain(`dateTime="${time(2, 14)}"`);
|
|
122
161
|
expect(html).not.toContain("ago");
|
|
123
|
-
expect(html).
|
|
162
|
+
expect(visible(html)).toContain(
|
|
163
|
+
"MONGO_PASSWORD broken, see the runbook and why",
|
|
164
|
+
);
|
|
165
|
+
expect(html).not.toContain("**");
|
|
124
166
|
expect(html).toContain(">Today</h3>");
|
|
125
167
|
expect(html).toContain(">Yesterday</h3>");
|
|
126
168
|
expect(visible(html).indexOf("recent")).toBeLessThan(
|
|
@@ -171,7 +213,7 @@ describe("RecentList", () => {
|
|
|
171
213
|
expect(text.indexOf("checkout")).toBeLessThan(
|
|
172
214
|
text.indexOf("shop · Deployment"),
|
|
173
215
|
);
|
|
174
|
-
expect(html).toContain("Deployment
|
|
216
|
+
expect(html).toContain("Deployment shop/checkout");
|
|
175
217
|
});
|
|
176
218
|
|
|
177
219
|
it("does not change displayed time when cluster-switch bookkeeping updates runs", () => {
|
|
@@ -311,3 +353,138 @@ describe("InvestigationHome", () => {
|
|
|
311
353
|
expect(html).not.toContain("textarea");
|
|
312
354
|
});
|
|
313
355
|
});
|
|
356
|
+
|
|
357
|
+
describe("RecentList question runs", () => {
|
|
358
|
+
it("titles a question-only run by its question and shows where it started", () => {
|
|
359
|
+
const html = visible(
|
|
360
|
+
render([
|
|
361
|
+
run({
|
|
362
|
+
kind: "",
|
|
363
|
+
group: "",
|
|
364
|
+
namespace: "",
|
|
365
|
+
name: "",
|
|
366
|
+
question: "checkout returns 502s",
|
|
367
|
+
namespaces: ["shop"],
|
|
368
|
+
lookBack: "1h",
|
|
369
|
+
}),
|
|
370
|
+
]),
|
|
371
|
+
);
|
|
372
|
+
expect(html).toContain("checkout returns 502s");
|
|
373
|
+
expect(html).toContain("shop · last 1h");
|
|
374
|
+
});
|
|
375
|
+
|
|
376
|
+
it("keeps a question about a resource under the resource, with what was asked", () => {
|
|
377
|
+
const html = visible(render([run({ question: "why did it restart?" })]));
|
|
378
|
+
expect(html).toContain("checkout");
|
|
379
|
+
expect(html).toContain("Asked: why did it restart?");
|
|
380
|
+
});
|
|
381
|
+
});
|
|
382
|
+
|
|
383
|
+
describe("RecentList loading", () => {
|
|
384
|
+
const renderState = (props: { loaded: boolean; loadFailed?: boolean }) =>
|
|
385
|
+
visible(
|
|
386
|
+
renderToStaticMarkup(
|
|
387
|
+
<RecentList
|
|
388
|
+
agentLabel="Codex"
|
|
389
|
+
runs={[]}
|
|
390
|
+
onSelect={() => {}}
|
|
391
|
+
onRetry={() => {}}
|
|
392
|
+
{...props}
|
|
393
|
+
/>,
|
|
394
|
+
),
|
|
395
|
+
);
|
|
396
|
+
|
|
397
|
+
it("never claims there are no investigations before the list arrives", () => {
|
|
398
|
+
expect(renderState({ loaded: false })).not.toContain(
|
|
399
|
+
"No investigations yet",
|
|
400
|
+
);
|
|
401
|
+
expect(
|
|
402
|
+
renderToStaticMarkup(
|
|
403
|
+
<RecentList
|
|
404
|
+
agentLabel="Codex"
|
|
405
|
+
runs={[]}
|
|
406
|
+
onSelect={() => {}}
|
|
407
|
+
loaded={false}
|
|
408
|
+
/>,
|
|
409
|
+
),
|
|
410
|
+
).toContain('aria-label="Loading investigations"');
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
it("offers a retry when the first load failed", () => {
|
|
414
|
+
const text = renderState({ loaded: false, loadFailed: true });
|
|
415
|
+
expect(text).toContain("Couldn’t load investigations");
|
|
416
|
+
expect(text).toContain("Try again");
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
it("says there are none only after an empty answer", () => {
|
|
420
|
+
expect(renderState({ loaded: true })).toContain("No investigations yet");
|
|
421
|
+
});
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
describe("RecentList findings", () => {
|
|
425
|
+
it("shows what each run found under its title", () => {
|
|
426
|
+
const text = visible(
|
|
427
|
+
render([
|
|
428
|
+
run({
|
|
429
|
+
id: "a",
|
|
430
|
+
preview: "The `api` container exits on a missing **env** var",
|
|
431
|
+
}),
|
|
432
|
+
]),
|
|
433
|
+
);
|
|
434
|
+
expect(text).toContain("The api container exits on a missing env var");
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it("does not attribute a question-only run to an issue", () => {
|
|
438
|
+
const text = visible(
|
|
439
|
+
render([
|
|
440
|
+
run({
|
|
441
|
+
kind: "",
|
|
442
|
+
group: "",
|
|
443
|
+
namespace: "",
|
|
444
|
+
name: "",
|
|
445
|
+
question: "checkout is slow",
|
|
446
|
+
health: { topReason: "CrashLoopBackOff" } as RunSummary["health"],
|
|
447
|
+
}),
|
|
448
|
+
]),
|
|
449
|
+
);
|
|
450
|
+
expect(text).not.toContain("Started with");
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
|
|
454
|
+
describe("RecentList beside the question composer", () => {
|
|
455
|
+
it("does not send people to a resource to start", () => {
|
|
456
|
+
const text = visible(
|
|
457
|
+
renderToStaticMarkup(
|
|
458
|
+
<RecentList
|
|
459
|
+
agentLabel="Codex"
|
|
460
|
+
runs={[]}
|
|
461
|
+
onSelect={() => {}}
|
|
462
|
+
questions
|
|
463
|
+
/>,
|
|
464
|
+
),
|
|
465
|
+
);
|
|
466
|
+
expect(text).toContain("No investigations yet");
|
|
467
|
+
expect(text).not.toContain("Open a resource");
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
|
|
471
|
+
describe("RecentList refresh failures", () => {
|
|
472
|
+
it("says a kept list is stale when a later refresh fails", () => {
|
|
473
|
+
const text = visible(
|
|
474
|
+
renderToStaticMarkup(
|
|
475
|
+
<RecentList
|
|
476
|
+
agentLabel="Codex"
|
|
477
|
+
runs={[run()]}
|
|
478
|
+
onSelect={() => {}}
|
|
479
|
+
loaded
|
|
480
|
+
loadFailed
|
|
481
|
+
onRetry={() => {}}
|
|
482
|
+
/>,
|
|
483
|
+
),
|
|
484
|
+
);
|
|
485
|
+
expect(text).toContain(
|
|
486
|
+
"Couldn’t refresh investigations; showing the last list.",
|
|
487
|
+
);
|
|
488
|
+
expect(text).toContain("checkout");
|
|
489
|
+
});
|
|
490
|
+
});
|