feat(KB): wizard AI policy step (RFC #883 Phase 3 task 13)
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.
This commit is contained in:
parent
9a684a5e62
commit
7a681d04ab
|
|
@ -122,6 +122,13 @@ export default function EasySetupWizard(props: {
|
|||
const [selectedServices, setSelectedServices] = useState<string[]>([])
|
||||
const [selectedMapCollections, setSelectedMapCollections] = useState<string[]>([])
|
||||
const [selectedAiModels, setSelectedAiModels] = useState<string[]>([])
|
||||
// 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: {
|
|||
<p className="text-text-secondary">No recommended AI models available at this time.</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 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. */}
|
||||
<div className="mt-8 pt-6 border-t border-border-subtle">
|
||||
<h4 className="text-lg font-semibold text-text-primary mb-1">
|
||||
Auto-index new content for {aiAssistantName}?
|
||||
</h4>
|
||||
<p className="text-sm text-text-muted mb-4">
|
||||
When you add new ZIMs, documents, or curated content, should {aiAssistantName} index them automatically so it can search them while answering your questions?
|
||||
</p>
|
||||
<div className="inline-flex rounded-md border border-border-default overflow-hidden" role="group">
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIngestPolicy('Always')}
|
||||
className={classNames(
|
||||
'px-5 py-2 text-sm font-medium transition-colors',
|
||||
ingestPolicy === 'Always'
|
||||
? 'bg-desert-green text-white'
|
||||
: 'bg-surface-primary text-text-secondary hover:bg-surface-secondary'
|
||||
)}
|
||||
>
|
||||
Yes, always
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setIngestPolicy('Manual')}
|
||||
className={classNames(
|
||||
'px-5 py-2 text-sm font-medium transition-colors border-l border-border-default',
|
||||
ingestPolicy === 'Manual'
|
||||
? 'bg-desert-green text-white'
|
||||
: 'bg-surface-primary text-text-secondary hover:bg-surface-secondary'
|
||||
)}
|
||||
>
|
||||
Ask me first
|
||||
</button>
|
||||
</div>
|
||||
<p className="text-xs text-text-muted mt-3">
|
||||
You can change this any time from the Knowledge Base panel inside AI Chat.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
|
@ -1157,6 +1222,25 @@ export default function EasySetupWizard(props: {
|
|||
</div>
|
||||
)}
|
||||
|
||||
{(selectedAiModels.length > 0 || remoteOllamaEnabled) && (
|
||||
<div className="bg-surface-primary rounded-lg border-2 border-desert-stone-light p-6">
|
||||
<h3 className="text-xl font-semibold text-text-primary mb-2">
|
||||
Auto-index Setting
|
||||
</h3>
|
||||
<p className="text-text-secondary text-sm">
|
||||
{ingestPolicy === 'Always' ? (
|
||||
<>
|
||||
New content will be <strong>indexed automatically</strong> as it arrives so {aiAssistantName} can search it.
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
New content will <strong>wait for you to opt in</strong> from the Knowledge Base panel before {aiAssistantName} indexes it.
|
||||
</>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Alert
|
||||
title="Ready to Start"
|
||||
message="Click 'Complete Setup' to begin installing apps and downloading content. This may take some time depending on your internet connection and the size of the downloads."
|
||||
|
|
|
|||
Loading…
Reference in New Issue