fix: TDZ crash - move voiceStream/buildPromptFromRefs before _handleSend
Some checks failed
Deploy Nyla Frontend to Production / deploy (push) Failing after 28s
Deploy Nyla Frontend to Integration / deploy (push) Failing after 51s

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
ValueOn AG 2026-06-02 09:23:31 +02:00
parent e94420dfe9
commit 2031c87529

View file

@ -337,6 +337,38 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
attachments.length > 0 || attachedDataSourceIds.length > 0 || attachedFeatureDataSourceIds.length > 0;
const _canSend = Boolean(prompt.trim()) || attachments.length > 0;
const _buildPromptFromRefs = useCallback(() => {
const parts = [
promptBeforeVoiceRef.current,
finalizedTextRef.current,
currentInterimRef.current,
].filter(Boolean);
return parts.join(' ');
}, []);
const voiceStream = useVoiceStream({
onFinal: (text) => {
finalizedTextRef.current = finalizedTextRef.current
? `${finalizedTextRef.current} ${text}`
: text;
currentInterimRef.current = '';
setPrompt(_buildPromptFromRefs());
},
onInterim: (text) => {
currentInterimRef.current = text;
setPrompt(_buildPromptFromRefs());
},
onError: (error) => {
console.warn('Workspace voice stream error', error);
setVoiceActive(false);
},
onStatusChange: (nextStatus) => {
if (nextStatus === 'idle' || nextStatus === 'error') {
setVoiceActive(false);
}
},
});
const _handleSend = useCallback(() => {
if ((!prompt.trim() && attachments.length === 0) || isProcessing) return;
if (voiceActive) {
@ -419,38 +451,6 @@ export const WorkspaceInput = forwardRef<WorkspaceInputHandle, WorkspaceInputPro
});
}, [_persistAttachments, attachedDataSourceIds]);
const _buildPromptFromRefs = useCallback(() => {
const parts = [
promptBeforeVoiceRef.current,
finalizedTextRef.current,
currentInterimRef.current,
].filter(Boolean);
return parts.join(' ');
}, []);
const voiceStream = useVoiceStream({
onFinal: (text) => {
finalizedTextRef.current = finalizedTextRef.current
? `${finalizedTextRef.current} ${text}`
: text;
currentInterimRef.current = '';
setPrompt(_buildPromptFromRefs());
},
onInterim: (text) => {
currentInterimRef.current = text;
setPrompt(_buildPromptFromRefs());
},
onError: (error) => {
console.warn('Workspace voice stream error', error);
setVoiceActive(false);
},
onStatusChange: (nextStatus) => {
if (nextStatus === 'idle' || nextStatus === 'error') {
setVoiceActive(false);
}
},
});
const _stopVoiceCapture = useCallback(() => {
if (currentInterimRef.current) {
finalizedTextRef.current = finalizedTextRef.current