@skyhook-io/radar-app 1.22.2 → 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 +35 -10
- package/src/RadarApp.basename.test.tsx +177 -0
- package/src/RadarApp.settings.test.tsx +33 -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 +122 -24
- 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 +315 -0
- package/src/api/workloadSource.ts +128 -12
- 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/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/AgentSetupNotice.tsx +5 -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/gitops/RemoteDestinationCloudHint.tsx +6 -14
- package/src/components/home/HomeAgentBlock.tsx +2 -0
- package/src/components/home/HomeView.tsx +3 -3
- 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/mcpToolCatalog.test.ts +10 -0
- package/src/components/home/mcpToolCatalog.ts +4 -4
- 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/PodRenderer.tsx +8 -2
- 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 +52 -13
- 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/contexts/RegistryAccessMode.test.tsx +51 -0
- package/src/contexts/RegistryAccessMode.tsx +25 -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
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { useState, type ReactNode } from 'react'
|
|
2
|
+
import { useLocation, useSearchParams } from 'react-router-dom'
|
|
3
|
+
import { Bot, Camera, FileCode, Globe, LayoutDashboard, RefreshCw, ScrollText } from 'lucide-react'
|
|
4
|
+
import { Badge, CodeViewer, DetailShell, DimensionValue, FactGrid, FactRow, FoldSection, PaneLoader, StatusDot, Tooltip, WorkspaceCard, toneTextClass, type DetailShellTab } from '@skyhook-io/k8s-ui'
|
|
5
|
+
import {
|
|
6
|
+
substrateErrorCode,
|
|
7
|
+
useSubstrateActor,
|
|
8
|
+
useSubstrateActorLogs,
|
|
9
|
+
useSubstrateWorkspace,
|
|
10
|
+
type SubstrateActorDetail,
|
|
11
|
+
type SubstrateActorLogs,
|
|
12
|
+
type SubstrateLogSource,
|
|
13
|
+
type SubstrateRef,
|
|
14
|
+
} from '../../api/substrateWorkspace'
|
|
15
|
+
import { RefreshFailedNotice, ScreenEmptyState, Segments, SectionTable, type TableColumn } from '../workspace/layout'
|
|
16
|
+
import { useWorkspaceNavigate } from '../workspace/useWorkspaceNavigate'
|
|
17
|
+
import { SubjectLink, type OpenSubject } from './SubstrateAttentionList'
|
|
18
|
+
import { NotInContext, useContextPin } from './contextPin'
|
|
19
|
+
import { ActorLogsBody, SubstrateActorOverview, egressText, workerLogsAvailable } from './SubstrateActorOverview'
|
|
20
|
+
import { bytesText, cpuText, definitiveFailure, fidelityLabel, killTie, resumeConditionSentence, tierReading } from './readings'
|
|
21
|
+
import { SUBSTRATE_PATH, SUBSTRATE_SCREENS } from './routes'
|
|
22
|
+
import { ActorStateBadge, PoolMatchLinks, Term, Unread, When } from './shared'
|
|
23
|
+
|
|
24
|
+
export type ActorTab = 'overview' | 'snapshots' | 'logs' | 'egress' | 'spec'
|
|
25
|
+
|
|
26
|
+
const TABS: ActorTab[] = ['overview', 'snapshots', 'logs', 'egress', 'spec']
|
|
27
|
+
|
|
28
|
+
function TabBody({ children }: { children: ReactNode }) {
|
|
29
|
+
return (
|
|
30
|
+
<div className="h-full overflow-y-auto">
|
|
31
|
+
<div className="mx-auto max-w-5xl space-y-4 px-6 py-4 phone:px-4">{children}</div>
|
|
32
|
+
</div>
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type SnapshotRow = NonNullable<SubstrateActorDetail['actor']['snapshots']>[number]
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Where a snapshot's state is kept: a durable copy in object storage, which
|
|
40
|
+
* outlives the node, or files on one node only. Substrate records no upload
|
|
41
|
+
* time, so none is shown.
|
|
42
|
+
*/
|
|
43
|
+
export function snapshotWhere(s: Pick<SnapshotRow, 'durable' | 'locality'>): { label: string; tone: 'healthy' | 'degraded'; detail: string; node?: string } {
|
|
44
|
+
switch (s.durable) {
|
|
45
|
+
case 'completed':
|
|
46
|
+
return s.locality
|
|
47
|
+
? { label: 'Durable copy', tone: 'healthy', detail: 'Uploaded to object storage. Recorded locality:', node: s.locality }
|
|
48
|
+
: { label: 'Durable copy', tone: 'healthy', detail: 'Uploaded to object storage.' }
|
|
49
|
+
case 'pending':
|
|
50
|
+
return s.locality
|
|
51
|
+
? { label: 'Only on its node', tone: 'degraded', detail: 'Upload pending. Recorded locality:', node: s.locality }
|
|
52
|
+
: { label: 'Upload pending', tone: 'degraded', detail: 'Substrate names no node holding its files.' }
|
|
53
|
+
default:
|
|
54
|
+
return s.locality
|
|
55
|
+
? { label: 'Only on its node', tone: 'degraded', detail: 'No durable copy recorded. Recorded locality:', node: s.locality }
|
|
56
|
+
: { label: 'Not stored', tone: 'degraded', detail: 'No durable copy or node locality recorded.' }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Generations below the newest that the list doesn't hold. */
|
|
61
|
+
export function unlistedGenerations(rows: Pick<SnapshotRow, 'generation'>[]): number {
|
|
62
|
+
if (rows.length === 0) return 0
|
|
63
|
+
const newest = Math.max(...rows.map((r) => r.generation))
|
|
64
|
+
return newest - new Set(rows.map((r) => r.generation)).size
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function SnapshotsTab({ detail, onOpenSubject }: { detail: SubstrateActorDetail; onOpenSubject: OpenSubject }) {
|
|
68
|
+
const rows = [...(detail.actor.snapshots ?? [])].sort((a, b) => b.generation - a.generation)
|
|
69
|
+
const source = rows.find((s) => s.generation === detail.row.resumeGeneration)
|
|
70
|
+
const place = source && snapshotWhere(source)
|
|
71
|
+
const columns: TableColumn<SnapshotRow>[] = [
|
|
72
|
+
{ header: 'Generation', width: '100px', cell: (s) => <span className="font-mono">{s.generation}</span> },
|
|
73
|
+
{
|
|
74
|
+
header: 'Holds',
|
|
75
|
+
cell: (s) => fidelityLabel(s.fidelity),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
header: 'Where it is kept',
|
|
79
|
+
width: '260px',
|
|
80
|
+
cell: (s) => {
|
|
81
|
+
const w = snapshotWhere(s)
|
|
82
|
+
return (
|
|
83
|
+
<span className="block min-w-0">
|
|
84
|
+
<span className={w.tone === 'healthy' ? undefined : toneTextClass(w.tone)}>{w.label}</span>
|
|
85
|
+
<span className="block text-xs text-theme-text-tertiary">{w.detail}</span>
|
|
86
|
+
{w.node && <SubjectLink subject={{ kind: 'Node', name: w.node }} onOpen={onOpenSubject} withKind={false} />}
|
|
87
|
+
</span>
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
{ header: 'Taken by', width: '100px', cell: (s) => (s.owner === 'tag' ? <Tooltip content="A tag’s copy, such as the template’s golden snapshot."><span>a tag</span></Tooltip> : s.owner === 'actor' ? 'this actor' : <Unread>unknown</Unread>) },
|
|
92
|
+
{ header: 'Sandbox class', width: '120px', cell: (s) => (s.sandboxClass ? <span className="font-mono text-[12.5px]">{s.sandboxClass}</span> : <Unread>unknown</Unread>) },
|
|
93
|
+
]
|
|
94
|
+
const unlisted = unlistedGenerations(rows)
|
|
95
|
+
return (
|
|
96
|
+
<TabBody>
|
|
97
|
+
<WorkspaceCard title="Resume source">
|
|
98
|
+
<FactGrid>
|
|
99
|
+
<FactRow label="Generation">
|
|
100
|
+
<DimensionValue tone={place?.tone ?? 'neutral'} source="Substrate’s recorded resume choice on the current template">
|
|
101
|
+
{detail.row.resumeGeneration === undefined ? 'Fresh boot' : `Generation ${detail.row.resumeGeneration}`}
|
|
102
|
+
{source && <> · {fidelityLabel(source.fidelity)} · {place?.label}</>}
|
|
103
|
+
</DimensionValue>
|
|
104
|
+
</FactRow>
|
|
105
|
+
<FactRow label="What returns">{resumeConditionSentence(detail.row.resumesWith, detail.row.resumeCondition)}</FactRow>
|
|
106
|
+
{place?.node && <FactRow label="Recorded locality"><SubjectLink subject={{ kind: 'Node', name: place.node }} onOpen={onOpenSubject} withKind={false} /></FactRow>}
|
|
107
|
+
</FactGrid>
|
|
108
|
+
</WorkspaceCard>
|
|
109
|
+
<SectionTable
|
|
110
|
+
title="Snapshots"
|
|
111
|
+
subtitle={
|
|
112
|
+
<>
|
|
113
|
+
Newest recorded generation first.
|
|
114
|
+
{unlisted > 0 && <> Substrate’s record of an actor lists only its active and in-progress generations, so {unlisted === 1 ? '1 earlier generation is' : `${unlisted} earlier generations are`} not listed.</>}
|
|
115
|
+
</>
|
|
116
|
+
}
|
|
117
|
+
columns={columns}
|
|
118
|
+
rows={rows}
|
|
119
|
+
rowKey={(s) => String(s.generation)}
|
|
120
|
+
empty="No snapshots yet: the actor has not suspended, so it would boot fresh."
|
|
121
|
+
minWidth={760}
|
|
122
|
+
/>
|
|
123
|
+
</TabBody>
|
|
124
|
+
)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* The actor's log lines with a source switch: container output or the
|
|
129
|
+
* worker's lifecycle events for it. From its current worker Pod, or, with no
|
|
130
|
+
* worker, candidates from the worker Pods on the node it last ran on; when
|
|
131
|
+
* neither holds them, what is missing and how to look further.
|
|
132
|
+
*/
|
|
133
|
+
function LogsTab({ detail }: { detail: SubstrateActorDetail }) {
|
|
134
|
+
const [view, setView] = useState<SubstrateLogSource>('all')
|
|
135
|
+
const [container, setContainer] = useState('')
|
|
136
|
+
const containers = detail.template?.containers ?? []
|
|
137
|
+
const filtered = hidesWorkerRecords(view, container)
|
|
138
|
+
const { actor } = detail
|
|
139
|
+
const logs = useSubstrateActorLogs(actor, {
|
|
140
|
+
source: view,
|
|
141
|
+
container: view === 'lifecycle' || view === 'worker' ? undefined : container || undefined,
|
|
142
|
+
tailLines: 500,
|
|
143
|
+
pollMs: actor.assignment?.pod && actor.assignment.namespace ? undefined : false,
|
|
144
|
+
})
|
|
145
|
+
const data = definitiveFailure(substrateErrorCode(logs.error)) ? undefined : logs.data
|
|
146
|
+
if (!data || !workerLogsAvailable(data)) {
|
|
147
|
+
const title = logs.isLoading ? 'Worker logs' : 'Worker logs unavailable'
|
|
148
|
+
return <TabBody><WorkspaceCard title={title}><ActorLogsBody actor={detail.actor} logs={logs} /></WorkspaceCard></TabBody>
|
|
149
|
+
}
|
|
150
|
+
// The server weighs a memory-limit kill on every source, so a view that leaves out the worker's records still knows of one.
|
|
151
|
+
const hiddenKill = filtered ? data?.memoryKill : undefined
|
|
152
|
+
return (
|
|
153
|
+
<TabBody>
|
|
154
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
155
|
+
<Segments
|
|
156
|
+
label="Log source"
|
|
157
|
+
value={view}
|
|
158
|
+
onChange={setView}
|
|
159
|
+
options={[
|
|
160
|
+
{ id: 'all', label: 'All' },
|
|
161
|
+
{ id: 'containers', label: 'Container output' },
|
|
162
|
+
{ id: 'lifecycle', label: 'Lifecycle events' },
|
|
163
|
+
{ id: 'worker', label: 'Worker process records' },
|
|
164
|
+
]}
|
|
165
|
+
/>
|
|
166
|
+
{(view === 'all' || view === 'containers') && containers.length > 1 && (
|
|
167
|
+
<label className="flex items-center gap-2 text-xs text-theme-text-secondary">
|
|
168
|
+
Container
|
|
169
|
+
<select value={container} onChange={(e) => setContainer(e.target.value)} className="rounded border border-theme-border bg-theme-base px-1.5 py-0.5 font-mono text-xs text-theme-text-primary">
|
|
170
|
+
<option value="">every container</option>
|
|
171
|
+
{containers.map((c) => <option key={c} value={c}>{c}</option>)}
|
|
172
|
+
</select>
|
|
173
|
+
</label>
|
|
174
|
+
)}
|
|
175
|
+
{data?.origin === 'worker' && logs.dataUpdatedAt > 0 && (
|
|
176
|
+
<span className="inline-flex items-center gap-1.5 text-xs text-theme-text-secondary">
|
|
177
|
+
<StatusDot tone="healthy" />
|
|
178
|
+
Live: re-read while this tab is open, newest at the bottom · <When iso={new Date(logs.dataUpdatedAt).toISOString()} prefix="read" />
|
|
179
|
+
</span>
|
|
180
|
+
)}
|
|
181
|
+
</div>
|
|
182
|
+
{hiddenKill && <HiddenKillNotice kill={hiddenKill} crashTime={detail.actor.state === 'crashed' ? detail.actor.crash?.time : undefined} onShowAll={() => { setView('all'); setContainer('') }} />}
|
|
183
|
+
<ActorLogsBody actor={detail.actor} logs={logs} killNoticeAbove={!!hiddenKill} />
|
|
184
|
+
</TabBody>
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/** A log view that leaves out the worker's own records, where a memory-limit kill is written. */
|
|
189
|
+
export function hidesWorkerRecords(view: SubstrateLogSource, container: string): boolean {
|
|
190
|
+
return view === 'containers' || view === 'lifecycle' || (view === 'all' && !!container)
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** Says a filter hides the kill record rather than changing the filter for the reader. */
|
|
194
|
+
export function HiddenKillNotice({ kill, crashTime, onShowAll }: { kill: Pick<NonNullable<SubstrateActorLogs['memoryKill']>, 'current' | 'time'>; crashTime?: string; onShowAll: () => void }) {
|
|
195
|
+
// A kill tied to this crash says what ties it: its timing.
|
|
196
|
+
const tie = killTie(kill, crashTime)
|
|
197
|
+
return (
|
|
198
|
+
<p className="text-xs text-theme-text-secondary">
|
|
199
|
+
This view hides the worker’s record of a memory-limit kill{kill.current ? `, ${tie ?? 'tied to this crash'}` : ' attempt whose tie to the crash is unconfirmed'}.{' '}
|
|
200
|
+
<button type="button" onClick={onShowAll} className="font-medium text-accent-text hover:underline">Show all sources</button>
|
|
201
|
+
</p>
|
|
202
|
+
)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
function EgressTab({ detail }: { detail: SubstrateActorDetail }) {
|
|
206
|
+
const e = detail.egress
|
|
207
|
+
const t = egressText(e)
|
|
208
|
+
return (
|
|
209
|
+
<TabBody>
|
|
210
|
+
<WorkspaceCard title="Outbound policy">
|
|
211
|
+
<DimensionValue tone={t.tone} source="Actor egress policy from Substrate">
|
|
212
|
+
{e.state === 'set' && e.rules > 0 ? `${e.rules} ${e.rules === 1 ? 'rule' : 'rules'}` : t.text}
|
|
213
|
+
</DimensionValue>
|
|
214
|
+
{e.state === 'set' && e.destinations && e.destinations.length > 0 && (
|
|
215
|
+
<>
|
|
216
|
+
<div className="mt-3 text-xs text-theme-text-tertiary">Destinations from policy</div>
|
|
217
|
+
<ul className="mt-1 flex flex-wrap gap-1.5">
|
|
218
|
+
{e.destinations.map((d) => <li key={d}><Badge tone="structural" size="sm">{d}</Badge></li>)}
|
|
219
|
+
{e.more ? <li className="text-xs text-theme-text-tertiary">and {e.more} more</li> : null}
|
|
220
|
+
</ul>
|
|
221
|
+
</>
|
|
222
|
+
)}
|
|
223
|
+
</WorkspaceCard>
|
|
224
|
+
</TabBody>
|
|
225
|
+
)
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function SpecTab({ detail, onOpenSubject }: { detail: SubstrateActorDetail; onOpenSubject: OpenSubject }) {
|
|
229
|
+
const t = detail.template
|
|
230
|
+
const selectorText = (sel?: Record<string, string>) =>
|
|
231
|
+
sel && Object.keys(sel).length ? <span className="font-mono">{Object.entries(sel).map(([k, v]) => `${k}=${v}`).join(', ')}</span> : <span className="text-theme-text-secondary">none</span>
|
|
232
|
+
const pools = detail.matchingPools
|
|
233
|
+
const workspace = useSubstrateWorkspace()
|
|
234
|
+
return (
|
|
235
|
+
<TabBody>
|
|
236
|
+
<WorkspaceCard title="Template configuration">
|
|
237
|
+
<FactGrid>
|
|
238
|
+
<FactRow label="Template"><SubjectLink subject={{ kind: 'ActorTemplate', ...detail.actor.template }} onOpen={onOpenSubject} withKind={false} /></FactRow>
|
|
239
|
+
{t ? (<>
|
|
240
|
+
<FactRow label="CPU">{t.cpuMillicores ? cpuText(t.cpuMillicores) : <Unread>not set</Unread>}</FactRow>
|
|
241
|
+
<FactRow label="Memory">{t.memoryBytes ? bytesText(t.memoryBytes) : <Unread>not set</Unread>}</FactRow>
|
|
242
|
+
<FactRow label="Containers">{t.containers?.length ? <span className="font-mono">{t.containers.join(', ')}</span> : <Unread>not listed</Unread>}</FactRow>
|
|
243
|
+
<FactRow label="Snapshots up to">{fidelityLabel(t.preferredFidelity)}</FactRow>
|
|
244
|
+
<FactRow label="Stored in">{t.storageLocation ? <span className="font-mono">{t.storageLocation}</span> : 'the API server’s default location'}</FactRow>
|
|
245
|
+
</>) : (
|
|
246
|
+
<FactRow label="Configuration"><Unread>Substrate’s templates were not read.</Unread></FactRow>
|
|
247
|
+
)}
|
|
248
|
+
</FactGrid>
|
|
249
|
+
</WorkspaceCard>
|
|
250
|
+
<WorkspaceCard title="Placement rules">
|
|
251
|
+
<FactGrid>
|
|
252
|
+
<FactRow label="Actor’s own selector">{selectorText(detail.actor.workerSelector)}</FactRow>
|
|
253
|
+
<FactRow label="Template’s selector">{t ? selectorText(t.workerSelector) : <Unread>unknown: templates were not read</Unread>}</FactRow>
|
|
254
|
+
<FactRow label="Pools matching both">
|
|
255
|
+
{pools === null ? (
|
|
256
|
+
<Unread title={detail.matchingPoolsComplete ? undefined : 'None of the pools Radar could read matches; others may.'}>unknown</Unread>
|
|
257
|
+
) : pools.length === 0 ? (
|
|
258
|
+
<span className="font-medium">none</span>
|
|
259
|
+
) : (
|
|
260
|
+
<>
|
|
261
|
+
{!detail.matchingPoolsComplete && <span>At least these pools match</span>}
|
|
262
|
+
<PoolMatchLinks pools={pools} workspace={workspace.data} />
|
|
263
|
+
</>
|
|
264
|
+
)}
|
|
265
|
+
<div className="text-xs text-theme-text-tertiary">Matching labels, not a promise it fits: CPU, memory and its snapshot’s runtime decide that.</div>
|
|
266
|
+
</FactRow>
|
|
267
|
+
</FactGrid>
|
|
268
|
+
</WorkspaceCard>
|
|
269
|
+
<WorkspaceCard>
|
|
270
|
+
<FoldSection title="Raw actor JSON" summary="Substrate API record" attention={false}>
|
|
271
|
+
<CodeViewer code={JSON.stringify(detail.actor, null, 2)} language="json" showLineNumbers={false} maxHeight="32rem" />
|
|
272
|
+
</FoldSection>
|
|
273
|
+
</WorkspaceCard>
|
|
274
|
+
</TabBody>
|
|
275
|
+
)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/** The actor page's or drawer's read failed: Substrate has no such actor, denied it, or the tier is down. */
|
|
279
|
+
export function ActorReadFailure({ actor, error, onBack, backLabel = 'Go to Actors' }: { actor: SubstrateRef; error: unknown; onBack: () => void; backLabel?: string }) {
|
|
280
|
+
const code = substrateErrorCode(error)
|
|
281
|
+
const tier = code && code !== 'notFound' && code !== 'denied' ? tierReading({ state: 'failed', code, reason: error instanceof Error ? error.message : undefined }) : undefined
|
|
282
|
+
const title = code === 'notFound' ? `Substrate has no actor ${actor.name}` : code === 'denied' ? `Substrate denied reading ${actor.name}` : tier?.title ?? `${actor.name} couldn’t be read`
|
|
283
|
+
const detail = code === 'notFound'
|
|
284
|
+
? `There is no actor ${actor.name} in atespace ${actor.atespace}. It may have been deleted since this link was made.`
|
|
285
|
+
: tier
|
|
286
|
+
? `${tier.detail}${tier.nextStep ? ` ${tier.nextStep}` : ''}`
|
|
287
|
+
: error instanceof Error
|
|
288
|
+
? error.message
|
|
289
|
+
: 'Radar could not read the actor.'
|
|
290
|
+
return (
|
|
291
|
+
<ScreenEmptyState
|
|
292
|
+
icon={Bot}
|
|
293
|
+
title={title}
|
|
294
|
+
detail={detail}
|
|
295
|
+
action={<button type="button" onClick={onBack} className="btn-secondary mt-3 px-3 py-1.5 text-sm">{backLabel}</button>}
|
|
296
|
+
/>
|
|
297
|
+
)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
* An actor's page: the crumb (Agent Substrate / Actors / atespace /), the
|
|
302
|
+
* Overview first, then its snapshots, logs (container output and lifecycle events), egress
|
|
303
|
+
* policy and spec. `ctx` pins the Kubernetes context the link was made in.
|
|
304
|
+
*/
|
|
305
|
+
export function SubstrateActorPage({ actor, onOpenSubject }: { actor: SubstrateRef; onOpenSubject: OpenSubject }) {
|
|
306
|
+
const location = useLocation()
|
|
307
|
+
const navigate = useWorkspaceNavigate()
|
|
308
|
+
const [params, setParams] = useSearchParams()
|
|
309
|
+
const pin = useContextPin()
|
|
310
|
+
const rawTab = params.get('tab') as ActorTab | null
|
|
311
|
+
const tab: ActorTab = rawTab && TABS.includes(rawTab) ? rawTab : 'overview'
|
|
312
|
+
const query = useSubstrateActor(pin.mismatch ? null : actor)
|
|
313
|
+
// A refresh that says the actor is gone or no longer readable replaces what was kept.
|
|
314
|
+
const detail = definitiveFailure(substrateErrorCode(query.error)) ? undefined : query.data
|
|
315
|
+
|
|
316
|
+
const setTab = (id: ActorTab) => {
|
|
317
|
+
const p = new URLSearchParams(params)
|
|
318
|
+
if (id === 'overview') p.delete('tab')
|
|
319
|
+
else p.set('tab', id)
|
|
320
|
+
setParams(p, { replace: true, state: location.state })
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (pin.mismatch) {
|
|
324
|
+
return <NotInContext name={actor.name} what={`actor ${actor.atespace} / ${actor.name}`} pinnedContext={pin.pinned!} activeContext={pin.active} />
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
const origin = location.state as { returnLabel?: string; returnPath?: string; returnCtx?: string } | null
|
|
328
|
+
const agentReturn = origin?.returnPath?.startsWith('/kagent/agents/') && origin.returnCtx === pin.active ? origin : null
|
|
329
|
+
const breadcrumb = (
|
|
330
|
+
<nav aria-label="Location" className="flex flex-wrap items-center gap-1.5 text-sm text-theme-text-tertiary">
|
|
331
|
+
{agentReturn && <><button type="button" onClick={() => navigate(agentReturn.returnPath!)} className="text-accent-text hover:underline">← {agentReturn.returnLabel}</button><span>/</span></>}
|
|
332
|
+
<Bot className="h-3.5 w-3.5" />
|
|
333
|
+
<button type="button" onClick={() => navigate(SUBSTRATE_PATH)} className="hover:text-theme-text-primary hover:underline">Agent Substrate</button>
|
|
334
|
+
<span>/</span>
|
|
335
|
+
<button type="button" onClick={() => navigate(SUBSTRATE_SCREENS.actors.path)} className="hover:text-theme-text-primary hover:underline">Actors</button>
|
|
336
|
+
<span>/</span>
|
|
337
|
+
</nav>
|
|
338
|
+
)
|
|
339
|
+
const identity = (
|
|
340
|
+
<div className="flex flex-wrap items-center gap-x-3 gap-y-1">
|
|
341
|
+
{breadcrumb}
|
|
342
|
+
<h1 className="min-w-0 truncate font-mono text-lg font-semibold text-theme-text-primary">{actor.name}</h1>
|
|
343
|
+
{detail && <ActorStateBadge state={detail.actor.state} impact={detail.row.workerImpact} updateTime={detail.actor.updateTime} />}
|
|
344
|
+
<span className="text-sm text-theme-text-secondary"><Term term="atespace">Atespace</Term>: <span className="font-mono">{actor.atespace}</span></span>
|
|
345
|
+
</div>
|
|
346
|
+
)
|
|
347
|
+
const snapshots = detail?.actor.snapshots?.length
|
|
348
|
+
const tabs: DetailShellTab<ActorTab>[] = [
|
|
349
|
+
{ id: 'overview', label: 'Overview', icon: <LayoutDashboard className="h-4 w-4" /> },
|
|
350
|
+
{ id: 'snapshots', label: 'Snapshots', icon: <Camera className="h-4 w-4" />, badge: snapshots ? <span className="font-mono text-xs text-theme-text-tertiary">{snapshots}</span> : undefined },
|
|
351
|
+
{ id: 'logs', label: 'Logs', icon: <ScrollText className="h-4 w-4" /> },
|
|
352
|
+
{ id: 'egress', label: 'Egress', icon: <Globe className="h-4 w-4" /> },
|
|
353
|
+
{ id: 'spec', label: 'Spec', icon: <FileCode className="h-4 w-4" /> },
|
|
354
|
+
]
|
|
355
|
+
let body: ReactNode
|
|
356
|
+
if (!detail && query.isLoading) body = <PaneLoader label={`Loading ${actor.name}…`} className="h-full" />
|
|
357
|
+
else if (!detail) body = <ActorReadFailure actor={actor} error={query.error} onBack={() => navigate(SUBSTRATE_SCREENS.actors.path)} />
|
|
358
|
+
else if (tab === 'snapshots') body = <SnapshotsTab detail={detail} onOpenSubject={onOpenSubject} />
|
|
359
|
+
else if (tab === 'logs') body = <LogsTab detail={detail} />
|
|
360
|
+
else if (tab === 'egress') body = <EgressTab detail={detail} />
|
|
361
|
+
else if (tab === 'spec') body = <SpecTab detail={detail} onOpenSubject={onOpenSubject} />
|
|
362
|
+
else body = <TabBody><SubstrateActorOverview detail={detail} onOpenSubject={onOpenSubject} onShowLogs={() => setTab('logs')} onShowSnapshots={() => setTab('snapshots')} onShowEgress={() => setTab('egress')} /></TabBody>
|
|
363
|
+
|
|
364
|
+
return (
|
|
365
|
+
<div className="flex h-full min-h-0 min-w-0 flex-1 flex-col">
|
|
366
|
+
<DetailShell
|
|
367
|
+
identity={identity}
|
|
368
|
+
headerActions={
|
|
369
|
+
<Tooltip content="Refresh" delay={150} position="bottom">
|
|
370
|
+
<button type="button" onClick={() => void query.refetch()} disabled={query.isFetching} aria-label="Refresh" className="mt-0.5 rounded p-1.5 text-theme-text-secondary hover:bg-theme-elevated hover:text-theme-text-primary disabled:opacity-50">
|
|
371
|
+
<RefreshCw className="h-5 w-5" />
|
|
372
|
+
</button>
|
|
373
|
+
</Tooltip>
|
|
374
|
+
}
|
|
375
|
+
tabs={tabs}
|
|
376
|
+
activeTab={tab}
|
|
377
|
+
onTabChange={setTab}
|
|
378
|
+
>
|
|
379
|
+
<RefreshFailedNotice queries={[query]} className="px-4 pt-3 xl:px-6" />
|
|
380
|
+
{body}
|
|
381
|
+
</DetailShell>
|
|
382
|
+
</div>
|
|
383
|
+
)
|
|
384
|
+
}
|