Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。
TypeScript agentai-agentai-assistantandroidclaude-codecodexelectroniosllmmacosreact-nativetypescriptwindows
fix(desktop): report rejected composer steer without losing draft
guyong0c7f3c793935
diff --git a/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts b/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.tsindex 33b323b6da..31db47cfcd 100644--- a/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts+++ b/apps/desktop/src/renderer/__tests__/makerChatStoreTextDeltaBatching.test.ts@@ -106,6 +106,8 @@ import * as messageService from '@/lib/messageService';import * as sessionService from '@/lib/sessionService';import * as sessionsBus from '@/lib/sessionsBus';import { setRemoteOptimisticAttachmentUrls } from '@/lib/composerDraftStore';+import { getToastSnapshot, toast } from '@/lib/toast';+import i18n from '@/i18n';import { remoteProjectsStore } from '@/features/device-link/remoteProjectsStore';import {__resetStickySessionOriginForTest,@@ -5993,6 +5995,56 @@ describe('makerChatStore text delta batching', () => {expect(restore).toHaveBeenCalledTimes(1);});+ // #2281 / unit: exercise the public steer entry with each explicit mirror+ // guard. Existing rejection tests protect error recovery, not immediate user+ // feedback or the no-send boundary. ChatInput's false-result restore path is+ // covered by chatInputAnnotationAbort.test.tsx.+ it.each([+ { steeringQueueClientIds: ['steer-in-flight'] },+ { queueAbortPending: true },+ ])('immediately reports an unsent composer steer without dispatching: %j', async (guard) => {+ onInputProjection?.(projection(SESSION_ID, guard));+ // A delayed refresh must not delay feedback or retry the rejected input.+ let resolveProjection!: (value: AgentInputProjection) => void;+ input.getProjection.mockReturnValueOnce(new Promise<AgentInputProjection>((resolve) => {+ resolveProjection = resolve;+ }));+ const before = makerChatStore.getSnapshot(SESSION_ID);+ const onInputCreated = vi.fn();+ const beforeEnqueue = vi.fn(async () => true);+ const file: AttachedFile = {+ id: 'draft-image', name: 'draft.png', path: 'draft.png', ext: '.png',+ size: 10, category: 'image', mimeType: 'image/png',+ annotationStrokes: [{ points: [{ x: 0.1, y: 0.2 }, { x: 0.3, y: 0.4 }] }],+ };+ try {+ const result = makerChatStore.steerMessage(+ SESSION_ID, 'keep my draft', MODEL, EFFORT, PERMISSION_MODE, WORKING_DIR,+ [file], undefined, { onInputCreated, beforeEnqueue },+ );+ expect(getToastSnapshot()).toContainEqual(expect.objectContaining({+ variant: 'warning', message: i18n.t('newChat.chatInput.steerNotSent'),+ }));+ await expect(result).resolves.toBe(false);+ expect(makerChatStore.getSnapshot(SESSION_ID)).toBe(before);+ expect(input.getProjection).toHaveBeenCalledWith(SESSION_ID);+ resolveProjection(projection(SESSION_ID));+ await flushPromises();+ expect(makerChatStore.getSnapshot(SESSION_ID).messages).toEqual(before.messages);+ expect(makerChatStore.getSnapshot(SESSION_ID).pendingQueue).toEqual(before.pendingQueue);+ expect(input.steer).not.toHaveBeenCalled();+ expect(input.enqueue).not.toHaveBeenCalled();+ expect(onInputCreated).not.toHaveBeenCalled();+ expect(beforeEnqueue).not.toHaveBeenCalled();+ expect(messageService.create).not.toHaveBeenCalled();+ expect(sessionService.touchUserSend).not.toHaveBeenCalled();+ expect(window.electronAPI.cacheMediaForSession).not.toHaveBeenCalled();+ } finally {+ toast.dismissAll();+ vi.advanceTimersByTime(300);+ }+ });+it('drops a standalone late projection when the data owner changes', async () => {remoteProjectsStore.setDeviceSessions('device-1', 'Test Mac', [{ id: SESSION_ID, status: 'active', title: 'Remote task' } as Session,diff --git a/apps/desktop/src/renderer/i18n/locales/en/common.json b/apps/desktop/src/renderer/i18n/locales/en/common.jsonindex 3c738a88a3..db55e859f9 100644--- a/apps/desktop/src/renderer/i18n/locales/en/common.json+++ b/apps/desktop/src/renderer/i18n/locales/en/common.json@@ -11263,6 +11263,7 @@},"credentialSwitchDeferred": "Model provider switched — it takes effect after the current task finishes.","effortRuntimeDirty": "Reasoning effort is still updating. Wait a moment, then send again.",+ "steerNotSent": "Message not sent. Steer is temporarily unavailable; your draft has been kept.","credentialSwitchApplied": "Model provider switch is now in effect.","credentialSwitchFailed": "Model provider switch failed. Choose the model again.","modelSwitchContextGuard": {diff --git a/apps/desktop/src/renderer/i18n/locales/ja/common.json b/apps/desktop/src/renderer/i18n/locales/ja/common.jsonindex 16e46c6a5f..d2428dd248 100644--- a/apps/desktop/src/renderer/i18n/locales/ja/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ja/common.json@@ -11228,6 +11228,7 @@},"credentialSwitchDeferred": "モデルプロバイダーを切り替えました。現在のタスク終了後に有効になります。","effortRuntimeDirty": "推論強度を更新しています。少し待ってからもう一度送信してください。",+ "steerNotSent": "送信されていません。現在は割り込みできません。下書きは保持されています。","credentialSwitchApplied": "モデルプロバイダーの切り替えが有効になりました。","credentialSwitchFailed": "モデルプロバイダーの切り替えに失敗しました。モデルを選び直してください。","modelSwitchContextGuard": {diff --git a/apps/desktop/src/renderer/i18n/locales/ko/common.json b/apps/desktop/src/renderer/i18n/locales/ko/common.jsonindex 7a3da69507..119e500b19 100644--- a/apps/desktop/src/renderer/i18n/locales/ko/common.json+++ b/apps/desktop/src/renderer/i18n/locales/ko/common.json@@ -11228,6 +11228,7 @@},"credentialSwitchDeferred": "모델 제공자를 전환했습니다. 현재 작업이 끝난 후 적용됩니다.","effortRuntimeDirty": "추론 강도를 업데이트하고 있습니다. 잠시 후 다시 전송해 주세요.",+ "steerNotSent": "전송되지 않았습니다. 지금은 끼어들기를 사용할 수 없습니다. 초안은 유지됩니다.","credentialSwitchApplied": "모델 제공자 전환이 적용되었습니다.","credentialSwitchFailed": "모델 제공자 전환에 실패했습니다. 모델을 다시 선택해 주세요.","modelSwitchContextGuard": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.jsonindex cd9abe6c41..487efad031 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-CN/common.json@@ -11228,6 +11228,7 @@},"credentialSwitchDeferred": "模型来源已切换,将在当前任务结束后生效。","effortRuntimeDirty": "推理强度还在更新,稍等一下再发送",+ "steerNotSent": "未发送,暂时无法插话,草稿已保留","credentialSwitchApplied": "模型来源切换已生效。","credentialSwitchFailed": "模型来源切换失败,请重新选择。","modelSwitchContextGuard": {diff --git a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.jsonindex 88743b15b0..bbdf644d8d 100644--- a/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json+++ b/apps/desktop/src/renderer/i18n/locales/zh-TW/common.json@@ -11228,6 +11228,7 @@},"credentialSwitchDeferred": "模型來源已切換,將在當前任務結束後生效。","effortRuntimeDirty": "推理強度還在更新,稍等一下再傳送",+ "steerNotSent": "未傳送,暫時無法插話,草稿已保留","credentialSwitchApplied": "模型來源切換已生效。","credentialSwitchFailed": "模型來源切換失敗,請重新選擇。","modelSwitchContextGuard": {diff --git a/apps/desktop/src/renderer/lib/makerChatStore.ts b/apps/desktop/src/renderer/lib/makerChatStore.tsindex 518ef95078..fdeae40fb7 100644--- a/apps/desktop/src/renderer/lib/makerChatStore.ts+++ b/apps/desktop/src/renderer/lib/makerChatStore.ts@@ -15646,13 +15646,14 @@ function steerMessage(remoteScopeAtStart?.clearGeneration ?? rendererClearGenerationBySession.get(sessionId) ?? 0;const current = getOrCreateState(sessionId);if (!canStartComposerSteer(current)) {- // 镜像里有在飞 steer 事务 → 静默拒绝对用户就是"没反应", 留痕 + 主动向- // main 拉一次 projection 自愈: 若镜像 stale (漏收 emit), 下一次点击就能恢复。+ // 明确未受理:立即反馈,返回 false 让输入框恢复草稿;projection 刷新只修镜像,+ // 不替用户重发。此时尚未创建消息或处理附件,不涉及已派发后的 ACK 边界。log.warn('steerMessage rejected: steering marker present in mirror', {sessionId,steeringQueueClientIds: current.steeringQueueClientIds,queueAbortPending: current.queueAbortPending,});+ toast.warning(i18n.t('newChat.chatInput.steerNotSent'));requestInputProjection(sessionId);return Promise.resolve(false);}