Skip to content

armgit / cindy

Public Imported from GitHub
0

Consider it done. The open-source AI agent that works out of the box · 想到,就能做到。开源、开箱即用的 AI Agent。

fix(desktop): block queue edits during voice capture

DavidShena35c42cc063d
diff --git a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
index c2d5fd2a1e..1da41859a7 100644
--- a/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/ChatInput.tsx
@@ -5942,7 +5942,8 @@ export function ChatInput({
!queueEditingClientId ||
!onQueueEditSubmit ||
disabled ||
- sendDispatchInFlight
+ sendDispatchInFlight ||
+ voiceBusyOnCurrentComposer
) {
return;
}
@@ -5967,6 +5968,7 @@ export function ChatInput({
queueEditingClientId,
sendDispatchInFlight,
t,
+ voiceBusyOnCurrentComposer,
]);
const acceptPromptRecommendation = useCallback((): boolean => {
@@ -8186,7 +8188,12 @@ export function ChatInput({
).kind === 'start';
const [voiceReleaseToSendActive, setVoiceReleaseToSendActive] = useState(false);
const sendButtonDisabled = queueEditActive
- ? Boolean(disabled || sendDispatchInFlight || (!hasMessage && !hasAttachments))
+ ? Boolean(
+ disabled ||
+ sendDispatchInFlight ||
+ voiceBusyOnCurrentComposer ||
+ (!hasMessage && !hasAttachments),
+ )
: Boolean(
disabled || sessionModelLoading ||
// 空態:当前 agent 无已连接来源 → Send 禁用(设计 Q7NYAD「send 置灰」),引导用户先去连接来源。
diff --git a/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx b/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx
index 9a83e22941..0d15911e39 100644
--- a/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx
+++ b/apps/desktop/src/renderer/components/new-chat/__tests__/chatInputModelLoading.test.tsx
@@ -105,9 +105,11 @@ const queuedMessage = {
function QueueEditHarness({
onCancel,
onRemove,
+ onSubmit = async () => true,
}: {
onCancel: () => void;
onRemove: () => void;
+ onSubmit?: NonNullable<ComponentProps<typeof ChatInput>['onQueueEditSubmit']>;
}) {
const [editingClientId, setEditingClientId] = useState<string | null>(queuedMessage.clientId);
@@ -121,7 +123,7 @@ function QueueEditHarness({
onQueueRemove={onRemove}
queueEditingClientId={editingClientId}
onQueueEditBegin={vi.fn()}
- onQueueEditSubmit={async () => true}
+ onQueueEditSubmit={onSubmit}
onQueueEditCancel={() => {
onCancel();
setEditingClientId(null);
@@ -209,6 +211,20 @@ it('hides queue removal while editing and exits editing from the composer cancel
expect(onRemove).not.toHaveBeenCalled();
});
+it('blocks queue edit saves while voice capture is active', async () => {
+ h.listening = true;
+ const onSubmit = vi.fn().mockResolvedValue(true);
+ render(<QueueEditHarness onCancel={vi.fn()} onRemove={vi.fn()} onSubmit={onSubmit} />);
+
+ const save = (await screen.findByRole('button', {
+ name: 'newChat.pendingQueue.editSaveAria',
+ })) as HTMLButtonElement;
+ expect(save.disabled).toBe(true);
+
+ fireEvent.click(save);
+ expect(onSubmit).not.toHaveBeenCalled();
+});
+
// The slot survives missing metadata; only the model control is withheld.
it.each([320, 480, 800])('preserves the model slot across hydration (width=%s)', async (width) => {
vi.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockReturnValue(width);