@skyhook-io/radar-app 1.18.2 → 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.
Files changed (78) hide show
  1. package/package.json +4 -4
  2. package/src/App.tsx +0 -1
  3. package/src/api/diagnose.test.ts +33 -2
  4. package/src/api/diagnose.ts +93 -3
  5. package/src/api/radarFeatures.ts +1 -0
  6. package/src/components/diagnose/AIMarkdown.tsx +1 -1
  7. package/src/components/diagnose/ActivityTurn.tsx +34 -14
  8. package/src/components/diagnose/AgentControls.tsx +53 -6
  9. package/src/components/diagnose/AgentSetupNotice.tsx +1 -1
  10. package/src/components/diagnose/AgentSigninNotice.test.tsx +98 -0
  11. package/src/components/diagnose/AgentSigninNotice.tsx +61 -0
  12. package/src/components/diagnose/AnalysisStory.test.tsx +22 -0
  13. package/src/components/diagnose/AnalysisStory.tsx +17 -4
  14. package/src/components/diagnose/AssessmentCard.tsx +39 -8
  15. package/src/components/diagnose/DiagnoseContext.capacity.test.tsx +113 -0
  16. package/src/components/diagnose/DiagnoseContext.question.test.tsx +245 -0
  17. package/src/components/diagnose/DiagnoseContext.tsx +205 -9
  18. package/src/components/diagnose/DiagnoseSurface.test.tsx +54 -0
  19. package/src/components/diagnose/DiagnoseSurface.tsx +93 -21
  20. package/src/components/diagnose/EvidenceCard.tsx +67 -14
  21. package/src/components/diagnose/Home.test.tsx +182 -5
  22. package/src/components/diagnose/Home.tsx +168 -36
  23. package/src/components/diagnose/InvestigationCapacityNotice.test.tsx +246 -0
  24. package/src/components/diagnose/InvestigationCapacityNotice.tsx +241 -0
  25. package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +97 -6
  26. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +57 -0
  27. package/src/components/diagnose/InvestigationEvidencePane.tsx +59 -11
  28. package/src/components/diagnose/InvestigationEvidenceSections.tsx +5 -1
  29. package/src/components/diagnose/InvestigationView.tsx +156 -29
  30. package/src/components/diagnose/LocalDiagnoseAction.tsx +23 -16
  31. package/src/components/diagnose/QuestionComposer.test.tsx +553 -0
  32. package/src/components/diagnose/QuestionComposer.tsx +487 -0
  33. package/src/components/diagnose/QuestionFocus.test.tsx +38 -0
  34. package/src/components/diagnose/QuestionFocus.tsx +123 -0
  35. package/src/components/diagnose/ResourcePicker.tsx +206 -0
  36. package/src/components/diagnose/StoryExcerpt.tsx +12 -3
  37. package/src/components/diagnose/assessmentCopy.ts +5 -0
  38. package/src/components/diagnose/investigationCase.runs.test.tsx +328 -0
  39. package/src/components/diagnose/investigationCase.ts +33 -1
  40. package/src/components/diagnose/investigationEvidence/adapters/coverage.test.tsx +46 -0
  41. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +8 -0
  42. package/src/components/diagnose/investigationEvidence/adapters/posture.ts +29 -1
  43. package/src/components/diagnose/investigationEvidence/adapters/prometheus.test.ts +40 -0
  44. package/src/components/diagnose/investigationEvidence/adapters/prometheus.ts +27 -1
  45. package/src/components/diagnose/investigationEvidence/bodies/metrics.test.tsx +111 -0
  46. package/src/components/diagnose/investigationEvidence/bodies/metrics.tsx +67 -16
  47. package/src/components/diagnose/investigationEvidence/excerpt.test.ts +18 -5
  48. package/src/components/diagnose/investigationEvidence/excerpt.ts +22 -11
  49. package/src/components/diagnose/investigationEvidence/index.ts +1 -1
  50. package/src/components/diagnose/investigationEvidence/navigation.tsx +2 -0
  51. package/src/components/diagnose/investigationEvidence/types.ts +2 -0
  52. package/src/components/diagnose/investigationEvidencePartition.ts +6 -1
  53. package/src/components/diagnose/investigationFocus.test.ts +271 -0
  54. package/src/components/diagnose/investigationFocus.ts +132 -0
  55. package/src/components/diagnose/parts.test.tsx +20 -0
  56. package/src/components/diagnose/questionSuggestions.test.ts +111 -0
  57. package/src/components/diagnose/questionSuggestions.ts +150 -0
  58. package/src/components/diagnose/storyParts.test.tsx +13 -0
  59. package/src/components/diagnose/target.test.ts +143 -2
  60. package/src/components/diagnose/target.ts +109 -7
  61. package/src/components/diagnose/testdata/story-runs.json +474 -0
  62. package/src/components/diagnose/verdictText.test.tsx +87 -0
  63. package/src/components/diagnose/verdictText.ts +68 -0
  64. package/src/components/home/ClusterHealthCard.tsx +13 -39
  65. package/src/components/home/HomeAgentBlock.test.tsx +113 -0
  66. package/src/components/home/HomeAgentBlock.tsx +94 -0
  67. package/src/components/home/HomeView.tsx +5 -6
  68. package/src/components/home/RadarVersionLine.test.tsx +0 -14
  69. package/src/components/home/RadarVersionLine.tsx +3 -28
  70. package/src/components/ui/Omnibar.investigate.test.tsx +105 -0
  71. package/src/components/ui/Omnibar.tsx +47 -3
  72. package/src/components/ui/RadarOmnibar.test.tsx +1 -0
  73. package/src/components/ui/RadarOmnibar.tsx +11 -0
  74. package/src/components/whats-new/WhatsNewDialog.test.tsx +3 -3
  75. package/src/components/whats-new/releaseNotes.ts +60 -1
  76. package/src/hooks/useAgentSignin.test.tsx +190 -0
  77. package/src/hooks/useAgentSignin.ts +160 -0
  78. package/src/hooks/useApproveAfterSignin.test.tsx +108 -0
