Skip to content

Commit 65c88e4

Browse files
committed
fix(web): queued edit Update saves while a send is pending
The previous commit kept the Update button enabled during compact-then-send, but onSend still returned early on the pending local dispatch, before it reached queuedRunEdit.saveEdit, so the click did nothing. Both the button and the send guard now use localDispatchHoldsSend, which lets a queued-message edit through. saveEdit already ignores repeat clicks while a save is running. Refs #26609
1 parent 5feaba2 commit 65c88e4

3 files changed

Lines changed: 20 additions & 3 deletions

File tree

‎apps/web/src/components/chat/composerSend.logic.test.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
approvalRedirectNotice,
99
composerSendBusy,
1010
loadBalancingSendWarning,
11+
localDispatchHoldsSend,
1112
multipleModelSendBlock,
1213
referencedThreadContexts,
1314
} from "./composerSend.logic";
@@ -126,7 +127,7 @@ describe("approvalRedirectNotice", () => {
126127
});
127128
});
128129

129-
describe("composerSendBusy", () => {
130+
describe("composerSendBusy and localDispatchHoldsSend", () => {
130131
const idle = {
131132
queuedRunEdit: { isEditing: false, isSaving: false },
132133
localDispatchPending: false,
@@ -147,5 +148,9 @@ describe("composerSendBusy", () => {
147148
expect(composerSendBusy({ ...idle, queuedRunEdit: { isEditing: true, isSaving: true } })).toBe(
148149
true,
149150
);
151+
expect(localDispatchHoldsSend({ ...idle, localDispatchPending: true })).toBe(true);
152+
expect(
153+
localDispatchHoldsSend({ queuedRunEdit: { isEditing: true }, localDispatchPending: true }),
154+
).toBe(false);
150155
});
151156
});

‎apps/web/src/components/chat/composerSend.logic.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,14 @@ export function approvalRedirectNotice(input: {
8080
return null;
8181
}
8282

83+
/** A pending local dispatch holds new sends, but not the save of a queued-message edit. */
84+
export function localDispatchHoldsSend(input: {
85+
readonly queuedRunEdit: { readonly isEditing: boolean };
86+
readonly localDispatchPending: boolean;
87+
}): boolean {
88+
return input.localDispatchPending && !input.queuedRunEdit.isEditing;
89+
}
90+
8391
/** Whether the send button spins. In queued-edit mode it saves that edit, which only its own save blocks. */
8492
export function composerSendBusy(input: {
8593
readonly queuedRunEdit: { readonly isEditing: boolean; readonly isSaving: boolean };
@@ -90,7 +98,7 @@ export function composerSendBusy(input: {
9098
}): boolean {
9199
if (input.queuedRunEdit.isEditing) return input.queuedRunEdit.isSaving;
92100
return (
93-
input.localDispatchPending ||
101+
localDispatchHoldsSend(input) ||
94102
(input.setupQueueSendThreadKey !== null &&
95103
input.setupQueueSendThreadKey === input.activeThreadKey) ||
96104
input.queuedRunEdit.isSaving ||

‎apps/web/src/components/chat/useComposerSend.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ import { environmentPresentations } from "../../state/presentation";
8989
import {
9090
approvalRedirectNotice,
9191
loadBalancingSendWarning,
92+
localDispatchHoldsSend,
9293
multipleModelSendBlock,
9394
referencedThreadContexts,
9495
} from "./composerSend.logic";
@@ -432,7 +433,10 @@ export function useComposerSend(input: ComposerSendInput) {
432433
if (
433434
!readEnvironmentScope(environmentId, AuthOrchestrationOperateScope) ||
434435
!activeThread ||
435-
(isSendBusy && !sendQueuesBehindSetup) ||
436+
localDispatchHoldsSend({
437+
queuedRunEdit,
438+
localDispatchPending: isSendBusy && !sendQueuesBehindSetup,
439+
}) ||
436440
isRevertingCheckpoint ||
437441
!clientSettingsHydrated ||
438442
threadDetailLoading ||

0 commit comments

Comments
 (0)