diff --git a/src/app/(app)/settings/ai/ai-settings-form.tsx b/src/app/(app)/settings/ai/ai-settings-form.tsx index 5619087..de4a278 100644 --- a/src/app/(app)/settings/ai/ai-settings-form.tsx +++ b/src/app/(app)/settings/ai/ai-settings-form.tsx @@ -29,7 +29,13 @@ import { DEFAULT_QUOTES_AI_SYSTEM_PROMPT } from "@/lib/server/ai-system-prompt"; import { DEFAULT_QUOTE_ASSISTANT_PROMPT } from "@/lib/server/quote-assistant-prompt"; // Plain string export, no server-only imports, so it is safe in a client component. import { DEFAULT_COLLECTION_AI_PROMPT } from "@/lib/server/collection-ai-prompt"; -import type { CollectionAiRunSummary, QuoteAssistantRunSummary } from "@/lib/types"; +// Plain string export, no server-only imports, so it is safe in a client component. +import { DEFAULT_ORDER_ASSISTANT_PROMPT } from "@/lib/server/order-assistant-prompt"; +import type { + CollectionAiRunSummary, + OrderAssistantRunSummary, + QuoteAssistantRunSummary, +} from "@/lib/types"; export interface AiSettingsFormInitial { provider: string; @@ -57,6 +63,14 @@ export interface AiSettingsFormInitial { /** Empty string = use the built-in default prompt. */ collection_ai_prompt: string; collection_ai_last_run_summary: CollectionAiRunSummary | null; + /** AI order assistant (matches orders to the quote they came from). */ + order_assistant_enabled: boolean; + order_assistant_interval_minutes: number; + order_assistant_auto_link: boolean; + order_assistant_fill_lines: boolean; + /** Empty string = use the built-in default prompt. */ + order_assistant_prompt: string; + order_assistant_last_run_summary: OrderAssistantRunSummary | null; } interface Props { @@ -107,6 +121,12 @@ export function AiSettingsForm({ initial }: Props) { const [caEnabled, setCaEnabled] = useState(initial.collection_ai_enabled); const [caPrompt, setCaPrompt] = useState(initial.collection_ai_prompt); const [showCaDefault, setShowCaDefault] = useState(false); + const [oaEnabled, setOaEnabled] = useState(initial.order_assistant_enabled); + const [oaInterval, setOaInterval] = useState(String(initial.order_assistant_interval_minutes)); + const [oaAutoLink, setOaAutoLink] = useState(initial.order_assistant_auto_link); + const [oaFillLines, setOaFillLines] = useState(initial.order_assistant_fill_lines); + const [oaPrompt, setOaPrompt] = useState(initial.order_assistant_prompt); + const [showOaDefault, setShowOaDefault] = useState(false); const [saveState, saveAction] = useActionState( saveAiSettingsAction, null, @@ -551,6 +571,150 @@ export function AiSettingsForm({ initial }: Props) { + + +
+ + Order assistant +
+ + Works out which quote an order came from, and links the order to it + when it is sure. It never changes a line's status, never creates a + purchase order and never sends anything. + +
+ +
+
+ +

+ Needs the AI switch above to be on too. Runs on a timer and looks at + orders that have no quote yet. +

+
+ +
+ +
+
+ + setOaInterval(e.target.value)} + /> +

Between 5 and 1440.

+
+ +
+
+
+ +

+ Links the order itself when the AI is certain. When unsure it only + suggests the quote and a person decides. +

+
+ +
+ +
+
+ +

+ Pre-fills the order lines from the matched quote. Not in use yet — + the assistant only matches orders to quotes. +

+
+ +
+
+
+ +
+
+ +
+ + +
+
+