feat: QR-Code Onboarding + TTS-Audio-Cache im Filesystem

QR-Code Onboarding
- Diagnostic: GET /api/onboarding gibt RVS-Credentials zurueck
- Einstellungen-UI: neue Sektion mit QR-Code (qrcode-generator via CDN)
- Format kompatibel mit bestehendem QRScanner.parseQRData (host/port/tls/token)
- App-SettingsScreen hatte QR-Scanner bereits — funktioniert out of the box
- Warnhinweis zu Token im Klartext

TTS-Audio-Cache
- Bridge: jede ARIA-Chat-Nachricht bekommt eine messageId (UUID)
  Audio-Payload wird mit messageId verknuepft (Piper-Pfade)
- ChatScreen: messageId + audioPath in ChatMessage Interface
- audioService.cacheAudio(): speichert Base64 in DocumentDirectory/tts_cache/<id>.wav
- audioService.playFromPath(): spielt aus Cache ohne Regenerierung
- Play-Button: wenn audioPath gesetzt → aus Cache, sonst tts_request
- cleanupOldTTSCache(): alte unreferenzierte WAVs (>30 Tage) weg
- Persistiert via AsyncStorage — ueberlebt App-Restart

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-19 16:16:25 +02:00
parent 8b0a72dc9b
commit b203503fd8
5 changed files with 169 additions and 7 deletions
+24 -5
View File
@@ -48,6 +48,10 @@ interface ChatMessage {
text: string;
timestamp: number;
attachments?: Attachment[];
/** Bridge-Message-ID zur Zuordnung von TTS-Audio */
messageId?: string;
/** Lokaler Pfad zur gecachten TTS-Audio-Datei (file://...) */
audioPath?: string;
}
// --- Konstanten ---
@@ -248,6 +252,7 @@ const ChatScreen: React.FC = () => {
text,
timestamp: ts,
attachments: message.payload.attachments as Attachment[] | undefined,
messageId: (message.payload.messageId as string) || undefined,
};
return capMessages([...prev, ariaMsg]);
});
@@ -255,7 +260,18 @@ const ChatScreen: React.FC = () => {
// TTS-Audio abspielen wenn vorhanden
if (message.type === 'audio' && message.payload.base64) {
audioService.playAudio(message.payload.base64 as string);
const b64 = message.payload.base64 as string;
const refId = (message.payload.messageId as string) || '';
audioService.playAudio(b64);
// Wenn messageId mitgeliefert wurde: Audio in Cache speichern + Pfad in Message eintragen
if (refId) {
audioService.cacheAudio(b64, refId).then(audioPath => {
if (!audioPath) return;
setMessages(prev => prev.map(m =>
m.messageId === refId ? { ...m, audioPath } : m
));
}).catch(() => {});
}
}
// Thinking-Indicator Status von der Bridge
@@ -620,16 +636,19 @@ const ChatScreen: React.FC = () => {
{item.text}
</Text>
)}
{/* Play-Button fuer ARIA-Nachrichten */}
{/* Play-Button fuer ARIA-Nachrichten — Cache bevorzugt, sonst Regenerierung */}
{!isUser && item.text.length > 0 && (
<TouchableOpacity
style={styles.playButton}
onPress={() => {
// TTS-Request an Bridge senden
rvs.send('tts_request' as any, { text: item.text, voice: '' });
if (item.audioPath) {
audioService.playFromPath(item.audioPath);
} else {
rvs.send('tts_request' as any, { text: item.text, voice: '' });
}
}}
>
<Text style={styles.playButtonText}>{'\uD83D\uDD0A'}</Text>
<Text style={styles.playButtonText}>{item.audioPath ? '\uD83D\uDD0A' : '\uD83D\uDD0A'}</Text>
</TouchableOpacity>
)}
<Text style={styles.timestamp}>{time}</Text>