Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Fix AI chat crash when model is undefined, disable chat when no model selected

Louis Beaumont8a2a6746fc81
diff --git a/screenpipe-app-tauri/components/rewind/chat-message.tsx b/screenpipe-app-tauri/components/rewind/chat-message.tsx
index 6c6beffff..4270f68e2 100644
--- a/screenpipe-app-tauri/components/rewind/chat-message.tsx
+++ b/screenpipe-app-tauri/components/rewind/chat-message.tsx
@@ -94,7 +94,7 @@ export function ChatMessage({ message, ...props }: ChatMessageProps) {
>
{message.role === "user" ? (
<IconUser />
- ) : activePreset?.model.includes("gpt") ? (
+ ) : activePreset?.model?.includes("gpt") ? (
<IconOpenAI />
) : activePreset?.model?.includes("claude") ? (
<IconClaude />
diff --git a/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx b/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx
index 202922896..3da204acf 100644
--- a/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx
+++ b/screenpipe-app-tauri/components/rewind/timeline/ai-panel.tsx
@@ -73,7 +73,8 @@ export function AIPanel({
const { selectionRange, setSelectionRange } = useTimelineSelection();
const { checkLogin } = useLoginDialog();
const isAvailable = settings.aiPresets && settings.aiPresets.length > 0;
- const error = !isAvailable ? "No AI presets configured" : "";
+ const hasValidModel = activePreset?.model && activePreset.model.trim() !== "";
+ const error = !isAvailable ? "No AI presets configured" : !hasValidModel ? "No model selected in preset" : "";
const [activePreset, setActivePreset] = useState<AIPreset | undefined>(undefined);
// Add abort controller ref
@@ -490,7 +491,7 @@ export function AIPanel({
onChange={(e) => setAiInput(e.target.value)}
placeholder="ask about this time range..."
className="flex-1 bg-background border border-muted-foreground text-foreground placeholder-muted-foreground"
- disabled={isAiLoading || !isAvailable}
+ disabled={isAiLoading || !isAvailable || !hasValidModel}
/>
</div>
</TooltipTrigger>
@@ -503,7 +504,7 @@ export function AIPanel({
type="submit"
variant="outline"
className="hover:bg-accent transition-colors"
- disabled={!isAvailable}
+ disabled={!isAvailable || !hasValidModel}
onClick={isStreaming ? handleStopStreaming : handleAiSubmit}
>
{isStreaming ? (