feat(ai): make default assistant mode (Ask/Agent) configurable

This commit is contained in:
Abeautifulsnow authored and GitHub committed 2026-08-10 01:06:44 +08:00
1 parent 681c6f35c5
commit 0402fea37b
19 files changed
+202 -15

No files matched your search

@@ -160,6 +160,19 @@ const isGenerating = ref(false);
const scrollRef = ref<InstanceType<typeof ScrollArea> | null>(null);
const activeAction = ref<AiAction>("general");
const assistantMode = ref<AiAssistantMode>("ask");
// The selection is loaded asynchronously. Apply it once when this panel mounts,
// but do not let later setting changes alter an active conversation.
let defaultModeInitialized = false;
watch(
() => settings.isAiConfigLoaded,
(loaded) => {
if (loaded && !defaultModeInitialized) {
assistantMode.value = settings.defaultAiMode;
defaultModeInitialized = true;
}
},
{ immediate: true },
);
const currentSessionId = ref("");
const conversationId = ref("");
const conversations = ref<AiConversation[]>([]);
@@ -2030,9 +2043,10 @@ async function deleteConversation(id: string) {
function startNewChat() {
clearMessages();
showConversationList.value = false;
// A fresh conversation always starts from the safe, non-executing default.
assistantMode.value = "ask";
activeAction.value = resolveDefaultAction("ask");
// A fresh conversation starts from the configured default mode.
const mode = settings.defaultAiMode;
assistantMode.value = mode;
activeAction.value = resolveDefaultAction(mode);
}
onMounted(async () => {
@@ -5549,6 +5549,30 @@ onUnmounted(() => {
</div>
</div>
<!-- Default AI Mode (list mode, global) -->
<div v-if="aiConfigListMode === 'list'" class="space-y-3">
<Separator />
<div>
<h3 class="text-sm font-medium">
{{ t("ai.defaultAiMode") }}
</h3>
<p class="text-xs text-muted-foreground">
{{ t("ai.defaultAiModeDescription") }}
</p>
</div>
<div class="flex items-center gap-2">
<div class="flex items-center gap-1 rounded-md border p-0.5">
<button type="button" class="rounded-sm px-2.5 py-1 text-xs" :class="settingsStore.defaultAiMode === 'ask' ? 'bg-accent text-accent-foreground font-medium' : 'text-muted-foreground hover:text-foreground'" @click="settingsStore.setDefaultAiMode('ask')">
{{ t("ai.modes.ask") }}
</button>
<button type="button" class="rounded-sm px-2.5 py-1 text-xs" :class="settingsStore.defaultAiMode === 'agent' ? 'bg-accent text-accent-foreground font-medium' : 'text-muted-foreground hover:text-foreground'" @click="settingsStore.setDefaultAiMode('agent')">
{{ t("ai.modes.agent") }}
</button>
</div>
<div class="flex-1"></div>
</div>
</div>
<!-- Max Retries (list mode, global) -->
<div v-if="aiConfigListMode === 'list'" class="space-y-3">
<Separator />