diff --git a/android/src/screens/ChatScreen.tsx b/android/src/screens/ChatScreen.tsx index e129c42..dd3baed 100644 --- a/android/src/screens/ChatScreen.tsx +++ b/android/src/screens/ChatScreen.tsx @@ -1060,6 +1060,17 @@ const ChatScreen: React.FC = () => { if (sender === 'stt') { const sttText = (message.payload.text as string) || ''; const sttAudioReqId = (message.payload.audioRequestId as string) || ''; + // Autoritative Projekt-Zuordnung vom Server (Voice-Router). Die App + // hatte die lokale Bubble optimistisch mit dem App-Focus getaggt; + // wenn der Router anders entschieden hat (Sticky, \u201Efuer X:"-Prefix, + // oder Fallback), uebernehmen wir hier den Server-Wert \u2014 sonst + // divergieren App- und Diagnostic-Ansicht (Frage im einen Kontext, + // Antwort im anderen). Nur uebernehmen wenn das Feld mitgeliefert + // wurde (leer/undefined = altes Bridge-Format \u2192 App-Focus behalten). + const hasServerPid = typeof (message.payload as any).projectId === 'string'; + const sttProjectId = ((message.payload as any).projectId as string) || ''; + const applyPid = (m: ChatMessage): ChatMessage => + hasServerPid ? { ...m, projectId: sttProjectId } : m; if (!sttText) { return; } @@ -1072,7 +1083,7 @@ const ChatScreen: React.FC = () => { const idxById = prev.findIndex(m => m.audioRequestId === sttAudioReqId); if (idxById >= 0) { const next = prev.slice(); - next[idxById] = { ...next[idxById], text: newText }; + next[idxById] = applyPid({ ...next[idxById], text: newText }); return next; } } @@ -1083,7 +1094,7 @@ const ChatScreen: React.FC = () => { ); if (idx >= 0) { const next = prev.slice(); - next[idx] = { ...next[idx], text: newText }; + next[idx] = applyPid({ ...next[idx], text: newText }); return next; } // Letzter Fallback: gar keine Placeholder \u2192 neue Bubble einfuegen @@ -1093,6 +1104,7 @@ const ChatScreen: React.FC = () => { text: newText, timestamp: message.timestamp, attachments: [{ type: 'audio', name: 'Sprachaufnahme' }], + projectId: hasServerPid ? sttProjectId : focusedProjectIdRef.current, }]); }); return;