@skyhook-io/radar-app 1.22.1 → 1.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/src/App.tsx +131 -38
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -0
- package/src/RadarApp.tsx +5 -0
- package/src/api/agentSandbox.ts +259 -0
- package/src/api/client.autoPromConnect.test.tsx +43 -0
- package/src/api/client.metricsRelayCheck.test.tsx +134 -0
- package/src/api/client.ts +128 -25
- package/src/api/cloudInstallDiscover.test.tsx +76 -0
- package/src/api/diagnose.ts +4 -0
- package/src/api/kagent.test.ts +82 -0
- package/src/api/kagent.ts +230 -0
- package/src/api/prometheusCharts.ts +5 -0
- package/src/api/radarFeatures.test.ts +9 -0
- package/src/api/radarFeatures.ts +13 -0
- package/src/api/substrateWorkspace.test.ts +72 -0
- package/src/api/substrateWorkspace.ts +1394 -0
- package/src/api/vulnerabilities.ts +207 -9
- package/src/api/workloadSource.test.tsx +1172 -0
- package/src/api/workloadSource.ts +408 -0
- package/src/components/APIUnreachableBanner.test.tsx +19 -0
- package/src/components/APIUnreachableBanner.tsx +20 -0
- package/src/components/CloudConnectFlow.tsx +46 -7
- package/src/components/CloudFunnelButton.test.tsx +193 -7
- package/src/components/CloudFunnelButton.tsx +127 -32
- package/src/components/ConnectionErrorView.test.tsx +63 -2
- package/src/components/ConnectionErrorView.tsx +88 -68
- package/src/components/SelfManagedStart.tsx +12 -2
- package/src/components/agentsandbox/AgentSandboxKindLists.tsx +41 -0
- package/src/components/agentsandbox/AgentSandboxLists.test.tsx +410 -0
- package/src/components/agentsandbox/AgentSandboxOverview.test.tsx +333 -0
- package/src/components/agentsandbox/AgentSandboxOverview.tsx +555 -0
- package/src/components/agentsandbox/AgentSandboxSidebar.test.tsx +97 -0
- package/src/components/agentsandbox/AgentSandboxSummary.test.tsx +439 -0
- package/src/components/agentsandbox/AgentSandboxSummary.tsx +956 -0
- package/src/components/agentsandbox/AgentSandboxTables.tsx +966 -0
- package/src/components/agentsandbox/AgentSandboxView.tsx +34 -0
- package/src/components/agentsandbox/agentsandbox.fixtures.ts +135 -0
- package/src/components/agentsandbox/data.ts +135 -0
- package/src/components/agentsandbox/host.test.ts +27 -0
- package/src/components/agentsandbox/host.tsx +85 -0
- package/src/components/agentsandbox/labels.test.ts +42 -0
- package/src/components/agentsandbox/labels.ts +146 -0
- package/src/components/agentsandbox/listFilters.ts +85 -0
- package/src/components/agentsandbox/lists.ts +52 -0
- package/src/components/agentsandbox/routes.ts +23 -0
- package/src/components/agentsandbox/shared.tsx +321 -0
- package/src/components/agentsandbox/useAgentSandboxSidebarWorkspace.ts +69 -0
- package/src/components/agentsandbox/workspace.fixtures.ts +125 -0
- package/src/components/agentsandbox/workspace.tsx +258 -0
- package/src/components/agentsandbox/workspaceRoute.ts +18 -0
- package/src/components/applications/ApplicationsView.openResource.test.tsx +248 -3
- package/src/components/applications/ApplicationsView.tsx +156 -3
- package/src/components/audit/VulnerabilitiesColumns.test.tsx +487 -0
- package/src/components/audit/VulnerabilitiesRisk.test.tsx +318 -0
- package/src/components/audit/VulnerabilitiesView.test.tsx +458 -13
- package/src/components/audit/VulnerabilitiesView.tsx +639 -199
- package/src/components/cloudHints/AgentSetupCloudRow.tsx +28 -0
- package/src/components/cloudHints/CloudHintLink.tsx +29 -0
- package/src/components/cloudHints/SharedInstallAiLine.tsx +36 -0
- package/src/components/cloudHints/cloudHints.test.ts +126 -0
- package/src/components/cloudHints/cloudHints.ts +131 -0
- package/src/components/cloudHints/cloudHintsGate.test.tsx +70 -0
- package/src/components/cloudHints/cloudLinks.test.ts +52 -0
- package/src/components/cloudHints/cloudLinks.ts +31 -0
- package/src/components/cloudHints/hintStorage.ts +28 -0
- package/src/components/cnpg/CNPGView.tsx +4 -7
- package/src/components/diagnose/ActivityTurn.tsx +6 -4
- package/src/components/diagnose/AgentSetupNotice.tsx +5 -0
- package/src/components/diagnose/AssessmentCard.tsx +1 -2
- package/src/components/diagnose/ContinueInAgentButton.test.tsx +7 -0
- package/src/components/diagnose/DiagnoseContext.tsx +7 -0
- package/src/components/diagnose/DiagnoseSurface.escape.test.tsx +215 -0
- package/src/components/diagnose/DiagnoseSurface.tsx +57 -1
- package/src/components/diagnose/Home.test.tsx +6 -0
- package/src/components/diagnose/Home.tsx +10 -3
- package/src/components/diagnose/InvestigationEvidencePane.story.test.tsx +1 -1
- package/src/components/diagnose/InvestigationEvidencePane.tsx +19 -2
- package/src/components/diagnose/InvestigationFindingsFooter.test.tsx +413 -0
- package/src/components/diagnose/InvestigationView.tsx +120 -23
- package/src/components/diagnose/investigationEvidence/identity.test.ts +1 -1
- package/src/components/diagnose/investigationEvidence/projection.test.ts +1 -1
- package/src/components/diagnose/investigationState.ts +9 -0
- package/src/components/diagnose/parts.test.tsx +11 -3
- package/src/components/diagnose/toolCallLabel.ts +3 -0
- package/src/components/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/ActivitySummary.tsx +3 -8
- package/src/components/home/ClusterHealthCard.tsx +91 -17
- package/src/components/home/ClusterHealthCard.utilization.test.tsx +187 -0
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +9 -29
- package/src/components/home/MCPSetupDialog.test.tsx +9 -0
- package/src/components/home/MCPSetupDialog.tsx +6 -2
- package/src/components/home/McpCloudLine.test.tsx +162 -0
- package/src/components/home/McpCloudLine.tsx +95 -0
- package/src/components/home/ProblemsPanel.investigate.test.tsx +2 -2
- package/src/components/home/TopologyPreview.test.tsx +31 -30
- package/src/components/home/TopologyPreview.tsx +19 -28
- package/src/components/home/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +7 -7
- package/src/components/issues/ClusterSchedulingBlockerRow.tsx +35 -0
- package/src/components/issues/IssuesPane.render.test.tsx +36 -1
- package/src/components/issues/IssuesPane.tsx +181 -23
- package/src/components/issues/SinceLastVisitRow.render.test.tsx +302 -0
- package/src/components/issues/SinceLastVisitRow.tsx +71 -0
- package/src/components/issues/sinceLastVisit.test.ts +266 -0
- package/src/components/issues/sinceLastVisit.ts +439 -0
- package/src/components/kagent/KagentAgentRenderer.test.ts +32 -0
- package/src/components/kagent/KagentAgentRenderer.tsx +87 -0
- package/src/components/kagent/KagentAgentSessions.test.tsx +166 -0
- package/src/components/kagent/KagentAgentSessions.tsx +124 -0
- package/src/components/kagent/KagentDetailPage.tsx +106 -0
- package/src/components/kagent/KagentLists.tsx +412 -0
- package/src/components/kagent/KagentOverview.tsx +234 -0
- package/src/components/kagent/KagentPages.tsx +690 -0
- package/src/components/kagent/KagentRuntimeTabs.test.tsx +219 -0
- package/src/components/kagent/KagentRuntimeTabs.tsx +283 -0
- package/src/components/kagent/KagentSidebar.test.tsx +112 -0
- package/src/components/kagent/KagentView.tsx +109 -0
- package/src/components/kagent/KagentWorkspace.test.tsx +876 -0
- package/src/components/kagent/host.tsx +144 -0
- package/src/components/kagent/routes.ts +31 -0
- package/src/components/kagent/shared.tsx +336 -0
- package/src/components/kagent/useKagentRuntime.test.tsx +77 -0
- package/src/components/kagent/useKagentSidebarWorkspace.ts +67 -0
- package/src/components/kagent/workspace.fixtures.ts +108 -0
- package/src/components/kagent/workspaceRoute.ts +18 -0
- package/src/components/resource/MetricsNotConnected.test.tsx +28 -0
- package/src/components/resource/MetricsNotConnected.tsx +10 -7
- package/src/components/resource/PrometheusCharts.tsx +10 -1
- package/src/components/resource/PrometheusChartsGrid.render.test.tsx +9 -0
- package/src/components/resource/PrometheusChartsGrid.tsx +3 -3
- package/src/components/resource/SubstrateHealthCharts.test.tsx +13 -1
- package/src/components/resource/SubstrateHealthCharts.tsx +9 -15
- package/src/components/resources/ResourceDetailDrawer.tsx +1 -0
- package/src/components/resources/ResourcesView.tsx +2 -6
- package/src/components/resources/renderers/JobAdmissionRenderers.tsx +5 -4
- package/src/components/resources/renderers/PodRenderer.tsx +8 -2
- package/src/components/resources/renderers/RolloutRenderer.tsx +4 -1
- package/src/components/resources/renderers/WorkloadRenderer.tsx +4 -1
- package/src/components/settings/LocalIntegrationStatus.test.tsx +1 -0
- package/src/components/settings/LocalIntegrationStatus.tsx +3 -2
- package/src/components/settings/SettingsDialog.tsx +84 -16
- package/src/components/settings/SubstrateSettings.lifecycle.test.tsx +210 -0
- package/src/components/settings/SubstrateSettings.test.tsx +131 -0
- package/src/components/settings/SubstrateSettings.tsx +544 -0
- package/src/components/settings/settings-state.test.ts +21 -3
- package/src/components/settings/settings-state.ts +13 -3
- package/src/components/share/ShareLinkButton.test.tsx +360 -0
- package/src/components/share/ShareLinkButton.tsx +391 -0
- package/src/components/share/openShareInCloud.test.ts +29 -0
- package/src/components/share/openShareInCloud.ts +10 -0
- package/src/components/share/shareLink.test.ts +129 -0
- package/src/components/share/shareLink.ts +175 -0
- package/src/components/substrate/SubstrateActorDrawer.tsx +87 -0
- package/src/components/substrate/SubstrateActorOverview.tsx +489 -0
- package/src/components/substrate/SubstrateActorPage.tsx +384 -0
- package/src/components/substrate/SubstrateActors.test.tsx +1094 -0
- package/src/components/substrate/SubstrateActors.tsx +612 -0
- package/src/components/substrate/SubstrateAttentionList.tsx +441 -0
- package/src/components/substrate/SubstrateConnect.tsx +88 -0
- package/src/components/substrate/SubstrateOverview.test.tsx +396 -0
- package/src/components/substrate/SubstrateOverview.tsx +575 -0
- package/src/components/substrate/SubstratePages.test.tsx +478 -0
- package/src/components/substrate/SubstratePool.test.tsx +462 -0
- package/src/components/substrate/SubstratePoolPage.tsx +95 -0
- package/src/components/substrate/SubstratePoolSummary.tsx +485 -0
- package/src/components/substrate/SubstrateSidebar.test.tsx +101 -0
- package/src/components/substrate/SubstrateStateBar.tsx +63 -0
- package/src/components/substrate/SubstrateTemplates.tsx +376 -0
- package/src/components/substrate/SubstrateView.tsx +173 -0
- package/src/components/substrate/SubstrateWorkerPodContext.tsx +73 -0
- package/src/components/substrate/SubstrateWorkers.tsx +389 -0
- package/src/components/substrate/attention.ts +81 -0
- package/src/components/substrate/contextPin.tsx +69 -0
- package/src/components/substrate/host.tsx +83 -0
- package/src/components/substrate/kubectlTarget.test.tsx +77 -0
- package/src/components/substrate/readings.test.ts +484 -0
- package/src/components/substrate/readings.ts +997 -0
- package/src/components/substrate/routes.ts +103 -0
- package/src/components/substrate/shared.tsx +426 -0
- package/src/components/substrate/substrate.fixtures.ts +325 -0
- package/src/components/substrate/useSubstrateSidebarWorkspace.ts +87 -0
- package/src/components/substrate/workspaceRoute.ts +23 -0
- package/src/components/traffic/TrafficConnectionsTable.test.tsx +9 -0
- package/src/components/traffic/TrafficConnectionsTable.tsx +4 -2
- package/src/components/traffic/TrafficFilterSidebar.tsx +19 -14
- package/src/components/traffic/TrafficFlowList.test.tsx +63 -0
- package/src/components/traffic/TrafficFlowList.tsx +9 -5
- package/src/components/traffic/TrafficGraph.test.tsx +26 -0
- package/src/components/traffic/TrafficGraph.tsx +17 -14
- package/src/components/traffic/TrafficGraphTooLarge.tsx +2 -0
- package/src/components/traffic/TrafficGraphUnavailable.tsx +3 -1
- package/src/components/traffic/TrafficView.tsx +26 -56
- package/src/components/traffic/trafficFilters.test.ts +61 -1
- package/src/components/traffic/trafficFilters.ts +68 -8
- package/src/components/velero/VeleroOverview.tsx +2 -2
- package/src/components/velero/VeleroView.tsx +3 -6
- package/src/components/vulnerabilities/columns.tsx +132 -0
- package/src/components/vulnerabilities/filters.tsx +317 -0
- package/src/components/vulnerabilities/owner.test.ts +54 -0
- package/src/components/vulnerabilities/owner.tsx +163 -0
- package/src/components/vulnerabilities/parts.test.ts +126 -12
- package/src/components/vulnerabilities/parts.tsx +612 -52
- package/src/components/vulnerabilities/traffic.test.tsx +65 -0
- package/src/components/vulnerabilities/traffic.tsx +40 -0
- package/src/components/workload/WorkloadView.substrateVersion.test.tsx +88 -0
- package/src/components/workload/WorkloadView.tsx +119 -14
- package/src/components/workload/WorkloadView.workloadSource.test.tsx +121 -0
- package/src/components/workspace/layout.tsx +13 -7
- package/src/components/workspace/sidebar.test.ts +48 -0
- package/src/components/workspace/sidebar.ts +73 -3
- package/src/components/workspace/table.ts +2 -1
- package/src/context/ConnectionContext.tsx +24 -5
- package/src/context/ConnectionProvider.connectionId.test.tsx +14 -0
- package/src/context/ConnectionProvider.handover.test.tsx +94 -0
- package/src/context/DiagnoseCustomization.tsx +20 -2
- package/src/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -0
- package/src/hooks/useEventSource.test.tsx +275 -4
- package/src/hooks/useEventSource.ts +278 -51
- package/src/index.ts +1 -0
- package/src/integrations/resourceHost.ts +12 -6
- package/src/integrations/resourceHosts.test.tsx +27 -1
- package/src/integrations/resourceHosts.tsx +15 -7
- package/src/integrations/sidebarWorkspaces.test.tsx +63 -0
- package/src/integrations/sidebarWorkspaces.ts +41 -0
- package/src/integrations/workspaceRoute.ts +1 -1
- package/src/integrations/workspaceRoutes.ts +7 -1
- package/src/integrations/workspaceScreens.tsx +6 -0
- package/src/utils/navigation.test.ts +1 -6
- package/src/utils/navigation.ts +9 -44
- package/src/utils/network-policy-navigation.test.ts +21 -36
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
// @vitest-environment jsdom
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
import { MemoryRouter } from 'react-router-dom'
|
|
4
|
+
import { act } from 'react'
|
|
5
|
+
import { createRoot } from 'react-dom/client'
|
|
6
|
+
import { describe, expect, it, vi } from 'vitest'
|
|
7
|
+
import type { RadarUpgradeRequirement } from '@skyhook-io/k8s-ui'
|
|
8
|
+
import { ApiError } from '../../api/client'
|
|
9
|
+
import type { KagentAgentSessions as Sessions } from '../../api/substrateWorkspace'
|
|
10
|
+
import { actorRow, connectedTier, counts, minutesAgo } from '../substrate/substrate.fixtures'
|
|
11
|
+
import { KagentAgentSessions } from './KagentAgentSessions'
|
|
12
|
+
|
|
13
|
+
const state = vi.hoisted(() => ({
|
|
14
|
+
data: undefined as Sessions | undefined,
|
|
15
|
+
error: null as unknown,
|
|
16
|
+
isLoading: false,
|
|
17
|
+
kagentUpgrade: null as RadarUpgradeRequirement | null,
|
|
18
|
+
}))
|
|
19
|
+
const navigate = vi.hoisted(() => vi.fn())
|
|
20
|
+
vi.mock('../workspace/useWorkspaceNavigate', () => ({ useWorkspaceNavigate: () => navigate }))
|
|
21
|
+
|
|
22
|
+
vi.mock('../../api/substrateWorkspace', async (importOriginal) => ({
|
|
23
|
+
...(await importOriginal<typeof import('../../api/substrateWorkspace')>()),
|
|
24
|
+
useKagentAgentSessions: () => ({ data: state.data, error: state.error, isLoading: state.isLoading, upgrade: null, kagentUpgrade: state.kagentUpgrade }),
|
|
25
|
+
}))
|
|
26
|
+
vi.mock('../../context/ConnectionContext', () => ({ useConnection: () => ({ connection: { context: 'kind-demo' } }) }))
|
|
27
|
+
|
|
28
|
+
const agent = { namespace: 'kagent', name: 'k8s-helper' }
|
|
29
|
+
const revision = 'aa5e9426eb2ead1c0f65f5c97cf535a9f41038ecd7f8f2b9a7ecc6d925987f40'
|
|
30
|
+
|
|
31
|
+
function sessions(overrides: Partial<Sessions> = {}): Sessions {
|
|
32
|
+
return {
|
|
33
|
+
apiTier: connectedTier,
|
|
34
|
+
agent: { ...agent, desiredRevision: revision, latestSuccessfulRevision: revision },
|
|
35
|
+
revisions: [{ revision, template: { atespace: 'kagent', name: 'k8s-helper-aa5e9426eb2e' }, newSessions: true, desired: true, sessions: 3 }],
|
|
36
|
+
sessions: counts({ suspended: 2, crashed: 1 }),
|
|
37
|
+
complete: true,
|
|
38
|
+
needAttention: 1,
|
|
39
|
+
attention: [actorRow({ atespace: 'kagent', name: 'session-7c9e6679-7425-40de-944b-e07fc1f90ae7', state: 'crashed', reason: 'exit 1', updateTime: minutesAgo(3),
|
|
40
|
+
kagent: { sessionId: '7c9e6679-7425-40de-944b-e07fc1f90ae7', kind: 'agentSession', agent, revision, newSessions: true, desired: true } })],
|
|
41
|
+
onEarlierRevisions: 0,
|
|
42
|
+
hintedEarlierRevisions: 0,
|
|
43
|
+
sources: ['snapshot'],
|
|
44
|
+
coverage: { actors: { state: 'full' }, templates: { state: 'full' } },
|
|
45
|
+
...overrides,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const plain = (html: string) => html.replace(/<\/?span[^>]*>/g, '').replace(/'/g, "'").replace(/"/g, '"').replace(/&/g, '&')
|
|
50
|
+
|
|
51
|
+
function render() {
|
|
52
|
+
return plain(renderToStaticMarkup(<MemoryRouter><KagentAgentSessions agent={agent} /></MemoryRouter>))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function reset() {
|
|
56
|
+
state.data = undefined
|
|
57
|
+
state.error = null
|
|
58
|
+
state.isLoading = false
|
|
59
|
+
state.kagentUpgrade = null
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('KagentAgentSessions', () => {
|
|
63
|
+
it.each([false, true])('returns from an attention session and links the filtered list (framed=%s)', async (framed) => {
|
|
64
|
+
reset()
|
|
65
|
+
state.data = sessions()
|
|
66
|
+
const path = '/kagent/agents/kagent/k8s-helper?ctx=kind-demo&tab=sessions'
|
|
67
|
+
const host = document.createElement('div')
|
|
68
|
+
const root = createRoot(host)
|
|
69
|
+
vi.stubGlobal('IS_REACT_ACT_ENVIRONMENT', true)
|
|
70
|
+
try {
|
|
71
|
+
await act(async () => root.render(<MemoryRouter initialEntries={[path]}><KagentAgentSessions agent={agent} framed={framed} /></MemoryRouter>))
|
|
72
|
+
const list = [...host.querySelectorAll('button')].find(b => b.textContent === 'List its sessions in Agent Substrate →')
|
|
73
|
+
expect(list).toBeDefined()
|
|
74
|
+
act(() => list!.click())
|
|
75
|
+
expect(navigate).toHaveBeenCalledWith('/substrate/actors?agent=kagent%2Fk8s-helper')
|
|
76
|
+
const button = [...host.querySelectorAll('button')].find(b => b.textContent === 'session …c1f90ae7')
|
|
77
|
+
expect(button).toBeDefined()
|
|
78
|
+
act(() => button!.click())
|
|
79
|
+
expect(navigate).toHaveBeenCalledWith(expect.stringContaining('/substrate/actors/'), { state: {
|
|
80
|
+
returnLabel: 'Agent: k8s-helper', returnPath: path, returnCtx: 'kind-demo',
|
|
81
|
+
} })
|
|
82
|
+
} finally {
|
|
83
|
+
act(() => root.unmount())
|
|
84
|
+
vi.unstubAllGlobals()
|
|
85
|
+
}
|
|
86
|
+
})
|
|
87
|
+
it('leads with every session, broken down by revision, and lists the ones needing attention', () => {
|
|
88
|
+
reset()
|
|
89
|
+
state.data = sessions()
|
|
90
|
+
const html = render()
|
|
91
|
+
expect(html).toContain('Sessions')
|
|
92
|
+
expect(html).toContain('3 sessions · 3 on the new-sessions revision, 0 on other revisions')
|
|
93
|
+
expect(html).toContain('1 needs attention')
|
|
94
|
+
expect(html).toContain('session …c1f90ae7')
|
|
95
|
+
expect(html).toContain('List its sessions in Agent Substrate →')
|
|
96
|
+
// The drawer's Agent section already says where new sessions start and that conversations aren't visible.
|
|
97
|
+
expect(html).not.toContain('New sessions start on')
|
|
98
|
+
expect(html).not.toContain('Conversation outcome')
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('counts sessions on earlier revisions in the total, not as zero', () => {
|
|
102
|
+
reset()
|
|
103
|
+
state.data = sessions({ sessions: counts({ suspended: 1 }), onEarlierRevisions: 1, needAttention: 0, attention: [],
|
|
104
|
+
revisions: [{ revision, template: { atespace: 'kagent', name: 'k8s-helper-aa5e9426eb2e' }, newSessions: true, desired: true, sessions: 0 }] })
|
|
105
|
+
expect(render()).toContain('1 session · 0 on the new-sessions revision, 1 on other revisions')
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
it('reads counts as lower bounds when Substrate’s actors were not all read', () => {
|
|
109
|
+
reset()
|
|
110
|
+
state.data = sessions({ complete: false, coverage: { actors: { state: 'partial', code: 'capExceeded' }, templates: { state: 'full' } } })
|
|
111
|
+
const html = render()
|
|
112
|
+
expect(html).toContain('at least 3 sessions')
|
|
113
|
+
expect(html).toContain('Lower bounds')
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
it('attributes a lower bound to unread templates when all actors were read', () => {
|
|
117
|
+
reset()
|
|
118
|
+
state.data = sessions({ complete: false, hintedEarlierRevisions: 1, coverage: { actors: { state: 'full' }, templates: { state: 'partial' } } })
|
|
119
|
+
expect(render()).toContain('Some templates were unread')
|
|
120
|
+
expect(render()).not.toContain('did not read every actor')
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
it('keeps unproven earlier revisions out of the count, and says when another Agent shares a template', () => {
|
|
124
|
+
reset()
|
|
125
|
+
state.data = sessions({
|
|
126
|
+
revisions: [{ revision, template: { atespace: 'kagent', name: 'k8s-helper-aa5e9426eb2e' }, newSessions: true, desired: true, ambiguous: true, sessions: 0 }],
|
|
127
|
+
hintedEarlierRevisions: 2,
|
|
128
|
+
})
|
|
129
|
+
const html = render()
|
|
130
|
+
expect(html).toContain('2 more sessions run on templates named for kagent/k8s-helper that Radar can’t prove are its')
|
|
131
|
+
expect(html).toContain('Radar doesn’t count them')
|
|
132
|
+
expect(html).toContain('Another Agent’s revision makes a template with the same name')
|
|
133
|
+
expect(html).toContain('3 sessions')
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
it('shows loading, an older Radar, a refused read and no access as themselves', () => {
|
|
137
|
+
reset()
|
|
138
|
+
state.isLoading = true
|
|
139
|
+
expect(render()).toContain('Reading this Agent’s sessions')
|
|
140
|
+
|
|
141
|
+
reset()
|
|
142
|
+
state.kagentUpgrade = { feature: 'kagent Agent sessions in Agent Substrate' }
|
|
143
|
+
expect(render()).toContain('kagent Agent sessions in Agent Substrate')
|
|
144
|
+
|
|
145
|
+
reset()
|
|
146
|
+
state.error = new ApiError('no sign-in', 403, { error: 'no sign-in', error_code: 'sharedRadar' })
|
|
147
|
+
expect(render()).toContain('Radar doesn’t read Substrate’s API here')
|
|
148
|
+
|
|
149
|
+
reset()
|
|
150
|
+
state.error = new ApiError('no access', 403, { error: 'no access' })
|
|
151
|
+
expect(render()).toContain('You can’t list kagent Agents in namespace kagent')
|
|
152
|
+
|
|
153
|
+
reset()
|
|
154
|
+
state.data = sessions()
|
|
155
|
+
state.error = new ApiError('Kubernetes token required', 403, { error_code: 'userTokenRequired' })
|
|
156
|
+
expect(render()).toContain('Sign-in token required')
|
|
157
|
+
expect(render()).not.toContain('3 sessions')
|
|
158
|
+
|
|
159
|
+
state.error = new ApiError('Namespace is outside the pin', 403, { error_code: 'outside_namespace_pin' })
|
|
160
|
+
expect(render()).toContain('Namespace is outside the pin')
|
|
161
|
+
|
|
162
|
+
reset()
|
|
163
|
+
state.error = new ApiError('not read', 503, { error: 'not read', error_code: 'incomplete' })
|
|
164
|
+
expect(render()).toContain('hasn’t read kagent’s Agents in namespace kagent yet')
|
|
165
|
+
})
|
|
166
|
+
})
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { useLocation } from 'react-router-dom'
|
|
3
|
+
import { MessagesSquare } from 'lucide-react'
|
|
4
|
+
import { RadarUpgradeNote, Section, WorkspaceCard } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import { isForbiddenError } from '../../api/client'
|
|
6
|
+
import { substrateErrorCode, useKagentAgentSessions, type KagentAgentRef, type SubstrateRef } from '../../api/substrateWorkspace'
|
|
7
|
+
import { useConnection } from '../../context/ConnectionContext'
|
|
8
|
+
import { Notice, RefreshFailedNotice } from '../workspace/layout'
|
|
9
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
10
|
+
import { agentFilterValue, agentText, shortSessionId, tierReading, definitiveFailure } from '../substrate/readings'
|
|
11
|
+
import { stateCellReading } from '../substrate/SubstrateActors'
|
|
12
|
+
import { substrateActorPath, substrateActorsPath } from '../substrate/routes'
|
|
13
|
+
import { ActorStateBadge, When } from '../substrate/shared'
|
|
14
|
+
import { SubstrateStateBar } from '../substrate/SubstrateStateBar'
|
|
15
|
+
|
|
16
|
+
function count(n: number, lowerBound: boolean): string {
|
|
17
|
+
return `${lowerBound ? 'at least ' : ''}${n.toLocaleString('en-US')}`
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface KagentAgentSessionsProps {
|
|
21
|
+
agent: KagentAgentRef
|
|
22
|
+
framed?: boolean
|
|
23
|
+
/** Opens one session's actor; defaults to its page in the Agent Substrate workspace. */
|
|
24
|
+
onOpenActor?: (ref: SubstrateRef) => void
|
|
25
|
+
/** Opens the Actors list narrowed to this Agent's sessions; defaults to navigating there. */
|
|
26
|
+
onOpenSessions?: (agent: KagentAgentRef) => void
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* One kagent Agent's chat sessions as Substrate runs them, inside the Agent's drawer: how many, on the
|
|
31
|
+
* current and earlier revisions, by state, and the few that need attention. Counts only exact matches;
|
|
32
|
+
* sessions Radar can't prove are this Agent's are a hint beside them. Where new sessions start and what
|
|
33
|
+
* Radar can't see of a conversation are the drawer's Agent section's to say.
|
|
34
|
+
*/
|
|
35
|
+
export function KagentAgentSessions({ agent, onOpenActor, onOpenSessions, framed }: KagentAgentSessionsProps) {
|
|
36
|
+
const navigate = useWorkspaceNavigate()
|
|
37
|
+
const location = useLocation()
|
|
38
|
+
const { connection } = useConnection()
|
|
39
|
+
const query = useKagentAgentSessions(agent)
|
|
40
|
+
const openActor = onOpenActor ?? ((ref: SubstrateRef) => navigate(substrateActorPath(ref, connection.context || undefined), location.pathname.startsWith('/kagent/agents/') ? {
|
|
41
|
+
state: { returnLabel: `Agent: ${agent.name}`, returnPath: location.pathname + location.search, returnCtx: connection.context },
|
|
42
|
+
} : undefined))
|
|
43
|
+
const openSessions = onOpenSessions ?? ((a: KagentAgentRef) => navigate(substrateActorsPath({ agent: agentFilterValue(a) })))
|
|
44
|
+
const frame = (body: ReactNode) => framed ? <WorkspaceCard title="Sessions"><div className="space-y-3">{body}</div></WorkspaceCard> : <Section title="Sessions" icon={MessagesSquare} defaultExpanded><div className="space-y-2">{body}</div></Section>
|
|
45
|
+
|
|
46
|
+
const upgrade = query.kagentUpgrade ?? query.upgrade
|
|
47
|
+
if (upgrade) return frame(<RadarUpgradeNote requirement={upgrade} />)
|
|
48
|
+
const code = substrateErrorCode(query.error)
|
|
49
|
+
const data = definitiveFailure(code) || isForbiddenError(query.error) ? undefined : query.data
|
|
50
|
+
if (!data) {
|
|
51
|
+
if (query.isLoading || !query.error) return frame(<p className="text-sm text-theme-text-tertiary">Reading this Agent’s sessions from Substrate…</p>)
|
|
52
|
+
return frame(<Notice>{sessionsFailure(query.error, agent)}</Notice>)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const lower = !data.complete
|
|
56
|
+
const total = data.sessions.total
|
|
57
|
+
const current = data.revisions.filter(r => r.newSessions).reduce((n, r) => n + r.sessions, 0)
|
|
58
|
+
const other = total - current
|
|
59
|
+
const actorsIncomplete = data.coverage.actors.state !== 'full' && !data.coverage.actors.readAtespaces?.includes(agent.namespace) || data.coverage.actors.code === 'capExceeded'
|
|
60
|
+
const templatesIncomplete = data.hintedEarlierRevisions > 0 && data.coverage.templates.state !== 'full'
|
|
61
|
+
return frame(
|
|
62
|
+
<>
|
|
63
|
+
<RefreshFailedNotice queries={[query]} />
|
|
64
|
+
<div className="flex flex-wrap items-baseline justify-between gap-x-3 gap-y-1">
|
|
65
|
+
<p className="text-sm text-theme-text-primary">
|
|
66
|
+
<span className="font-medium">{count(total, lower)}</span> {total === 1 && !lower ? 'session' : 'sessions'}
|
|
67
|
+
{total > 0 && (
|
|
68
|
+
<span className="text-theme-text-secondary"> · {count(current, lower)} on the new-sessions revision, {count(other, lower)} on other revisions</span>
|
|
69
|
+
)}
|
|
70
|
+
{data.needAttention > 0 && <span className="text-theme-text-secondary"> · {count(data.needAttention, lower)} {data.needAttention === 1 ? 'needs' : 'need'} attention</span>}
|
|
71
|
+
</p>
|
|
72
|
+
{total > 0 && (
|
|
73
|
+
<button type="button" onClick={() => openSessions(agent)} className="text-sm text-accent-text hover:underline">List its sessions in Agent Substrate →</button>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
{lower && (
|
|
77
|
+
<p className="text-xs text-theme-text-tertiary">
|
|
78
|
+
Lower bounds apply.
|
|
79
|
+
{actorsIncomplete && <> Radar did not read every actor in atespace {agent.namespace}{data.coverage.actors.code === 'capExceeded' ? ', which holds more than its read limit' : ''}.</>}
|
|
80
|
+
{templatesIncomplete && <> Some templates were unread, so more sessions may belong to this Agent.</>}
|
|
81
|
+
</p>
|
|
82
|
+
)}
|
|
83
|
+
{total > 0 && <SubstrateStateBar counts={data.sessions} partial={lower} />}
|
|
84
|
+
{data.attention.length > 0 && (
|
|
85
|
+
<ul className="space-y-1">
|
|
86
|
+
{data.attention.map((row) => (
|
|
87
|
+
<li key={`${row.atespace}/${row.name}`} className="flex flex-wrap items-center gap-x-2 gap-y-0.5 text-sm">
|
|
88
|
+
<ActorStateBadge state={row.state} impact={row.workerImpact} updateTime={row.updateTime} />
|
|
89
|
+
<button type="button" onClick={() => openActor(row)} className="font-mono text-[12.5px] text-accent-text hover:underline">
|
|
90
|
+
session {row.kagent ? shortSessionId(row.kagent.sessionId) : row.name}
|
|
91
|
+
</button>
|
|
92
|
+
{stateCellReading(row).text && <span className="min-w-0 truncate text-xs text-theme-text-secondary">{stateCellReading(row).text}</span>}
|
|
93
|
+
{row.updateTime && <span className="text-xs text-theme-text-tertiary"><When iso={row.updateTime} /></span>}
|
|
94
|
+
</li>
|
|
95
|
+
))}
|
|
96
|
+
</ul>
|
|
97
|
+
)}
|
|
98
|
+
{data.revisions.some((r) => r.ambiguous) && (
|
|
99
|
+
<p className="text-xs text-theme-text-secondary">Another Agent’s revision makes a template with the same name, so Radar counts the sessions on it for neither Agent.</p>
|
|
100
|
+
)}
|
|
101
|
+
{data.hintedEarlierRevisions > 0 && (
|
|
102
|
+
<p className="text-xs text-theme-text-secondary">
|
|
103
|
+
{count(data.hintedEarlierRevisions, lower)} more {data.hintedEarlierRevisions === 1 ? 'session runs' : 'sessions run'} on templates named for {agentText(agent)} that Radar can’t prove are its: a deleted Agent with the same name leaves the same names{data.hintShared ? ', and another Agent’s name fits some of them too' : ''}. Radar doesn’t count {data.hintedEarlierRevisions === 1 ? 'it' : 'them'}.
|
|
104
|
+
</p>
|
|
105
|
+
)}
|
|
106
|
+
</>,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Why the sessions could not be read, in a sentence. */
|
|
111
|
+
export function sessionsFailure(error: unknown, agent: KagentAgentRef): string {
|
|
112
|
+
const code = substrateErrorCode(error)
|
|
113
|
+
if (code === 'sharedRadar' || code === 'apiDisabled' || code === 'mintDenied' || code === 'userTokenRequired' || code === 'notConfigured' || code === 'targetChanged' || code === 'notInstalled' || code === 'unreachable' || code === 'unauthenticated') {
|
|
114
|
+
const r = tierReading({ state: code === 'notConfigured' || code === 'targetChanged' ? 'notConfigured' : code === 'sharedRadar' || code === 'apiDisabled' ? 'disabled' : 'failed', code, reason: error instanceof Error ? error.message : undefined })
|
|
115
|
+
return `Radar doesn’t read Substrate’s API here, so it can’t count this Agent’s sessions. ${r.title}${r.detail ? `: ${r.detail}` : '.'}`
|
|
116
|
+
}
|
|
117
|
+
if (code === 'outside_namespace_pin' && error instanceof Error) return error.message
|
|
118
|
+
if (isForbiddenError(error)) {
|
|
119
|
+
return `You can’t list kagent Agents in namespace ${agent.namespace}, so Radar can’t say which actors are this Agent’s sessions.`
|
|
120
|
+
}
|
|
121
|
+
if (code === 'incomplete') return `Radar hasn’t read kagent’s Agents in namespace ${agent.namespace} yet. Try again shortly.`
|
|
122
|
+
if (code === 'notFound') return `Radar doesn’t find Agent ${agentText(agent)} among kagent’s Agents.`
|
|
123
|
+
return `Radar couldn’t read this Agent’s sessions: ${error instanceof Error ? error.message : 'unknown error'}.`
|
|
124
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { PaneLoader } from '@skyhook-io/k8s-ui'
|
|
2
|
+
import type { WorkloadExtraTab } from '@skyhook-io/k8s-ui'
|
|
3
|
+
import { History, MessagesSquare } from 'lucide-react'
|
|
4
|
+
import type { SelectedResource } from '../../types'
|
|
5
|
+
import { useCapabilities, useRadarFeature, useResource } from '../../api/client'
|
|
6
|
+
import { WorkloadView } from '../workload/WorkloadView'
|
|
7
|
+
import { ScreenEmptyState } from '../workspace/layout'
|
|
8
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
9
|
+
import { useContextPin } from '../substrate/contextPin'
|
|
10
|
+
import { KAGENT_GROUP, KAGENT_KINDS, type KagentTarget } from './routes'
|
|
11
|
+
import { getKagentAgentRevisions, readKagent } from '@skyhook-io/k8s-ui/components/resources/resource-utils-kagent'
|
|
12
|
+
import { KagentAgentRenderer as AgentSpec } from '@skyhook-io/k8s-ui/components/resources/renderers/KagentAgentRenderer'
|
|
13
|
+
import { KagentRevisions, KagentSessionsTab } from './KagentRuntimeTabs'
|
|
14
|
+
|
|
15
|
+
export function KagentDetailPage({
|
|
16
|
+
target,
|
|
17
|
+
onOpenResource,
|
|
18
|
+
}: {
|
|
19
|
+
target: KagentTarget
|
|
20
|
+
onOpenResource: (resource: SelectedResource) => void
|
|
21
|
+
}) {
|
|
22
|
+
const pin = useContextPin()
|
|
23
|
+
const navigate = useWorkspaceNavigate()
|
|
24
|
+
const feature = useRadarFeature('kagentWorkspace')
|
|
25
|
+
const { isPending: checking } = useCapabilities()
|
|
26
|
+
const agent = useResource<any>('agents', target.namespace, target.name, KAGENT_GROUP, { enabled: !pin.mismatch && target.plural === 'agents' && feature.support === 'supported' })
|
|
27
|
+
const reading = agent.data ? readKagent(agent.data) : undefined
|
|
28
|
+
const latestChange = reading?.state === 'ready' ? 'prepared' : reading?.state === 'stale' ? 'notProcessed' : reading?.state
|
|
29
|
+
const spec = KAGENT_KINDS[target.plural]
|
|
30
|
+
if (feature.support === 'unknown' && checking) return <PaneLoader label="Checking kagent workspace support…" className="flex-1" />
|
|
31
|
+
if (pin.mismatch)
|
|
32
|
+
return (
|
|
33
|
+
<ScreenEmptyState
|
|
34
|
+
icon={History}
|
|
35
|
+
title={`${target.name} is not in ${pin.active}`}
|
|
36
|
+
detail={`This link names ${pin.pinned}. Radar does not open a same-named object from another cluster.`}
|
|
37
|
+
action={
|
|
38
|
+
<button type="button" onClick={() => navigate('/kagent')} className="btn-secondary mt-3 px-3 py-1.5 text-sm">
|
|
39
|
+
Go to kagent overview
|
|
40
|
+
</button>
|
|
41
|
+
}
|
|
42
|
+
/>
|
|
43
|
+
)
|
|
44
|
+
const tabs: WorkloadExtraTab[] | undefined =
|
|
45
|
+
target.plural === 'agents' && feature.support === 'supported'
|
|
46
|
+
? [
|
|
47
|
+
{
|
|
48
|
+
id: 'sessions',
|
|
49
|
+
label: 'Sessions',
|
|
50
|
+
after: 'overview',
|
|
51
|
+
icon: <MessagesSquare className="h-4 w-4" />,
|
|
52
|
+
render: () => <KagentSessionsTab agent={target} />,
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'revisions',
|
|
56
|
+
label: 'Revisions',
|
|
57
|
+
after: 'overview',
|
|
58
|
+
icon: <History className="h-4 w-4" />,
|
|
59
|
+
render: () => (
|
|
60
|
+
<KagentRevisions
|
|
61
|
+
agent={target}
|
|
62
|
+
agentRevisions={agent.data ? getKagentAgentRevisions(agent.data) : undefined}
|
|
63
|
+
latestChange={latestChange}
|
|
64
|
+
/>
|
|
65
|
+
),
|
|
66
|
+
},
|
|
67
|
+
]
|
|
68
|
+
: undefined
|
|
69
|
+
return (
|
|
70
|
+
<WorkloadView
|
|
71
|
+
key={`${target.plural}/${target.namespace}/${target.name}/${pin.active}`}
|
|
72
|
+
kind={target.plural}
|
|
73
|
+
group={KAGENT_GROUP}
|
|
74
|
+
namespace={target.namespace}
|
|
75
|
+
name={target.name}
|
|
76
|
+
expanded
|
|
77
|
+
hideKindBadge
|
|
78
|
+
hideBackButton
|
|
79
|
+
inlineBadges
|
|
80
|
+
onBack={() => navigate(spec.listPath)}
|
|
81
|
+
onNavigateToResource={onOpenResource}
|
|
82
|
+
extraTabs={tabs}
|
|
83
|
+
specTab={target.plural === 'agents' && feature.support === 'supported' ? { render: () => <KagentAgentSpec target={target} /> } : undefined}
|
|
84
|
+
tabOrder={['overview', 'sessions', 'revisions', 'spec', 'timeline', 'events', 'yaml']}
|
|
85
|
+
titlePrefix={
|
|
86
|
+
<nav aria-label="Location" className="flex items-center gap-1.5 text-sm text-theme-text-tertiary">
|
|
87
|
+
<button type="button" onClick={() => navigate('/kagent')} className="hover:underline">
|
|
88
|
+
kagent
|
|
89
|
+
</button>
|
|
90
|
+
<span>/</span>
|
|
91
|
+
<button type="button" onClick={() => navigate(spec.listPath)} className="hover:underline">
|
|
92
|
+
{spec.label}
|
|
93
|
+
</button>
|
|
94
|
+
<span>/</span>
|
|
95
|
+
</nav>
|
|
96
|
+
}
|
|
97
|
+
/>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function KagentAgentSpec({ target }: { target: KagentTarget }) {
|
|
102
|
+
const query = useResource<any>('agents', target.namespace, target.name, KAGENT_GROUP)
|
|
103
|
+
if (query.isLoading) return <PaneLoader label="Reading Agent spec…" />
|
|
104
|
+
if (!query.data) return <p className="p-4 text-sm text-theme-text-secondary">{query.error instanceof Error ? query.error.message : 'Agent spec could not be read.'}</p>
|
|
105
|
+
return <AgentSpec data={query.data} specOnly />
|
|
106
|
+
}
|