@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.
Files changed (173) hide show
  1. package/README.md +1 -1
  2. package/package.json +5 -5
  3. package/src/App.tsx +31 -5
  4. package/src/api/application-evidence.ts +63 -0
  5. package/src/api/argoSync.test.ts +22 -0
  6. package/src/api/client.audit-gating.test.tsx +48 -0
  7. package/src/api/client.kueuePosition.test.ts +32 -0
  8. package/src/api/client.kueueQueueWorkloads.test.tsx +71 -0
  9. package/src/api/client.resource-identity.test.ts +3 -0
  10. package/src/api/client.resourceIssues.test.tsx +239 -0
  11. package/src/api/client.resourcePath.test.ts +3 -0
  12. package/src/api/client.ts +285 -55
  13. package/src/api/config.ts +21 -0
  14. package/src/api/diagnose.ts +4 -0
  15. package/src/api/radarFeatures.render.test.tsx +33 -1
  16. package/src/api/radarFeatures.test.ts +47 -0
  17. package/src/api/radarFeatures.ts +40 -1
  18. package/src/api/rbac.settled.test.tsx +42 -0
  19. package/src/api/rbac.test.ts +18 -0
  20. package/src/api/rbac.ts +37 -7
  21. package/src/api/traffic.ts +9 -4
  22. package/src/api/usage-data.fixtures.ts +3 -1
  23. package/src/api/usage-data.test.tsx +134 -0
  24. package/src/api/usage-data.ts +35 -7
  25. package/src/api/workloadPodsPolling.test.ts +26 -0
  26. package/src/components/CloudConnectFlow.test.tsx +86 -0
  27. package/src/components/CloudConnectFlow.tsx +65 -27
  28. package/src/components/CloudFunnelButton.test.tsx +140 -5
  29. package/src/components/CloudFunnelButton.tsx +50 -9
  30. package/src/components/ConnectionErrorView.test.tsx +34 -0
  31. package/src/components/ConnectionErrorView.tsx +35 -11
  32. package/src/components/ContextSwitcher.tsx +5 -2
  33. package/src/components/SwitchAwareConnectionError.test.tsx +43 -0
  34. package/src/components/SwitchAwareConnectionError.tsx +85 -0
  35. package/src/components/application-evidence/ApplicationEvidenceAction.flow.test.tsx +234 -0
  36. package/src/components/application-evidence/ApplicationEvidenceAction.test.tsx +144 -0
  37. package/src/components/application-evidence/ApplicationEvidenceAction.tsx +218 -0
  38. package/src/components/capacity/CapacityDemand.tsx +3 -2
  39. package/src/components/capacity/demandSummary.test.ts +38 -0
  40. package/src/components/capacity/shared.tsx +12 -1
  41. package/src/components/cost/ApplicationCostTab.tsx +4 -0
  42. package/src/components/cost/CostTrendChart.tsx +2 -0
  43. package/src/components/cost/WorkloadCostTab.tsx +4 -0
  44. package/src/components/cost/source.test.ts +5 -0
  45. package/src/components/cost/source.ts +11 -0
  46. package/src/components/diagnose/AIMarkdown.tsx +3 -0
  47. package/src/components/diagnose/AgentSetupNotice.test.tsx +17 -0
  48. package/src/components/diagnose/AgentSetupNotice.tsx +21 -3
  49. package/src/components/diagnose/ContinueInAgentButton.mounted.test.tsx +182 -0
  50. package/src/components/diagnose/ContinueInAgentButton.test.tsx +128 -0
  51. package/src/components/diagnose/ContinueInAgentButton.tsx +303 -0
  52. package/src/components/diagnose/DiagnoseContext.question.test.tsx +1 -1
  53. package/src/components/diagnose/DiagnoseContext.tsx +68 -2
  54. package/src/components/diagnose/DiagnoseSurface.tsx +58 -113
  55. package/src/components/diagnose/ExampleInvestigationLink.tsx +20 -0
  56. package/src/components/diagnose/Home.test.tsx +26 -0
  57. package/src/components/diagnose/Home.tsx +20 -1
  58. package/src/components/diagnose/InvestigationEvidenceSections.tsx +45 -22
  59. package/src/components/diagnose/InvestigationView.tsx +94 -26
  60. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +450 -0
  61. package/src/components/diagnose/LocalDiagnoseAction.tsx +354 -35
  62. package/src/components/diagnose/NextStepJump.test.tsx +92 -0
  63. package/src/components/diagnose/NextStepJump.tsx +75 -0
  64. package/src/components/diagnose/QuestionComposer.tsx +8 -0
  65. package/src/components/diagnose/exampleInvestigation.events.json +191 -0
  66. package/src/components/diagnose/exampleInvestigation.loadFailure.test.tsx +94 -0
  67. package/src/components/diagnose/exampleInvestigation.test.tsx +248 -0
  68. package/src/components/diagnose/exampleInvestigation.ts +121 -0
  69. package/src/components/diagnose/investigationCase.test.tsx +9 -1
  70. package/src/components/diagnose/investigationEvidence/adapters/applicationFindings.test.ts +739 -0
  71. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +50 -2
  72. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +9 -0
  73. package/src/components/diagnose/investigationEvidence/builder.ts +30 -0
  74. package/src/components/diagnose/investigationEvidence/observations.ts +121 -2
  75. package/src/components/diagnose/investigationEvidence/projection.test.ts +85 -3
  76. package/src/components/diagnose/investigationEvidence/types.ts +5 -0
  77. package/src/components/diagnose/investigationState.ts +28 -0
  78. package/src/components/diagnose/lastInvestigation.test.ts +95 -0
  79. package/src/components/diagnose/lastInvestigation.ts +58 -0
  80. package/src/components/diagnose/launch.test.ts +125 -1
  81. package/src/components/diagnose/launch.ts +57 -10
  82. package/src/components/diagnose/toolCallLabel.test.ts +10 -4
  83. package/src/components/execution/BatchExecutionView.tsx +24 -11
  84. package/src/components/execution/JobSetAdmission.test.tsx +42 -0
  85. package/src/components/execution/JobSetAdmission.tsx +18 -3
  86. package/src/components/execution/JobSetMemberComparison.tsx +2 -1
  87. package/src/components/execution/runState.test.ts +14 -0
  88. package/src/components/execution/runState.ts +8 -0
  89. package/src/components/gitops/GitOpsView.rollbackGate.test.tsx +202 -0
  90. package/src/components/gitops/GitOpsView.syncRequest.test.tsx +369 -0
  91. package/src/components/gitops/GitOpsView.tsx +86 -17
  92. package/src/components/gitops/RemoteDestinationCloudHint.tsx +2 -3
  93. package/src/components/gitops/destination-toast.test.ts +1 -1
  94. package/src/components/gitops/destination-toast.ts +2 -2
  95. package/src/components/home/ClusterHealthCard.tsx +1 -1
  96. package/src/components/home/HomeAgentBlock.test.tsx +31 -3
  97. package/src/components/home/HomeAgentBlock.tsx +13 -4
  98. package/src/components/home/HomeDiagramCard.tsx +47 -0
  99. package/src/components/home/HomeView.tsx +81 -41
  100. package/src/components/home/MCPSetupDialog.test.tsx +95 -5
  101. package/src/components/home/MCPSetupDialog.tsx +30 -5
  102. package/src/components/home/ProblemsPanel.investigate.test.tsx +171 -0
  103. package/src/components/home/ProblemsPanel.test.tsx +3 -1
  104. package/src/components/home/TopologyPreview.test.tsx +73 -0
  105. package/src/components/home/TopologyPreview.tsx +120 -233
  106. package/src/components/home/TrafficSummary.test.tsx +63 -0
  107. package/src/components/home/TrafficSummary.tsx +135 -138
  108. package/src/components/home/mcpToolCatalog.ts +23 -10
  109. package/src/components/issues/IssuesPane.test.ts +11 -0
  110. package/src/components/issues/IssuesPane.tsx +15 -5
  111. package/src/components/issues/uncheckedSources.test.ts +20 -1
  112. package/src/components/issues/uncheckedSources.ts +18 -0
  113. package/src/components/kueue/KueuePendingPosition.tsx +35 -0
  114. package/src/components/kueue/useRelatedObjects.test.tsx +219 -0
  115. package/src/components/kueue/useRelatedReads.test.ts +56 -0
  116. package/src/components/kueue/useRelatedReads.ts +205 -0
  117. package/src/components/logs/MultiPodLogsTab.test.tsx +93 -0
  118. package/src/components/logs/MultiPodLogsTab.tsx +120 -0
  119. package/src/components/logs/PodLogsUnavailable.test.tsx +18 -0
  120. package/src/components/logs/PodLogsUnavailable.tsx +21 -0
  121. package/src/components/logs/RayClusterLogsTab.reselect.test.tsx +67 -0
  122. package/src/components/logs/RayClusterLogsTab.test.tsx +167 -0
  123. package/src/components/logs/RayClusterLogsTab.tsx +109 -0
  124. package/src/components/logs/ScheduledWorkloadLogsViewer.tsx +3 -2
  125. package/src/components/logs/rayClusterPods.ts +32 -0
  126. package/src/components/outageSince.test.ts +21 -0
  127. package/src/components/outageSince.ts +10 -0
  128. package/src/components/resource/PrometheusCharts.overlays.test.ts +12 -0
  129. package/src/components/resource/PrometheusCharts.tsx +3 -40
  130. package/src/components/resources/crd/CRDSchemaTab.test.tsx +28 -0
  131. package/src/components/resources/crd/CRDSchemaTab.tsx +13 -0
  132. package/src/components/resources/crd/host.tsx +14 -0
  133. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.test.tsx +27 -0
  134. package/src/components/resources/renderers/CustomResourceDefinitionRenderer.tsx +12 -0
  135. package/src/components/resources/renderers/JobAdmissionRenderers.test.tsx +4 -1
  136. package/src/components/resources/renderers/JobAdmissionRenderers.tsx +4 -3
  137. package/src/components/resources/renderers/KueueHostRenderers.test.tsx +117 -0
  138. package/src/components/resources/renderers/KueueQueueRenderers.test.tsx +97 -0
  139. package/src/components/resources/renderers/KueueQueueRenderers.tsx +139 -0
  140. package/src/components/resources/renderers/KueueWorkloadRenderer.test.tsx +7 -1
  141. package/src/components/resources/renderers/KueueWorkloadRenderer.tsx +47 -7
  142. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.test.tsx +67 -0
  143. package/src/components/resources/renderers/OpenTelemetryCollectorRenderer.tsx +31 -0
  144. package/src/components/resources/renderers/RayClusterRenderer.test.tsx +81 -3
  145. package/src/components/resources/renderers/RayClusterRenderer.tsx +19 -4
  146. package/src/components/traffic/TrafficView.tsx +3 -3
  147. package/src/components/ui/command-items-crd.test.tsx +23 -0
  148. package/src/components/ui/command-items.ts +2 -1
  149. package/src/components/useContextSwitchFlow.test.tsx +61 -0
  150. package/src/components/useContextSwitchFlow.tsx +21 -4
  151. package/src/components/whats-new/WhatsNew.test.ts +10 -3
  152. package/src/components/whats-new/WhatsNew.tsx +5 -1
  153. package/src/components/whats-new/WhatsNewDialog.test.tsx +17 -3
  154. package/src/components/whats-new/releaseNotes.ts +77 -4
  155. package/src/components/workload/RelatedFindingsSection.test.tsx +126 -0
  156. package/src/components/workload/RelatedFindingsSection.tsx +80 -0
  157. package/src/components/workload/WorkloadView.test.ts +10 -1
  158. package/src/components/workload/WorkloadView.tsx +85 -98
  159. package/src/components/workload/issueResourceOpener.test.ts +20 -0
  160. package/src/components/workload/issueResourceOpener.ts +17 -0
  161. package/src/context/ConnectionContext.tsx +133 -60
  162. package/src/context/ConnectionProvider.retry.test.tsx +176 -0
  163. package/src/context/ContextSwitchContext.tsx +14 -1
  164. package/src/context/DiagnoseCustomization.tsx +3 -0
  165. package/src/context/clusterConnected.ts +10 -0
  166. package/src/contexts/CapabilitiesContext.tsx +6 -4
  167. package/src/hooks/useElementSize.ts +30 -0
  168. package/src/integrations/resourceHost.test.tsx +1 -0
  169. package/src/integrations/resourceHost.ts +5 -1
  170. package/src/integrations/resourceHosts.test.tsx +21 -4
  171. package/src/integrations/resourceHosts.tsx +12 -0
  172. package/src/main.tsx +5 -0
  173. package/src/utils/related-findings.ts +46 -0
