@skyhook-io/k8s-ui 1.15.0 → 1.16.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.
- package/package.json +3 -3
- package/src/components/audit/AuditFindingsTable.tsx +1 -1
- package/src/components/checks/ChecksView.tsx +8 -8
- package/src/components/gitops/GitOpsDetailLayout.tsx +3 -1
- package/src/components/gitops/GitOpsHealthSourceNotice.tsx +12 -2
- package/src/components/gitops/index.ts +1 -0
- package/src/components/gitops/insights/GitOpsInsightViews.tsx +4 -1
- package/src/components/issues/IssuesView.tsx +2 -2
- package/src/components/logs/LogCore.tsx +131 -97
- package/src/components/logs/StructuredLogLine.tsx +18 -28
- package/src/components/logs/log-palette.ts +4 -0
- package/src/components/logs/useLogBuffer.ts +8 -39
- package/src/components/logs/useLogSearch.ts +52 -24
- package/src/components/namespace-switcher/NamespacePicker.test.tsx +140 -0
- package/src/components/namespace-switcher/NamespacePicker.tsx +26 -20
- package/src/components/resources/renderers/PodRenderer.test.tsx +15 -0
- package/src/components/resources/renderers/PodRenderer.tsx +10 -2
- package/src/components/resources/renderers/PolicySection.test.tsx +42 -0
- package/src/components/resources/renderers/PolicySection.tsx +10 -1
- package/src/components/shared/DrainPlanDialog.test.tsx +10 -0
- package/src/components/shared/DrainPlanDialog.tsx +14 -3
- package/src/components/shared/ResourceActionsBar.tsx +14 -9
- package/src/components/ui/FilterPill.tsx +1 -1
- package/src/components/ui/RadarUpgradeNote.click.test.tsx +24 -0
- package/src/components/ui/RadarUpgradeNote.test.tsx +66 -0
- package/src/components/ui/RadarUpgradeNote.tsx +129 -0
- package/src/components/ui/ResourceBar.tsx +12 -6
- package/src/components/ui/SelectMenu.tsx +62 -19
- package/src/components/ui/index.ts +8 -0
- package/src/components/workload/WorkloadView.tsx +109 -3
- package/src/types/core.ts +25 -4
- package/src/types/fetch-error.ts +33 -0
- package/src/utils/log-format.ts +1 -1
- package/src/utils/log-level.test.ts +269 -0
- package/src/utils/log-level.ts +301 -0
- package/src/utils/resource-hierarchy.test.ts +69 -0
- package/src/utils/resource-hierarchy.ts +87 -52
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skyhook-io/k8s-ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/skyhook-io/radar",
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"diff": "^9.0.0",
|
|
101
101
|
"elkjs": "^0.11.1",
|
|
102
102
|
"jsdom": "^29.1.1",
|
|
103
|
-
"lucide-react": "^1.
|
|
103
|
+
"lucide-react": "^1.48.0",
|
|
104
104
|
"monaco-editor": "0.55.1",
|
|
105
105
|
"react": "^19.3.0",
|
|
106
106
|
"react-dom": "^19.3.0",
|
|
107
107
|
"typescript": "^6.0.2",
|
|
108
|
-
"vitest": "^
|
|
108
|
+
"vitest": "^5.0.2",
|
|
109
109
|
"yaml": "^2.9.0"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -515,7 +515,7 @@ function FlatFindingRow({ finding, onResourceClick, showCluster, onClusterClick
|
|
|
515
515
|
onClusterClick ? (
|
|
516
516
|
<button
|
|
517
517
|
onClick={() => onClusterClick(finding.cluster!.id)}
|
|
518
|
-
className="text-xs text-[var(--color-radar-accent)] hover:underline shrink-0 max-w-[160px] truncate text-left"
|
|
518
|
+
className="text-xs text-[var(--color-radar-accent,var(--accent))] hover:underline shrink-0 max-w-[160px] truncate text-left"
|
|
519
519
|
>
|
|
520
520
|
{finding.cluster.name}
|
|
521
521
|
</button>
|
|
@@ -285,7 +285,7 @@ export function ChecksView({ checks, catalog, anyData, evaluated, missingInputs
|
|
|
285
285
|
placeholder="Search checks…"
|
|
286
286
|
value={search}
|
|
287
287
|
onChange={(e) => filters.setString('q', e.target.value)}
|
|
288
|
-
className="w-64 rounded-lg border border-theme-border-light bg-theme-base py-1.5 pl-9 pr-8 text-sm text-theme-text-primary placeholder-theme-text-disabled focus:outline-none focus:ring-2 focus:ring-[var(--color-radar-accent)]"
|
|
288
|
+
className="w-64 rounded-lg border border-theme-border-light bg-theme-base py-1.5 pl-9 pr-8 text-sm text-theme-text-primary placeholder-theme-text-disabled focus:outline-none focus:ring-2 focus:ring-[var(--color-radar-accent,var(--accent))]"
|
|
289
289
|
/>
|
|
290
290
|
{search && (
|
|
291
291
|
<button
|
|
@@ -340,7 +340,7 @@ export function ChecksView({ checks, catalog, anyData, evaluated, missingInputs
|
|
|
340
340
|
return (
|
|
341
341
|
<span
|
|
342
342
|
key={id}
|
|
343
|
-
className="inline-flex items-center gap-1 rounded-full border border-[var(--color-radar-accent)]/30 bg-[var(--color-radar-accent)]/10 py-1 pl-2.5 pr-1 text-xs text-theme-text-primary"
|
|
343
|
+
className="inline-flex items-center gap-1 rounded-full border border-[var(--color-radar-accent,var(--accent))]/30 bg-[var(--color-radar-accent,var(--accent))]/10 py-1 pl-2.5 pr-1 text-xs text-theme-text-primary"
|
|
344
344
|
>
|
|
345
345
|
<span className="min-w-0 max-w-[12rem] truncate">
|
|
346
346
|
<ClusterName name={label} />
|
|
@@ -520,7 +520,7 @@ function CheckReferenceLinks({ references }: { references: CheckReference[] }) {
|
|
|
520
520
|
href={r.url}
|
|
521
521
|
target="_blank"
|
|
522
522
|
rel="noreferrer"
|
|
523
|
-
className="inline-flex items-center gap-1 text-xs font-medium text-[var(--color-radar-accent)] hover:underline"
|
|
523
|
+
className="inline-flex items-center gap-1 text-xs font-medium text-[var(--color-radar-accent,var(--accent))] hover:underline"
|
|
524
524
|
>
|
|
525
525
|
{r.label}
|
|
526
526
|
<ExternalLink className="h-3 w-3" />
|
|
@@ -594,7 +594,7 @@ export function CheckCardShell({
|
|
|
594
594
|
onToggle()
|
|
595
595
|
}
|
|
596
596
|
}}
|
|
597
|
-
className={`group flex cursor-pointer items-center gap-3 border-l-[3px] py-3 pl-3 pr-4 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-radar-accent)]/40 ${open ? SEVERITY_HEADER_BAND_CLASS[sev] : SEVERITY_RAIL_CLASS[sev]}`}
|
|
597
|
+
className={`group flex cursor-pointer items-center gap-3 border-l-[3px] py-3 pl-3 pr-4 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-radar-accent,var(--accent))]/40 ${open ? SEVERITY_HEADER_BAND_CLASS[sev] : SEVERITY_RAIL_CLASS[sev]}`}
|
|
598
598
|
>
|
|
599
599
|
<SeverityIcon className={`h-[18px] w-[18px] shrink-0 ${SEVERITY_TEXT_CLASS[sev]}`} aria-hidden />
|
|
600
600
|
|
|
@@ -701,7 +701,7 @@ export function CheckClusterBreakdownShell<T extends CheckClusterBreakdownGroup>
|
|
|
701
701
|
<button
|
|
702
702
|
type="button"
|
|
703
703
|
onClick={() => setShowAllClusters(true)}
|
|
704
|
-
className="mt-0.5 inline-flex w-fit items-center gap-1 rounded px-2 py-1 text-xs font-medium text-[var(--color-radar-accent)] hover:underline"
|
|
704
|
+
className="mt-0.5 inline-flex w-fit items-center gap-1 rounded px-2 py-1 text-xs font-medium text-[var(--color-radar-accent,var(--accent))] hover:underline"
|
|
705
705
|
>
|
|
706
706
|
View all {groups.length} clusters →
|
|
707
707
|
</button>
|
|
@@ -849,7 +849,7 @@ function ResourceList({
|
|
|
849
849
|
<button
|
|
850
850
|
type="button"
|
|
851
851
|
onClick={() => setShowAll(true)}
|
|
852
|
-
className="mt-0.5 inline-flex w-fit items-center gap-1 rounded px-2 py-1 text-xs font-medium text-[var(--color-radar-accent)] hover:underline"
|
|
852
|
+
className="mt-0.5 inline-flex w-fit items-center gap-1 rounded px-2 py-1 text-xs font-medium text-[var(--color-radar-accent,var(--accent))] hover:underline"
|
|
853
853
|
>
|
|
854
854
|
View all {check.findings.length} →
|
|
855
855
|
</button>
|
|
@@ -875,7 +875,7 @@ function FindingLine({
|
|
|
875
875
|
<>
|
|
876
876
|
<span className="flex min-w-0 items-baseline gap-2">
|
|
877
877
|
<span className="shrink-0 font-mono text-[11px] uppercase tracking-wide text-theme-text-tertiary">{r.kind}</span>
|
|
878
|
-
<span className={`min-w-0 break-all font-medium ${linkable ? 'text-[var(--color-radar-accent)]' : 'text-theme-text-primary'}`}>
|
|
878
|
+
<span className={`min-w-0 break-all font-medium ${linkable ? 'text-[var(--color-radar-accent,var(--accent))]' : 'text-theme-text-primary'}`}>
|
|
879
879
|
{r.namespace ? `${r.namespace} / ` : ''}
|
|
880
880
|
{r.name}
|
|
881
881
|
</span>
|
|
@@ -1010,7 +1010,7 @@ function ClusterFilter({
|
|
|
1010
1010
|
onClick={() => onToggle(o.id)}
|
|
1011
1011
|
className="flex w-full items-center gap-2 px-3 py-1.5 text-left text-sm text-theme-text-secondary transition-colors hover:bg-theme-hover hover:text-theme-text-primary"
|
|
1012
1012
|
>
|
|
1013
|
-
<span className={`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${on ? 'border-[var(--color-radar-accent)] bg-[var(--color-radar-accent)] text-white' : 'border-theme-border'}`}>
|
|
1013
|
+
<span className={`flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-sm border ${on ? 'border-[var(--color-radar-accent,var(--accent))] bg-[var(--color-radar-accent,var(--accent))] text-white' : 'border-theme-border'}`}>
|
|
1014
1014
|
{on && <span className="text-[9px] leading-none">✓</span>}
|
|
1015
1015
|
</span>
|
|
1016
1016
|
<span className="min-w-0 truncate">
|
|
@@ -147,6 +147,7 @@ export interface GitOpsDetailLayoutProps {
|
|
|
147
147
|
remoteDestinationHint?: ReactNode
|
|
148
148
|
// Opens the host's Argo CD settings, when it has such a place.
|
|
149
149
|
onOpenSettings?: () => void
|
|
150
|
+
settingsNote?: string
|
|
150
151
|
|
|
151
152
|
// Action buttons — Argo + Flux. Exactly one applies for any given CR.
|
|
152
153
|
isArgoApp: boolean
|
|
@@ -235,6 +236,7 @@ export function GitOpsDetailLayout(props: GitOpsDetailLayoutProps) {
|
|
|
235
236
|
healthDocsUrl,
|
|
236
237
|
remoteDestinationHint,
|
|
237
238
|
onOpenSettings,
|
|
239
|
+
settingsNote,
|
|
238
240
|
isArgoApp,
|
|
239
241
|
isFlux,
|
|
240
242
|
isFluxWorkload,
|
|
@@ -475,7 +477,7 @@ export function GitOpsDetailLayout(props: GitOpsDetailLayoutProps) {
|
|
|
475
477
|
{!fullscreen && (
|
|
476
478
|
<>
|
|
477
479
|
<GitOpsStatusStrip insight={insight ?? undefined} loading={insightLoading} renderRevisionMeta={renderRevisionMeta} />
|
|
478
|
-
<GitOpsHealthSourceNotice summary={insight?.summary} changes={insight?.changes} docsUrl={healthDocsUrl} remoteDestinationHint={remoteDestinationHint} onOpenSettings={onOpenSettings} />
|
|
480
|
+
<GitOpsHealthSourceNotice summary={insight?.summary} changes={insight?.changes} docsUrl={healthDocsUrl} remoteDestinationHint={remoteDestinationHint} onOpenSettings={onOpenSettings} settingsNote={settingsNote} />
|
|
479
481
|
<GitOpsIssuesBand
|
|
480
482
|
issues={insight?.issues}
|
|
481
483
|
terminating={terminating}
|
|
@@ -61,12 +61,18 @@ export function hasRadarFinding(changes: GitOpsChange[] | undefined): boolean {
|
|
|
61
61
|
return (changes ?? []).some((c) => c.healthSource === 'radar' && (c.health === 'Degraded' || c.health === 'Missing'))
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
+
export function hasHealthSettingsHint(summary: HealthSourceNoticeSummary | undefined, changes: GitOpsChange[] | undefined): boolean {
|
|
65
|
+
return healthSourceNoticeKind(summary) === 'appTree'
|
|
66
|
+
&& (!!summary?.resourceHealthApiError || (!hasRadarFinding(changes) && summary?.health === 'Degraded'))
|
|
67
|
+
}
|
|
68
|
+
|
|
64
69
|
export function GitOpsHealthSourceNotice({
|
|
65
70
|
summary,
|
|
66
71
|
changes,
|
|
67
72
|
docsUrl,
|
|
68
73
|
remoteDestinationHint,
|
|
69
74
|
onOpenSettings,
|
|
75
|
+
settingsNote,
|
|
70
76
|
}: {
|
|
71
77
|
summary: HealthSourceNoticeSummary | undefined
|
|
72
78
|
// Decides between the two appTree sentences: with a Radar-sourced
|
|
@@ -84,6 +90,9 @@ export function GitOpsHealthSourceNotice({
|
|
|
84
90
|
// the first way out, and "check Settings" when a configured connection
|
|
85
91
|
// didn't deliver. Without it, only the Argo-side knob is named.
|
|
86
92
|
onOpenSettings?: () => void
|
|
93
|
+
// Host context shown before the settings link, such as settings that can
|
|
94
|
+
// be copied for this cluster.
|
|
95
|
+
settingsNote?: string
|
|
87
96
|
}) {
|
|
88
97
|
const kind = healthSourceNoticeKind(summary)
|
|
89
98
|
if (!kind) return null
|
|
@@ -92,7 +101,7 @@ export function GitOpsHealthSourceNotice({
|
|
|
92
101
|
// app with no Radar finding has nothing here to attribute.
|
|
93
102
|
const radarFinding = hasRadarFinding(changes)
|
|
94
103
|
const apiError = summary?.resourceHealthApiError
|
|
95
|
-
if (kind === 'appTree' && !radarFinding && !
|
|
104
|
+
if (kind === 'appTree' && !radarFinding && !hasHealthSettingsHint(summary, changes)) return null
|
|
96
105
|
const settingsLink = (label: string) =>
|
|
97
106
|
onOpenSettings ? (
|
|
98
107
|
<button type="button" onClick={onOpenSettings} className="underline decoration-theme-border underline-offset-2 hover:text-theme-text-primary">
|
|
@@ -117,7 +126,7 @@ export function GitOpsHealthSourceNotice({
|
|
|
117
126
|
{apiError ? (
|
|
118
127
|
<>
|
|
119
128
|
{APP_TREE_API_ERROR_NOTICE}: {apiError}.
|
|
120
|
-
{onOpenSettings && <> {settingsLink('Check Argo CD in Settings')}.</>}
|
|
129
|
+
{onOpenSettings && <> {settingsNote} {settingsLink('Check Argo CD in Settings')}.</>}
|
|
121
130
|
{' '}
|
|
122
131
|
{radarFinding ? APP_TREE_API_ERROR_FINDINGS : APP_TREE_API_ERROR_NO_FINDINGS}
|
|
123
132
|
</>
|
|
@@ -127,6 +136,7 @@ export function GitOpsHealthSourceNotice({
|
|
|
127
136
|
{!radarFinding && (
|
|
128
137
|
<>
|
|
129
138
|
{' '}
|
|
139
|
+
{settingsNote && onOpenSettings && <>{settingsNote}{' '}</>}
|
|
130
140
|
To see Argo's per-resource health here, {onOpenSettings && <>{settingsLink('connect Radar to your Argo CD server')}, or </>}
|
|
131
141
|
{APP_TREE_PERSIST_REMEDY}
|
|
132
142
|
</>
|
|
@@ -61,4 +61,5 @@ export type {
|
|
|
61
61
|
GitOpsHelmValuesData,
|
|
62
62
|
} from './GitOpsDetailLayout'
|
|
63
63
|
export { GitOpsHealthSourceNotice, healthSourceNoticeKind, hasRadarFinding, APP_TREE_HEALTH_NOTICE, APP_TREE_NO_FINDINGS_NOTICE, REMOTE_DESTINATION_NOTICE, REMOTE_FLUX_TARGET_NOTICE } from './GitOpsHealthSourceNotice'
|
|
64
|
+
export { hasHealthSettingsHint } from './GitOpsHealthSourceNotice'
|
|
64
65
|
export { radarHealthNote, RADAR_HEALTH_NOTE } from './health-provenance'
|
|
@@ -739,6 +739,7 @@ interface GitOpsChangesViewProps {
|
|
|
739
739
|
// Opens the global Settings dialog. Backs the "Connect Argo CD" hint shown
|
|
740
740
|
// when the root is an Argo Application without the diff integration.
|
|
741
741
|
onOpenSettings?: () => void
|
|
742
|
+
settingsNote?: string
|
|
742
743
|
}
|
|
743
744
|
|
|
744
745
|
// Status facets for the Resources list. OutOfSync is a sync-status concern
|
|
@@ -749,7 +750,7 @@ const STATUS_FACETS: { key: ResourceStatusFacet; label: string; tone: FilterPill
|
|
|
749
750
|
{ key: 'missing', label: 'Missing', tone: 'danger' },
|
|
750
751
|
]
|
|
751
752
|
|
|
752
|
-
export function GitOpsChangesView({ insight, error, onOpenResource, onSyncResource, syncResourceDisabledReason, focusKey, tree, renderResourceDiff, onOpenSettings }: GitOpsChangesViewProps) {
|
|
753
|
+
export function GitOpsChangesView({ insight, error, onOpenResource, onSyncResource, syncResourceDisabledReason, focusKey, tree, renderResourceDiff, onOpenSettings, settingsNote }: GitOpsChangesViewProps) {
|
|
753
754
|
// "All resources" toggle: when on, render generated descendants alongside
|
|
754
755
|
// the controller's declared inventory. Argo's UI defaults to "all" — we
|
|
755
756
|
// default to "declared" because the diagnostic data (drift, events) lives
|
|
@@ -1009,12 +1010,14 @@ export function GitOpsChangesView({ insight, error, onOpenResource, onSyncResour
|
|
|
1009
1010
|
{insight.capabilities?.argoConfigured ? (
|
|
1010
1011
|
<>
|
|
1011
1012
|
Argo CD's full Git-rendered diff isn't available for this app (connection down or token not authorized).{' '}
|
|
1013
|
+
{settingsNote && <>{settingsNote} </>}
|
|
1012
1014
|
<button type="button" onClick={onOpenSettings} className="font-medium text-accent-text hover:underline">
|
|
1013
1015
|
Check Argo CD in Settings
|
|
1014
1016
|
</button>.
|
|
1015
1017
|
</>
|
|
1016
1018
|
) : (
|
|
1017
1019
|
<>
|
|
1020
|
+
{settingsNote && <>{settingsNote} </>}
|
|
1018
1021
|
<button type="button" onClick={onOpenSettings} className="font-medium text-accent-text hover:underline">
|
|
1019
1022
|
Connect Argo CD
|
|
1020
1023
|
</button>{' '}
|
|
@@ -283,7 +283,7 @@ export function IssueRow({
|
|
|
283
283
|
onToggle();
|
|
284
284
|
}
|
|
285
285
|
}}
|
|
286
|
-
className={`group @container/issue flex cursor-pointer items-center gap-3 border-l-[3px] py-3 pl-3 pr-4 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-radar-accent)]/40 ${open ? ISSUE_SEVERITY_HEADER_BAND_CLASS[severity] : ISSUE_SEVERITY_RAIL_CLASS[severity]}`}
|
|
286
|
+
className={`group @container/issue flex cursor-pointer items-center gap-3 border-l-[3px] py-3 pl-3 pr-4 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--color-radar-accent,var(--accent))]/40 ${open ? ISSUE_SEVERITY_HEADER_BAND_CLASS[severity] : ISSUE_SEVERITY_RAIL_CLASS[severity]}`}
|
|
287
287
|
>
|
|
288
288
|
<SeverityIcon className={`h-[18px] w-[18px] shrink-0 ${ISSUE_SEVERITY_TEXT_CLASS[severity]}`} aria-hidden />
|
|
289
289
|
|
|
@@ -719,7 +719,7 @@ function ResourceLine({
|
|
|
719
719
|
) : (
|
|
720
720
|
<span className="shrink-0 font-mono text-[11px] uppercase tracking-wide text-theme-text-tertiary">{r.kind}</span>
|
|
721
721
|
)}
|
|
722
|
-
<span className={`min-w-0 truncate text-sm ${linkable ? `${compact ? 'font-semibold' : 'font-medium'} text-[var(--color-radar-accent)]` : 'font-medium text-theme-text-primary'}`}>
|
|
722
|
+
<span className={`min-w-0 truncate text-sm ${linkable ? `${compact ? 'font-semibold' : 'font-medium'} text-[var(--color-radar-accent,var(--accent))]` : 'font-medium text-theme-text-primary'}`}>
|
|
723
723
|
{r.namespace ? `${r.namespace} / ` : ''}
|
|
724
724
|
{r.name}
|
|
725
725
|
</span>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useRef, useCallback, useState, useMemo, useEffect, type ReactNode } from 'react'
|
|
2
2
|
import { Virtuoso, type VirtuosoHandle } from 'react-virtuoso'
|
|
3
|
-
import { Play, Square, Download, FileDown, Search, X, Terminal, RotateCcw, ChevronUp, ChevronDown, ChevronRight, CaseSensitive, Regex, WrapText, Clock, Copy, Trash2, Filter, Braces, Palette, ListCollapse, Sun, Moon } from 'lucide-react'
|
|
3
|
+
import { Play, Square, Download, FileDown, Search, X, Terminal, RotateCcw, ChevronUp, ChevronDown, ChevronRight, CaseSensitive, Regex, WrapText, Clock, Copy, Trash2, Filter, EyeOff, Highlighter, Braces, Palette, ListCollapse, Sun, Moon } from 'lucide-react'
|
|
4
4
|
import type { LogEntry, LogLevel } from './useLogBuffer'
|
|
5
|
-
import { useLogSearch } from './useLogSearch'
|
|
5
|
+
import { useLogSearch, type LogSearchMode } from './useLogSearch'
|
|
6
6
|
import { StructuredLogLine } from './StructuredLogLine'
|
|
7
7
|
import { Tooltip } from '../ui/Tooltip'
|
|
8
8
|
import { Input } from '../ui/Input'
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
TIMESTAMP_FORMAT_LABELS,
|
|
17
17
|
} from '../../utils/log-format'
|
|
18
18
|
import { getLogPalette, getLogLevelColor, type LogPalette } from './log-palette'
|
|
19
|
+
import { associateContinuations, groupContinuations, type LogGroup } from '../../utils/log-level'
|
|
19
20
|
import { copyText } from '../../utils/clipboard'
|
|
20
21
|
import { useAnimatedUnmount } from '../../hooks/useAnimatedUnmount'
|
|
21
22
|
import { TRANSITION_MENU, overlayExitMs, overlayTransitionStyle } from '../../utils/animation'
|
|
@@ -71,13 +72,16 @@ interface LogCoreProps {
|
|
|
71
72
|
interface LevelOption {
|
|
72
73
|
level: LogLevel
|
|
73
74
|
label: string
|
|
75
|
+
/** What the chip's lines are called in its tooltip */
|
|
76
|
+
noun: string
|
|
74
77
|
}
|
|
75
78
|
|
|
76
79
|
const LEVEL_OPTIONS: LevelOption[] = [
|
|
77
|
-
{ level: 'error', label: 'ERR' },
|
|
78
|
-
{ level: 'warn', label: 'WARN' },
|
|
79
|
-
{ level: 'info', label: 'INFO' },
|
|
80
|
-
{ level: 'debug', label: 'DBG' },
|
|
80
|
+
{ level: 'error', label: 'ERR', noun: 'error logs' },
|
|
81
|
+
{ level: 'warn', label: 'WARN', noun: 'warning logs' },
|
|
82
|
+
{ level: 'info', label: 'INFO', noun: 'info logs' },
|
|
83
|
+
{ level: 'debug', label: 'DBG', noun: 'debug logs' },
|
|
84
|
+
{ level: 'unknown', label: 'OTHER', noun: 'lines with no level' },
|
|
81
85
|
]
|
|
82
86
|
|
|
83
87
|
function getLevelActiveColor(level: LogLevel, palette: LogPalette): string {
|
|
@@ -86,7 +90,7 @@ function getLevelActiveColor(level: LogLevel, palette: LogPalette): string {
|
|
|
86
90
|
case 'warn': return palette.levelActiveWarn
|
|
87
91
|
case 'info': return palette.levelActiveInfo
|
|
88
92
|
case 'debug': return palette.levelActiveDebug
|
|
89
|
-
default: return palette.
|
|
93
|
+
default: return palette.levelActiveOther
|
|
90
94
|
}
|
|
91
95
|
}
|
|
92
96
|
|
|
@@ -121,19 +125,6 @@ const TIMESTAMP_FORMAT_SHORT_LABELS: Record<TimestampFormat, string> = {
|
|
|
121
125
|
'epoch': 'Unix time',
|
|
122
126
|
}
|
|
123
127
|
|
|
124
|
-
function isContinuationLine(content: string): boolean {
|
|
125
|
-
// Lines starting with whitespace are the dominant stack-trace continuation pattern:
|
|
126
|
-
// Java `\tat com.foo.Bar`, Go `\tpackage.func`, Node ` at func`, Python ` File "..."`.
|
|
127
|
-
if (/^\s/.test(content)) return true
|
|
128
|
-
// Java's secondary chain markers that don't start with whitespace.
|
|
129
|
-
return /^(Caused by:|Suppressed:|\.\.\. \d+ more)/.test(content)
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
interface LogGroup {
|
|
133
|
-
head: LogEntry
|
|
134
|
-
continuations: LogEntry[]
|
|
135
|
-
}
|
|
136
|
-
|
|
137
128
|
const TIP_DELAY = 150
|
|
138
129
|
|
|
139
130
|
export function LogCore({
|
|
@@ -201,7 +192,7 @@ export function LogCore({
|
|
|
201
192
|
try { return localStorage.getItem('radar-logs-collapse-stacks') !== 'false' } catch { return true }
|
|
202
193
|
})
|
|
203
194
|
const [enabledLevels, setEnabledLevels] = useState<Set<LogLevel>>(
|
|
204
|
-
new Set(['error', 'warn', 'info', 'debug'])
|
|
195
|
+
new Set(['error', 'warn', 'info', 'debug', 'unknown'])
|
|
205
196
|
)
|
|
206
197
|
const [showDownloadMenu, setShowDownloadMenu] = useState(false)
|
|
207
198
|
const downloadMenu = useAnimatedUnmount(showDownloadMenu, overlayExitMs('menu'))
|
|
@@ -232,32 +223,50 @@ export function LogCore({
|
|
|
232
223
|
return () => clearInterval(id)
|
|
233
224
|
}, [tsFormat, showTimestamps])
|
|
234
225
|
|
|
235
|
-
//
|
|
236
|
-
//
|
|
226
|
+
// One membership rule for filtering, counting and grouping: a stack-trace
|
|
227
|
+
// line belongs to the record its own pod and container started.
|
|
228
|
+
const association = useMemo(() => {
|
|
229
|
+
const { headOf, effectiveLevel } = associateContinuations(entries)
|
|
230
|
+
const headIdById = new Map<number, number>()
|
|
231
|
+
for (let i = 0; i < entries.length; i++) {
|
|
232
|
+
if (headOf[i] !== i) headIdById.set(entries[i].id, entries[headOf[i]].id)
|
|
233
|
+
}
|
|
234
|
+
return { headOf, effectiveLevel, headIdById }
|
|
235
|
+
}, [entries])
|
|
236
|
+
|
|
237
|
+
// Frames take their record's level so they filter and render as part of it.
|
|
238
|
+
const recordEntries = useMemo(
|
|
239
|
+
() => entries.map((e, i) => (association.effectiveLevel[i] === e.level ? e : { ...e, level: association.effectiveLevel[i] })),
|
|
240
|
+
[entries, association],
|
|
241
|
+
)
|
|
242
|
+
|
|
237
243
|
const levelFilteredEntries = useMemo(() => {
|
|
238
244
|
const allEnabled = LEVEL_OPTIONS.every(opt => enabledLevels.has(opt.level))
|
|
239
|
-
if (allEnabled) return
|
|
240
|
-
return
|
|
241
|
-
}, [
|
|
245
|
+
if (allEnabled) return recordEntries
|
|
246
|
+
return recordEntries.filter(e => enabledLevels.has(e.level))
|
|
247
|
+
}, [recordEntries, enabledLevels])
|
|
242
248
|
|
|
243
|
-
//
|
|
249
|
+
// Chip counts count records, so a 40-frame stack trace is one error.
|
|
244
250
|
const levelCounts = useMemo(() => {
|
|
245
251
|
const counts: Record<LogLevel, number> = { error: 0, warn: 0, info: 0, debug: 0, unknown: 0 }
|
|
246
|
-
for (
|
|
247
|
-
counts[
|
|
252
|
+
for (let i = 0; i < entries.length; i++) {
|
|
253
|
+
if (association.headOf[i] === i) counts[entries[i].level]++
|
|
248
254
|
}
|
|
249
255
|
return counts
|
|
250
|
-
}, [entries])
|
|
256
|
+
}, [entries, association])
|
|
251
257
|
|
|
252
258
|
const hasStructuredEntries = useMemo(() => entries.some(e => e.isJson || e.isLogfmt), [entries])
|
|
253
259
|
|
|
254
|
-
|
|
255
|
-
|
|
260
|
+
const recordIdOf = useCallback(
|
|
261
|
+
(e: LogEntry) => association.headIdById.get(e.id) ?? e.id,
|
|
262
|
+
[association],
|
|
263
|
+
)
|
|
264
|
+
const search = useLogSearch(levelFilteredEntries, virtuosoRef, recordIdOf)
|
|
256
265
|
|
|
257
|
-
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
266
|
+
const displayEntries = search.isFiltering ? search.filteredEntries : levelFilteredEntries
|
|
267
|
+
const hiddenCount = levelFilteredEntries.length - displayEntries.length
|
|
268
|
+
// Hidden lines leave nothing to highlight, so Hide keeps normal rendering and stack grouping.
|
|
269
|
+
const highlightQuery = search.mode === 'hide' ? '' : search.query
|
|
261
270
|
|
|
262
271
|
const exportTriggerRef = useRef<HTMLButtonElement>(null)
|
|
263
272
|
const closeExportMenu = useCallback(() => {
|
|
@@ -464,12 +473,12 @@ export function LogCore({
|
|
|
464
473
|
}, [])
|
|
465
474
|
|
|
466
475
|
// Clicking a filter chip in a structured log value pushes the value into the
|
|
467
|
-
// log search and
|
|
476
|
+
// log search and shows only the lines that match it.
|
|
468
477
|
const handleFilterValue = useCallback((value: string) => {
|
|
469
478
|
search.setQuery(value)
|
|
470
479
|
// Values often contain regex metacharacters — force literal-substring matching.
|
|
471
480
|
search.setIsRegex(false)
|
|
472
|
-
search.
|
|
481
|
+
search.setMode('only')
|
|
473
482
|
if (!search.isOpen) search.open()
|
|
474
483
|
}, [search])
|
|
475
484
|
|
|
@@ -486,28 +495,19 @@ export function LogCore({
|
|
|
486
495
|
}, [])
|
|
487
496
|
|
|
488
497
|
// Highlight set for current match
|
|
489
|
-
const currentHighlightId = search.matchIndices.length
|
|
490
|
-
?
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
//
|
|
496
|
-
// Disabled while search is active so matches inside continuations remain visible.
|
|
498
|
+
const currentHighlightId = search.matchIndices.length === 0 || search.mode === 'hide'
|
|
499
|
+
? -1
|
|
500
|
+
: levelFilteredEntries[search.matchIndices[search.currentMatch]]?.id
|
|
501
|
+
|
|
502
|
+
// Group stack-trace lines under the line that started their record. Disabled
|
|
503
|
+
// while highlighting so matches inside stack frames remain visible. A line
|
|
504
|
+
// whose record start is filtered out stays on its own row.
|
|
497
505
|
const groupedEntries = useMemo<LogGroup[]>(() => {
|
|
498
|
-
if (!collapseStacks ||
|
|
506
|
+
if (!collapseStacks || highlightQuery) {
|
|
499
507
|
return displayEntries.map(e => ({ head: e, continuations: [] }))
|
|
500
508
|
}
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
if (groups.length > 0 && isContinuationLine(entry.content)) {
|
|
504
|
-
groups[groups.length - 1].continuations.push(entry)
|
|
505
|
-
} else {
|
|
506
|
-
groups.push({ head: entry, continuations: [] })
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
return groups
|
|
510
|
-
}, [displayEntries, collapseStacks, search.query])
|
|
509
|
+
return groupContinuations(displayEntries, association.headIdById)
|
|
510
|
+
}, [displayEntries, collapseStacks, highlightQuery, association])
|
|
511
511
|
|
|
512
512
|
const scrollToBottom = useCallback(() => {
|
|
513
513
|
virtuosoRef.current?.scrollToIndex({
|
|
@@ -584,7 +584,7 @@ export function LogCore({
|
|
|
584
584
|
const active = enabledLevels.has(opt.level)
|
|
585
585
|
const count = levelCounts[opt.level]
|
|
586
586
|
return (
|
|
587
|
-
<Tooltip key={opt.level} content={`${active ? 'Hide' : 'Show'} ${opt.
|
|
587
|
+
<Tooltip key={opt.level} content={`${active ? 'Hide' : 'Show'} ${opt.noun}`} delay={TIP_DELAY} position="bottom">
|
|
588
588
|
<button
|
|
589
589
|
onClick={() => toggleLevel(opt.level)}
|
|
590
590
|
className={`px-1.5 py-0.5 text-[10px] font-medium rounded border transition-colors ${
|
|
@@ -876,7 +876,7 @@ export function LogCore({
|
|
|
876
876
|
|
|
877
877
|
{/* Search bar */}
|
|
878
878
|
{search.isOpen && (
|
|
879
|
-
<div className={
|
|
879
|
+
<div className={`@container/logsearch flex items-center gap-2 px-3 py-2 border-b ${palette.border} ${palette.toolbarBgMuted}`}>
|
|
880
880
|
<Search className={`w-4 h-4 ${palette.textSecondary} shrink-0`} />
|
|
881
881
|
<Input
|
|
882
882
|
value={search.query}
|
|
@@ -921,47 +921,43 @@ export function LogCore({
|
|
|
921
921
|
</button>
|
|
922
922
|
</Tooltip>
|
|
923
923
|
|
|
924
|
-
|
|
925
|
-
<Tooltip content={search.isFilterMode ? 'Highlight mode' : 'Filter mode'} delay={TIP_DELAY} position="bottom">
|
|
926
|
-
<button
|
|
927
|
-
onClick={search.toggleFilterMode}
|
|
928
|
-
className={`p-1 rounded transition-colors ${
|
|
929
|
-
search.isFilterMode ? palette.toolbarActive : `${palette.textTertiary} ${palette.hoverText}`
|
|
930
|
-
}`}
|
|
931
|
-
>
|
|
932
|
-
<Filter className="w-3.5 h-3.5" />
|
|
933
|
-
</button>
|
|
934
|
-
</Tooltip>
|
|
924
|
+
<SearchModeControl mode={search.mode} onChange={search.setMode} palette={palette} />
|
|
935
925
|
|
|
936
926
|
{search.query && (
|
|
937
927
|
<>
|
|
938
928
|
<span className={`text-xs whitespace-nowrap ${search.regexError ? palette.textError : palette.textTertiary}`}>
|
|
939
929
|
{search.regexError
|
|
940
930
|
? 'Invalid regex'
|
|
941
|
-
: search.
|
|
942
|
-
? `${
|
|
943
|
-
:
|
|
931
|
+
: search.mode === 'hide'
|
|
932
|
+
? `${hiddenCount.toLocaleString()} hidden`
|
|
933
|
+
: search.matchCount > 0
|
|
934
|
+
? `${search.currentMatch + 1} / ${search.matchCount}`
|
|
935
|
+
: '0 results'}
|
|
944
936
|
</span>
|
|
945
937
|
|
|
946
|
-
{/*
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
938
|
+
{/* Matches are off screen in Hide mode, so there is nothing to step through */}
|
|
939
|
+
{search.mode !== 'hide' && (
|
|
940
|
+
<>
|
|
941
|
+
<Tooltip content="Previous (Shift+Enter)" delay={TIP_DELAY} position="bottom">
|
|
942
|
+
<button
|
|
943
|
+
onClick={search.goToPrev}
|
|
944
|
+
disabled={search.matchCount === 0}
|
|
945
|
+
className={`p-1 rounded ${palette.textSecondary} ${palette.hoverText} disabled:opacity-30`}
|
|
946
|
+
>
|
|
947
|
+
<ChevronUp className="w-3.5 h-3.5" />
|
|
948
|
+
</button>
|
|
949
|
+
</Tooltip>
|
|
950
|
+
<Tooltip content="Next (Enter)" delay={TIP_DELAY} position="bottom">
|
|
951
|
+
<button
|
|
952
|
+
onClick={search.goToNext}
|
|
953
|
+
disabled={search.matchCount === 0}
|
|
954
|
+
className={`p-1 rounded ${palette.textSecondary} ${palette.hoverText} disabled:opacity-30`}
|
|
955
|
+
>
|
|
956
|
+
<ChevronDown className="w-3.5 h-3.5" />
|
|
957
|
+
</button>
|
|
958
|
+
</Tooltip>
|
|
959
|
+
</>
|
|
960
|
+
)}
|
|
965
961
|
|
|
966
962
|
<button
|
|
967
963
|
onClick={() => search.setQuery('')}
|
|
@@ -990,8 +986,8 @@ export function LogCore({
|
|
|
990
986
|
) : groupedEntries.length === 0 ? (
|
|
991
987
|
<div className={`${EMPTY_STATE_CLASS} ${palette.textTertiary}`}>
|
|
992
988
|
<Terminal className="w-8 h-8" />
|
|
993
|
-
<span>{emptyMessage}</span>
|
|
994
|
-
{emptyCommand && (
|
|
989
|
+
<span>{entries.length > 0 ? `Filters hide all ${entries.length.toLocaleString()} loaded lines` : emptyMessage}</span>
|
|
990
|
+
{entries.length === 0 && emptyCommand && (
|
|
995
991
|
<button type="button" onClick={() => { void copyText(emptyCommand) }} className={`mt-2 inline-flex max-w-[80%] items-center gap-2 rounded border px-3 py-2 font-mono text-xs ${palette.border} ${palette.toolbarBg}`} title="Copy recovery command">
|
|
996
992
|
<code className="truncate">{emptyCommand}</code>
|
|
997
993
|
<Copy className="h-3.5 w-3.5 shrink-0" />
|
|
@@ -1011,7 +1007,7 @@ export function LogCore({
|
|
|
1011
1007
|
itemContent={(_index, group) => (
|
|
1012
1008
|
<LogGroupItem
|
|
1013
1009
|
group={group}
|
|
1014
|
-
searchQuery={
|
|
1010
|
+
searchQuery={highlightQuery}
|
|
1015
1011
|
searchIsRegex={search.isRegex}
|
|
1016
1012
|
searchIsCaseSensitive={search.isCaseSensitive}
|
|
1017
1013
|
showPodName={showPodName}
|
|
@@ -1047,14 +1043,52 @@ export function LogCore({
|
|
|
1047
1043
|
<div className={`flex items-center gap-4 px-3 py-1 border-t ${palette.border} ${palette.toolbarBg} text-[10px] ${palette.textDisabled}`}>
|
|
1048
1044
|
{onStartStream && <Shortcut keys="S" label={isStreaming ? 'Stop stream' : 'Stream'} palette={palette} />}
|
|
1049
1045
|
<Shortcut keys="Ctrl+F" label="Search" palette={palette} />
|
|
1050
|
-
|
|
1051
|
-
|
|
1046
|
+
{search.mode !== 'hide' && (
|
|
1047
|
+
<>
|
|
1048
|
+
<Shortcut keys="Enter" label="Next match" palette={palette} />
|
|
1049
|
+
<Shortcut keys="Shift+Enter" label="Prev match" palette={palette} />
|
|
1050
|
+
</>
|
|
1051
|
+
)}
|
|
1052
1052
|
<Shortcut keys="Esc" label="Close search" palette={palette} />
|
|
1053
1053
|
</div>
|
|
1054
1054
|
</div>
|
|
1055
1055
|
)
|
|
1056
1056
|
}
|
|
1057
1057
|
|
|
1058
|
+
const SEARCH_MODES: { mode: LogSearchMode; label: string; tip: string; Icon: typeof Filter }[] = [
|
|
1059
|
+
{ mode: 'highlight', label: 'Highlight', tip: 'Show all lines and highlight matches', Icon: Highlighter },
|
|
1060
|
+
{ mode: 'only', label: 'Only matching', tip: 'Show only matching lines, with their stack traces', Icon: Filter },
|
|
1061
|
+
{ mode: 'hide', label: 'Hide matching', tip: 'Hide matching lines and their stack traces, like grep -v', Icon: EyeOff },
|
|
1062
|
+
]
|
|
1063
|
+
|
|
1064
|
+
/** What the search query does to the list. Labels collapse to icons when the search row is narrow. */
|
|
1065
|
+
function SearchModeControl({ mode, onChange, palette }: {
|
|
1066
|
+
mode: LogSearchMode
|
|
1067
|
+
onChange: (mode: LogSearchMode) => void
|
|
1068
|
+
palette: LogPalette
|
|
1069
|
+
}) {
|
|
1070
|
+
return (
|
|
1071
|
+
<div role="radiogroup" aria-label="Search mode" className={`flex items-center shrink-0 rounded border ${palette.border}`}>
|
|
1072
|
+
{SEARCH_MODES.map(({ mode: m, label, tip, Icon }) => (
|
|
1073
|
+
<Tooltip key={m} content={tip} delay={TIP_DELAY} position="bottom">
|
|
1074
|
+
<button
|
|
1075
|
+
role="radio"
|
|
1076
|
+
aria-checked={mode === m}
|
|
1077
|
+
aria-label={label}
|
|
1078
|
+
onClick={() => onChange(m)}
|
|
1079
|
+
className={`flex items-center gap-1 px-1.5 py-0.5 text-[11px] whitespace-nowrap transition-colors ${
|
|
1080
|
+
mode === m ? palette.toolbarActive : `${palette.textTertiary} ${palette.hoverText}`
|
|
1081
|
+
}`}
|
|
1082
|
+
>
|
|
1083
|
+
<Icon className="w-3.5 h-3.5" />
|
|
1084
|
+
<span className="hidden @xl/logsearch:inline">{label}</span>
|
|
1085
|
+
</button>
|
|
1086
|
+
</Tooltip>
|
|
1087
|
+
))}
|
|
1088
|
+
</div>
|
|
1089
|
+
)
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1058
1092
|
/** One pill in the export popover's scope and format rows. */
|
|
1059
1093
|
function ExportChoice({ active, onClick, palette, children }: {
|
|
1060
1094
|
active: boolean
|