@@ -0,0 +1,241 @@
1
+ import { useState } from "react";
2
+ import { formatRelativeAgeTime } from "@skyhook-io/k8s-ui/utils/format";
3
+ import { stopRun, type RunSummary } from "../../api/diagnose";
4
+ import { useContexts } from "../../api/client";
5
+ import {
6
+ useDiagnose,
7
+ type StartCapacity,
8
+ type Target,
9
+ } from "./DiagnoseContext";
10
+ import { formatInvestigationTarget, formatInvestigationTitle } from "./target";
11
+
12
+ // The runs holding a slot, oldest first: the order they were started in.
13
+ export function runsHoldingSlots(runs: RunSummary[]): RunSummary[] {
14
+ return runs
15
+ .filter((r) => r.status === "running" || r.status === "stopping")
16
+ .sort(
17
+ (a, b) =>
18
+ new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime(),
19
+ );
20
+ }
21
+
22
+ // A question-only run is named by its question, as in the history.
23
+ function runLabel(run: RunSummary): string {
24
+ return run.name || run.question
25
+ ? formatInvestigationTitle(run)
26
+ : run.preview || "Investigation";
27
+ }
28
+
29
+ function targetLabel(target: Target): string {
30
+ if (target.name) return formatInvestigationTarget(target);
31
+ return target.question
32
+ ? `“${formatInvestigationTitle(target)}”`
33
+ : "this investigation";
34
+ }
35
+
36
+ // A start refused without a cluster name (a host that sends none) has
37
+ // nothing to compare, so it is taken as this one.
38
+ export function capacityCluster(
39
+ refusedIn: string | undefined,
40
+ current: string | undefined,
41
+ ): "same" | "changed" | "unknown" {
42
+ if (!refusedIn || current === refusedIn) return "same";
43
+ return current ? "changed" : "unknown";
44
+ }
45
+
46
+ function without(set: ReadonlySet<string>, id: string): ReadonlySet<string> {
47
+ const next = new Set(set);
48
+ next.delete(id);
49
+ return next;
50
+ }
51
+
52
+ const SECONDARY_BUTTON =
53
+ "rounded-lg border border-theme-border px-3 py-1.5 text-sm text-theme-text-secondary hover:bg-theme-hover disabled:cursor-not-allowed disabled:opacity-50";
54
+
55
+ /**
56
+ * The start the user asked for was refused because every investigation slot
57
+ * is taken. Lists what holds them, with a way to open or stop each, and
58
+ * starts the same request again once a slot is free. Starting stays a click:
59
+ * it spends an agent run and takes over the panel, and by the time a slot
60
+ * frees the user may be reading one of the others.
61
+ *
62
+ * runsKnown is false until the runs list has loaded, or while it fails: an
63
+ * empty list then says nothing about free slots, so Start stays available
64
+ * and the server decides.
65
+ *
66
+ * cluster compares the cluster the start was refused in with the current
67
+ * one. A retry resolves the same namespace and name against whatever Radar
68
+ * is connected to, so it waits for a confirmed match.
69
+ */
70
+ export function InvestigationCapacityNotice({
71
+ capacity,
72
+ runs,
73
+ runsKnown,
74
+ cluster,
75
+ onOpenRun,
76
+ onStop,
77
+ onStart,
78
+ onDismiss,
79
+ }: {
80
+ capacity: StartCapacity;
81
+ runs: RunSummary[];
82
+ runsKnown: boolean;
83
+ cluster: "same" | "changed" | "unknown";
84
+ onOpenRun: (id: string) => void;
85
+ onStop: (id: string) => Promise<void>;
86
+ onStart: () => void;
87
+ onDismiss: () => void;
88
+ }) {
89
+ // Runs whose stop request is in flight, then the ones it settled for. The
90
+ // server marks a run stopped before answering, so a settled run the
91
+ // refreshed list still shows running did not stop.
92
+ const [stopping, setStopping] = useState<ReadonlySet<string>>(new Set());
93
+ const [stopSettled, setStopSettled] = useState<ReadonlySet<string>>(
94
+ new Set(),
95
+ );
96
+ const holding = runsHoldingSlots(runs);
97
+ const slotFree = runsKnown && holding.length < capacity.limit;
98
+ const canStart = cluster === "same" && (!runsKnown || slotFree);
99
+ const target = targetLabel(capacity.target);
100
+
101
+ const stop = (id: string) => {
102
+ setStopping((prev) => new Set(prev).add(id));
103
+ setStopSettled((prev) => without(prev, id));
104
+ const settle = () => {
105
+ setStopping((prev) => without(prev, id));
106
+ setStopSettled((prev) => new Set(prev).add(id));
107
+ };
108
+ onStop(id).then(settle, settle);
109
+ };
110
+
111
+ if (cluster === "changed") {
112
+ return (
113
+ <div className="flex flex-1 flex-col items-center justify-center gap-3 px-6 text-center">
114
+ <p className="text-sm text-theme-text-secondary">
115
+ {`The cluster changed since you asked to investigate ${target}, so Radar won’t start it here. Open the resource in this cluster to investigate it.`}
116
+ </p>
117
+ <button type="button" onClick={onDismiss} className={SECONDARY_BUTTON}>
118
+ Dismiss
119
+ </button>
120
+ </div>
121
+ );
122
+ }
123
+
124
+ return (
125
+ <div className="flex flex-1 flex-col overflow-y-auto px-4 py-6">
126
+ <div className="mx-auto flex w-full max-w-xl flex-col gap-4">
127
+ <div>
128
+ <h2 className="text-sm font-medium text-theme-text-primary">
129
+ {slotFree
130
+ ? "A slot is free"
131
+ : `${capacity.limit} investigations are already running`}
132
+ </h2>
133
+ <p className="mt-1 text-sm text-theme-text-secondary">
134
+ {slotFree
135
+ ? `Start ${target} now.`
136
+ : `Radar runs up to ${capacity.limit} at a time. Stop one to start ${target}, or wait for one to finish.`}
137
+ </p>
138
+ </div>
139
+ {!runsKnown ? (
140
+ <p className="text-sm text-theme-text-tertiary">
141
+ Loading the running investigations…
142
+ </p>
143
+ ) : holding.length > 0 ? (
144
+ <ul
145
+ aria-label="Running investigations"
146
+ className="divide-y divide-theme-border rounded-lg border border-theme-border"
147
+ >
148
+ {holding.map((run) => {
149
+ const isStopping =
150
+ stopping.has(run.id) || run.status === "stopping";
151
+ const didNotStop =
152
+ !isStopping &&
153
+ stopSettled.has(run.id) &&
154
+ run.status === "running";
155
+ return (
156
+ <li key={run.id} className="flex items-center gap-3 px-3 py-2">
157
+ <div className="min-w-0 flex-1">
158
+ <div className="truncate text-sm text-theme-text-primary">
159
+ {runLabel(run)}
160
+ </div>
161
+ <div className="text-xs text-theme-text-tertiary">
162
+ {isStopping
163
+ ? "Stopping…"
164
+ : didNotStop
165
+ ? "Still running. Radar couldn’t stop it; try again."
166
+ : `Started ${formatRelativeAgeTime(run.createdAt)}`}
167
+ </div>
168
+ </div>
169
+ <button
170
+ type="button"
171
+ onClick={() => onOpenRun(run.id)}
172
+ className={SECONDARY_BUTTON}
173
+ >
174
+ Open
175
+ </button>
176
+ <button
177
+ type="button"
178
+ disabled={isStopping}
179
+ onClick={() => stop(run.id)}
180
+ className={SECONDARY_BUTTON}
181
+ aria-label={`Stop ${runLabel(run)}`}
182
+ >
183
+ Stop
184
+ </button>
185
+ </li>
186
+ );
187
+ })}
188
+ </ul>
189
+ ) : null}
190
+ <div className="flex flex-wrap items-center gap-2">
191
+ <button
192
+ type="button"
193
+ disabled={!canStart}
194
+ onClick={onStart}
195
+ className="btn-brand px-3 py-1.5 text-sm"
196
+ >
197
+ Start investigation
198
+ </button>
199
+ <button
200
+ type="button"
201
+ onClick={onDismiss}
202
+ className={SECONDARY_BUTTON}
203
+ >
204
+ Cancel
205
+ </button>
206
+ {cluster === "unknown" ? (
207
+ <span className="text-xs text-theme-text-tertiary">
208
+ Checking which cluster Radar is connected to…
209
+ </span>
210
+ ) : null}
211
+ </div>
212
+ </div>
213
+ </div>
214
+ );
215
+ }
216
+
217
+ /** InvestigationCapacityNotice wired to the investigation state. */
218
+ export function InvestigationCapacityRecovery({
219
+ capacity,
220
+ }: {
221
+ capacity: StartCapacity;
222
+ }) {
223
+ const d = useDiagnose();
224
+ const { data: contexts } = useContexts();
225
+ const current = contexts?.find((c) => c.isCurrent)?.name;
226
+ return (
227
+ <InvestigationCapacityNotice
228
+ capacity={capacity}
229
+ runs={d.runs}
230
+ runsKnown={d.runsLoaded && !d.runsLoadFailed}
231
+ cluster={capacityCluster(capacity.context, current)}
232
+ onOpenRun={d.openRun}
233
+ onStop={async (id) => {
234
+ await stopRun(id);
235
+ await d.refreshRuns();
236
+ }}
237
+ onStart={() => d.openInvestigation(capacity.target)}
238
+ onDismiss={d.dismissError}
239
+ />
240
+ );
241
+ }
@@ -1,4 +1,7 @@
1
+ // @vitest-environment jsdom
1
2
  import { describe, expect, it } from "vitest";
