The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 09:30 UTC
fix(web): typed answer moved to the draft by an option click is announced (#24331)
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com> Co-authored-by: maria-rcks <maria@kuuro.net>
voida6 committed
Nov 1, 2026 at 13:30 UTC
16233e7529683ba67d591c679fd9eb6f85902920
2 files changed
+49
-1
apps/web/src/components/chat/ComposerPendingUserInputPanel.navigation.browser.test.tsx
+41
-1
@@ -17,7 +17,9 @@ vi.mock(import("../ChatMarkdown"), async (importOriginal) => ({
17
}));
18
19
import { act, fakeTimers, render } from "../../../test/render";
20
+import { useComposerDraftStore } from "../../composerDraftStore";
21
import { makeThreadProjectionFixture } from "../../test-fixtures";
22
+import { toastManager } from "../ui/toast";
23
import { usePendingThreadRequests } from "./usePendingThreadRequests";
24
25
const threadRef = { environmentId: EnvironmentId.make("env"), threadId: ThreadId.make("thread") };
@@ -89,7 +91,8 @@ function useProbeRequests({ environmentId, projection, loading = false }: ProbeP
91
serverProjection: loading ? null : projection,
92
supportsQuestionAttachments: false,
93
composerDraftTarget: { environmentId, threadId: projection.thread.id },
92
- setComposerDraftPrompt: () => {},
94
+ setComposerDraftPrompt: (target, prompt) =>
95
+ useComposerDraftStore.getState().setPrompt(target, prompt),
96
promptRef,
97
composerRef,
98
setThreadError: () => {},
@@ -141,6 +144,43 @@ it("retains answers, selections and question position after leaving chat, includ
144
expect(requests).toMatchObject(expected);
145
});
146
147
+it("tells the user when an option click moves their typed answer into the hidden composer draft", async () => {
148
+ using _timers = fakeTimers();
149
+ const environmentId = EnvironmentId.make("displaced-environment");
150
+ const draftTarget = { environmentId, threadId: threadRef.threadId };
151
+ const draftPrompt = () => useComposerDraftStore.getState().getComposerDraft(draftTarget)?.prompt;
152
+ using toast = vi.spyOn(toastManager, "add");
153
+ await using _screen = await render(
154
+ <PendingRequestsProbe
155
+ environmentId={environmentId}
156
+ projection={questionProjection(threadRef.threadId)}
157
+ />,
158
+ );
159
+
160
+ await act(() => requests.onSelectActivePendingUserInputOption("question-0", "Incremental"));
161
+ expect(toast).not.toHaveBeenCalled();
162
+
163
+ await act(() => requests.onChangeActivePendingUserInputCustomAnswer("question-0", "first try"));
164
+ await act(() => requests.onSelectActivePendingUserInputOption("question-0", "Incremental"));
165
+ expect(draftPrompt()).toBe("first try");
166
+ expect(toast).toHaveBeenCalledTimes(1);
167
+ expect(toast).toHaveBeenCalledWith(
168
+ expect.objectContaining({
169
+ type: "info",
170
+ title: "Your typed text was set aside",
171
+ description: "It will be back in the composer once the question is answered.",
172
+ data: { threadRef: draftTarget },
173
+ }),
174
+ );
175
+
176
+ await act(() => requests.onChangeActivePendingUserInputCustomAnswer("question-0", "second try"));
177
+ expect(draftPrompt()).toBe("first try");
178
+ expect(requests.activePendingDraftAnswers["question-0"]).toMatchObject({
179
+ customAnswer: "second try",
180
+ });
181
+ expect(toast).toHaveBeenCalledTimes(1);
182
+});
183
+
184
function QuestionPositionProbe(props: ProbeProps) {
185
const state = useProbeRequests(props);
186
return (
apps/web/src/components/chat/usePendingThreadRequests.ts
+8
@@ -50,6 +50,8 @@ import { readEnvironmentScope } from "../../state/session";
50
import { threadEnvironment } from "../../state/threads";
51
import { useAtomCommand } from "../../state/use-atom-command";
52
import { useOrchestrationCommand } from "../../state/use-orchestration-command";
53
+import { toastManager } from "../ui/toast";
54
+
55
import type { ChatComposerHandle } from "./ChatComposer";
56
57
const EMPTY_PENDING_USER_INPUT_ANSWERS: Record<string, PendingUserInputDraftAnswer> = {};
@@ -403,6 +405,12 @@ export function usePendingThreadRequests(input: {
405
const nextPrompt = carryDisplacedCustomAnswerIntoPrompt(currentPrompt, displacedAnswer);
406
if (nextPrompt !== currentPrompt) {
407
setComposerDraftPrompt(composerDraftTarget, nextPrompt);
408
+ toastManager.add({
409
+ type: "info",
410
+ title: "Your typed text was set aside",
411
+ description: "It will be back in the composer once the question is answered.",
412
+ data: { threadRef: activeThreadId ? { environmentId, threadId: activeThreadId } : null },
413
+ });
414
if (activeThreadId) {
415
const store = useComposerDraftStore.getState();
416
const questionTarget = questionAttachmentDraftId(