@@ -1,6 +1,10 @@
1
1
  import { describe, expect, it } from "vitest";
2
2
  import type { RunSummary } from "../../api/diagnose";
3
- import { buildLaunchCommand, launchAgentLabel } from "./launch";
3
+ import {
4
+ buildLaunchCommand,
5
+ launchAgentLabel,
6
+ launchTrustHint,
7
+ } from "./launch";
4
8
 
5
9
  describe("OpenCode terminal handoff", () => {
6
10
  it("uses the correct label without launching a different agent", () => {
@@ -21,3 +25,123 @@ describe("OpenCode terminal handoff", () => {
21
25
  expect(buildLaunchCommand(run, "http://localhost:9280/mcp")).toBeNull();
22
26
  });
23
27
  });
28
+
29
+ describe("launchTrustHint", () => {
30
+ const base: RunSummary = {
31
+ id: "run-test",
32
+ kind: "Deployment",
33
+ group: "apps",
34
+ namespace: "default",
35
+ name: "demo",
36
+ context: "test",
37
+ agent: "claude",
38
+ status: "done",
39
+ sessionId: "ses_1",
40
+ createdAt: "2026-09-21T00:00:00Z",
41
+ updatedAt: "2026-09-21T00:00:00Z",
42
+ };
43
+
44
+ it("warns about Claude Code's folder trust prompt", () => {
45
+ expect(launchTrustHint(base)).toMatch(/trust Radar's agent folder/);
46
+ });
47
+
48
+ it("stays quiet for agents without that prompt", () => {
49
+ expect(launchTrustHint({ ...base, agent: "codex" })).toBeNull();
50
+ });
51
+ });
52
+
53
+ describe("Claude Code resume command", () => {
54
+ const run: RunSummary = {
55
+ id: "run-test",
56
+ kind: "Deployment",
57
+ group: "apps",
58
+ namespace: "default",
59
+ name: "demo",
60
+ context: "test",
61
+ agent: "claude",
62
+ status: "done",
63
+ sessionId: "ses_1",
64
+ createdAt: "2026-09-21T00:00:00Z",
65
+ updatedAt: "2026-09-21T00:00:00Z",
66
+ };
67
+
68
+ it("resumes from the folder Radar runs Claude in", () => {
69
+ expect(buildLaunchCommand(run, "http://localhost:9280/mcp", "posix")).toBe(
70
+ 'mkdir -p -m 700 ~/.radar/agent && cd ~/.radar/agent && claude --resume \'ses_1\' --mcp-config \'{"mcpServers":{"radar":{"type":"http","url":"http://localhost:9280/mcp"}}}\'',
71
+ );
72
+ });
73
+
74
+ // Windows PowerShell 5.1 has no && and strips the quotes inside a native
75
+ // argument; --% passes the JSON through with C-runtime escaping instead.
76
+ it("uses a form Windows PowerShell 5.1 runs", () => {
77
+ expect(
78
+ buildLaunchCommand(run, "http://localhost:9280/mcp", "powershell"),
79
+ ).toBe(
80
+ 'New-Item -ItemType Directory -Force -Path "$HOME\\.radar\\agent" -ErrorAction Stop | Out-Null; ' +
81
+ 'Set-Location -LiteralPath "$HOME\\.radar\\agent" -ErrorAction Stop; ' +
82
+ "& (Get-Command claude -CommandType Application -ErrorAction Stop)[0].Source --% " +
83
+ '--resume ses_1 --mcp-config "{\\"mcpServers\\":{\\"radar\\":{\\"type\\":\\"http\\",\\"url\\":\\"http://localhost:9280/mcp\\"}}}"',
84
+ );
85
+ });
86
+
87
+ it("gives Codex the same pass-through under PowerShell", () => {
88
+ expect(
89
+ buildLaunchCommand(
90
+ { ...run, agent: "codex", sessionId: "019a-b2" },
91
+ "http://localhost:9280/mcp",
92
+ "powershell",
93
+ ),
94
+ ).toBe(
95
+ "& (Get-Command codex -CommandType Application -ErrorAction Stop)[0].Source --% " +
96
+ 'resume 019a-b2 -c "mcp_servers.radar.url=\\"http://localhost:9280/mcp\\""',
97
+ );
98
+ });
99
+
100
+ it("offers no PowerShell command it can't pass through intact", () => {
101
+ expect(
102
+ buildLaunchCommand(
103
+ { ...run, sessionId: 'a"b' },
104
+ "http://localhost:9280/mcp",
105
+ "powershell",
106
+ ),
107
+ ).toBeNull();
108
+ expect(
109
+ buildLaunchCommand(run, "http://localhost:9280/%41/mcp", "powershell"),
110
+ ).toBeNull();
111
+ });
112
+ });
113
+
114
+ describe("an agent the hand-off doesn't know", () => {
115
+ const base: RunSummary = {
116
+ id: "run-x",
117
+ kind: "Deployment",
118
+ group: "apps",
119
+ namespace: "default",
120
+ name: "demo",
121
+ context: "test",
122
+ status: "done",
123
+ sessionId: "ses_1",
124
+ createdAt: "2026-09-21T00:00:00Z",
125
+ updatedAt: "2026-09-21T00:00:00Z",
126
+ };
127
+
128
+ it("is named by its own label, with no Claude warning and no command", () => {
129
+ const run = { ...base, agent: "gemini" };
130
+ expect(launchAgentLabel(run)).toBe("Gemini CLI");
131
+ expect(launchTrustHint(run)).toBeNull();
132
+ expect(
133
+ buildLaunchCommand(run, "http://localhost:9280/mcp", "posix"),
134
+ ).toBeNull();
135
+ });
136
+
137
+ it("falls back to the agent's own name when Radar has no label for it", () => {
138
+ expect(launchAgentLabel({ ...base, agent: "newagent" })).toBe("newagent");
139
+ });
140
+
141
+ it("still resumes a run from before Radar recorded the agent as Claude Code", () => {
142
+ expect(launchAgentLabel(base)).toBe("Claude Code");
143
+ expect(
144
+ buildLaunchCommand(base, "http://localhost:9280/mcp", "posix"),
145
+ ).toMatch(/claude --resume 'ses_1'/);
146
+ });
147
+ });
@@ -4,6 +4,7 @@
4
4
  // from the contained in-panel engine. The endpoint follows the server MCP mode.
5
5
  // In full mode, the client approval prompts gate changes.
6
6
  import { type RunSummary } from "../../api/diagnose";
7
+ import { agentLabelFor } from "./DiagnoseContext";
7
8
 
8
9
  // sq POSIX-single-quotes a string so it's a safe single shell argument regardless
9
10
  // of content. Findings carry backticks, quotes, and newlines — inside single
@@ -13,11 +14,26 @@ function sq(s: string): string {
13
14
  return "'" + s.replace(/'/g, "'\\''") + "'";
14
15
  }
15
16
 
17
+ // Radar also creates it before each Claude turn, but a run from before Radar
18
+ // used it can be continued first. Unquoted so the shell expands ~.
19
+ const AGENT_DIR = "~/.radar/agent";
20
+
21
+ // A run with no recorded agent predates recording it, when Claude Code was
22
+ // the only one. Any other agent is named by its own label, with no Claude
23
+ // specifics, and gets no resume command it hasn't been taught.
24
+ function isClaudeRun(run: RunSummary): boolean {
25
+ return !run.agent || run.agent === "claude";
26
+ }
27
+
16
28
  export function launchAgentLabel(run: RunSummary): string {
17
- if (run.agent === "codex") return "Codex";
18
- if (run.agent === "opencode") return "OpenCode";
19
- if (run.agent === "cursor-agent") return "Cursor";
20
- return "Claude Code";
29
+ return isClaudeRun(run) ? "Claude Code" : agentLabelFor(run.agent ?? "");
30
+ }
31
+
32
+ // Claude Code asks once whether to trust the folder the resume runs in, and
33
+ // its default answer exits, so a user who presses Enter loses the session.
34
+ export function launchTrustHint(run: RunSummary): string | null {
35
+ if (!isClaudeRun(run)) return null;
36
+ return "The first time, Claude Code may ask to trust Radar's agent folder. Select Yes before pressing Enter; the default exits.";
21
37
  }
22
38
 
23
39
  // openInTerminal asks App (which owns the DockProvider) to open Radar's local
@@ -40,6 +56,7 @@ export function openInTerminal(command: string, title: string) {
40
56
  export function buildLaunchCommand(
41
57
  run: RunSummary,
42
58
  mcpUrl: string,
59
+ shell: "posix" | "powershell" = "posix",
43
60
  ): string | null {
44
61
  if (!run.sessionId || run.status === "stale") return null;
45
62
 
@@ -55,15 +72,45 @@ export function buildLaunchCommand(
55
72
  }
56
73
  if (run.agent === "codex") {
57
74
  // Codex threads are stored globally by id (cwd-independent); -c re-attaches MCP.
75
+ if (shell === "powershell") {
76
+ if (!psSafe(run.sessionId, mcpUrl)) return null;
77
+ return psNative(
78
+ "codex",
79
+ `resume ${run.sessionId} -c "mcp_servers.radar.url=\\"${mcpUrl}\\""`,
80
+ );
81
+ }
58
82
  return `codex resume ${sq(run.sessionId)} -c ${sq(`mcp_servers.radar.url="${mcpUrl}"`)}`;
59
83
  }
60
- // Claude Code: --resume is cwd-scoped, and Radar runs its headless sessions from
61
- // the home dir (see claudeAgent). The Radar terminal starts there too, but a user
62
- // pasting this into their own terminal is usually in a project dir — so prefix
63
- // `cd ~` to resolve the session wherever it's run (harmless in the home-dir case).
64
- // --mcp-config MERGES radar alongside the user's own servers.
84
+ if (!isClaudeRun(run)) return null;
85
+ // Claude Code: resume from the folder Radar runs Claude turns in (claudeWorkDir
86
+ // in agent_claude.go). Older versions find a session only from the folder it
87
+ // was created in, and Claude Code remembers the folder-trust answer there,
88
+ // which it never does for the home dir. --mcp-config MERGES radar alongside
89
+ // the user's own servers.
65
90
  const cfg = JSON.stringify({
66
91
  mcpServers: { radar: { type: "http", url: mcpUrl } },
67
92
  });
68
- return `cd ~ && claude --resume ${sq(run.sessionId)} --mcp-config ${sq(cfg)}`;
93
+ if (shell === "powershell") {
94
+ if (!psSafe(run.sessionId, mcpUrl)) return null;
95
+ const dir = '"$HOME\\.radar\\agent"';
96
+ return `New-Item -ItemType Directory -Force -Path ${dir} -ErrorAction Stop | Out-Null; Set-Location -LiteralPath ${dir} -ErrorAction Stop; ${psNative("claude", `--resume ${run.sessionId} --mcp-config "${cfg.replace(/"/g, '\\"')}"`)}`;
97
+ }
98
+ return `mkdir -p -m 700 ${AGENT_DIR} && cd ${AGENT_DIR} && claude --resume ${sq(run.sessionId)} --mcp-config ${sq(cfg)}`;
99
+ }
100
+
101
+ // Radar's terminal on Windows is Windows PowerShell 5.1, which has no `&&`
102
+ // or `mkdir -p`, and drops the double quotes inside an argument it passes to a
103
+ // program. `--%` hands the rest of the line to the program unparsed, where the
104
+ // C runtime turns \" back into ". It applies to programs, not to npm's .ps1
105
+ // shims, so the program is found as an application (.exe or .cmd). A failing
106
+ // step stops the line (-ErrorAction Stop), so the agent never starts in the
107
+ // wrong folder.
108
+ function psNative(program: string, rawArgs: string): string {
109
+ return `& (Get-Command ${program} -CommandType Application -ErrorAction Stop)[0].Source --% ${rawArgs}`;
110
+ }
111
+
112
+ // The --% text can't carry a quote, a % or a backslash, so a session id or URL
113
+ // holding one gets no command rather than a broken one.
114
+ function psSafe(sessionId: string, mcpUrl: string): boolean {
115
+ return /^[\w-]+$/.test(sessionId) && !/["%\\]/.test(mcpUrl);
69
116
  }
@@ -15,11 +15,17 @@ describe("describeToolCall", () => {
15
15
  });
16
16
 
17
17
  it("scopes the runtime inventory to its namespace", () => {
18
- expect(describeToolCall("get_runtime_versions", JSON.stringify({ runtime: "php" }))).toBe(
19
- "Reading runtime versions of running images",
20
- );
21
18
  expect(
22
- describeToolCall("get_runtime_versions", JSON.stringify({ namespace: "shop", runtime: "php" })),
19
+ describeToolCall(
20
+ "get_runtime_versions",
21
+ JSON.stringify({ runtime: "php" }),
22
+ ),
23
+ ).toBe("Reading runtime versions of running images");
24
+ expect(
25
+ describeToolCall(
26
+ "get_runtime_versions",
27
+ JSON.stringify({ namespace: "shop", runtime: "php" }),
28
+ ),
23
29
  ).toBe("Reading runtime versions of running images in shop");
24
30
  });
25
31
 
@@ -30,6 +30,7 @@ import { useIsAuthEnabled } from '../../contexts/CapabilitiesContext'
30
30
  import { executionDefinitionDiffers, executionDefinitionSummary, type ExecutionDefinitionSummary, type ExecutionUnitSummary } from './execution-definition'
31
31
  import { batchRunHasContainerOutcome, batchRunNextStep, isFailedRunPhase, type BatchRunNextStep } from './batch-run-actions'
32
32
  import { JobSetAdmission } from './JobSetAdmission'
33
+ import { runStateLabel } from './runState'
33
34
 
34
35
  const EMPTY_RUNS: WorkloadRun[] = []
35
36
  const SCHEDULED_KINDS = new Set(['CronJob', 'CronWorkflow', 'WorkflowTemplate', 'ClusterWorkflowTemplate', 'ScaledJob', 'JobSet'])
@@ -122,7 +123,15 @@ interface BatchExecutionProps {
122
123
  viewNamespaces?: string[]
123
124
  }
124
125
 
125
- export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace, name, resource, selectedRunKey = '', canViewLogs = false, onSelectRun, onSwitchToLogs, onSwitchToTimeline, onNavigateToResource, viewNamespaces }: BatchExecutionProps) {
126
+ export function BatchExecutionFullscreen(props: BatchExecutionProps) {
127
+ const { resource, namespace, name, onNavigateToResource } = props
128
+ if (resource.apiVersion !== 'batch/v1' || resource.kind !== 'Job') return <BatchExecutionContent {...props} />
129
+ return <JobSetAdmission resource={resource} namespace={namespace} name={name} onNavigate={onNavigateToResource}>
130
+ {(admissionContent, kueueManaged) => <BatchExecutionContent {...props} admissionContent={admissionContent} kueueManaged={kueueManaged} />}
131
+ </JobSetAdmission>
132
+ }
133
+
134
+ function BatchExecutionContent({ leadContent, kind, apiKind, namespace, name, resource, selectedRunKey = '', canViewLogs = false, onSelectRun, onSwitchToLogs, onSwitchToTimeline, onNavigateToResource, viewNamespaces, admissionContent, kueueManaged = false }: BatchExecutionProps & { admissionContent?: ReactNode; kueueManaged?: boolean }) {
126
135
  const scheduled = SCHEDULED_KINDS.has(kind)
127
136
  const clusterScoped = kind === 'ClusterWorkflowTemplate'
128
137
  const jobSetRoot = isJobSetV1Alpha2(resource)
@@ -179,6 +188,7 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
179
188
  }, [runsQuery.data, runsQuery.isPlaceholderData, runs, resolvedRuns, selectedRunKey, defaultRun, onSelectRun, selectionMissing])
180
189
 
181
190
  const selectedRun = selectionMissing ? undefined : resolvedRuns.find((run) => workloadRunKey(run) === selectedRunKey) ?? defaultRun
191
+ const selectedRunHeldByKueue = kueueManaged && selectedRun?.kind === 'jobs' && selectedRun.namespace === namespace && selectedRun.name === name && selectedRun.phase === 'Suspended'
182
192
  useEffect(() => {
183
193
  if (!selectedRun) return
184
194
  const selectionChanged = previousSelection.current !== selectedRunKey
@@ -355,7 +365,8 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
355
365
  <JobSetRenderer data={resource} mode="overview" shownMemberCounts={shownMemberCounts} onSelectRole={memberCollection ? selectRole : undefined} />
356
366
  </section>
357
367
  )}
358
- {(jobSetRoot || (resource.apiVersion === 'batch/v1' && resource.kind === 'Job')) && <JobSetAdmission resource={resource} namespace={namespace} name={name} onNavigate={onNavigateToResource} />}
368
+ {admissionContent}
369
+ {jobSetRoot && <JobSetAdmission resource={resource} namespace={namespace} name={name} onNavigate={onNavigateToResource} />}
359
370
  {memberShell && <JobSetMemberComparison
360
371
  runs={runs} total={runsQuery.data?.total ?? 0} filteredTotal={runsQuery.data?.filteredTotal ?? runs.length}
361
372
  truncated={runsQuery.data?.truncated ?? false} loading={runsQuery.isLoading} error={runsQuery.error}
@@ -407,7 +418,7 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
407
418
  {selectedResourceQuery.isFetching && <span>refreshing</span>}
408
419
  </div>
409
420
  </div>
410
- <span className={clsx('badge', phaseBadgeClass(selectedRun.phase))}>{selectedRun.phase}{selectedRun.deleting ? ' · deleting' : ''}</span>
421
+ <span className={clsx('badge', selectedRunHeldByKueue ? 'status-neutral' : phaseBadgeClass(selectedRun.phase))}>{selectedRunHeldByKueue ? `Held by Kueue until admitted${selectedRun.deleting ? ' · deleting' : ''}` : runStateLabel(selectedRun)}</span>
411
422
  </div>
412
423
  {memberCollection && <div className="flex flex-wrap items-center gap-3 border-b border-theme-border px-4 py-2 text-xs">
413
424
  {!runs.some(run => workloadRunKey(run) === selectedRunKey) && <span className="text-theme-text-secondary">Selected Job is outside the current filter or shown window.</span>}
@@ -470,7 +481,7 @@ export function BatchExecutionFullscreen({ leadContent, kind, apiKind, namespace
470
481
  <JobSetRenderer data={resource} mode="configuration" />
471
482
  ) : (
472
483
  <SourceFacts
473
- source={sourceFacts(kind, definitionResource, runs)}
484
+ source={sourceFacts(kind, definitionResource, runs, kueueManaged)}
474
485
  namespace={selectedRun?.namespace || namespace}
475
486
  definitionLoading={Boolean(referencedDefinitionTarget) && referencedDefinitionQuery.isLoading}
476
487
  definitionError={referencedDefinitionTarget ? referencedDefinitionQuery.error : undefined}
@@ -564,7 +575,7 @@ function scaledJobTone(resource: any): 'info' | 'warning' | 'success' | 'error'
564
575
  }
565
576
  }
566
577
 
567
- function sourceFacts(kind: string, resource: any, runs: WorkloadRun[]) {
578
+ function sourceFacts(kind: string, resource: any, runs: WorkloadRun[], kueueManaged = false) {
568
579
  const spec = resource?.spec ?? {}
569
580
  const status = resource?.status ?? {}
570
581
  const latest = pickLatestRun(runs)
@@ -649,9 +660,11 @@ function sourceFacts(kind: string, resource: any, runs: WorkloadRun[]) {
649
660
  }
650
661
  }
651
662
  if (kind === 'Job') {
663
+ const phase = jobPhase(resource)
664
+ const heldByKueue = kueueManaged && phase === 'Suspended'
652
665
  return {
653
- state: jobPhase(resource),
654
- stateTone: phaseTone(jobPhase(resource)),
666
+ state: heldByKueue ? 'Held by Kueue until admitted' : phase,
667
+ stateTone: heldByKueue ? 'info' : phaseTone(phase),
655
668
  progress: latest?.progress,
656
669
  duration: latest ? formatRunDuration(latest) : '',
657
670
  work: latest ? workCount(latest) : '',
@@ -678,7 +691,7 @@ function SourceFacts({ source, namespace, definitionLoading = false, definitionE
678
691
  return (
679
692
  <>
680
693
  <div className="grid grid-cols-2 gap-2">
681
- {source.state !== 'Definition' && <FactTile label="State" value={source.state} tone={source.stateTone} />}
694
+ {source.state !== 'Definition' && <FactTile label="State" value={source.state} tone={source.stateTone} wrap />}
682
695
  {source.schedule && <FactTile label="Schedule" value={source.schedule} mono />}
683
696
  {source.concurrency && <FactTile label="Concurrency" value={source.concurrency} />}
684
697
  </div>
@@ -1273,16 +1286,16 @@ function RunRailButton({ run, selected, showNamespace, onClick }: { run: Workloa
1273
1286
  {formatRunTime(run) || 'time unknown'}{formatRunDuration(run) ? ` · ${formatRunDuration(run)}` : ''} · {workCount(run)}
1274
1287
  </span>
1275
1288
  </span>
1276
- <span className={clsx('badge-sm shrink-0', phaseBadgeClass(run.phase))}>{shortPhase(run.phase)}{run.deleting ? ' · deleting' : ''}</span>
1289
+ <span className={clsx('badge-sm shrink-0', phaseBadgeClass(run.phase))}>{runStateLabel(run, shortPhase)}</span>
1277
1290
  </button>
1278
1291
  )
1279
1292
  }
1280
1293
 
1281
- function FactTile({ label, value, tone, mono }: { label: string; value: string | number; tone?: string; mono?: boolean }) {
1294
+ function FactTile({ label, value, tone, mono, wrap = false }: { label: string; value: string | number; tone?: string; mono?: boolean; wrap?: boolean }) {
1282
1295
  return (
1283
1296
  <div className="rounded-md border border-theme-border bg-theme-surface px-3 py-2">
1284
1297
  <div className="text-[10px] font-medium uppercase tracking-wide text-theme-text-tertiary">{label}</div>
1285
- <div className={clsx('mt-1 truncate text-sm font-semibold text-theme-text-primary', mono && 'font-mono', tone && phaseTextClass(tone))}>{value}</div>
1298
+ <div className={clsx('mt-1 text-sm font-semibold text-theme-text-primary', wrap ? 'break-words' : 'truncate', mono && 'font-mono', tone && phaseTextClass(tone))}>{value}</div>
1286
1299
  </div>
1287
1300
  )
1288
1301
  }
@@ -1,6 +1,8 @@
1
1
  import { renderToStaticMarkup } from "react-dom/server";
2
2
  import { beforeEach, describe, expect, it, vi } from "vitest";
3
3
  import { KueueAdmission } from "./JobSetAdmission";
4
+ import { JobRenderer } from '../resources/renderers/JobAdmissionRenderers'
5
+ import { BatchExecutionFullscreen } from './BatchExecutionView'
4
6
  const mock = vi.hoisted(() => ({ result: {} as any, calls: [] as any[] }));
5
7
  vi.mock("../../api/client", () => ({
6
8
  ApiError: class extends Error {
@@ -10,6 +12,10 @@ vi.mock("../../api/client", () => ({
10
12
  mock.calls.push(args);
11
13
  return mock.result;
12
14
  },
15
+ useResource: () => ({}),
16
+ useWorkloadPods: () => ({}),
17
+ useJobSetResources: () => ({}),
18
+ useWorkloadRuns: () => ({ data: { runs: [{ kind: 'jobs', namespace: 'ml', name: 'train', phase: 'Suspended', active: false }], total: 1 } }),
13
19
  }));
14
20
  const job = {
15
21
  apiVersion: "batch/v1",
@@ -115,6 +121,42 @@ describe("Job admission host", () => {
115
121
  });
116
122
  });
117
123
 
124
+ describe.each(['drawer', 'fullscreen'])('suspended Job wording in %s', (surface) => {
125
+ const renderJob = (resource: any) => renderToStaticMarkup(surface === 'drawer'
126
+ ? <JobRenderer data={resource} />
127
+ : <BatchExecutionFullscreen kind="Job" apiKind="jobs" namespace="ml" name="train" resource={resource} />)
128
+ const expectHeld = (html: string) => {
129
+ expect(html.match(/Held by Kueue until admitted/g)).toHaveLength(surface === 'drawer' ? 1 : 2)
130
+ expect(html).not.toContain('>Suspended<')
131
+ expect(html).not.toContain('Pods will not be created until this Job is resumed.')
132
+ if (surface === 'drawer') expect(html).toContain('See Kueue admission')
133
+ }
134
+ const expectPlain = (html: string) => {
135
+ expect(html).not.toContain('Held by Kueue')
136
+ if (surface === 'drawer') {
137
+ expect(html).toContain('Job Suspended')
138
+ expect(html).toContain('Pods will not be created until this Job is resumed.')
139
+ } else expect(html.match(/>Suspended</g)).toHaveLength(2)
140
+ }
141
+
142
+ it.each([{ isLoading: true }, { data: empty }, { error: new Error('denied') }])('uses the queue label even without a successful admission lookup: %j', (result) => {
143
+ mock.result = result
144
+ expectHeld(renderJob(hinted))
145
+ })
146
+ it('uses controller-owned Workload evidence for an unlabeled Job', () => {
147
+ mock.result = { data: evidence }
148
+ expectHeld(renderJob(job))
149
+ })
150
+ it.each([{ isLoading: true }, { data: empty }, { error: new Error('denied') }, { data: { ...evidence, uid: 'old' } }, { data: evidence, error: new Error('cache unavailable') }])('keeps ordinary wording without current readable evidence: %j', (result) => {
151
+ mock.result = result
152
+ expectPlain(renderJob(job))
153
+ })
154
+ it('does not infer Kueue from an arbitrary controller', () => {
155
+ mock.result = { data: empty }
156
+ expectPlain(renderJob({ ...job, spec: { ...job.spec, managedBy: 'other.io/controller' } }))
157
+ })
158
+ })
159
+
118
160
  describe("JobSet admission identity", () => {
119
161
  it("rejects evidence and absence for a different root instance", () => {
120
162
  const resource = {
@@ -1,11 +1,15 @@
1
1
  import { KueueAdmissionSection } from '@skyhook-io/k8s-ui/components/resources/KueueAdmissionSection'
2
+ import type { KueueAdmissionWorkload } from '@skyhook-io/k8s-ui/types/scheduling'
2
3
  import { ApiError, useKueueAdmission } from '../../api/client'
4
+ import { KueuePendingPosition } from '../kueue/KueuePendingPosition'
5
+ import type { ReactNode } from 'react'
3
6
 
4
- export function KueueAdmission({ resource, namespace, name, onNavigate, presentation }: {
7
+ export function KueueAdmission({ resource, namespace, name, onNavigate, presentation, children }: {
5
8
  presentation?: 'card' | 'drawer'
6
9
  resource: any
7
10
  namespace: string
8
11
  name: string
12
+ children?: (admissionContent: ReactNode, hasKueueEvidence: boolean) => ReactNode
9
13
  onNavigate?: (ref: { kind: string; namespace: string; name: string; group?: string }) => void
10
14
  }) {
11
15
  const isJob = resource.apiVersion === 'batch/v1' && resource.kind === 'Job'
@@ -18,9 +22,20 @@ export function KueueAdmission({ resource, namespace, name, onNavigate, presenta
18
22
  const query = useKueueAdmission(namespace, name, resource.metadata?.uid, { isJob, isRayJob, hinted, terminal })
19
23
  const data = query.data?.uid === resource.metadata?.uid ? query.data : undefined
20
24
  const error = query.error?.message ?? (query.data && !data ? 'Admission evidence belongs to a different workload instance; waiting for a fresh observation.' : undefined)
21
- if ((isJob || isRayJob) && !hinted && !data?.workloads.length) return null
25
+ const hasKueueEvidence = Boolean(labels?.['kueue.x-k8s.io/queue-name'] || (!query.error && data?.workloads.length))
26
+ const visible = !((isJob || isRayJob) && !hinted && !data?.workloads.length)
22
27
  const hasOwner = (resource.metadata?.ownerReferences ?? []).some((owner: any) => owner.controller === true && !(owner.apiVersion === 'batch/v1' && owner.kind === 'CronJob'))
23
- return <KueueAdmissionSection presentation={presentation} data={data} loading={query.isLoading} error={error} forbidden={query.error instanceof ApiError && query.error.status === 403} hinted={hinted} externalExecution={externalExecution} hasOwner={isJob && hasOwner} onRetry={() => { void query.refetch() }} onNavigate={onNavigate} />
28
+ const content = visible ? <KueueAdmissionSection presentation={presentation} data={data} loading={query.isLoading} error={error} forbidden={query.error instanceof ApiError && query.error.status === 403} hinted={hinted} externalExecution={externalExecution} hasOwner={isJob && hasOwner} onRetry={() => { void query.refetch() }} onNavigate={onNavigate} renderWorkloadExtra={renderPendingPosition} /> : null
29
+ return children ? children(content, hasKueueEvidence) : content
30
+ }
31
+
32
+ // Kueue's reported position, for a Workload the admission projection reads as
33
+ // pending and active: the same rule the Workload drawer and the server apply.
34
+ function renderPendingPosition(workload: KueueAdmissionWorkload) {
35
+ const kueue = workload.scheduling?.observations?.find(observation => observation.kueue)?.kueue
36
+ const queue = workload.scheduling?.observations?.flatMap(observation => observation.queues ?? []).find(entry => entry.roles.includes('submission'))?.name
37
+ if (!kueue || kueue.phase !== 'pending' || kueue.active === false) return null
38
+ return <p className="text-sm"><span className="text-theme-text-secondary">Queue position: </span><KueuePendingPosition namespace={workload.namespace} name={workload.name} uid={workload.uid} queueName={queue} requeueAt={kueue.requeueState?.requeueAt} /></p>
24
39
  }
25
40
 
26
41
  export { KueueAdmission as JobSetAdmission }
@@ -1,6 +1,7 @@
1
1
  import { Badge, EmptyState, FetchResult } from '@skyhook-io/k8s-ui'
2
2
  import { formatCPUNanocores, formatMemoryBytes } from '@skyhook-io/k8s-ui/utils/format'
3
3
  import type { JobSetResources, JobSetUsage, WorkloadRun } from '../../api/client'
4
+ import { runStateLabel } from './runState'
4
5
 
5
6
  interface Props {
6
7
  runs: WorkloadRun[]
@@ -74,7 +75,7 @@ export function JobSetMemberComparison(props: Props) {
74
75
  return <tr key={key} className={`border-b border-theme-border-subtle last:border-0 ${props.selected === key ? 'selection' : 'hover:bg-theme-hover'}`}>
75
76
  <td className="px-3 py-2 text-theme-text-secondary">{run.jobset?.replicatedJob ?? 'Not reported'}{run.jobset?.jobIndex !== undefined && ` #${run.jobset.jobIndex}`}</td>
76
77
  <th scope="row" className="max-w-xs px-3 py-2 font-medium"><button type="button" aria-pressed={props.selected === key} className="block max-w-full truncate text-accent-text hover:underline" onClick={() => props.onSelect?.(key)}>{run.name}</button></th>
77
- <td className="px-3 py-2"><Badge severity={run.phase === 'Failed' || run.phase === 'Error' ? 'error' : run.phase === 'Succeeded' ? 'success' : run.active ? 'info' : 'neutral'}>{run.phase}{run.deleting ? ' · deleting' : ''}</Badge></td>
78
+ <td className="px-3 py-2"><Badge severity={run.phase === 'Failed' || run.phase === 'Error' ? 'error' : run.phase === 'Succeeded' ? 'success' : run.active ? 'info' : 'neutral'}>{runStateLabel(run)}</Badge></td>
78
79
  <td className="whitespace-nowrap px-3 py-2 text-theme-text-secondary">{props.durationFor(run) || '—'}</td>
79
80
  <td className="whitespace-nowrap px-3 py-2"><UsageValue usage={usage} resource="cpu" /></td>
80
81
  <td className="whitespace-nowrap px-3 py-2"><UsageValue usage={usage} resource="memory" /></td>
@@ -0,0 +1,14 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { runStateLabel } from './runState'
3
+
4
+ describe('runStateLabel', () => {
5
+ it('reads a deleting Job with no active Pods as Deleting, not Pending', () => {
6
+ expect(runStateLabel({ phase: 'Pending', deleting: true })).toBe('Deleting')
7
+ })
8
+
9
+ it('keeps the phase for other runs, marking deletion', () => {
10
+ expect(runStateLabel({ phase: 'Running', deleting: true })).toBe('Running · deleting')
11
+ expect(runStateLabel({ phase: 'Pending' })).toBe('Pending')
12
+ expect(runStateLabel({ phase: 'Succeeded', deleting: true }, () => 'OK')).toBe('OK · deleting')
13
+ })
14
+ })
@@ -0,0 +1,8 @@
1
+ import type { WorkloadRun } from '../../api/client'
2
+
3
+ // A Job being deleted whose Pods are still terminating has no active Pods, so
4
+ // its derived phase falls back to Pending, which reads as "not started yet".
5
+ export function runStateLabel(run: Pick<WorkloadRun, 'phase' | 'deleting'>, formatPhase: (phase: string) => string = phase => phase): string {
6
+ if (run.deleting && run.phase === 'Pending') return 'Deleting'
7
+ return `${formatPhase(run.phase)}${run.deleting ? ' · deleting' : ''}`
8
+ }