@skyhook-io/radar-app 1.22.0 → 1.22.1

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 (57) hide show
  1. package/package.json +1 -1
  2. package/src/App.tsx +2 -1
  3. package/src/api/client.ts +12 -0
  4. package/src/api/cnpg-history.ts +3 -3
  5. package/src/api/cnpg-storage.ts +3 -3
  6. package/src/api/diagnose.test.ts +34 -0
  7. package/src/api/diagnose.ts +17 -4
  8. package/src/api/radarFeatures.test.ts +13 -1
  9. package/src/api/radarFeatures.ts +2 -0
  10. package/src/api/resourceActions.test.ts +829 -0
  11. package/src/api/resourceActions.ts +584 -0
  12. package/src/api/resourceActions.ui.test.tsx +1882 -0
  13. package/src/api/reviewedActionMutation.ts +56 -28
  14. package/src/api/substrateHealth.ts +2 -3
  15. package/src/api/traffic.ts +13 -5
  16. package/src/api/workloadMetrics.test.ts +11 -2
  17. package/src/api/workloadMetrics.ts +2 -2
  18. package/src/components/diagnose/AnalysisStory.test.tsx +12 -0
  19. package/src/components/diagnose/DiagnoseContext.question.test.tsx +34 -1
  20. package/src/components/diagnose/DiagnoseContext.tsx +28 -3
  21. package/src/components/diagnose/DiagnoseSurface.tsx +5 -4
  22. package/src/components/diagnose/Home.tsx +3 -0
  23. package/src/components/diagnose/InvestigationEvidencePane.test.tsx +61 -0
  24. package/src/components/diagnose/InvestigationView.followupFailure.test.tsx +122 -0
  25. package/src/components/diagnose/InvestigationView.tsx +10 -2
  26. package/src/components/diagnose/LocalDiagnoseAction.history.test.tsx +1 -1
  27. package/src/components/diagnose/LocalDiagnoseAction.tsx +2 -2
  28. package/src/components/diagnose/QuestionComposer.test.tsx +16 -2
  29. package/src/components/diagnose/QuestionComposer.tsx +13 -8
  30. package/src/components/diagnose/diagnoseEvidenceTypes.ts +47 -8
  31. package/src/components/diagnose/investigationEvidence/adapters/diagnose.test.ts +153 -0
  32. package/src/components/diagnose/investigationEvidence/adapters/diagnose.ts +9 -13
  33. package/src/components/diagnose/investigationEvidence/adapters/issues.ts +21 -5
  34. package/src/components/diagnose/investigationEvidence/bodies/network.tsx +63 -26
  35. package/src/components/diagnose/launch.ts +1 -1
  36. package/src/components/dock/PodDebugSession.test.tsx +66 -0
  37. package/src/components/dock/PodDebugSession.tsx +3 -1
  38. package/src/components/dock/TerminalTab.test.tsx +43 -3
  39. package/src/components/dock/TerminalTab.tsx +10 -1
  40. package/src/components/helm/HelmReleaseDrawer.tsx +1 -1
  41. package/src/components/helm/InstallWizard.tsx +1 -1
  42. package/src/components/home/mcpToolCatalog.ts +1 -1
  43. package/src/components/resources/PodEvictAction.test.tsx +951 -0
  44. package/src/components/resources/PodEvictAction.tsx +167 -0
  45. package/src/components/resources/ResourcesView.tsx +3 -0
  46. package/src/components/resources/renderers/WorkloadRenderer.tsx +3 -0
  47. package/src/components/settings/LocalConnectionSettings.tsx +4 -4
  48. package/src/components/settings/SettingsDialog.tsx +23 -18
  49. package/src/components/settings/integrationQueries.test.ts +98 -0
  50. package/src/components/settings/integrationQueries.ts +36 -0
  51. package/src/components/traffic/TrafficView.reconnect.test.tsx +229 -0
  52. package/src/components/traffic/TrafficView.tsx +91 -35
  53. package/src/components/ui/Markdown.test.tsx +37 -0
  54. package/src/components/ui/Markdown.tsx +15 -2
  55. package/src/components/useContextSwitchFlow.test.tsx +27 -2
  56. package/src/components/useContextSwitchFlow.tsx +20 -22
  57. package/src/components/workload/WorkloadView.tsx +16 -3
