Refactor DebugDrawer to use a ref for text prompt dialog state management. Update closeTextPromptDialog function to utilize the ref for improved handling of dialog state, ensuring consistent behavior during interactions.
This commit is contained in:
@@ -1994,6 +1994,7 @@ export const DebugDrawer: React.FC<{
|
|||||||
waitForResponse: boolean;
|
waitForResponse: boolean;
|
||||||
};
|
};
|
||||||
}>({ open: false, message: '' });
|
}>({ open: false, message: '' });
|
||||||
|
const textPromptDialogRef = useRef(textPromptDialog);
|
||||||
const [textSessionStarted, setTextSessionStarted] = useState(false);
|
const [textSessionStarted, setTextSessionStarted] = useState(false);
|
||||||
const [wsStatus, setWsStatus] = useState<'disconnected' | 'connecting' | 'ready' | 'error'>('disconnected');
|
const [wsStatus, setWsStatus] = useState<'disconnected' | 'connecting' | 'ready' | 'error'>('disconnected');
|
||||||
const [wsError, setWsError] = useState('');
|
const [wsError, setWsError] = useState('');
|
||||||
@@ -2193,6 +2194,10 @@ export const DebugDrawer: React.FC<{
|
|||||||
wsStatusRef.current = wsStatus;
|
wsStatusRef.current = wsStatus;
|
||||||
}, [wsStatus]);
|
}, [wsStatus]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
textPromptDialogRef.current = textPromptDialog;
|
||||||
|
}, [textPromptDialog]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dynamicVariableSeqRef.current = 0;
|
dynamicVariableSeqRef.current = 0;
|
||||||
setDynamicVariables([]);
|
setDynamicVariables([]);
|
||||||
@@ -2432,20 +2437,10 @@ export const DebugDrawer: React.FC<{
|
|||||||
};
|
};
|
||||||
|
|
||||||
const closeTextPromptDialog = (action: 'confirm' | 'dismiss') => {
|
const closeTextPromptDialog = (action: 'confirm' | 'dismiss') => {
|
||||||
let pending:
|
const snapshot = textPromptDialogRef.current;
|
||||||
| {
|
const pending = snapshot?.pendingResult;
|
||||||
toolCallId: string;
|
const message = snapshot?.message || '';
|
||||||
toolName: string;
|
setTextPromptDialog({ open: false, message: '' });
|
||||||
toolDisplayName: string;
|
|
||||||
waitForResponse: boolean;
|
|
||||||
}
|
|
||||||
| undefined;
|
|
||||||
let message = '';
|
|
||||||
setTextPromptDialog((prev) => {
|
|
||||||
pending = prev.pendingResult;
|
|
||||||
message = prev.message;
|
|
||||||
return { open: false, message: '' };
|
|
||||||
});
|
|
||||||
if (pending?.waitForResponse) {
|
if (pending?.waitForResponse) {
|
||||||
emitClientToolResult(
|
emitClientToolResult(
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user