Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): keep multi-select questions open after the first click (#6646)

RaitP11a5ff424cee1
diff --git a/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx b/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
index 75dc5a6f5..d50a0c264 100644
--- a/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
+++ b/apps/web/src/components/chat/ComposerPendingUserInputPanel.tsx
@@ -1,5 +1,5 @@
import { type ApprovalRequestId } from "@t3tools/contracts";
-import { memo, useEffect, useEffectEvent, useRef, useState } from "react";
+import { memo, useCallback, useEffect, useRef, useState } from "react";
import { type PendingUserInput } from "../../session-logic";
import {
derivePendingUserInputProgress,
@@ -109,21 +109,24 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
};
}, []);
- const handleOptionSelection = useEffectEvent((questionId: string, optionLabel: string) => {
- if (activeQuestion?.multiSelect) {
+ const handleOptionSelection = useCallback(
+ (questionId: string, optionLabel: string) => {
+ if (activeQuestion?.multiSelect) {
+ onToggleOption(questionId, optionLabel);
+ return;
+ }
+ setOptimisticSingleSelect({ questionId, optionLabel });
onToggleOption(questionId, optionLabel);
- return;
- }
- setOptimisticSingleSelect({ questionId, optionLabel });
- onToggleOption(questionId, optionLabel);
- if (autoAdvanceTimerRef.current !== null) {
- window.clearTimeout(autoAdvanceTimerRef.current);
- }
- autoAdvanceTimerRef.current = window.setTimeout(() => {
- autoAdvanceTimerRef.current = null;
- onAdvanceRef.current();
- }, 200);
- });
+ if (autoAdvanceTimerRef.current !== null) {
+ window.clearTimeout(autoAdvanceTimerRef.current);
+ }
+ autoAdvanceTimerRef.current = window.setTimeout(() => {
+ autoAdvanceTimerRef.current = null;
+ onAdvanceRef.current();
+ }, 200);
+ },
+ [activeQuestion, onToggleOption],
+ );
// Keyboard shortcut: number keys 1-9 select corresponding options when focus is
// outside editable fields. Multi-select prompts toggle options in place; single-
@@ -154,7 +157,7 @@ const ComposerPendingUserInputCard = memo(function ComposerPendingUserInputCard(
};
document.addEventListener("keydown", handler);
return () => document.removeEventListener("keydown", handler);
- }, [activeQuestion, isCollapsed, isResponding]);
+ }, [activeQuestion, handleOptionSelection, isCollapsed, isResponding]);
if (!activeQuestion) {
return null;