@@ -1,13 +1,12 @@
1
- import { useLayoutEffect, useState, type ReactNode } from 'react'
1
+ import { useId, useLayoutEffect, useState, type ReactNode } from 'react'
2
2
  import { AlertTriangle } from 'lucide-react'
3
- import { pluralize } from '@skyhook-io/k8s-ui'
3
+ import { DialogPortal, pluralize } from '@skyhook-io/k8s-ui'
4
4
  import { useSwitchContext, fetchSessionCounts, SwitchContextError, type SessionCounts } from '../api/client'
5
5
  import { finishSwitch, followSwitch, followingSwitch, switchInProgress, useTrackedContextSwitch } from '../api/contextSwitch'
6
6
  import { useConnection } from '../context/ConnectionContext'
7
7
  import { useContextSwitch } from '../context/ContextSwitchContext'
8
8
  import { useToast } from './ui/Toast'
9
9
  import { Tooltip } from './ui/Tooltip'
10
- import { useDock } from './dock'
11
10
  import type { ContextInfo, SelectedResource } from '../types'
12
11
  import { parseContextForSwitcher } from '../utils/context-name'
13
12
 
@@ -36,8 +35,10 @@ export function useContextSwitchFlow() {
36
35
  const switchContext = useSwitchContext()
37
36
  const { isSwitching, startSwitch, endSwitch, setOpenAfterSwitch, setFailedSwitch } = useContextSwitch()
38
37
  const { showError } = useToast()
39
- const { tabs } = useDock()
40
38
  const [pending, setPending] = useState<PendingSwitch | null>(null)
39
+ // Separate from `pending`, which the dialog keeps showing while it animates out.
40
+ const [confirming, setConfirming] = useState(false)
41
+ const titleId = useId()
41
42
  const [sessionCounts, setSessionCounts] = useState<SessionCounts | null>(null)
42
43
 
43
44
  const performSwitch = async ({ context, openAfter }: PendingSwitch) => {
@@ -74,15 +75,15 @@ export function useContextSwitchFlow() {
74
75
  setFailedSwitch(null)
75
76
  return
76
77
  }
77
- // Active sessions (port forwards from API + terminal tabs from dock) get
78
- // a confirmation prompt — switching contexts kills both.
78
+ // A switch ends the connection's port forwards and Pod and node terminals,
79
+ // so live ones get a confirmation. Local host terminals survive it.
79
80
  try {
80
81
  const counts = await fetchSessionCounts()
81
- const terminalTabs = tabs.filter(t => t.type === 'terminal').length
82
- const total = counts.portForwards + terminalTabs
82
+ const total = counts.portForwards + counts.execSessions
83
83
  if (total > 0) {
84
- setSessionCounts({ ...counts, execSessions: terminalTabs, total })
84
+ setSessionCounts({ ...counts, total })
85
85
  setPending({ context, openAfter })
86
+ setConfirming(true)
86
87
  return
87
88
  }
88
89
  } catch (error) {
@@ -99,21 +100,18 @@ export function useContextSwitchFlow() {
99
100
  }
100
101
 
101
102
  const confirm = () => {
102
- if (pending) performSwitch(pending)
103
- setPending(null)
103
+ if (confirming && pending) performSwitch(pending)
104
+ setConfirming(false)
104
105
  }
105
106
 
106
- const cancel = () => {
107
- setPending(null)
108
- setSessionCounts(null)
109
- }
107
+ const cancel = () => setConfirming(false)
110
108
 
111
- const confirmDialog: ReactNode = pending && sessionCounts ? (
112
- <div className="fixed inset-0 z-[100] flex items-center justify-center bg-black/50">
113
- <div className="bg-theme-surface border border-theme-border rounded-lg shadow-xl max-w-md mx-4 overflow-hidden">
109
+ const confirmDialog: ReactNode = (
110
+ <DialogPortal open={confirming} onClose={cancel} className="w-full max-w-md" ariaLabelledBy={titleId}>
111
+ {pending && sessionCounts && <>
114
112
  <div className="px-4 py-3 border-b border-theme-border flex items-center gap-2">
115
113
  <AlertTriangle className="w-5 h-5 text-amber-400" />
116
- <span className="font-medium text-theme-text-primary">Active Sessions</span>
114
+ <h2 id={titleId} className="font-medium text-theme-text-primary">Active Sessions</h2>
117
115
  </div>
118
116
  <div className="px-4 py-4">
119
117
  <p className="text-sm text-theme-text-secondary mb-3">
@@ -154,9 +152,9 @@ export function useContextSwitchFlow() {
154
152
  Switch Anyway
155
153
  </button>
156
154
  </div>
157
- </div>
158
- </div>
159
- ) : null
155
+ </>}
156
+ </DialogPortal>
157
+ )
160
158
 
161
159
  return {
162
160
  requestSwitch,
@@ -113,11 +113,13 @@ import { RightsizingStrip } from '../resource/RightsizingStrip'
113
113
  import { PrometheusChartsGrid } from '../resource/PrometheusChartsGrid'
114
114
  import { DatadogSetupHint, DatadogWorkloadCharts, useDatadogWorkloadCharts, WorkloadCostRightsizing } from '../resource/DatadogWorkloadCharts'
115
115
  import { PodDebugAction, usePodDetailAccess, type PodDebugTarget } from '../resources/PodDebugAction'
116
+ import { PodEvictAction, podEvictAccessKey, type PodEvictTarget } from '../resources/PodEvictAction'
116
117
  import { useNavCustomization } from '../../context/NavCustomization'
117
118
  import { RestartEventLane } from '../resource/RestartChart'
118
119
  import { WorkloadCostTab } from '../cost/WorkloadCostTab'
119
120
  import { isOpenCostWorkloadKind } from '../cost/kinds'
120
121
  import { isRadarFeatureUnsupported } from '../../api/radarFeatures'
122
+ import { useResourceActionAdapter } from '../../api/resourceActions'
121
123
  import { useTrafficAvailable } from '../../api/traffic'
122
124
  import { useIssueExpansion, useIssueRowNotes } from '../issues/useIssueExpansion'
123
125
  import { isNotFoundError, useResourceAudit, useResourceIssues, useSubjectIssues, useRadarFeature, useTrace, fetchTraceWithProbes, fetchInClusterCapability, runInClusterMerged } from '../../api/client'
@@ -343,7 +345,8 @@ function useActionsBarProps(
343
345
  group: string | undefined,
344
346
  cascadeEnabled: boolean,
345
347
  nodeUID: string,
346
- pod?: PodDebugTarget,
348
+ pod?: PodDebugTarget & PodEvictTarget,
349
+ podEvictEnabled = true,
347
350
  ) {
348
351
  const [deletePreviewOpen, setDeletePreviewOpen] = useState(false)
349
352
  const { showCopied } = useToast()
@@ -362,6 +365,7 @@ function useActionsBarProps(
362
365
  const showPortForward = canPortForward || !isLocal
363
366
 
364
367
  const deleteMutation = useDeleteResource()
368
+ const resourceActionAdapter = useResourceActionAdapter()
365
369
  const restartWorkloadMutation = useRestartWorkload()
366
370
  const pauseDeploymentMutation = usePauseDeployment()
367
371
  const resumeDeploymentMutation = useResumeDeployment()
@@ -392,8 +396,13 @@ function useActionsBarProps(
392
396
  const { support: replicaSetLogSupport } = useRadarFeature('replicaSetLogs')
393
397
  const isAppsReplicaSet = kind === 'replicasets' && group === 'apps'
394
398
  const { support: deploymentPauseSupport } = useRadarFeature('deploymentPause')
399
+ const deploymentPauseAvailable =
400
+ deploymentPauseSupport === 'supported' ||
401
+ (resourceActionAdapter.support === 'supported' &&
402
+ resourceActionAdapter.supportsAction('apps/Deployment/pause') &&
403
+ resourceActionAdapter.supportsAction('apps/Deployment/resume'))
395
404
  const canPauseDeployments = !workloadWritesPending &&
396
- canPauseDeployment({ name: kind, group }, workloadWrites, deploymentPauseSupport === 'supported')
405
+ canPauseDeployment({ name: kind, group }, workloadWrites, deploymentPauseAvailable)
397
406
  const cronJobPermissionsReady = kind === 'cronjobs' && group === 'batch' && !workloadWritesPending
398
407
  const allowCronJobTrigger = cronJobPermissionsReady && canTriggerCronJob(workloadWrites)
399
408
  const allowCronJobSuspend = cronJobPermissionsReady && canSuspendCronJob(workloadWrites)
@@ -457,6 +466,7 @@ function useActionsBarProps(
457
466
  canPortForward: showPortForward,
458
467
  onOpenTerminal: openTerminal,
459
468
  podDebugAction: pod && <PodDebugAction key={pod.metadata.uid} pod={pod} defaultImage={debugImage} unverifiedReview={unverifiedReview} debugDenial={debugDenial} reviewStatus={reviewStatus} />,
469
+ podEvictAction: pod && <PodEvictAction pod={pod} adapter={resourceActionAdapter} enabled={podEvictEnabled} />,
460
470
  onOpenLogs: openLogs,
461
471
  onOpenWorkloadLogs: openWorkloadLogs,
462
472
  replicaSetLogs: isAppsReplicaSet && replicaSetLogSupport === 'supported',
@@ -496,6 +506,7 @@ function useActionsBarProps(
496
506
  restartWorkloadMutation.mutate(params)
497
507
  : undefined,
498
508
  isRestarting: restartWorkloadMutation.isPending,
509
+ resourceActionAdapter,
499
510
  onPauseDeployment: canPauseDeployments
500
511
  ? (params: Parameters<typeof pauseDeploymentMutation.mutate>[0]) =>
501
512
  pauseDeploymentMutation.mutate(params)
@@ -728,6 +739,7 @@ export function WorkloadView({
728
739
  ...(apiKind === 'pods' && !effectiveGroup && resource?.metadata?.uid ? [
729
740
  queryClient.invalidateQueries({queryKey: ['capabilities', namespace], exact: true}),
730
741
  queryClient.invalidateQueries({queryKey: podDebugAccessKey(namespace, name, resource.metadata.uid)}),
742
+ queryClient.invalidateQueries({queryKey: podEvictAccessKey(namespace, name, resource.metadata.uid)}),
731
743
  ] : []),
732
744
  ...(apiKind === 'rayjobs' && effectiveGroup === 'ray.io' ? [
733
745
  queryClient.refetchQueries({ queryKey: ['resource', 'jobs', namespace, name, 'batch'], type: 'active' }),
@@ -936,7 +948,8 @@ export function WorkloadView({
936
948
  effectiveGroup,
937
949
  !resourceLoading && Boolean(resource),
938
950
  apiKind === 'nodes' && !effectiveGroup ? resource?.metadata?.uid ?? '' : '',
939
- apiKind === 'pods' && resource?.apiVersion === 'v1' && resource?.kind === 'Pod' ? resource : undefined,
951
+ apiKind === 'pods' && !effectiveGroup && resource?.apiVersion === 'v1' && resource?.kind === 'Pod' && resource?.metadata?.namespace === namespace && resource?.metadata?.name === name ? resource : undefined,
952
+ rest.active !== false && !resourceLoading && !isNotFoundError(resourceError),
940
953
  )
941
954
  const desktopDownload = useDesktopDownload()
942
955