From 7a681d04ab46f2cca6d05b0659ecdf54b885ba81 Mon Sep 17 00:00:00 2001 From: Chris Sherwood Date: Thu, 14 May 2026 16:28:53 -0700 Subject: [PATCH] feat(KB): wizard AI policy step (RFC #883 Phase 3 task 13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds an inline auto-index policy choice inside the Easy Setup wizard's existing AI section (Step 3 'Content', alongside AI model selection). The selection is persisted to KVStore['rag.defaultIngestPolicy'] on wizard submit — same key #894's KB modal toggle reads/writes — so a user who completes the wizard never sees the first-chat JIT prompt (#899); their decision is already recorded. Default is 'Always' so new users who keep the default get the 'just works' experience: content downloaded by the wizard becomes searchable as soon as it finishes embedding, without a follow-up step. Users who prefer the explicit-opt-in flow can flip to 'Manual' before submitting. Skipped when the user doesn't select the AI capability — the KV stays null and the JIT prompt handles the decision later if/when they enable AI from settings. UI placement - Step 3 'Content': new section below AI Models grid (only when AI is selected), two-button radio matching #894's KB-modal toggle pattern for visual consistency - Step 4 'Review': new 'Auto-index Setting' card summarizing the choice in plain English ('New content will be indexed automatically' vs 'New content will wait for you to opt in') so the user knows what they're agreeing to before clicking Complete Setup handleFinish - New api.updateSetting('rag.defaultIngestPolicy', ingestPolicy) call runs first, before service installs/downloads, so any content that finishes embedding during this same wizard run sees the right policy - Wrapped in its own try/catch so a transient KV write failure doesn't abort the rest of the wizard Stacks on feat/kb-policy-toggle (#894) — uses the policy KV mechanism that PR introduces. Auto-rebases to rc when #894 merges. Pairs with #899 (JIT prompt): wizard users decide here; non-wizard users decide at first chat. Together they cover every entry path to v1.32.0 without double-prompting. --- admin/inertia/pages/easy-setup/index.tsx | 84 ++++++++++++++++++++++++ 1 file changed, 84 insertions(+) diff --git a/admin/inertia/pages/easy-setup/index.tsx b/admin/inertia/pages/easy-setup/index.tsx index 2036faf..f310db8 100644 --- a/admin/inertia/pages/easy-setup/index.tsx +++ b/admin/inertia/pages/easy-setup/index.tsx @@ -122,6 +122,13 @@ export default function EasySetupWizard(props: { const [selectedServices, setSelectedServices] = useState([]) const [selectedMapCollections, setSelectedMapCollections] = useState([]) const [selectedAiModels, setSelectedAiModels] = useState([]) + // Auto-index policy for the AI Assistant Knowledge Base. Defaults to + // 'Always' so a new user who keeps the default behavior gets the "just + // works" experience — downloads become searchable automatically. Persisted + // to KVStore['rag.defaultIngestPolicy'] on wizard submit (same key #894's + // KB modal toggle reads/writes) so the JIT prompt at first chat sees a + // decided policy and doesn't ask again. + const [ingestPolicy, setIngestPolicy] = useState<'Always' | 'Manual'>('Always') const [isProcessing, setIsProcessing] = useState(false) const [showAdditionalTools, setShowAdditionalTools] = useState(false) const [remoteOllamaEnabled, setRemoteOllamaEnabled] = useState( @@ -338,6 +345,23 @@ export default function EasySetupWizard(props: { setIsProcessing(true) try { + // Persist the auto-index policy choice before kicking off downloads so + // any content that finishes during this same wizard run sees the right + // policy. Skipped when the user did not select the AI capability — the + // KV stays null and the first-chat JIT prompt (#899) handles the + // decision later if/when the user enables AI. + const aiSelected = + selectedServices.includes(SERVICE_NAMES.OLLAMA) || + installedServices.some((s) => s.service_name === SERVICE_NAMES.OLLAMA) + if (aiSelected) { + try { + await api.updateSetting('rag.defaultIngestPolicy', ingestPolicy) + } catch (err) { + // Non-fatal: the user can still set the policy from the KB modal. + console.warn('Could not persist ingest policy from wizard:', err) + } + } + // If using remote Ollama, configure it first before other installs if (remoteOllamaEnabled && remoteOllamaUrl) { const remoteResult = await api.configureRemoteOllama(remoteOllamaUrl) @@ -921,6 +945,47 @@ export default function EasySetupWizard(props: {

No recommended AI models available at this time.

)} + + {/* Auto-index policy — choose now so the JIT prompt at first chat + doesn't ask again (RFC #883 Phase 3 task 13). Persisted to + rag.defaultIngestPolicy on wizard submit. */} +
+

+ Auto-index new content for {aiAssistantName}? +

+

+ When you add new ZIMs, documents, or curated content, should {aiAssistantName} index them automatically so it can search them while answering your questions? +

+
+ + +
+

+ You can change this any time from the Knowledge Base panel inside AI Chat. +

+
)} @@ -1157,6 +1222,25 @@ export default function EasySetupWizard(props: { )} + {(selectedAiModels.length > 0 || remoteOllamaEnabled) && ( +
+

+ Auto-index Setting +

+

+ {ingestPolicy === 'Always' ? ( + <> + New content will be indexed automatically as it arrives so {aiAssistantName} can search it. + + ) : ( + <> + New content will wait for you to opt in from the Knowledge Base panel before {aiAssistantName} indexes it. + + )} +

+
+ )} +