@skyhook-io/radar-app 1.19.0 → 1.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +5 -5
- package/src/App.tsx +31 -5
- package/src/api/application-evidence.ts +63 -0
- package/src/api/argoSync.test.ts +22 -0
- package/src/api/client.audit-gating.test.tsx +48 -0
- package/src/api/client.kueuePosition.test.ts +32 -0
- package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
- package/src/api/client.resource-identity.test.ts +3 -0
- package/src/api/client.resourceIssues.test.tsx +239 -0
- package/src/api/client.resourcePath.test.ts +3 -0
- package/src/api/client.ts +285 -55
- package/src/api/config.ts +21 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/radarFeatures.render.test.tsx +33 -1
- package/src/api/radarFeatures.test.ts +47 -0
- package/src/api/radarFeatures.ts +40 -1
- package/src/api/rbac.settled.test.tsx +42 -0
- package/src/api/rbac.test.ts +18 -0
- package/src/api/rbac.ts +37 -7
- package/src/api/traffic.ts +9 -4
- package/src/api/usage-data.fixtures.ts +3 -1
- package/src/api/usage-data.test.tsx +134 -0
- package/src/api/usage-data.ts +35 -7
- package/src/api/workloadPodsPolling.test.ts +26 -0
- package/src/components/CloudConnectFlow.test.tsx +86 -0
- package/src/components/CloudConnectFlow.tsx +65 -27
- package/src/components/CloudFunnelButton.test.tsx +140 -5
- package/src/components/CloudFunnelButton.tsx +50 -9
- package/src/components/ConnectionErrorView.test.tsx +34 -0
- package/src/components/ConnectionErrorView.tsx +35 -11
- package/src/components/ContextSwitcher.tsx +5 -2
- package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
- package/src/components/SwitchAwareConnectionError.tsx +85 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
- package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
- package/src/components/capacity/CapacityDemand.tsx +3 -2
- package/src/components/capacity/demandSummary.test.ts +38 -0
- package/src/components/capacity/shared.tsx +12 -1
- package/src/components/cost/ApplicationCostTab.tsx +4 -0
- package/src/components/cost/CostTrendChart.tsx +2 -0
- package/src/components/cost/WorkloadCostTab.tsx +4 -0
- package/src/components/cost/source.test.ts +5 -0
- package/src/components/cost/source.ts +11 -0
- package/src/components/diagnose/AIMarkdown.tsx +3 -0
- package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
- package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
- package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
- package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
- package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
- package/src/components/diagnose/DiagnoseContext.tsx +68 -2
- package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
- package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
- package/src/components/diagnose/Home.test.tsx +26 -0
- package/src/components/diagnose/Home.tsx +20 -1
- package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
- package/src/components/diagnose/InvestigationView.tsx +94 -26
- package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
- package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
- package/src/components/diagnose/NextStepJump.test.tsx +92 -0
- package/src/components/diagnose/NextStepJump.tsx +75 -0
- package/src/components/diagnose/QuestionComposer.tsx +8 -0
- package/src/components/diagnose/exampleInvestigation.events.json +191 -0
- package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
- package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
- package/src/components/diagnose/exampleInvestigation.ts +121 -0
- package/src/components/diagnose/investigationCase.test.tsx +9 -1
- package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
- package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
- package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
- package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
- package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
- package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
- package/src/components/diagnose/investigationEvidence/types.ts +5 -0
- package/src/components/diagnose/investigationState.ts +28 -0
- package/src/components/diagnose/lastInvestigation.test.ts +95 -0
- package/src/components/diagnose/lastInvestigation.ts +58 -0
- package/src/components/diagnose/launch.test.ts +125 -1
- package/src/components/diagnose/launch.ts +57 -10
- package/src/components/diagnose/toolCallLabel.test.ts +10 -4
- package/src/components/execution/BatchExecutionView.tsx +24 -11
- package/src/components/execution/JobSetAdmission.test.tsx +42 -0
- package/src/components/execution/JobSetAdmission.tsx +18 -3
- package/src/components/execution/JobSetMemberComparison.tsx +2 -1
- package/src/components/execution/runState.test.ts +14 -0
- package/src/components/execution/runState.ts +8 -0
- package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
- package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
- package/src/components/gitops/GitOpsView.tsx +86 -17
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
- package/src/components/gitops/destination-toast.test.ts +1 -1
- package/src/components/gitops/destination-toast.ts +2 -2
- package/src/components/home/ClusterHealthCard.tsx +1 -1
- package/src/components/home/HomeAgentBlock.test.tsx +31 -3
- package/src/components/home/HomeAgentBlock.tsx +13 -4
- package/src/components/home/HomeDiagramCard.tsx +47 -0
- package/src/components/home/HomeView.tsx +81 -41
- package/src/components/home/MCPSetupDialog.test.tsx +95 -5
- package/src/components/home/MCPSetupDialog.tsx +30 -5
- package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
- package/src/components/home/ProblemsPanel.test.tsx +3 -1
- package/src/components/home/TopologyPreview.test.tsx +73 -0
- package/src/components/home/TopologyPreview.tsx +120 -233
- package/src/components/home/TrafficSummary.test.tsx +63 -0
- package/src/components/home/TrafficSummary.tsx +135 -138
- package/src/components/home/mcpToolCatalog.ts +23 -10
- package/src/components/issues/IssuesPane.test.ts +11 -0
- package/src/components/issues/IssuesPane.tsx +15 -5
- package/src/components/issues/uncheckedSources.test.ts +20 -1
- package/src/components/issues/uncheckedSources.ts +18 -0
- package/src/components/kueue/KueuePendingPosition.tsx +35 -0
- package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
- package/src/components/kueue/useRelatedReads.test.ts +56 -0
- package/src/components/kueue/useRelatedReads.ts +205 -0
- package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
- package/src/components/logs/MultiPodLogsTab.tsx +120 -0
- package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
- package/src/components/logs/PodLogsUnavailable.tsx +21 -0
- package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
- package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
- package/src/components/logs/RayClusterLogsTab.tsx +109 -0
- package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
- package/src/components/logs/rayClusterPods.ts +32 -0
- package/src/components/outageSince.test.ts +21 -0
- package/src/components/outageSince.ts +10 -0
- package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
- package/src/components/resource/PrometheusCharts.tsx +3 -40
- package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
- package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
- package/src/components/resources/crd/host.tsx +14 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
- package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
- package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
- package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
- package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
- package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
- package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
- package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
- package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
- package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
- package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
- package/src/components/traffic/TrafficView.tsx +3 -3
- package/src/components/ui/command-items-crd.test.tsx +23 -0
- package/src/components/ui/command-items.ts +2 -1
- package/src/components/useContextSwitchFlow.test.tsx +61 -0
- package/src/components/useContextSwitchFlow.tsx +21 -4
- package/src/components/whats-new/WhatsNew.test.ts +10 -3
- package/src/components/whats-new/WhatsNew.tsx +5 -1
- package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
- package/src/components/whats-new/releaseNotes.ts +77 -4
- package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
- package/src/components/workload/RelatedFindingsSection.tsx +80 -0
- package/src/components/workload/WorkloadView.test.ts +10 -1
- package/src/components/workload/WorkloadView.tsx +85 -98
- package/src/components/workload/issueResourceOpener.test.ts +20 -0
- package/src/components/workload/issueResourceOpener.ts +17 -0
- package/src/context/ConnectionContext.tsx +133 -60
- package/src/context/ConnectionProvider.retry.test.tsx +176 -0
- package/src/context/ContextSwitchContext.tsx +14 -1
- package/src/context/DiagnoseCustomization.tsx +3 -0
- package/src/context/clusterConnected.ts +10 -0
- package/src/contexts/CapabilitiesContext.tsx +6 -4
- package/src/hooks/useElementSize.ts +30 -0
- package/src/integrations/resourceHost.test.tsx +1 -0
- package/src/integrations/resourceHost.ts +5 -1
- package/src/integrations/resourceHosts.test.tsx +21 -4
- package/src/integrations/resourceHosts.tsx +12 -0
- package/src/main.tsx +5 -0
- package/src/utils/related-findings.ts +46 -0
|
@@ -5,6 +5,7 @@ import { copyText } from "@skyhook-io/k8s-ui/utils/clipboard";
|
|
|
5
5
|
import { SUPPORTED_AGENTS, type AgentInstall } from "./agentCatalog";
|
|
6
6
|
import { type DiagnoseSetup } from "./DiagnoseContext";
|
|
7
7
|
import { openExternal } from "../../utils/navigation";
|
|
8
|
+
import { ExampleInvestigationLink } from "./ExampleInvestigationLink";
|
|
8
9
|
|
|
9
10
|
const REPORT_URL =
|
|
10
11
|
"https://github.com/skyhook-io/radar/issues/new?labels=bug&template=bug_report.md";
|
|
@@ -101,12 +102,15 @@ export function AgentSetupNotice({
|
|
|
101
102
|
checkingAgents,
|
|
102
103
|
agentsCheckFailed,
|
|
103
104
|
recheckAgents,
|
|
105
|
+
onOpenExample,
|
|
104
106
|
}: {
|
|
105
107
|
setupState: DiagnoseSetup;
|
|
106
108
|
cliOverride: boolean;
|
|
107
109
|
checkingAgents: boolean;
|
|
108
110
|
agentsCheckFailed: boolean;
|
|
109
111
|
recheckAgents: () => Promise<void>;
|
|
112
|
+
/** Shows what an investigation produces before anything is set up. */
|
|
113
|
+
onOpenExample?: () => void;
|
|
110
114
|
}) {
|
|
111
115
|
// The state the panel was in when a check started. "Still…" is only true when
|
|
112
116
|
// the finished check left it there.
|
|
@@ -123,7 +127,10 @@ export function AgentSetupNotice({
|
|
|
123
127
|
|
|
124
128
|
if (cliOverride) {
|
|
125
129
|
return (
|
|
126
|
-
<SetupFrame
|
|
130
|
+
<SetupFrame
|
|
131
|
+
title="Radar can't run your RADAR_AI_CLI_BIN"
|
|
132
|
+
onOpenExample={onOpenExample}
|
|
133
|
+
>
|
|
127
134
|
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
128
135
|
Fix the path, or remove it and restart Radar.
|
|
129
136
|
</p>
|
|
@@ -139,7 +146,10 @@ export function AgentSetupNotice({
|
|
|
139
146
|
}
|
|
140
147
|
if (setupState === "needs-restart") {
|
|
141
148
|
return (
|
|
142
|
-
<SetupFrame
|
|
149
|
+
<SetupFrame
|
|
150
|
+
title="AI investigations aren't available right now"
|
|
151
|
+
onOpenExample={onOpenExample}
|
|
152
|
+
>
|
|
143
153
|
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
144
154
|
Try again in a moment.
|
|
145
155
|
</p>
|
|
@@ -154,7 +164,7 @@ export function AgentSetupNotice({
|
|
|
154
164
|
);
|
|
155
165
|
}
|
|
156
166
|
return (
|
|
157
|
-
<SetupFrame title="Set up AI investigations">
|
|
167
|
+
<SetupFrame title="Set up AI investigations" onOpenExample={onOpenExample}>
|
|
158
168
|
<p className="mt-1 text-sm text-theme-text-secondary">
|
|
159
169
|
Radar runs investigations through a coding agent CLI on your own
|
|
160
170
|
machine, with no Radar cloud and no API key. Install one of these:
|
|
@@ -186,9 +196,11 @@ export function AgentSetupNotice({
|
|
|
186
196
|
function SetupFrame({
|
|
187
197
|
title,
|
|
188
198
|
children,
|
|
199
|
+
onOpenExample,
|
|
189
200
|
}: {
|
|
190
201
|
title: string;
|
|
191
202
|
children: ReactNode;
|
|
203
|
+
onOpenExample?: () => void;
|
|
192
204
|
}) {
|
|
193
205
|
return (
|
|
194
206
|
<div className="mx-auto max-w-md px-1 py-6">
|
|
@@ -199,6 +211,12 @@ function SetupFrame({
|
|
|
199
211
|
{title}
|
|
200
212
|
</h3>
|
|
201
213
|
{children}
|
|
214
|
+
{onOpenExample && (
|
|
215
|
+
<p className="mt-4 text-sm text-theme-text-secondary">
|
|
216
|
+
Not sure yet?{" "}
|
|
217
|
+
<ExampleInvestigationLink onOpen={onOpenExample} />
|
|
218
|
+
</p>
|
|
219
|
+
)}
|
|
202
220
|
<p className="mt-4 text-xs text-theme-text-tertiary">
|
|
203
221
|
Your agent runs locally. Resource details and logs are sent to its model
|
|
204
222
|
provider under your account, not to Radar.
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { act } from "react";
|
|
3
|
+
import { createRoot, type Root } from "react-dom/client";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
6
|
+
import { ContinueInAgentButton } from "./ContinueInAgentButton";
|
|
7
|
+
|
|
8
|
+
const caps = vi.hoisted(() => ({ localTerminal: true }));
|
|
9
|
+
vi.mock("../../contexts/CapabilitiesContext", () => ({
|
|
10
|
+
useCapabilitiesContext: () => ({
|
|
11
|
+
localTerminal: caps.localTerminal,
|
|
12
|
+
mcpReadOnly: false,
|
|
13
|
+
}),
|
|
14
|
+
}));
|
|
15
|
+
const launch = vi.hoisted(() => ({ openInTerminal: vi.fn() }));
|
|
16
|
+
vi.mock("./launch", async (importOriginal) => ({
|
|
17
|
+
...(await importOriginal<object>()),
|
|
18
|
+
openInTerminal: launch.openInTerminal,
|
|
19
|
+
}));
|
|
20
|
+
const clipboard = vi.hoisted(() => ({ copyText: vi.fn() }));
|
|
21
|
+
vi.mock("@skyhook-io/k8s-ui/utils/clipboard", () => clipboard);
|
|
22
|
+
|
|
23
|
+
Object.assign(globalThis, { IS_REACT_ACT_ENVIRONMENT: true });
|
|
24
|
+
let root: Root;
|
|
25
|
+
const run: RunSummary = {
|
|
26
|
+
id: "r1",
|
|
27
|
+
kind: "Deployment",
|
|
28
|
+
group: "apps",
|
|
29
|
+
namespace: "shop",
|
|
30
|
+
name: "api",
|
|
31
|
+
context: "test",
|
|
32
|
+
agent: "claude",
|
|
33
|
+
status: "done",
|
|
34
|
+
sessionId: "ses_1",
|
|
35
|
+
createdAt: "2026-10-01T00:00:00Z",
|
|
36
|
+
updatedAt: "2026-10-01T00:00:00Z",
|
|
37
|
+
};
|
|
38
|
+
const flush = () =>
|
|
39
|
+
act(async () => {
|
|
40
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
41
|
+
});
|
|
42
|
+
const caret = () =>
|
|
43
|
+
document.querySelector<HTMLButtonElement>('button[aria-haspopup="dialog"]')!;
|
|
44
|
+
const panel = () => document.querySelector('[role="dialog"]');
|
|
45
|
+
|
|
46
|
+
async function mount(r: RunSummary = run) {
|
|
47
|
+
await act(async () =>
|
|
48
|
+
root.render(<ContinueInAgentButton run={r} command="claude --resume x" />),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
beforeEach(async () => {
|
|
53
|
+
clipboard.copyText.mockReset();
|
|
54
|
+
launch.openInTerminal.mockReset();
|
|
55
|
+
caps.localTerminal = true;
|
|
56
|
+
const el = document.createElement("div");
|
|
57
|
+
document.body.appendChild(el);
|
|
58
|
+
root = createRoot(el);
|
|
59
|
+
await mount();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
afterEach(async () => {
|
|
63
|
+
await act(async () => root.unmount());
|
|
64
|
+
document.body.replaceChildren();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
async function openPanel() {
|
|
68
|
+
await act(async () => caret().click());
|
|
69
|
+
await flush();
|
|
70
|
+
// The panel animates in over two frames, then takes focus.
|
|
71
|
+
for (let i = 0; i < 2; i++)
|
|
72
|
+
await act(async () => {
|
|
73
|
+
await new Promise((resolve) =>
|
|
74
|
+
requestAnimationFrame(() => resolve(null)),
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
await flush();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
describe("the continue panel", () => {
|
|
81
|
+
it("opens as a dialog holding the command, and copies it", async () => {
|
|
82
|
+
clipboard.copyText.mockResolvedValue(true);
|
|
83
|
+
await openPanel();
|
|
84
|
+
expect(caret().getAttribute("aria-expanded")).toBe("true");
|
|
85
|
+
expect(panel()?.textContent).toContain("claude --resume x");
|
|
86
|
+
const copy = panel()!.querySelector<HTMLButtonElement>(
|
|
87
|
+
'button[aria-label="Copy command"]',
|
|
88
|
+
)!;
|
|
89
|
+
await act(async () => copy.click());
|
|
90
|
+
await flush();
|
|
91
|
+
expect(clipboard.copyText).toHaveBeenCalledWith("claude --resume x");
|
|
92
|
+
expect(copy.getAttribute("aria-label")).toBe("Command copied");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("says so when the copy fails", async () => {
|
|
96
|
+
clipboard.copyText.mockResolvedValue(false);
|
|
97
|
+
await openPanel();
|
|
98
|
+
const copy = panel()!.querySelector<HTMLButtonElement>(
|
|
99
|
+
'button[aria-label="Copy command"]',
|
|
100
|
+
)!;
|
|
101
|
+
await act(async () => copy.click());
|
|
102
|
+
await flush();
|
|
103
|
+
expect(copy.getAttribute("aria-label")).toBe("Copy failed");
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("closes on Escape without letting it reach the panel underneath", async () => {
|
|
107
|
+
await openPanel();
|
|
108
|
+
const underneath = vi.fn();
|
|
109
|
+
window.addEventListener("keydown", underneath);
|
|
110
|
+
await act(async () =>
|
|
111
|
+
document.activeElement!.dispatchEvent(
|
|
112
|
+
new KeyboardEvent("keydown", { key: "Escape", bubbles: true }),
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
116
|
+
expect(document.activeElement).toBe(caret());
|
|
117
|
+
expect(underneath).not.toHaveBeenCalled();
|
|
118
|
+
window.removeEventListener("keydown", underneath);
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("closes when the pane scrolls or resizes, since its placement would be stale", async () => {
|
|
122
|
+
await openPanel();
|
|
123
|
+
await act(async () => document.dispatchEvent(new Event("scroll")));
|
|
124
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
125
|
+
await openPanel();
|
|
126
|
+
await act(async () => window.dispatchEvent(new Event("resize")));
|
|
127
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("tabs between its buttons, and back to the caret past the last", async () => {
|
|
131
|
+
await openPanel();
|
|
132
|
+
const [runHere, copy] = Array.from(
|
|
133
|
+
panel()!.querySelectorAll<HTMLButtonElement>("button"),
|
|
134
|
+
);
|
|
135
|
+
expect(document.activeElement).toBe(runHere);
|
|
136
|
+
const tab = (shiftKey = false) =>
|
|
137
|
+
act(async () =>
|
|
138
|
+
document.activeElement!.dispatchEvent(
|
|
139
|
+
new KeyboardEvent("keydown", { key: "Tab", shiftKey, bubbles: true }),
|
|
140
|
+
),
|
|
141
|
+
);
|
|
142
|
+
await tab();
|
|
143
|
+
// Not the last button: the panel stays open and the browser moves focus.
|
|
144
|
+
expect(caret().getAttribute("aria-expanded")).toBe("true");
|
|
145
|
+
copy.focus();
|
|
146
|
+
await tab();
|
|
147
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
148
|
+
expect(document.activeElement).toBe(caret());
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it("leads with the trust warning and Run in Radar terminal, focused", async () => {
|
|
152
|
+
await openPanel();
|
|
153
|
+
// Described by the explanation and the warning, so a screen reader reads
|
|
154
|
+
// them when focus lands on the button below.
|
|
155
|
+
const described = (panel()!.getAttribute("aria-describedby") ?? "")
|
|
156
|
+
.split(" ")
|
|
157
|
+
.map((id) => document.getElementById(id)?.textContent ?? "")
|
|
158
|
+
.join(" ");
|
|
159
|
+
expect(described).toContain("Resumes this session");
|
|
160
|
+
expect(described).toContain("Select Yes before pressing Enter");
|
|
161
|
+
const runHere = panel()!.querySelector<HTMLButtonElement>("button")!;
|
|
162
|
+
expect(runHere.textContent).toBe("Run in Radar terminal");
|
|
163
|
+
expect(document.activeElement).toBe(runHere);
|
|
164
|
+
await act(async () => runHere.click());
|
|
165
|
+
expect(launch.openInTerminal).toHaveBeenCalledWith(
|
|
166
|
+
"claude --resume x",
|
|
167
|
+
"Radar Investigation",
|
|
168
|
+
);
|
|
169
|
+
expect(caret().getAttribute("aria-expanded")).toBe("false");
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
it("offers copy first without a terminal, and no trust warning for Codex", async () => {
|
|
173
|
+
caps.localTerminal = false;
|
|
174
|
+
await mount({ ...run, agent: "codex" });
|
|
175
|
+
await openPanel();
|
|
176
|
+
expect(panel()!.textContent).not.toContain("Run in Radar terminal");
|
|
177
|
+
expect(panel()!.textContent).not.toContain("Select Yes");
|
|
178
|
+
expect(document.activeElement?.getAttribute("aria-label")).toBe(
|
|
179
|
+
"Copy command",
|
|
180
|
+
);
|
|
181
|
+
});
|
|
182
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { renderToStaticMarkup } from "react-dom/server";
|
|
3
|
+
import type { RunSummary } from "../../api/diagnose";
|
|
4
|
+
import { ContinueInAgentButton } from "./ContinueInAgentButton";
|
|
5
|
+
import { canContinueInOwnAgent } from "./investigationState";
|
|
6
|
+
|
|
7
|
+
let mockLocalTerminal = true;
|
|
8
|
+
vi.mock("../../contexts/CapabilitiesContext", () => ({
|
|
9
|
+
useCapabilitiesContext: () => ({
|
|
10
|
+
localTerminal: mockLocalTerminal,
|
|
11
|
+
mcpReadOnly: false,
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
mockLocalTerminal = true;
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
function run(overrides: Partial<RunSummary> = {}): RunSummary {
|
|
19
|
+
return {
|
|
20
|
+
id: "r1",
|
|
21
|
+
kind: "Deployment",
|
|
22
|
+
group: "apps",
|
|
23
|
+
namespace: "gl-crash-config",
|
|
24
|
+
name: "api",
|
|
25
|
+
context: "test",
|
|
26
|
+
agent: "claude",
|
|
27
|
+
status: "done",
|
|
28
|
+
sessionId: "ses_1",
|
|
29
|
+
createdAt: "2026-10-01T00:00:00Z",
|
|
30
|
+
updatedAt: "2026-10-01T00:00:00Z",
|
|
31
|
+
...overrides,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const settled = {
|
|
36
|
+
run: run(),
|
|
37
|
+
busy: false,
|
|
38
|
+
requestPending: false,
|
|
39
|
+
gone: false,
|
|
40
|
+
streamReady: true,
|
|
41
|
+
verificationPending: false,
|
|
42
|
+
latestTurnStatus: "done" as const,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
describe("canContinueInOwnAgent", () => {
|
|
46
|
+
it("offers the hand-off once the verdict is in", () => {
|
|
47
|
+
expect(canContinueInOwnAgent(settled)).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("waits while any turn is writing to the session", () => {
|
|
51
|
+
expect(canContinueInOwnAgent({ ...settled, busy: true })).toBe(false);
|
|
52
|
+
expect(canContinueInOwnAgent({ ...settled, requestPending: true })).toBe(
|
|
53
|
+
false,
|
|
54
|
+
);
|
|
55
|
+
expect(
|
|
56
|
+
canContinueInOwnAgent({ ...settled, latestTurnStatus: "running" }),
|
|
57
|
+
).toBe(false);
|
|
58
|
+
expect(
|
|
59
|
+
canContinueInOwnAgent({
|
|
60
|
+
...settled,
|
|
61
|
+
run: run({ status: "running" }),
|
|
62
|
+
latestTurnStatus: undefined,
|
|
63
|
+
}),
|
|
64
|
+
).toBe(false);
|
|
65
|
+
expect(
|
|
66
|
+
canContinueInOwnAgent({ ...settled, verificationPending: true }),
|
|
67
|
+
).toBe(false);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it("waits for a replay to catch up before trusting the transcript", () => {
|
|
71
|
+
expect(canContinueInOwnAgent({ ...settled, streamReady: false })).toBe(
|
|
72
|
+
false,
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("waits through stopping, whose terminal frame precedes the exit", () => {
|
|
77
|
+
expect(
|
|
78
|
+
canContinueInOwnAgent({ ...settled, run: run({ status: "stopping" }) }),
|
|
79
|
+
).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it("trusts a finished transcript over a lagging run summary", () => {
|
|
83
|
+
expect(
|
|
84
|
+
canContinueInOwnAgent({ ...settled, run: run({ status: "running" }) }),
|
|
85
|
+
).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it("stays hidden on a run that is gone", () => {
|
|
89
|
+
expect(canContinueInOwnAgent({ ...settled, gone: true })).toBe(false);
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
describe("ContinueInAgentButton", () => {
|
|
94
|
+
const command =
|
|
95
|
+
"mkdir -p ~/.radar/agent && cd ~/.radar/agent && claude --resume 'ses_1'";
|
|
96
|
+
|
|
97
|
+
it("is one button that opens a dialog, named for the agent", () => {
|
|
98
|
+
const html = renderToStaticMarkup(
|
|
99
|
+
<ContinueInAgentButton run={run()} command={command} />,
|
|
100
|
+
);
|
|
101
|
+
expect(html).toContain('aria-label="Continue in Claude Code"');
|
|
102
|
+
expect(html).toContain("Claude Code…");
|
|
103
|
+
expect(html).toContain('aria-haspopup="dialog"');
|
|
104
|
+
expect(html).toContain('aria-expanded="false"');
|
|
105
|
+
expect(html.match(/<button/g)).toHaveLength(1);
|
|
106
|
+
// Nothing about the trust prompt until the panel opens and shows it.
|
|
107
|
+
expect(html).not.toContain("Select Yes");
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("names the agent that ran the investigation", () => {
|
|
111
|
+
const html = renderToStaticMarkup(
|
|
112
|
+
<ContinueInAgentButton
|
|
113
|
+
run={run({ agent: "codex" })}
|
|
114
|
+
command="codex resume 'ses_1'"
|
|
115
|
+
/>,
|
|
116
|
+
);
|
|
117
|
+
expect(html).toContain('aria-label="Continue in Codex"');
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it("is the same button when Radar has no terminal", () => {
|
|
121
|
+
mockLocalTerminal = false;
|
|
122
|
+
const html = renderToStaticMarkup(
|
|
123
|
+
<ContinueInAgentButton run={run()} command={command} />,
|
|
124
|
+
);
|
|
125
|
+
expect(html).toContain('aria-haspopup="dialog"');
|
|
126
|
+
expect(html.match(/<button/g)).toHaveLength(1);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useEffect,
|
|
3
|
+
useId,
|
|
4
|
+
useLayoutEffect,
|
|
5
|
+
useRef,
|
|
6
|
+
useState,
|
|
7
|
+
type FocusEvent,
|
|
8
|
+
type KeyboardEvent,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { Check, Copy, TerminalSquare } from "lucide-react";
|
|
11
|
+
import { clsx } from "clsx";
|
|
12
|
+
import { copyText } from "@skyhook-io/k8s-ui/utils/clipboard";
|
|
13
|
+
import { useAnimatedUnmount } from "../../hooks/useAnimatedUnmount";
|
|
14
|
+
import {
|
|
15
|
+
TRANSITION_MENU,
|
|
16
|
+
overlayExitMs,
|
|
17
|
+
overlayTransitionStyle,
|
|
18
|
+
} from "../../utils/animation";
|
|
19
|
+
import { type RunSummary } from "../../api/diagnose";
|
|
20
|
+
import { mcpEndpointUrl } from "../../api/config";
|
|
21
|
+
import { useCapabilitiesContext } from "../../contexts/CapabilitiesContext";
|
|
22
|
+
import {
|
|
23
|
+
buildLaunchCommand,
|
|
24
|
+
launchAgentLabel,
|
|
25
|
+
launchTrustHint,
|
|
26
|
+
openInTerminal,
|
|
27
|
+
} from "./launch";
|
|
28
|
+
|
|
29
|
+
const TERMINAL_TITLE = "Radar Investigation";
|
|
30
|
+
|
|
31
|
+
export function useContinueInAgentCommand(
|
|
32
|
+
run: RunSummary | null,
|
|
33
|
+
): string | null {
|
|
34
|
+
const { mcpReadOnly, localShell } = useCapabilitiesContext();
|
|
35
|
+
return run
|
|
36
|
+
? buildLaunchCommand(run, mcpEndpointUrl(mcpReadOnly), localShell)
|
|
37
|
+
: null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function ContinueInAgentButton({
|
|
41
|
+
run,
|
|
42
|
+
command,
|
|
43
|
+
}: {
|
|
44
|
+
run: RunSummary;
|
|
45
|
+
command: string;
|
|
46
|
+
}) {
|
|
47
|
+
const { localTerminal } = useCapabilitiesContext();
|
|
48
|
+
const label = launchAgentLabel(run);
|
|
49
|
+
const trustHint = launchTrustHint(run);
|
|
50
|
+
const [open, setOpen] = useState(false);
|
|
51
|
+
const [copy, setCopy] = useState<"idle" | "copied" | "failed">("idle");
|
|
52
|
+
const { shouldRender, isOpen } = useAnimatedUnmount(
|
|
53
|
+
open,
|
|
54
|
+
overlayExitMs("menu"),
|
|
55
|
+
);
|
|
56
|
+
const rootRef = useRef<HTMLDivElement>(null);
|
|
57
|
+
const menuRef = useRef<HTMLDivElement>(null);
|
|
58
|
+
const triggerRef = useRef<HTMLButtonElement>(null);
|
|
59
|
+
const menuId = useId();
|
|
60
|
+
const introId = useId();
|
|
61
|
+
const hintId = useId();
|
|
62
|
+
const copyingRef = useRef(false);
|
|
63
|
+
// The menu lives inside the Findings scroller, which clips it: open toward
|
|
64
|
+
// the side with room, and cap the height when neither side has enough.
|
|
65
|
+
const [placement, setPlacement] = useState<{
|
|
66
|
+
up: boolean;
|
|
67
|
+
maxHeight?: number;
|
|
68
|
+
}>({ up: false });
|
|
69
|
+
|
|
70
|
+
useLayoutEffect(() => {
|
|
71
|
+
if (!open || !shouldRender) return;
|
|
72
|
+
const trigger = rootRef.current?.getBoundingClientRect();
|
|
73
|
+
const menuHeight = menuRef.current?.scrollHeight ?? 0;
|
|
74
|
+
if (!trigger) return;
|
|
75
|
+
const bounds = rootRef.current
|
|
76
|
+
?.closest("[data-investigation-findings-scroll]")
|
|
77
|
+
?.getBoundingClientRect() ?? { top: 0, bottom: window.innerHeight };
|
|
78
|
+
const below = bounds.bottom - trigger.bottom - 8;
|
|
79
|
+
const above = trigger.top - bounds.top - 8;
|
|
80
|
+
const up = menuHeight > below && above > below;
|
|
81
|
+
const room = up ? above : below;
|
|
82
|
+
setPlacement({ up, maxHeight: menuHeight > room ? room : undefined });
|
|
83
|
+
}, [open, shouldRender]);
|
|
84
|
+
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
if (!open) return;
|
|
87
|
+
const onPointerDown = (event: PointerEvent) => {
|
|
88
|
+
if (!rootRef.current?.contains(event.target as Node)) setOpen(false);
|
|
89
|
+
};
|
|
90
|
+
// Capture phase, consumed: the Escape that closes this menu must not also
|
|
91
|
+
// close the investigation panel.
|
|
92
|
+
const onKeyDown = (event: globalThis.KeyboardEvent) => {
|
|
93
|
+
if (event.key !== "Escape") return;
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
setOpen(false);
|
|
97
|
+
triggerRef.current?.focus();
|
|
98
|
+
};
|
|
99
|
+
// Placement is measured on open, so moving the pane closes the menu.
|
|
100
|
+
const close = () => setOpen(false);
|
|
101
|
+
const onScroll = (event: Event) => {
|
|
102
|
+
if (!menuRef.current?.contains(event.target as Node)) close();
|
|
103
|
+
};
|
|
104
|
+
document.addEventListener("pointerdown", onPointerDown);
|
|
105
|
+
document.addEventListener("keydown", onKeyDown, true);
|
|
106
|
+
window.addEventListener("scroll", onScroll, true);
|
|
107
|
+
window.addEventListener("resize", close);
|
|
108
|
+
return () => {
|
|
109
|
+
document.removeEventListener("pointerdown", onPointerDown);
|
|
110
|
+
document.removeEventListener("keydown", onKeyDown, true);
|
|
111
|
+
window.removeEventListener("scroll", onScroll, true);
|
|
112
|
+
window.removeEventListener("resize", close);
|
|
113
|
+
};
|
|
114
|
+
}, [open]);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
if (open && isOpen) {
|
|
118
|
+
menuRef.current
|
|
119
|
+
?.querySelector<HTMLElement>("button")
|
|
120
|
+
?.focus({ preventScroll: true });
|
|
121
|
+
}
|
|
122
|
+
}, [open, isOpen]);
|
|
123
|
+
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
if (copy === "idle") return;
|
|
126
|
+
const t = window.setTimeout(() => setCopy("idle"), 1400);
|
|
127
|
+
return () => window.clearTimeout(t);
|
|
128
|
+
}, [copy]);
|
|
129
|
+
|
|
130
|
+
const toggle = () => {
|
|
131
|
+
setCopy("idle");
|
|
132
|
+
setOpen((v) => !v);
|
|
133
|
+
};
|
|
134
|
+
const runInTerminal = () => {
|
|
135
|
+
setOpen(false);
|
|
136
|
+
openInTerminal(command, TERMINAL_TITLE);
|
|
137
|
+
};
|
|
138
|
+
const copyCommand = () => {
|
|
139
|
+
// The clipboard fallback focuses a temporary textarea outside the menu.
|
|
140
|
+
copyingRef.current = true;
|
|
141
|
+
void copyText(command).then((ok) => {
|
|
142
|
+
copyingRef.current = false;
|
|
143
|
+
setCopy(ok ? "copied" : "failed");
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
// Only focus that lands somewhere else closes the menu. Safari does not
|
|
147
|
+
// focus a clicked button, so a click inside blurs to nothing; clicks outside
|
|
148
|
+
// are the pointerdown listener's job.
|
|
149
|
+
const onFocusLeave = (event: FocusEvent<HTMLDivElement>) => {
|
|
150
|
+
const next = event.relatedTarget as Node | null;
|
|
151
|
+
if (next && !copyingRef.current && !rootRef.current?.contains(next))
|
|
152
|
+
setOpen(false);
|
|
153
|
+
};
|
|
154
|
+
const onMenuKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
155
|
+
const items = Array.from(
|
|
156
|
+
menuRef.current?.querySelectorAll<HTMLElement>("button") ?? [],
|
|
157
|
+
);
|
|
158
|
+
if (items.length === 0) return;
|
|
159
|
+
// Tab moves between the panel's buttons; leaving either end closes it
|
|
160
|
+
// and goes back to the button that opened it.
|
|
161
|
+
if (event.key === "Tab") {
|
|
162
|
+
const edge = event.shiftKey ? items[0] : items[items.length - 1];
|
|
163
|
+
if (document.activeElement !== edge) return;
|
|
164
|
+
event.preventDefault();
|
|
165
|
+
setOpen(false);
|
|
166
|
+
triggerRef.current?.focus();
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return;
|
|
170
|
+
event.preventDefault();
|
|
171
|
+
const at = items.indexOf(document.activeElement as HTMLElement);
|
|
172
|
+
const step = event.key === "ArrowDown" ? 1 : -1;
|
|
173
|
+
items[(at + step + items.length) % items.length].focus();
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// One button that always opens the panel: the hand-off is rare and
|
|
177
|
+
// deliberate, so the panel can say what happens (and warn about Claude
|
|
178
|
+
// Code's trust prompt) before anything runs. Docked, the header is narrow
|
|
179
|
+
// and the label keeps only where it goes.
|
|
180
|
+
return (
|
|
181
|
+
<div
|
|
182
|
+
ref={rootRef}
|
|
183
|
+
onBlur={onFocusLeave}
|
|
184
|
+
className="relative inline-flex shrink-0"
|
|
185
|
+
>
|
|
186
|
+
<button
|
|
187
|
+
ref={triggerRef}
|
|
188
|
+
type="button"
|
|
189
|
+
onClick={toggle}
|
|
190
|
+
aria-haspopup="dialog"
|
|
191
|
+
aria-expanded={open}
|
|
192
|
+
aria-controls={shouldRender ? menuId : undefined}
|
|
193
|
+
aria-label={`Continue in ${label}`}
|
|
194
|
+
className="inline-flex items-center gap-1.5 whitespace-nowrap rounded-md border border-theme-border bg-theme-surface px-2 py-1 text-xs font-medium text-theme-text-primary hover:bg-theme-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
|
|
195
|
+
>
|
|
196
|
+
<TerminalSquare
|
|
197
|
+
className="h-3.5 w-3.5 text-theme-text-tertiary"
|
|
198
|
+
aria-hidden
|
|
199
|
+
/>
|
|
200
|
+
<span>
|
|
201
|
+
<span className="hidden @min-[640px]/diagnose-surface:inline">
|
|
202
|
+
Continue in{" "}
|
|
203
|
+
</span>
|
|
204
|
+
{label}…
|
|
205
|
+
</span>
|
|
206
|
+
</button>
|
|
207
|
+
{shouldRender && (
|
|
208
|
+
<div
|
|
209
|
+
ref={menuRef}
|
|
210
|
+
id={menuId}
|
|
211
|
+
role="dialog"
|
|
212
|
+
aria-label={`Continue in ${label}`}
|
|
213
|
+
aria-describedby={trustHint ? `${introId} ${hintId}` : introId}
|
|
214
|
+
inert={!open}
|
|
215
|
+
onKeyDown={onMenuKeyDown}
|
|
216
|
+
className={clsx(
|
|
217
|
+
"absolute right-0 z-30 w-[min(22rem,calc(100cqw-2rem))] rounded-lg border border-theme-border bg-theme-surface p-3 shadow-theme-lg",
|
|
218
|
+
placement.maxHeight !== undefined && "overflow-y-auto",
|
|
219
|
+
placement.up
|
|
220
|
+
? "bottom-full mb-1 origin-bottom-right"
|
|
221
|
+
: "top-full mt-1 origin-top-right",
|
|
222
|
+
TRANSITION_MENU,
|
|
223
|
+
isOpen
|
|
224
|
+
? "translate-y-0 scale-100 opacity-100"
|
|
225
|
+
: placement.up
|
|
226
|
+
? "translate-y-1 scale-[0.97] opacity-0"
|
|
227
|
+
: "-translate-y-1 scale-[0.97] opacity-0",
|
|
228
|
+
!open && "pointer-events-none",
|
|
229
|
+
)}
|
|
230
|
+
style={{
|
|
231
|
+
...overlayTransitionStyle(isOpen, "menu"),
|
|
232
|
+
maxHeight: placement.maxHeight,
|
|
233
|
+
}}
|
|
234
|
+
>
|
|
235
|
+
<p id={introId} className="text-xs text-theme-text-secondary">
|
|
236
|
+
Resumes this session in {label} with Radar's MCP attached.
|
|
237
|
+
</p>
|
|
238
|
+
{trustHint && (
|
|
239
|
+
<p
|
|
240
|
+
id={hintId}
|
|
241
|
+
data-continue-trust-hint
|
|
242
|
+
className="mt-1 text-xs text-theme-text-tertiary"
|
|
243
|
+
>
|
|
244
|
+
{trustHint}
|
|
245
|
+
</p>
|
|
246
|
+
)}
|
|
247
|
+
{localTerminal && (
|
|
248
|
+
<button
|
|
249
|
+
type="button"
|
|
250
|
+
onClick={runInTerminal}
|
|
251
|
+
className="btn-brand mt-3 inline-flex w-full items-center justify-center gap-1.5 rounded-md px-2.5 py-1.5 text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50"
|
|
252
|
+
>
|
|
253
|
+
<TerminalSquare className="h-3.5 w-3.5" aria-hidden />
|
|
254
|
+
Run in Radar terminal
|
|
255
|
+
</button>
|
|
256
|
+
)}
|
|
257
|
+
<p className="mt-3 text-[11px] text-theme-text-tertiary">
|
|
258
|
+
{localTerminal ? "Or paste it" : "Paste it"} where you run {label}:
|
|
259
|
+
</p>
|
|
260
|
+
<div className="mt-1 flex items-start gap-1 rounded-md border border-theme-border bg-theme-base py-1 pl-2 pr-1">
|
|
261
|
+
<code
|
|
262
|
+
data-continue-command
|
|
263
|
+
className="max-h-24 min-w-0 flex-1 overflow-y-auto whitespace-pre-wrap break-all py-0.5 font-mono text-[11px] leading-snug text-theme-text-secondary"
|
|
264
|
+
>
|
|
265
|
+
{command}
|
|
266
|
+
</code>
|
|
267
|
+
<button
|
|
268
|
+
type="button"
|
|
269
|
+
onClick={copyCommand}
|
|
270
|
+
aria-label={
|
|
271
|
+
copy === "copied"
|
|
272
|
+
? "Command copied"
|
|
273
|
+
: copy === "failed"
|
|
274
|
+
? "Copy failed"
|
|
275
|
+
: "Copy command"
|
|
276
|
+
}
|
|
277
|
+
aria-live="polite"
|
|
278
|
+
className={clsx(
|
|
279
|
+
"inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-1 text-[11px] font-medium hover:bg-theme-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/50",
|
|
280
|
+
copy === "copied"
|
|
281
|
+
? "text-theme-text-primary"
|
|
282
|
+
: copy === "failed"
|
|
283
|
+
? "text-warning-text"
|
|
284
|
+
: "text-theme-text-tertiary hover:text-theme-text-primary",
|
|
285
|
+
)}
|
|
286
|
+
>
|
|
287
|
+
{copy === "copied" ? (
|
|
288
|
+
<>
|
|
289
|
+
<Check className="h-3.5 w-3.5 text-success" aria-hidden />
|
|
290
|
+
Copied
|
|
291
|
+
</>
|
|
292
|
+
) : copy === "failed" ? (
|
|
293
|
+
"Copy failed"
|
|
294
|
+
) : (
|
|
295
|
+
<Copy className="h-3.5 w-3.5" aria-hidden />
|
|
296
|
+
)}
|
|
297
|
+
</button>
|
|
298
|
+
</div>
|
|
299
|
+
</div>
|
|
300
|
+
)}
|
|
301
|
+
</div>
|
|
302
|
+
);
|
|
303
|
+
}
|