3
+ import { act } from "react";
4
+ import { createRoot } from "react-dom/client";
2
5
  import { renderToStaticMarkup } from "react-dom/server";
3
6
 
4
7
  import { InvestigationEvidencePane } from "./InvestigationEvidencePane";
@@ -621,7 +624,12 @@ describe("story card defaults", () => {
621
624
  matches: 1,
622
625
  row: { kind: "ConfigMap", namespace: "b", name: "config" },
623
626
  },
624
- { key: "ConfigMap//missing", label: "missing", matches: 0, row: undefined },
627
+ {
628
+ key: "ConfigMap//missing",
629
+ label: "missing",
630
+ matches: 0,
631
+ row: undefined,
632
+ },
625
633
  ]);
626
634
  // Rows of a namespace-scoped listing omit their namespace: the scope is
627
635
  // theirs, and only that namespace satisfies a namespaced citation.
@@ -749,21 +757,104 @@ describe("story card defaults", () => {
749
757
  },
750
758
  },
751
759
  ];
752
- const html = renderToStaticMarkup(
760
+ const render = (report: string, items = evidence) =>
761
+ renderToStaticMarkup(
762
+ <InvestigationEvidencePane
763
+ projection={projection}
764
+ investigationCase={resolveInvestigationCase(
765
+ projection,
766
+ { evidence: items },
767
+ 0,
768
+ )}
769
+ story={{ report, evidence: items }}
770
+ collecting={false}
771
+ animateGroupIds={new Set()}
772
+ onViewSource={() => {}}
773
+ onViewActivity={() => {}}
774
+ />,
775
+ );
776
+ const symptom = render("Memory climbs.\n\n[[radar:evidence=0]]");
777
+ expect(symptom).toContain("data-story-metrics");
778
+ expect(symptom).not.toContain("height:140px");
779
+ const context = [{ ...evidence[0], role: "context" as const }];
780
+ const contextHtml = render(
781
+ "Memory climbs.\n\n[[radar:evidence=0]]",
782
+ context,
783
+ );
784
+ expect(contextHtml).toContain("data-story-metrics");
785
+ expect(contextHtml).toContain("height:140px");
786
+ expect(contextHtml).toContain('aria-expanded="true"');
787
+ expect(contextHtml).not.toContain("data-chart-reading");
788
+ const folded = render(
789
+ "Memory climbs.\n\n[[radar:evidence=0|compact]]",
790
+ context,
791
+ );
792
+ expect(folded).not.toContain("data-story-metrics");
793
+ expect(folded).toContain('aria-expanded="false"');
794
+ expect(folded).toMatch(/data-chart-reading[^>]*>161\.5 Mi?B?/);
795
+ // Agents mark cards compact for the prose's flow, not their weight, so a
796
+ // compact symptom stays open.
797
+ const compactSymptom = render(
798
+ "Memory climbs.\n\n[[radar:evidence=0|compact]]",
799
+ );
800
+ expect(compactSymptom).toContain("data-story-metrics");
801
+ expect(compactSymptom).not.toContain("height:140px");
802
+ // The collapsed preview bounds its height and leaves the chart out.
803
+ expect(
804
+ render("Memory climbs.\n\n[[radar:evidence=0]]\n\nMore after the fold."),
805
+ ).not.toContain("data-story-metrics");
806
+
807
+ const container = document.createElement("div");
808
+ document.body.appendChild(container);
809
+ const root = createRoot(container);
810
+ const pane = (report: string, items: DiagnosisEvidenceItem[]) => (
753
811
  <InvestigationEvidencePane
754
812
  projection={projection}
755
813
  investigationCase={resolveInvestigationCase(
756
814
  projection,
757
- { evidence },
815
+ { evidence: items },
758
816
  0,
759
817
  )}
760
- story={{ report: "Memory climbs.\n\n[[radar:evidence=0]]", evidence }}
818
+ story={{ report, evidence: items }}
761
819
  collecting={false}
762
820
  animateGroupIds={new Set()}
763
821
  onViewSource={() => {}}
764
822
  onViewActivity={() => {}}
765
- />,
823
+ />
824
+ );
825
+ // The story's card comes first; Captured results follows it.
826
+ const header = () =>
827
+ container.querySelector<HTMLButtonElement>("button[aria-expanded]")!;
828
+ act(() =>
829
+ root.render(
830
+ pane("Memory climbs.\n\n[[radar:evidence=0|compact]]", context),
831
+ ),
832
+ );
833
+ expect(container.querySelector("[data-story-metrics]")).toBeNull();
834
+ act(() => header().click());
835
+ expect(header().getAttribute("aria-expanded")).toBe("true");
836
+ expect(container.querySelector("[data-story-metrics]")).not.toBeNull();
837
+ expect(container.querySelector("[data-chart-reading]")).toBeNull();
838
+ act(() => header().click());
839
+ expect(header().getAttribute("aria-expanded")).toBe("false");
840
+ expect(container.querySelector("[data-chart-reading]")).not.toBeNull();
841
+ act(() =>
842
+ root.render(
843
+ pane(
844
+ "Memory climbs.\n\n[[radar:evidence=0|compact]]\n\nSee [[radar:evidence=0]] again.",
845
+ context,
846
+ ),
847
+ ),
766
848
  );
767
- expect(html).toContain("data-story-metrics");
849
+ act(() => header().click());
850
+ expect(container.querySelector("[data-chart-reading]")).not.toBeNull();
851
+ const reference = container.querySelector<HTMLButtonElement>(
852
+ "[data-story-ref-direction]",
853
+ )!;
854
+ Element.prototype.scrollIntoView ??= () => {};
855
+ act(() => reference.click());
856
+ expect(header().getAttribute("aria-expanded")).toBe("true");
857
+ act(() => root.unmount());
858
+ container.remove();
768
859
  });
