feat: persist last-used model in LocalStorage instead of preference
Drop the summaryModel preference (and the awkward textfield holding a raw model ID nobody could discover without poking the SDK types). Each AI view now controls its model dropdown, loads the shared velum.ai.last-model on mount, and writes it back on submit — so picking Claude 4.7 Opus in the summarize command becomes the prefilled default in briefing, action-items, structured-data, and reply next time around. Also drops 'model' from ReplyDefaults; the shared key supersedes it. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,6 @@ import {
|
||||
import { copyRichText, markdownToHtml, maybeCloseRaycast } from "./ai-views";
|
||||
import { getSelectedTextSafely } from "./selection";
|
||||
import { useEffect, useMemo, useRef, useState } from "react";
|
||||
import { getPreferences } from "./preferences";
|
||||
import {
|
||||
createSession,
|
||||
getActiveSessionId,
|
||||
@@ -23,7 +22,13 @@ import {
|
||||
setActiveSession,
|
||||
updateSessionMapping,
|
||||
} from "./sessions";
|
||||
import { CREATIVITY_OPTIONS, MODEL_OPTIONS } from "./ai";
|
||||
import {
|
||||
CREATIVITY_OPTIONS,
|
||||
DEFAULT_MODEL,
|
||||
getLastUsedModel,
|
||||
MODEL_OPTIONS,
|
||||
setLastUsedModel,
|
||||
} from "./ai";
|
||||
import { buildSummaryPrompt, type Creativity } from "./summarize";
|
||||
import type { EntityType, VelumSession } from "./types";
|
||||
import {
|
||||
@@ -49,23 +54,25 @@ type FormValues = {
|
||||
};
|
||||
|
||||
export default function Command() {
|
||||
const preferences = getPreferences();
|
||||
const [text, setText] = useState("");
|
||||
const [sessions, setSessions] = useState<VelumSession[]>([]);
|
||||
const [activeSessionId, setActiveSessionId] = useState<string>();
|
||||
const [entityTypes, setEntityTypes] = useState<EntityType[]>([]);
|
||||
const [selectedEntityTypes, setSelectedEntityTypes] = useState<string[]>([]);
|
||||
const [model, setModel] = useState<string>(DEFAULT_MODEL);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
const { push } = useNavigation();
|
||||
|
||||
useEffect(() => {
|
||||
async function load() {
|
||||
const [loadedSessions, activeId] = await Promise.all([
|
||||
const [loadedSessions, activeId, lastModel] = await Promise.all([
|
||||
listSessions(),
|
||||
getActiveSessionId(),
|
||||
getLastUsedModel(),
|
||||
]);
|
||||
setSessions(loadedSessions);
|
||||
setActiveSessionId(activeId);
|
||||
setModel(lastModel);
|
||||
|
||||
const selection = await getSelectedTextSafely();
|
||||
if (selection && selection.trim()) {
|
||||
@@ -124,6 +131,8 @@ export default function Command() {
|
||||
return;
|
||||
}
|
||||
|
||||
void setLastUsedModel(values.model);
|
||||
|
||||
const toast = await showToast({
|
||||
style: Toast.Style.Animated,
|
||||
title: "Pseudonymisiere…",
|
||||
@@ -238,7 +247,8 @@ export default function Command() {
|
||||
<Form.Dropdown
|
||||
id="model"
|
||||
title="KI-Modell"
|
||||
defaultValue={preferences.summaryModel}
|
||||
value={model}
|
||||
onChange={setModel}
|
||||
>
|
||||
{MODEL_OPTIONS.map((option) => (
|
||||
<Form.Dropdown.Item
|
||||
|
||||
Reference in New Issue
Block a user