fix(extract): auto-run the AI fallback when the addon is enabled

Booking import only fell back to the LLM when each user flipped an 'always retry with AI' toggle, so by default files kitinerary returned nothing for just failed. Run the fallback automatically whenever the AI Parsing addon is on (fallback-on-empty); drop the now-redundant per-user toggle and its setting.
This commit is contained in:
Maurice
2026-06-24 21:20:19 +02:00
committed by Maurice
parent ae14a6c860
commit b859ae8b00
4 changed files with 4 additions and 41 deletions
@@ -7,7 +7,6 @@ import { useTranslation } from '../../i18n'
import { useToast } from '../shared/Toast'
import { reservationsApi, healthApi } from '../../api/client'
import { useTripStore } from '../../store/tripStore'
import { useSettingsStore } from '../../store/settingsStore'
interface BookingImportModalProps {
isOpen: boolean
@@ -55,7 +54,6 @@ export default function BookingImportModal({ isOpen, onClose, tripId, pushUndo }
const { t } = useTranslation()
const toast = useToast()
const loadTrip = useTripStore((s) => s.loadTrip)
const alwaysRetryAi = useSettingsStore((s) => s.settings.llm_always_retry)
const fileInputRef = useRef<HTMLInputElement>(null)
const mouseDownTarget = useRef<EventTarget | null>(null)
@@ -139,9 +137,9 @@ export default function BookingImportModal({ isOpen, onClose, tripId, pushUndo }
setLoading(true)
setError('')
try {
// When the user opted into "always retry with AI", rescue files kitinerary
// can't read automatically; otherwise offer a per-file retry in the preview.
const mode = aiParsing && alwaysRetryAi ? 'fallback-on-empty' : 'no-ai'
// Auto-rescue: whenever AI parsing is available, files kitinerary can't
// read fall back to the LLM automatically — no extra confirmation step.
const mode = aiParsing ? 'fallback-on-empty' : 'no-ai'
const result = await reservationsApi.importBookingPreview(tripId, files, mode)
setPreviewItems(result.items ?? [])
setWarnings(result.warnings ?? [])
@@ -360,37 +360,6 @@ export default function DisplaySettingsTab(): React.ReactElement {
</div>
</div>
{/* Always retry booking imports with AI */}
<div>
<label className="block text-sm font-medium mb-2 text-content-secondary">{t('settings.aiAlwaysRetry')}</label>
<div className="flex gap-3">
{[
{ value: true, label: t('settings.on') || 'On' },
{ value: false, label: t('settings.off') || 'Off' },
].map(opt => (
<button
key={String(opt.value)}
onClick={async () => {
try { await updateSetting('llm_always_retry', opt.value) }
catch (e: unknown) { toast.error(e instanceof Error ? e.message : t('common.error')) }
}}
style={{
display: 'flex', alignItems: 'center', gap: 8,
padding: '10px 20px', borderRadius: 10, cursor: 'pointer',
fontFamily: 'inherit', fontSize: 14, fontWeight: 500,
border: (!!settings.llm_always_retry) === opt.value ? '2px solid var(--text-primary)' : '2px solid var(--border-primary)',
background: (!!settings.llm_always_retry) === opt.value ? 'var(--bg-hover)' : 'var(--bg-card)',
color: 'var(--text-primary)',
transition: 'all 0.15s',
}}
>
{opt.label}
</button>
))}
</div>
<p className="text-xs mt-1 text-content-faint">{t('settings.aiAlwaysRetryHint')}</p>
</div>
{/* Optimize route from accommodation */}
<div>
<label className="block text-sm font-medium mb-2 text-content-secondary">{t('settings.optimizeFromAccommodation')}</label>
-1
View File
@@ -130,7 +130,6 @@ export interface Settings {
dashboard_timezones?: string[]
// AI booking-import fallback (per-user config; used when the admin has not set
// instance-wide config on the llm_parsing addon). llm_api_key is masked on read.
llm_always_retry?: boolean
llm_provider?: 'local' | 'openai' | 'anthropic'
llm_model?: string
llm_base_url?: string
+1 -4
View File
@@ -31,9 +31,6 @@ export const DEFAULTABLE_USER_SETTING_KEYS = [
'llm_base_url',
'llm_multimodal',
'llm_api_key',
// "Always retry with AI" toggle — when on, the preview auto-runs the LLM on
// files kitinerary returns nothing for.
'llm_always_retry',
] as const;
type DefaultableKey = typeof DEFAULTABLE_USER_SETTING_KEYS[number];
@@ -47,7 +44,7 @@ const VALID_VALUES: Partial<Record<DefaultableKey, unknown[]>> = {
llm_provider: ['local', 'openai', 'anthropic'],
};
const BOOLEAN_KEYS = new Set<DefaultableKey>(['blur_booking_codes', 'mapbox_3d_enabled', 'mapbox_quality_mode', 'llm_multimodal', 'llm_always_retry']);
const BOOLEAN_KEYS = new Set<DefaultableKey>(['blur_booking_codes', 'mapbox_3d_enabled', 'mapbox_quality_mode', 'llm_multimodal']);
function parseValue(raw: string): unknown {
try { return JSON.parse(raw); } catch { return raw; }