Skip to content

Commit 082d135

Browse files
Copiloteliteprox
andauthored
Fix text output panel visibility - hide by default, show on first text output (#428)
* Fix text output panel visibility - hide by default, show on first text output Co-authored-by: John | Elite Encoder <[email protected]>
1 parent e51e7cb commit 082d135

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

ui/src/components/room.tsx

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,20 @@ function useToast() {
5656
}
5757

5858
// Wrapper component to access peer context
59-
function TranscriptionViewerWrapper() {
59+
function TranscriptionViewerWrapper({ onFirstTextOutput }: { onFirstTextOutput: () => void }) {
6060
const peer = usePeerContext();
61+
const hasNotifiedRef = useRef(false);
62+
63+
// Watch for first text output and notify parent
64+
useEffect(() => {
65+
if (peer?.textOutputData && peer.textOutputData.trim() && !hasNotifiedRef.current) {
66+
// Check if it's not a warmup message
67+
if (!peer.textOutputData.includes('__WARMUP_SENTINEL__')) {
68+
hasNotifiedRef.current = true;
69+
onFirstTextOutput();
70+
}
71+
}
72+
}, [peer?.textOutputData, onFirstTextOutput]);
6173

6274
return (
6375
<TextOutputViewer
@@ -342,7 +354,8 @@ export const Room = () => {
342354
const [isRecordingsPanelOpen, setIsRecordingsPanelOpen] = useState(false);
343355

344356
// Transcription state
345-
const [isTranscriptionPanelOpen, setIsTranscriptionPanelOpen] = useState(true);
357+
const [isTranscriptionPanelOpen, setIsTranscriptionPanelOpen] = useState(false);
358+
const [hasReceivedTextOutput, setHasReceivedTextOutput] = useState(false);
346359

347360
// Helper to get timestamped filenames
348361
const getFilename = (type: 'input' | 'output', extension: string) => {
@@ -416,6 +429,7 @@ export const Room = () => {
416429
const handleDisconnected = useCallback(() => {
417430
setIsConnected(false);
418431
setIsComfyUIReady(false);
432+
setHasReceivedTextOutput(false); // Reset text output state
419433
showToast("Stream disconnected", "error");
420434
}, [showToast]);
421435

@@ -569,6 +583,14 @@ export const Room = () => {
569583

570584
const [isControlPanelOpen, setIsControlPanelOpen] = useState(false);
571585

586+
// Callback to handle first text output received
587+
const handleFirstTextOutput = useCallback(() => {
588+
if (!hasReceivedTextOutput && !isTranscriptionPanelOpen) {
589+
setHasReceivedTextOutput(true);
590+
setIsTranscriptionPanelOpen(true);
591+
}
592+
}, [hasReceivedTextOutput, isTranscriptionPanelOpen]);
593+
572594
return (
573595
<main className="fixed inset-0 overflow-hidden overscroll-none">
574596
<meta
@@ -721,7 +743,7 @@ export const Room = () => {
721743
{isConnected && (
722744
<div className={`w-full flex justify-center px-4 mt-4 ${isTranscriptionPanelOpen ? '' : 'hidden'}`}>
723745
<div className="w-full max-w-[1040px]">
724-
<TranscriptionViewerWrapper />
746+
<TranscriptionViewerWrapper onFirstTextOutput={handleFirstTextOutput} />
725747
</div>
726748
</div>
727749
)}

0 commit comments

Comments
 (0)