769
860
  });
@@ -2802,6 +2802,63 @@ describe("cited broader cards and coverage rows", () => {
2802
2802
  expect(render(projection)).toContain(
2803
2803
  "4 results about other resources are not shown; they appear here when the assessment cites them.",
2804
2804
  );
2805
+ // A question with no resource has no "other" resource to speak of.
2806
+ expect(
2807
+ renderToStaticMarkup(
2808
+ <InvestigationEvidencePane
2809
+ projection={projection}
2810
+ collecting={false}
2811
+ animateGroupIds={new Set()}
2812
+ onViewSource={onViewSource}
2813
+ onViewActivity={() => {}}
2814
+ withoutTarget
2815
+ />,
2816
+ ),
2817
+ ).toContain(
2818
+ "4 results the assessment didn’t cite are not shown; they appear here when the assessment cites them.",
2819
+ );
2820
+ // Before there is an assessment nothing has been passed over yet.
2821
+ expect(
2822
+ renderToStaticMarkup(
2823
+ <InvestigationEvidencePane
2824
+ projection={projection}
2825
+ collecting
2826
+ animateGroupIds={new Set()}
2827
+ onViewSource={onViewSource}
2828
+ onViewActivity={() => {}}
2829
+ withoutTarget
2830
+ assessmentPending
2831
+ />,
2832
+ ),
2833
+ ).toContain(
2834
+ "4 results are held for the assessment; the ones it cites appear here.",
2835
+ );
2836
+ // A run that stopped without one will never cite anything: show it all.
2837
+ const stopped = partitionInvestigationEvidence(
2838
+ projection.groups,
2839
+ undefined,
2840
+ undefined,
2841
+ false,
2842
+ true,
2843
+ );
2844
+ expect(stopped.hiddenBroader).toBe(0);
2845
+ expect(stopped.main.length + stopped.workload.length).toBe(4);
2846
+ const stoppedMarkup = renderToStaticMarkup(
2847
+ <InvestigationEvidencePane
2848
+ projection={projection}
2849
+ collecting={false}
2850
+ animateGroupIds={new Set()}
2851
+ onViewSource={onViewSource}
2852
+ onViewActivity={() => {}}
2853
+ withoutTarget
2854
+ assessmentPending
2855
+ showUncited
2856
+ />,
2857
+ );
2858
+ expect(stoppedMarkup).not.toContain("not shown");
2859
+ expect(stoppedMarkup).toContain("Evidence collected");
2860
+ expect(stoppedMarkup).not.toContain("about this resource");
2861
+ expect(stoppedMarkup).not.toContain("No relevant evidence");
2805
2862
 
2806
2863
  const resolution = resolveInvestigationRootCauseEvidence(
2807
2864
  projection,
@@ -68,6 +68,9 @@ export function InvestigationEvidencePane({
68
68
  onViewActivity,
69
69
  onOpenResource,
70
70
  onOpenTimeline,
71
+ withoutTarget = false,
72
+ assessmentPending = false,
73
+ showUncited = false,
71
74
  afterEvidence,
72
75
  recordNotes,
73
76
  storyShell = false,
@@ -91,7 +94,6 @@ export function InvestigationEvidencePane({
91
94
  report: string;
92
95
  evidence?: DiagnosisEvidenceItem[];
93
96
  };
94
- /** Open the story fully instead of the bounded preview — when the layout has room for it. */
95
97
  collecting: boolean;
96
98
  animateGroupIds: ReadonlySet<string>;
97
99
  onViewSource: (
@@ -115,6 +117,13 @@ export function InvestigationEvidencePane({
115
117
  /** Explicit Activity → Findings navigation, including repeat clicks. */
116
118
  revealRequest?: { sourceId: string; requestId: number };
117
119
  onRevealReady?: (sourceId: string) => void;
120
+ /** A question with no resource: every result is "about another resource",
121
+ * so withheld ones are counted as uncited instead. */
122
+ withoutTarget?: boolean;
123
+ /** No assessment yet: nothing has been cited, so nothing is "uncited". */
124
+ assessmentPending?: boolean;
125
+ /** The run stopped without an assessment; withheld results are shown. */
126
+ showUncited?: boolean;
118
127
  }) {
119
128
  const [expandedGroupIds, setExpandedGroupIds] = useState<ReadonlySet<string>>(
120
129
  new Set(),
@@ -142,6 +151,7 @@ export function InvestigationEvidencePane({
142
151
  rootCauseEvidence,
143
152
  investigationCase,
144
153
  storyMode,
154
+ showUncited,
145
155
  );
146
156
  const hasCurrentEvidence =
147
157
  partition.main.length + partition.workload.length > 0;
@@ -352,7 +362,10 @@ export function InvestigationEvidencePane({
352
362
  projection.groups.map((group) => [group.id, group] as const),
353
363
  );
354
364
  const renderStoryPlacement = useCallback(
355
- (target: StoryPlacementTarget, { compact }: { compact: boolean }) => {
365
+ (
366
+ target: StoryPlacementTarget,
367
+ { compact, preview }: { compact: boolean; preview: boolean },
368
+ ) => {
356
369
  const group = target.item.groupId
357
370
  ? groupsById.get(target.item.groupId)
358
371
  : undefined;
@@ -366,6 +379,7 @@ export function InvestigationEvidencePane({
366
379
  onViewSource={onViewSource}
367
380
  spanFullRow
368
381
  compact={compact}
382
+ storyPreview={preview}
369
383
  noteMode="chip"
370
384
  gapRoles={storyGapRoles}
371
385
  />
@@ -408,8 +422,16 @@ export function InvestigationEvidencePane({
408
422
  // A card behind the fold may be mounted and inert, or not mounted at all
409
423
  // before the fold first opens; either way the fold opens first and the
410
424
  // card is found once it has settled.
425
+ const [storyReveal, setStoryReveal] = useState<{
426
+ domId: string;
427
+ requestId: number;
428
+ }>();
411
429
  const revealStoryTarget = useCallback(
412
430
  (target: StoryPlacementTarget) => {
431
+ setStoryReveal((previous) => ({
432
+ domId: target.domId,
433
+ requestId: (previous?.requestId ?? 0) + 1,
434
+ }));
413
435
  const land = (placed: HTMLElement) => {
414
436
  placed.scrollIntoView({
415
437
  block: "center",
@@ -454,10 +476,16 @@ export function InvestigationEvidencePane({
454
476
  partition.earlier.length;
455
477
  const resultsSummary = [
456
478
  partition.hiddenBroader > 0
457
- ? `${partition.hiddenBroader} about other resources not shown`
479
+ ? withoutTarget
480
+ ? assessmentPending
481
+ ? `${partition.hiddenBroader} not shown yet`
482
+ : `${partition.hiddenBroader} not cited, not shown`
483
+ : `${partition.hiddenBroader} about other resources not shown`
458
484
  : undefined,
459
485
  partition.hiddenMetrics > 0
460
- ? `${partition.hiddenMetrics} broader metric ${partition.hiddenMetrics === 1 ? "result" : "results"} not shown`
486
+ ? withoutTarget && assessmentPending
487
+ ? `${partition.hiddenMetrics} metric ${partition.hiddenMetrics === 1 ? "result" : "results"} not shown yet`
488
+ : `${partition.hiddenMetrics} ${withoutTarget ? "uncited" : "broader"} metric ${partition.hiddenMetrics === 1 ? "result" : "results"} not shown`
461
489
  : undefined,
462
490
  projection.limitations.length > 0
463
491
  ? `${projection.limitations.length} ${projection.limitations.length === 1 ? "check" : "checks"} limited`
@@ -485,9 +513,17 @@ export function InvestigationEvidencePane({
485
513
  className="text-xs text-theme-text-tertiary"
486
514
  data-testid="investigation-hidden-evidence"
487
515
  >
488
- {partition.hiddenBroader === 1
489
- ? "1 result about another resource is not shown; it appears here when the assessment cites it."
490
- : `${partition.hiddenBroader} results about other resources are not shown; they appear here when the assessment cites them.`}
516
+ {withoutTarget && assessmentPending
517
+ ? partition.hiddenBroader === 1
518
+ ? "1 result is held for the assessment; it appears here if the assessment cites it."
519
+ : `${partition.hiddenBroader} results are held for the assessment; the ones it cites appear here.`
520
+ : withoutTarget
521
+ ? partition.hiddenBroader === 1
522
+ ? "1 result the assessment didn’t cite is not shown; it appears here when the assessment cites it."
523
+ : `${partition.hiddenBroader} results the assessment didn’t cite are not shown; they appear here when the assessment cites them.`
524
+ : partition.hiddenBroader === 1
525
+ ? "1 result about another resource is not shown; it appears here when the assessment cites it."
526
+ : `${partition.hiddenBroader} results about other resources are not shown; they appear here when the assessment cites them.`}
491
527
  </p>
492
528
  ) : null}
493
529
 
@@ -496,15 +532,20 @@ export function InvestigationEvidencePane({
496
532
  className="text-xs text-theme-text-tertiary"
497
533
  data-testid="investigation-hidden-metrics"
498
534
  >
499
- {partition.hiddenMetrics === 1
500
- ? "1 broader metric result is not shown; it appears here when the assessment cites it."
501
- : `${partition.hiddenMetrics} broader metric results are not shown; they appear here when the assessment cites them.`}
535
+ {withoutTarget && assessmentPending
536
+ ? partition.hiddenMetrics === 1
537
+ ? "1 metric result is held for the assessment; it appears here if the assessment cites it."
538
+ : `${partition.hiddenMetrics} metric results are held for the assessment; the ones it cites appear here.`
539
+ : partition.hiddenMetrics === 1
540
+ ? `1 ${withoutTarget ? "uncited" : "broader"} metric result is not shown; it appears here when the assessment cites it.`
541
+ : `${partition.hiddenMetrics} ${withoutTarget ? "uncited" : "broader"} metric results are not shown; they appear here when the assessment cites them.`}
502
542
  </p>
503
543
  ) : null}
504
544
 
505
545
  {!hasCurrentEvidence ? (
506
546
  <EmptyCollection
507
547
  collecting={collecting}
548
+ withoutTarget={withoutTarget}
508
549
  hasEarlierEvidence={partition.earlier.length > 0}
509
550
  onViewActivity={onViewActivity}
510
551
  />
@@ -512,7 +553,13 @@ export function InvestigationEvidencePane({
512
553
 
513
554
  <CollapsedEvidenceCollection
514
555
  id="investigation-workload-evidence"
515
- title="More evidence about this resource"
556
+ title={
557
+ withoutTarget || showUncited
558
+ ? partition.main.length > 0
559
+ ? "More evidence collected"
560
+ : "Evidence collected"
561
+ : "More evidence about this resource"
562
+ }
516
563
  description=""
517
564
  groups={partition.workload}
518
565
  totalCount={partition.workload.length + partition.earlier.length}
@@ -703,6 +750,7 @@ export function InvestigationEvidencePane({
703
750
  onGroupOpenChange,
704
751
  revealSourceId: caseReveal?.sourceId ?? revealRequest?.sourceId,
705
752
  revealRequestId: caseReveal?.requestId ?? revealRequest?.requestId,
753
+ storyReveal,
706
754
  caseByGroup: investigationCaseByGroup(investigationCase),
707
755
  excludedByItem: new Map(
708
756
  (investigationCase?.ruledOut ?? []).map((entry) => [
@@ -121,10 +121,12 @@ export function EmptyCollection({
121
121
  collecting,
122
122
  hasEarlierEvidence,
123
123
  onViewActivity,
124
+ withoutTarget = false,
124
125
  }: {
125
126
  collecting: boolean;
126
127
  hasEarlierEvidence: boolean;
127
128
  onViewActivity: () => void;
129
+ withoutTarget?: boolean;
128
130
  }) {
129
131
  return (
130
132
  <div className="rounded-lg border border-dashed border-theme-border px-4 py-5 text-center">
@@ -148,7 +150,9 @@ export function EmptyCollection({
148
150
  ? "The Activity pane remains the live record while the agent investigates."
149
151
  : hasEarlierEvidence
150
152
  ? "Earlier observations remain below. This does not prove that those conditions resolved."
151
- : "Investigation details are still available in Activity. This does not mean the resource is healthy."}
153
+ : withoutTarget
154
+ ? "Investigation details are still available in Activity. This does not mean nothing is wrong."
155
+ : "Investigation details are still available in Activity. This does not mean the resource is healthy."}
152
156
  </p>
153
157
  <button
154
158
  type="button"