mirror of
https://github.com/block/buzz.git
synced 2026-11-08 10:21:46 +00:00
Preserve imported persona model on provider select
This commit is contained in:
@@ -32,6 +32,7 @@ import {
|
||||
getImportErrorLabel,
|
||||
IMPORT_ERROR_VISIBILITY_MS,
|
||||
} from "./personaDialogImportState";
|
||||
import { shouldClearModelForRuntimeChange } from "./personaRuntimeModel";
|
||||
|
||||
type PersonaDialogProps = {
|
||||
open: boolean;
|
||||
@@ -543,8 +544,16 @@ export function PersonaDialog({
|
||||
<Select
|
||||
disabled={isPending || runtimesLoading}
|
||||
onValueChange={(nextRuntime) => {
|
||||
const previousRuntime = runtime;
|
||||
setRuntime(nextRuntime);
|
||||
setModel("");
|
||||
if (
|
||||
shouldClearModelForRuntimeChange(
|
||||
previousRuntime,
|
||||
nextRuntime,
|
||||
)
|
||||
) {
|
||||
setModel("");
|
||||
}
|
||||
}}
|
||||
value={runtime}
|
||||
>
|
||||
|
||||
16
desktop/src/features/agents/ui/personaRuntimeModel.test.mjs
Normal file
16
desktop/src/features/agents/ui/personaRuntimeModel.test.mjs
Normal file
@@ -0,0 +1,16 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { shouldClearModelForRuntimeChange } from "./personaRuntimeModel.ts";
|
||||
|
||||
test("shouldClearModelForRuntimeChange preserves model for first runtime selection", () => {
|
||||
assert.equal(shouldClearModelForRuntimeChange("", "goose"), false);
|
||||
});
|
||||
|
||||
test("shouldClearModelForRuntimeChange clears model when switching runtimes", () => {
|
||||
assert.equal(shouldClearModelForRuntimeChange("goose", "claude"), true);
|
||||
});
|
||||
|
||||
test("shouldClearModelForRuntimeChange keeps model for unchanged runtime", () => {
|
||||
assert.equal(shouldClearModelForRuntimeChange("goose", "goose"), false);
|
||||
});
|
||||
9
desktop/src/features/agents/ui/personaRuntimeModel.ts
Normal file
9
desktop/src/features/agents/ui/personaRuntimeModel.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export function shouldClearModelForRuntimeChange(
|
||||
previousRuntime: string,
|
||||
nextRuntime: string,
|
||||
): boolean {
|
||||
const previous = previousRuntime.trim();
|
||||
const next = nextRuntime.trim();
|
||||
|
||||
return previous.length > 0 && next.length > 0 && previous !== next;
|
||||
}
|
||||
Reference in New Issue
Block a user