ciyidogan commited on
Commit
3bc1c26
·
verified ·
1 Parent(s): 6f489d0

Update flare-ui/src/app/components/chat/realtime-chat.component.ts

Browse files
flare-ui/src/app/components/chat/realtime-chat.component.ts CHANGED
@@ -345,64 +345,64 @@ export class RealtimeChatComponent implements OnInit, OnDestroy, AfterViewChecke
345
  }
346
 
347
  ngOnInit(): void {
348
- console.log('🎤 RealtimeChat component initialized');
349
- console.log('Session ID:', this.sessionId);
350
- console.log('Project Name:', this.projectName);
351
-
352
- // Check browser support
353
- if (!AudioStreamService.checkBrowserSupport()) {
354
- this.error = 'Tarayıcınız ses kaydını desteklemiyor. Lütfen modern bir tarayıcı kullanın.';
355
- this.snackBar.open(this.error, 'Close', {
356
- duration: 5000,
357
- panelClass: 'error-snackbar'
 
 
 
 
 
 
 
358
  });
359
- return;
360
- }
361
-
362
- // Check microphone permission
363
- this.checkMicrophonePermission();
364
-
365
- // Subscribe to conversation state
366
- this.conversationManager.currentState$.pipe(
367
- takeUntil(this.destroyed$)
368
- ).subscribe(state => {
369
- console.log('📊 Conversation state:', state);
370
- this.currentState = state;
371
- this.updateRecordingState(state);
372
- });
373
-
374
- // Subscribe to messages
375
- this.conversationManager.messages$.pipe(
376
- takeUntil(this.destroyed$)
377
- ).subscribe(messages => {
378
- console.log('💬 Messages updated:', messages.length, 'messages');
379
- this.messages = messages;
380
- this.shouldScrollToBottom = true;
381
 
382
- // Check if we have initial welcome message
383
- if (messages.length > 0) {
384
- const lastMessage = messages[messages.length - 1];
385
- console.log('📝 Last message:', lastMessage.role, lastMessage.text?.substring(0, 50) + '...');
 
 
 
 
386
  }
387
- });
388
-
389
- // Subscribe to transcription
390
- this.conversationManager.transcription$.pipe(
391
- takeUntil(this.destroyed$)
392
- ).subscribe(text => {
393
- if (text) {
394
- console.log('🎙️ Transcription:', text);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395
  }
396
- this.currentTranscription = text;
397
- });
398
-
399
- // Load initial messages from session if available
400
- const initialMessages = this.conversationManager.getMessages();
401
- console.log('📋 Initial messages:', initialMessages.length);
402
- if (initialMessages.length > 0) {
403
- this.messages = initialMessages;
404
- this.shouldScrollToBottom = true;
405
- }
406
  }
407
 
408
  ngAfterViewChecked(): void {
 
345
  }
346
 
347
  ngOnInit(): void {
348
+ console.log('🎤 RealtimeChat component initialized');
349
+ console.log('Session ID:', this.sessionId);
350
+ console.log('Project Name:', this.projectName);
351
+
352
+ // Subscribe to messages FIRST - before any connection
353
+ this.conversationManager.messages$.pipe(
354
+ takeUntil(this.destroyed$)
355
+ ).subscribe(messages => {
356
+ console.log('💬 Messages updated:', messages.length, 'messages');
357
+ this.messages = messages;
358
+ this.shouldScrollToBottom = true;
359
+
360
+ // Check if we have initial welcome message
361
+ if (messages.length > 0) {
362
+ const lastMessage = messages[messages.length - 1];
363
+ console.log('📝 Last message:', lastMessage.role, lastMessage.text?.substring(0, 50) + '...');
364
+ }
365
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
366
 
367
+ // Check browser support
368
+ if (!AudioStreamService.checkBrowserSupport()) {
369
+ this.error = 'Tarayıcınız ses kaydını desteklemiyor. Lütfen modern bir tarayıcı kullanın.';
370
+ this.snackBar.open(this.error, 'Close', {
371
+ duration: 5000,
372
+ panelClass: 'error-snackbar'
373
+ });
374
+ return;
375
  }
376
+
377
+ // Check microphone permission
378
+ this.checkMicrophonePermission();
379
+
380
+ // Subscribe to conversation state
381
+ this.conversationManager.currentState$.pipe(
382
+ takeUntil(this.destroyed$)
383
+ ).subscribe(state => {
384
+ console.log('📊 Conversation state:', state);
385
+ this.currentState = state;
386
+ this.updateRecordingState(state);
387
+ });
388
+
389
+ // Subscribe to transcription
390
+ this.conversationManager.transcription$.pipe(
391
+ takeUntil(this.destroyed$)
392
+ ).subscribe(text => {
393
+ if (text) {
394
+ console.log('🎙️ Transcription:', text);
395
+ }
396
+ this.currentTranscription = text;
397
+ });
398
+
399
+ // Load initial messages from session if available
400
+ const initialMessages = this.conversationManager.getMessages();
401
+ console.log('📋 Initial messages:', initialMessages.length);
402
+ if (initialMessages.length > 0) {
403
+ this.messages = initialMessages;
404
+ this.shouldScrollToBottom = true;
405
  }
 
 
 
 
 
 
 
 
 
 
406
  }
407
 
408
  ngAfterViewChecked(): void {