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(chat): stop chat model dropdown from rewriting the default preset

Louis Beaumont9cdfe0185b40
diff --git a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
index 960a4bf60..8dece2051 100644
--- a/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
+++ b/apps/screenpipe-app-tauri/components/rewind/ai-presets-selector.tsx
@@ -1132,17 +1132,18 @@ export const AIPresetsSelector = ({
const nextIndex = (currentIndex + 1) % aiPresets.length;
const nextPreset = aiPresets[nextIndex];
- // Set the next preset as default
- const updatedPresets = aiPresets.map((p) => ({
- ...p,
- defaultPreset: p.id === nextPreset.id,
- }));
-
- updateSettings({
- aiPresets: updatedPresets,
- });
-
- onPresetSaved?.(nextPreset);
+ if (isControlled) {
+ // Controlled (e.g. chat composer): cycle the host's local selection
+ // without rewriting the user's default preset in settings.
+ onControlledSelect?.(nextPreset.id);
+ } else {
+ const updatedPresets = aiPresets.map((p) => ({
+ ...p,
+ defaultPreset: p.id === nextPreset.id,
+ }));
+ updateSettings({ aiPresets: updatedPresets });
+ onPresetSaved?.(nextPreset);
+ }
toast.success("Preset changed", {
description: `Switched to ${nextPreset.id} (${nextPreset.model})`,
@@ -1152,7 +1153,7 @@ export const AIPresetsSelector = ({
window.addEventListener("keydown", handleKeyDown);
return () => window.removeEventListener("keydown", handleKeyDown);
- }, [aiPresets, selectedPreset, updateSettings, shortcutKey, onPresetSaved]);
+ }, [aiPresets, selectedPreset, updateSettings, shortcutKey, onPresetSaved, isControlled, onControlledSelect]);
const handleSavePreset = (preset: Partial<AIPreset>) => {
if (!canManageEmployeePresets) {
diff --git a/apps/screenpipe-app-tauri/components/standalone-chat.tsx b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
index 54c88aeca..9ad820e10 100644
--- a/apps/screenpipe-app-tauri/components/standalone-chat.tsx
+++ b/apps/screenpipe-app-tauri/components/standalone-chat.tsx
@@ -8771,13 +8771,20 @@ export function StandaloneChat({
showModelOnly
containerClassName="w-[180px] max-w-[42vw] min-w-[120px] shrink-0 gap-0"
triggerClassName="h-8 border-0 bg-transparent px-1.5 text-xs text-muted-foreground shadow-none hover:bg-muted/50 hover:text-foreground"
- onPresetChange={setActivePreset}
onPresetSaved={handlePiRestart}
- controlledPresetId={activePipeExecution ? activePreset?.id : undefined}
- onControlledSelect={activePipeExecution ? (id) => {
+ controlledPresetId={
+ activePreset?.id ??
+ settings.aiPresets?.find((p) => p.defaultPreset)?.id ??
+ settings.aiPresets?.[0]?.id ??
+ null
+ }
+ onControlledSelect={(id) => {
+ if (!id) return;
const match = settings.aiPresets?.find((p) => p.id === id);
- if (match) setActivePreset(match);
- } : undefined}
+ if (!match) return;
+ setActivePreset(match);
+ if (!activePipeExecution) handlePiRestart(match);
+ }}
/>
{(() => {
const hasInput = input.trim().length > 0 || pastedImages.length > 0;