A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
fix(editor): a conversation no longer disappears on a click aimed at the model name
esengine35122a8cc0a7
diff --git a/desktop/src/components/AgentDrawer.tsx b/desktop/src/components/AgentDrawer.tsxindex 896998910..e0f71d8e9 100644--- a/desktop/src/components/AgentDrawer.tsx+++ b/desktop/src/components/AgentDrawer.tsx@@ -31,7 +31,7 @@ import {} from 'lucide-react';import { useEditorStore } from '@/store/editorStore';import {- useAgent, sendAgentMessage, stopAgentTurn, confirmAgentCall, resetAgentSession,+ useAgent, sendAgentMessage, stopAgentTurn, confirmAgentCall, startNewConversation,peekEntities, entitiesInInput, effectiveSelection, selectAgentModel, retryAgentTurn, setAgentDraft,type AgentTurn, type AgentEntry, type AgentToolEntry, type AgentProseEntry,} from '@/store/AgentStore';@@ -688,7 +688,7 @@ function ModelPicker() {className={`ag-picker-it${current?.model === m && current.providerId === p.id ? ' on' : ''}${keyed ? '' : ' locked'}`}onClick={() => {setOpen(false);- if (keyed) selectAgentModel(p.id, m);+ if (keyed) void selectAgentModel(p.id, m);else openAgentSettings();}}>@@ -933,7 +933,7 @@ export function AgentPanel({ docked }: { docked?: boolean }) {<AgentMark size={docked ? 13 : 15} live={status.phase !== 'idle'} />{!docked && <span className="ag-ttl">{t('agent.title')}</span>}<span className="ag-sp" />- <button type="button" title={t('agent.newConversation')} onClick={() => void resetAgentSession()}>+ <button type="button" title={t('agent.newConversation')} onClick={() => void startNewConversation()}><Plus size={14} strokeWidth={2} /></button>{!docked && (diff --git a/desktop/src/i18n/messages/agent.ts b/desktop/src/i18n/messages/agent.tsindex 07c0630ee..0274d1d4e 100644--- a/desktop/src/i18n/messages/agent.ts+++ b/desktop/src/i18n/messages/agent.ts@@ -29,6 +29,20 @@ export const agentMessages = defineMessages({'agent.hint.mention': { en: 'reference', zh: '引用' },'agent.mention': { en: 'Reference', zh: '引用' },+ // — Ending a conversation, on purpose or as the price of a switch —+ 'agent.new.title': { en: 'Start a new conversation?', zh: '开始新对话?' },+ 'agent.new.body': {+ en: 'This one is dropped and the agent forgets what was said. What it changed in the scene stays.',+ zh: '当前这段会被丢弃,Agent 会忘掉说过的话。它对场景做过的改动仍然保留。',+ },+ 'agent.new.confirm': { en: 'Start new', zh: '新建' },+ 'agent.switch.title': { en: 'Switch to {model}?', zh: '切换到 {model}?' },+ 'agent.switch.body': {+ en: 'A conversation belongs to the model that answered it, so this one ends here. What it changed in the scene stays.',+ zh: '一段对话属于回答它的那个模型,所以当前对话会在此结束。它对场景做过的改动仍然保留。',+ },+ 'agent.switch.confirm': { en: 'Switch and start over', zh: '切换并重新开始' },+// — Which model the next message runs on —'agent.picker.none': { en: 'Pick a model', zh: '选择模型' },'agent.picker.noKey': { en: 'no key', zh: '未配置密钥' },diff --git a/desktop/src/store/AgentStore.ts b/desktop/src/store/AgentStore.tsindex b72f6ce0f..a2f706b65 100644--- a/desktop/src/store/AgentStore.ts+++ b/desktop/src/store/AgentStore.ts@@ -24,6 +24,8 @@ import {} from '@/agent/providers';import { refreshSecret, secretStatus, subscribeSecrets } from '@/store/SecretStore';import { useSettings } from '@/store/settingsStore';+import { confirm } from '@/components/confirm';+import { t } from '@/i18n';export type { AgentStatus, AgentEvent };@@ -222,8 +224,23 @@ export function syncAgentEndpoint(): void {* than continued: a session is built for one model, thinking blocks have to* come back to the model that produced them, and the cached prefix is a byte* match — so "same conversation, different model" is not a thing that exists.+ *+ * Which is why it asks. Ending the conversation is the unavoidable COST of the+ * switch, not part of what the user asked for, and a transcript that vanished+ * on a click aimed at the model name reads as having lost something rather than+ * as having chosen it. Declining leaves the pick alone too: a selection saved+ * for "next time" while this conversation keeps answering on the old model is a+ * picker that lies about what is running.*/-export function selectAgentModel(providerId: string, model: string): void {+export async function selectAgentModel(providerId: string, model: string): Promise<void> {+ if (useAgent.getState().turns.length > 0) {+ const ok = await confirm({+ title: t('agent.switch.title', { model }),+ body: t('agent.switch.body'),+ confirmLabel: t('agent.switch.confirm'),+ });+ if (!ok) return;+ }const selection: AgentSelection = { providerId, model };useAgent.setState({ selection });try {@@ -542,6 +559,25 @@ export function confirmAgentCall(callId: string, answer: ConfirmAnswer, declinedvoid window.estella?.agent?.confirm(callId, answer, declined);}+/**+ * Drop the conversation and start over, at the user's asking.+ *+ * Separate from {@link resetAgentSession} because that one is also how the+ * editor ends a session it has no choice about (a model switch), and a+ * confirmation there would either ask twice or ask the wrong question.+ */+export async function startNewConversation(): Promise<void> {+ if (useAgent.getState().turns.length > 0) {+ const ok = await confirm({+ title: t('agent.new.title'),+ body: t('agent.new.body'),+ confirmLabel: t('agent.new.confirm'),+ });+ if (!ok) return;+ }+ await resetAgentSession();+}+/** Drop the conversation — a new one starts with the next message. */export async function resetAgentSession(): Promise<void> {useAgent.setState({ turns: [], driving: false, queued: [] });