Skip to content

Project NOMAD is an offline-first knowledge and education server. Wikipedia, thousands of books, courses, maps, and optional local AI, all running on hardware you own with no internet required.

TypeScript

fix(KB): TierSelectionModal hook order + register IconLibrary

Chris Sherwood6e5284e563a4
diff --git a/admin/inertia/components/TierSelectionModal.tsx b/admin/inertia/components/TierSelectionModal.tsx
index 3db50941..255adb3f 100644
--- a/admin/inertia/components/TierSelectionModal.tsx
+++ b/admin/inertia/components/TierSelectionModal.tsx
@@ -96,6 +96,18 @@ const TierSelectionModal: React.FC<TierSelectionModalProps> = ({
// underneath. Cancel returns to the tier modal as-is; Proceed closes both
// and runs the original onSelectTier path.
const [guardrailVerdict, setGuardrailVerdict] = useState<GuardrailVerdict | null>(null)
+
+ // Compute disk-free bytes from system info; 0 means "unknown", which the
+ // guardrail helper treats as "skip the relative-disk check".
+ // Must be declared before the `!category` early return so the hook count
+ // stays constant across renders (category transitions null → non-null when
+ // the user opens the modal).
+ const freeBytes = useMemo<number>(() => {
+ const primary = getPrimaryDiskInfo(systemInfo?.disk, systemInfo?.fsSize)
+ if (!primary) return 0
+ return Math.max(0, primary.totalSize - primary.totalUsed)
+ }, [systemInfo])
+
const ingestPolicy: 'Always' | 'Manual' =
ingestPolicySetting?.value === 'Manual' ? 'Manual' : 'Always'
@@ -114,14 +126,6 @@ const TierSelectionModal: React.FC<TierSelectionModalProps> = ({
}
}
- // Compute disk-free bytes from system info; 0 means "unknown", which the
- // guardrail helper treats as "skip the relative-disk check".
- const freeBytes = useMemo<number>(() => {
- const primary = getPrimaryDiskInfo(systemInfo?.disk, systemInfo?.fsSize)
- if (!primary) return 0
- return Math.max(0, primary.totalSize - primary.totalUsed)
- }, [systemInfo])
-
/**
* Runs the original onSelectTier-then-onClose flow. Pulled out of
* handleSubmit so the guardrail modal's confirm path can call it after
diff --git a/admin/inertia/lib/icons.ts b/admin/inertia/lib/icons.ts
index cf9484d7..75a039df 100644
--- a/admin/inertia/lib/icons.ts
+++ b/admin/inertia/lib/icons.ts
@@ -32,6 +32,7 @@ import {
IconInfoCircle,
IconBug,
IconCopy,
+ IconLibrary,
IconServer,
IconMenu2,
IconArrowLeft,
@@ -75,6 +76,7 @@ export const icons = {
IconDownload,
IconHome,
IconInfoCircle,
+ IconLibrary,
IconLogs,
IconMap,
IconMenu2,