Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cd72068e76 | |||
| 8b567e15bf | |||
| 64c06db308 | |||
| 63dde6506f | |||
| 5fb08b4ea5 | |||
| d49ec64e27 |
@@ -79,8 +79,8 @@ android {
|
||||
applicationId "com.ariacockpit"
|
||||
minSdkVersion rootProject.ext.minSdkVersion
|
||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||
versionCode 10908
|
||||
versionName "0.1.9.8"
|
||||
versionCode 20000
|
||||
versionName "0.2.0.0"
|
||||
// Fallback fuer Libraries mit Product Flavors
|
||||
missingDimensionStrategy 'react-native-camera', 'general'
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "aria-cockpit",
|
||||
"version": "0.1.9.8",
|
||||
"version": "0.2.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android": "react-native run-android",
|
||||
|
||||
@@ -36,6 +36,12 @@ interface Props {
|
||||
/** Wird gerufen wenn Stefan ein anderes Projekt fokussiert (App-lokale
|
||||
* UI-Entscheidung, wechselt den Chat-Focus). */
|
||||
onActiveChanged?: (project: Project | null) => void;
|
||||
/** Der aktuell in der App fokussierte Kontext (App-lokale Source-of-Truth).
|
||||
* Leer = Hauptchat. Steuert das ✓-FOCUS-Highlight. WICHTIG: der Drawer darf
|
||||
* den Focus NICHT aus dem Brain-Status ableiten — im Multi-Threading gibt es
|
||||
* kein globales active_project mehr (status.active ist null), das wuerde den
|
||||
* Focus bei jedem Drawer-Oeffnen auf Hauptchat zuruecksetzen. */
|
||||
currentFocusId?: string;
|
||||
/** Queue-Status pro Kontext (key "__main__" = Hauptchat, sonst project_id).
|
||||
* Wenn geliefert: Status-Dot pro Zeile gerendert. */
|
||||
queueStatus?: Record<string, { busy: boolean; queue_size: number }>;
|
||||
@@ -51,7 +57,7 @@ function _fmtRel(unixSec: number): string {
|
||||
return new Date(unixSec * 1000).toLocaleDateString('de-DE');
|
||||
}
|
||||
|
||||
export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onActiveChanged, queueStatus }) => {
|
||||
export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onActiveChanged, currentFocusId, queueStatus }) => {
|
||||
const _statusDot = (pid: string) => {
|
||||
const s = queueStatus?.[pid];
|
||||
if (!s) return { color: '#555570', label: '' };
|
||||
@@ -80,9 +86,11 @@ export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onAc
|
||||
setLoading(true); setErr(null);
|
||||
brainApi.getProjectStatus()
|
||||
.then(status => {
|
||||
// NUR die Projektliste + Queue uebernehmen. NICHT status.active in den
|
||||
// App-Focus pushen — im Multi-Threading ist das Brain-active_project
|
||||
// bedeutungslos (null), das wuerde den Focus bei jedem Drawer-Oeffnen
|
||||
// auf Hauptchat zuruecksetzen und alle Nachrichten dort landen lassen.
|
||||
setProjects(status.projects || []);
|
||||
setActiveId(status.active_id || '');
|
||||
onActiveChangedRef.current?.(status.active);
|
||||
})
|
||||
.catch(e => setErr(String(e?.message || e)))
|
||||
.finally(() => setLoading(false));
|
||||
@@ -90,6 +98,10 @@ export const ProjectsBrowser: React.FC<Props> = ({ visible = true, onClose, onAc
|
||||
|
||||
useEffect(() => { if (visible) load(); }, [visible, load]);
|
||||
|
||||
// Highlight („✓ FOCUS") folgt dem App-Focus (Source-of-Truth), nicht dem
|
||||
// Brain. switchTo setzt activeId zusaetzlich sofort fuer Instant-Feedback.
|
||||
useEffect(() => { setActiveId(currentFocusId || ''); }, [currentFocusId]);
|
||||
|
||||
// Reload bei RVS-Reconnect — sonst zeigt die Liste den Fast-Fail ewig
|
||||
useEffect(() => {
|
||||
if (!visible) return;
|
||||
|
||||
@@ -499,8 +499,14 @@ const ChatScreen: React.FC = () => {
|
||||
// fuer den Auto-Fall angenehm.
|
||||
useEffect(() => {
|
||||
AsyncStorage.setItem('aria_focused_project_id', focusedProjectId).catch(() => {});
|
||||
focusedProjectIdRef.current = focusedProjectId;
|
||||
}, [focusedProjectId]);
|
||||
|
||||
// Ref-Spiegel damit useCallback-Handler die aktuelle Focus-ID lesen
|
||||
// ohne dass wir die Deps in jedes Callback muessen (sonst re-createn
|
||||
// die sich bei jedem Wechsel).
|
||||
const focusedProjectIdRef = useRef<string>('');
|
||||
|
||||
// Queue-Status alle 2s pollen — fuers Status-Dot im Focus-Header und
|
||||
// fuer die Drawer-Anzeige. Nur wenn RVS verbunden ist (sonst 30s Timeout).
|
||||
useEffect(() => {
|
||||
@@ -1414,6 +1420,7 @@ const ChatScreen: React.FC = () => {
|
||||
noSpeechTimeoutMs: windowMs,
|
||||
endpointMs: 1500,
|
||||
hardCapMs: 60000,
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
import('../services/logger').then(m => m.reportAppDebug('wake.cb', `startStreamingRecording returned ok=${ok}`)).catch(()=>{});
|
||||
if (ok) {
|
||||
@@ -1509,6 +1516,7 @@ const ChatScreen: React.FC = () => {
|
||||
noSpeechTimeoutMs: windowMs,
|
||||
endpointMs: 1500,
|
||||
hardCapMs: 60000,
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
if (ok) {
|
||||
ToastAndroid.show('🎤 Mikro offen — sprich jetzt', ToastAndroid.SHORT);
|
||||
@@ -1565,6 +1573,7 @@ const ChatScreen: React.FC = () => {
|
||||
noSpeechTimeoutMs: Math.min(passiveMs, 30000),
|
||||
endpointMs: 1500,
|
||||
hardCapMs: Math.max(passiveMs + 5000, 35000),
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
if (!ok) {
|
||||
console.warn('[Chat] passive streaming start failed — exit passive listening');
|
||||
@@ -1880,7 +1889,7 @@ const ChatScreen: React.FC = () => {
|
||||
const location = await getCurrentLocation();
|
||||
|
||||
const cmid = nextClientMsgId();
|
||||
const activePid = focusedProjectId;
|
||||
const activePid = focusedProjectIdRef.current;
|
||||
const userMsg: ChatMessage = {
|
||||
id: nextId(),
|
||||
sender: 'user',
|
||||
@@ -1963,6 +1972,7 @@ const ChatScreen: React.FC = () => {
|
||||
noSpeechTimeoutMs: 0,
|
||||
endpointMs: 1500,
|
||||
hardCapMs: 300000,
|
||||
projectId: focusedProjectIdRef.current,
|
||||
});
|
||||
if (!ok) {
|
||||
// Mikro nicht verfuegbar (Anruf? OpenWakeWord blockiert?) — Bubble weg.
|
||||
@@ -2584,7 +2594,7 @@ const ChatScreen: React.FC = () => {
|
||||
style={{ flexDirection: 'row', alignItems: 'center', gap: 8 }}
|
||||
hitSlop={{top:6,bottom:6,left:6,right:6}}
|
||||
>
|
||||
<Text style={{ fontSize: 20 }}>☰</Text>
|
||||
<Text style={{ fontSize: 22, color: '#E0E0F0', fontWeight: '700' }}>☰</Text>
|
||||
{otherActive > 0 && (
|
||||
<View style={{ backgroundColor: '#FF6E6E', borderRadius: 8, minWidth: 16, height: 16, paddingHorizontal: 4, alignItems: 'center', justifyContent: 'center' }}>
|
||||
<Text style={{ color: '#fff', fontSize: 10, fontWeight: '700' }}>{otherActive}</Text>
|
||||
@@ -2597,6 +2607,21 @@ const ChatScreen: React.FC = () => {
|
||||
</Text>
|
||||
<View style={{ width: 8, height: 8, borderRadius: 4, backgroundColor: dot.color }} />
|
||||
<Text style={{ fontSize: 10, color: '#8888AA' }}>{dot.label}</Text>
|
||||
{/* Direkter Zurueck-zum-Hauptchat-Button — nur wenn man in einem
|
||||
Projekt ist. Ein Tap statt Drawer→Hauptchat. */}
|
||||
{!isMain && (
|
||||
<TouchableOpacity
|
||||
onPress={() => setFocusedProjectId('')}
|
||||
hitSlop={{top:8,bottom:8,left:8,right:8}}
|
||||
style={{
|
||||
marginLeft: 4, paddingHorizontal: 10, paddingVertical: 4,
|
||||
borderRadius: 12, backgroundColor: 'rgba(255,255,255,0.12)',
|
||||
flexDirection: 'row', alignItems: 'center', gap: 4,
|
||||
}}
|
||||
>
|
||||
<Text style={{ color: '#E0E0F0', fontSize: 12, fontWeight: '700' }}>← Hauptchat</Text>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
@@ -2607,6 +2632,7 @@ const ChatScreen: React.FC = () => {
|
||||
visible={projectsVisible}
|
||||
onClose={() => setProjectsVisible(false)}
|
||||
onActiveChanged={(p) => setFocusedProjectId(p?.id || '')}
|
||||
currentFocusId={focusedProjectId}
|
||||
queueStatus={queueStatus}
|
||||
/>
|
||||
|
||||
|
||||
@@ -982,6 +982,10 @@ class AudioService {
|
||||
noSpeechTimeoutMs?: number;
|
||||
endpointMs?: number;
|
||||
hardCapMs?: number;
|
||||
/** Focused projectId — Bridge nutzt das als Default fuer den Voice-Router.
|
||||
* Leer = Hauptchat. Ohne Prefix / Sticky landet die STT-Nachricht damit
|
||||
* automatisch in dem Kontext den Stefan gerade sieht. */
|
||||
projectId?: string;
|
||||
}): Promise<{ requestId: string; ok: boolean }> {
|
||||
if (this.recordingState !== 'idle') {
|
||||
console.warn('[Audio] startStreamingRecording: bereits aktiv (state=%s)', this.recordingState);
|
||||
@@ -1055,6 +1059,7 @@ class AudioService {
|
||||
endpointMs: typeof opts.endpointMs === 'number' ? opts.endpointMs : 1500,
|
||||
hardCapMs: typeof opts.hardCapMs === 'number' ? opts.hardCapMs : 60000,
|
||||
sampleRate: 16000,
|
||||
projectId: opts.projectId || '',
|
||||
});
|
||||
|
||||
// No-Speech-Watchdog — ersetzt den alten VAD-noSpeechTimer.
|
||||
|
||||
@@ -112,6 +112,17 @@ async def lifespan(app: FastAPI):
|
||||
except Exception as exc:
|
||||
logger.warning("Lifespan: spotify fast_patterns Migration: %s", exc)
|
||||
|
||||
# Einmalige Migration: project_id aus conversation.jsonl nach chat_backup.jsonl
|
||||
# zurueckschreiben, damit alt-getaggte Projekt-Nachrichten (getaggt bevor
|
||||
# chat_backup project_id fuehrte) in der UI wieder im richtigen Projekt
|
||||
# landen. Idempotent (Marker), nicht-destruktiv (.bak), atomar.
|
||||
try:
|
||||
import migrate_backfill_projectid
|
||||
res = migrate_backfill_projectid.run()
|
||||
logger.info("Lifespan: chat_backup project_id Backfill: %s", res)
|
||||
except Exception as exc:
|
||||
logger.warning("Lifespan: project_id Backfill Migration: %s", exc)
|
||||
|
||||
task = asyncio.create_task(background_mod.run_loop(agent))
|
||||
logger.info("Lifespan: Trigger-Loop gestartet")
|
||||
try:
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
"""Einmalige Migration: project_id aus conversation.jsonl nach chat_backup.jsonl
|
||||
zurueckschreiben.
|
||||
|
||||
Hintergrund: Seit es Projekte gibt (fc0f91d) taggt das Brain jeden Turn in
|
||||
conversation.jsonl mit project_id. chat_backup.jsonl (die Anzeige-Quelle fuer
|
||||
App + Diagnostic) bekam project_id aber erst spaeter (f51ad15). Alle Projekt-
|
||||
Nachrichten aus dem Zeitfenster dazwischen liegen daher in conversation.jsonl
|
||||
korrekt getaggt, in chat_backup.jsonl aber untagged → die UI zeigt sie im
|
||||
Hauptchat statt im Projekt.
|
||||
|
||||
Diese Migration matcht chat_backup-Eintraege gegen conversation-Turns ueber
|
||||
(role, text) in Reihenfolge und traegt die fehlende project_id nach. Sie ist:
|
||||
- idempotent (Marker-Datei, laeuft genau einmal),
|
||||
- nicht-destruktiv (legt .bak an, aendert nur LEERE project_ids, entfernt nie
|
||||
einen bestehenden Tag),
|
||||
- atomar (tmp-Datei + os.replace).
|
||||
|
||||
Reihenfolge-erhaltend: pro (role, normalisiertem Text) wird eine Deque der
|
||||
project_ids aus conversation.jsonl aufgebaut (inklusive "" fuer Hauptthread-
|
||||
Turns), damit wiederholte identische Texte ihre jeweils richtige Zuordnung
|
||||
bekommen und Hauptchat-Interleaving nicht faelschlich getaggt wird.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
from collections import defaultdict, deque
|
||||
from pathlib import Path
|
||||
|
||||
logger = logging.getLogger("aria.migrate.backfill_projectid")
|
||||
|
||||
CONVERSATION_FILE = Path(os.environ.get("CONVERSATION_FILE", "/data/conversation.jsonl"))
|
||||
CHAT_BACKUP_FILE = Path(os.environ.get("CHAT_BACKUP_FILE", "/shared/config/chat_backup.jsonl"))
|
||||
MARKER_FILE = Path("/shared/config/.chat_backup_projectid_backfill_v1")
|
||||
|
||||
|
||||
def _norm(text: str) -> str:
|
||||
"""Match-Key: getrimmt + auf 500 Zeichen begrenzt. Reicht um Turns eindeutig
|
||||
zu unterscheiden, ist aber tolerant gegen minimale Trailing-Unterschiede."""
|
||||
return (text or "").strip()[:500]
|
||||
|
||||
|
||||
def run() -> dict:
|
||||
"""Fuehrt die Migration aus. Returns Status-Dict fuers Logging.
|
||||
Laeuft nur einmal (Marker). Fehlt eine der Quelldateien: still ueberspringen."""
|
||||
if MARKER_FILE.exists():
|
||||
return {"skipped": "marker_exists"}
|
||||
if not CHAT_BACKUP_FILE.exists():
|
||||
return {"skipped": "no_chat_backup"}
|
||||
if not CONVERSATION_FILE.exists():
|
||||
# Ohne Brain-Historie gibt es nichts zu uebernehmen — Marker trotzdem
|
||||
# setzen, damit wir nicht bei jedem Start neu pruefen.
|
||||
_write_marker(0, 0)
|
||||
return {"skipped": "no_conversation"}
|
||||
|
||||
# 1) conversation.jsonl → Deque der project_ids je (role, normtext), in Reihenfolge.
|
||||
tag_queues: dict[tuple[str, str], deque[str]] = defaultdict(deque)
|
||||
conv_turns = 0
|
||||
for line in _iter_jsonl(CONVERSATION_FILE):
|
||||
role = line.get("role")
|
||||
if role not in ("user", "assistant"):
|
||||
continue
|
||||
content = line.get("content")
|
||||
if not isinstance(content, str):
|
||||
continue
|
||||
conv_turns += 1
|
||||
tag_queues[(role, _norm(content))].append((line.get("project_id") or "").strip())
|
||||
|
||||
# 2) chat_backup.jsonl durchgehen, leere project_ids nachtragen.
|
||||
try:
|
||||
backup_lines = CHAT_BACKUP_FILE.read_text(encoding="utf-8").splitlines()
|
||||
except Exception as exc:
|
||||
logger.warning("[backfill] chat_backup lesen fehlgeschlagen: %s", exc)
|
||||
return {"error": f"read_backup: {exc}"}
|
||||
|
||||
out_lines: list[str] = []
|
||||
patched = 0
|
||||
matched = 0
|
||||
for raw in backup_lines:
|
||||
raw = raw.strip()
|
||||
if not raw:
|
||||
continue
|
||||
try:
|
||||
obj = json.loads(raw)
|
||||
except Exception:
|
||||
out_lines.append(raw) # unveraendert durchreichen
|
||||
continue
|
||||
|
||||
role = obj.get("role")
|
||||
text = obj.get("text")
|
||||
# Nur echte Chat-Bubbles matchen (keine file_deleted-/type-Marker).
|
||||
if role in ("user", "assistant") and isinstance(text, str):
|
||||
q = tag_queues.get((role, _norm(text)))
|
||||
if q:
|
||||
pid = q.popleft() # verbraucht → Reihenfolge fuer Duplikate bleibt korrekt
|
||||
matched += 1
|
||||
existing = (obj.get("project_id") or "").strip()
|
||||
# Nur setzen wenn Backup-Eintrag noch KEINEN Tag hat und der
|
||||
# conversation-Turn einem Projekt gehoert. Bestehende Tags bleiben.
|
||||
if not existing and pid:
|
||||
obj["project_id"] = pid
|
||||
patched += 1
|
||||
out_lines.append(json.dumps(obj, ensure_ascii=False))
|
||||
|
||||
# 3) Nichts zu tun? Marker setzen und raus.
|
||||
if patched == 0:
|
||||
_write_marker(conv_turns, 0)
|
||||
logger.info("[backfill] nichts nachzutragen (conv_turns=%s, matched=%s)",
|
||||
conv_turns, matched)
|
||||
return {"conv_turns": conv_turns, "matched": matched, "patched": 0}
|
||||
|
||||
# 4) Sicherung + atomarer Rewrite.
|
||||
try:
|
||||
bak = CHAT_BACKUP_FILE.with_suffix(".jsonl.pre-backfill-v1.bak")
|
||||
if not bak.exists():
|
||||
bak.write_bytes(CHAT_BACKUP_FILE.read_bytes())
|
||||
tmp = CHAT_BACKUP_FILE.with_suffix(".jsonl.tmp")
|
||||
tmp.write_text("\n".join(out_lines) + "\n", encoding="utf-8")
|
||||
os.replace(tmp, CHAT_BACKUP_FILE)
|
||||
except Exception as exc:
|
||||
logger.warning("[backfill] Rewrite fehlgeschlagen: %s", exc)
|
||||
return {"error": f"rewrite: {exc}"}
|
||||
|
||||
_write_marker(conv_turns, patched)
|
||||
logger.info("[backfill] %s Bubbles nachtraeglich getaggt (conv_turns=%s, matched=%s). Backup: %s",
|
||||
patched, conv_turns, matched, bak.name)
|
||||
return {"conv_turns": conv_turns, "matched": matched, "patched": patched}
|
||||
|
||||
|
||||
def _iter_jsonl(path: Path):
|
||||
try:
|
||||
for raw in path.read_text(encoding="utf-8").splitlines():
|
||||
raw = raw.strip()
|
||||
if not raw:
|
||||
continue
|
||||
try:
|
||||
yield json.loads(raw)
|
||||
except Exception:
|
||||
continue
|
||||
except Exception as exc:
|
||||
logger.warning("[backfill] %s lesen fehlgeschlagen: %s", path, exc)
|
||||
|
||||
|
||||
def _write_marker(conv_turns: int, patched: int) -> None:
|
||||
try:
|
||||
MARKER_FILE.parent.mkdir(parents=True, exist_ok=True)
|
||||
MARKER_FILE.write_text(
|
||||
json.dumps({"conv_turns": conv_turns, "patched": patched}, ensure_ascii=False),
|
||||
encoding="utf-8",
|
||||
)
|
||||
except Exception as exc:
|
||||
logger.warning("[backfill] Marker schreiben fehlgeschlagen: %s", exc)
|
||||
+64
-8
@@ -618,6 +618,11 @@ class ARIABridge:
|
||||
# interceptiert und aendern hier den Sticky OHNE Brain-Roundtrip.
|
||||
self._voice_sticky_project_id: str = ""
|
||||
self._voice_sticky_expires_at: float = 0.0
|
||||
# Focused-project pro Stream: die App schickt bei stt_stream_start
|
||||
# die projectId ihres aktuellen Focus mit. Wenn das Voice-Ergebnis
|
||||
# weder Meta-Kommando noch Prefix ist und der Sticky abgelaufen,
|
||||
# nutzen wir das als Default (Voice folgt dem sichtbaren Kontext).
|
||||
self._stt_stream_projects: dict[str, str] = {}
|
||||
# Voice-Override aus letzter Chat-Nachricht einer App.
|
||||
# Wird fuer die direkt folgende ARIA-Antwort genutzt und dann zurueckgesetzt.
|
||||
# So kann jedes Geraet seine bevorzugte Stimme bekommen (pro Request).
|
||||
@@ -2788,6 +2793,25 @@ class ARIABridge:
|
||||
future.set_result(text)
|
||||
return
|
||||
|
||||
elif msg_type == "stt_stream_start":
|
||||
# App startet eine neue Streaming-STT-Session. Wir merken uns
|
||||
# ihre Focus-projectId damit der Voice-Router beim spaeteren
|
||||
# stt_endpoint einen sinnvollen Default hat (Voice folgt dem
|
||||
# visuellen Focus).
|
||||
req_id = payload.get("requestId", "") or ""
|
||||
focused_pid = str(payload.get("projectId") or "")
|
||||
if req_id:
|
||||
self._stt_stream_projects[req_id] = focused_pid
|
||||
logger.info("[rvs] stt_stream_start id=%s focus=%s",
|
||||
req_id[:12], focused_pid or "(main)")
|
||||
return
|
||||
|
||||
elif msg_type == "stt_stream_end":
|
||||
# Session vorbei — Focus-Tracking fuer diese requestId aufraeumen.
|
||||
req_id = payload.get("requestId", "") or ""
|
||||
self._stt_stream_projects.pop(req_id, None)
|
||||
return
|
||||
|
||||
elif msg_type == "stt_endpoint":
|
||||
# Phase 2 Brain-Shortcut: die whisper-bridge hat im Streaming-Modus
|
||||
# einen Endpoint erkannt und schickt den finalen Text direkt.
|
||||
@@ -2836,9 +2860,15 @@ class ARIABridge:
|
||||
if self._is_duplicate_client_msg(client_msg_id):
|
||||
return
|
||||
|
||||
# App-Focus aus stt_stream_start-Registry auflösen (falls die
|
||||
# App-Version die projectId noch nicht mitschickt: leer = Hauptchat).
|
||||
stream_req_id = payload.get("requestId", "") or ""
|
||||
focused_pid = self._stt_stream_projects.pop(stream_req_id, "")
|
||||
|
||||
asyncio.create_task(self._process_endpoint_text(
|
||||
text, interrupted, audio_request_id, location,
|
||||
client_msg_id=client_msg_id))
|
||||
client_msg_id=client_msg_id,
|
||||
focused_project_id=focused_pid))
|
||||
return
|
||||
|
||||
elif msg_type == "oauth_callback":
|
||||
@@ -2986,7 +3016,20 @@ class ARIABridge:
|
||||
# Voice-Router-Konstanten
|
||||
_VOICE_STICKY_TIMEOUT_SEC = 30.0
|
||||
_VOICE_META_BACK_TO_MAIN = re.compile(
|
||||
r"^\s*(?:aria[,.]?\s+)?(?:zur(?:ü|ue)ck\s+zum\s+hauptchat|hauptchat\s+bitte|aria\s+hauptchat)\s*[.!?]?\s*$",
|
||||
r"^\s*(?:aria[,.]?\s+)?"
|
||||
r"(?:"
|
||||
# „zurück zum hauptchat / hauptmenü / haupt / menü / main"
|
||||
r"zur(?:ü|ue)ck\s+(?:zum|zur|ins?|in\s+den)\s+"
|
||||
r"(?:hauptchat|hauptmen(?:ü|ue)|haupt|men(?:ü|ue)|main)"
|
||||
r"|"
|
||||
# „zurück hauptchat / zurück haupt"
|
||||
r"zur(?:ü|ue)ck\s+(?:hauptchat|hauptmen(?:ü|ue)|haupt|main)"
|
||||
r"|"
|
||||
# „hauptchat bitte", „aria hauptchat" (auch mit Menü/Main)
|
||||
r"(?:hauptchat|hauptmen(?:ü|ue)|main)\s+bitte"
|
||||
r"|"
|
||||
r"aria[,.]?\s+(?:hauptchat|hauptmen(?:ü|ue)|haupt|main)"
|
||||
r")\s*[.!?]?\s*$",
|
||||
re.IGNORECASE,
|
||||
)
|
||||
_VOICE_META_PROJECT_PREFIX = re.compile(
|
||||
@@ -2994,7 +3037,8 @@ class ARIABridge:
|
||||
re.IGNORECASE | re.DOTALL,
|
||||
)
|
||||
|
||||
def _apply_voice_router(self, text: str) -> tuple[bool, str, str, str]:
|
||||
def _apply_voice_router(self, text: str,
|
||||
default_project_id: str = "") -> tuple[bool, str, str, str]:
|
||||
"""Voice-Router: entscheidet ob ein STT-Text ans Brain geht und wenn ja
|
||||
an welchen Projekt-Kontext.
|
||||
|
||||
@@ -3004,9 +3048,14 @@ class ARIABridge:
|
||||
- should_forward=True: cleaned_text ans Brain, project_id ist Focus.
|
||||
Bei Prefix wird der Prefix aus dem Text entfernt.
|
||||
|
||||
Sticky-Logik: nach einem projekt-getaggten Voice-Turn wird der Sticky
|
||||
30s lang gehalten. Innerhalb dieses Fensters gehen weitere Voice-Msgs
|
||||
OHNE Prefix in dasselbe Projekt. Nach Ablauf: Default Hauptchat.
|
||||
Prioritaets-Reihenfolge:
|
||||
1. Meta „zurueck zum hauptchat" → Sticky reset, kein Forward.
|
||||
2. „fuer <name>:"-Prefix → Sticky auf gematchtes Projekt.
|
||||
3. Sticky aktiv (<=30s alt) → dessen Projekt.
|
||||
4. default_project_id (App-Focus) — Voice folgt dem sichtbaren
|
||||
Kontext. Wenn App in Projekt X guckt, geht die STT-Nachricht
|
||||
ohne weitere Marker dort rein.
|
||||
5. Fallback: Hauptchat.
|
||||
"""
|
||||
import time as _time
|
||||
now = _time.time()
|
||||
@@ -3056,13 +3105,18 @@ class ARIABridge:
|
||||
return (True, stripped, self._voice_sticky_project_id, "sticky")
|
||||
# Sticky abgelaufen — zurücksetzen
|
||||
self._voice_sticky_project_id = ""
|
||||
# 4) App-Focus als Default: Voice folgt dem sichtbaren Kontext
|
||||
if default_project_id:
|
||||
return (True, stripped, default_project_id, "app_focus")
|
||||
# 5) Fallback Hauptchat
|
||||
return (True, stripped, "", "default")
|
||||
|
||||
async def _process_endpoint_text(self, text: str,
|
||||
interrupted: bool = False,
|
||||
audio_request_id: str = "",
|
||||
location: Optional[dict] = None,
|
||||
client_msg_id: Optional[str] = None) -> None:
|
||||
client_msg_id: Optional[str] = None,
|
||||
focused_project_id: str = "") -> None:
|
||||
"""Phase-2 Brain-Shortcut: Streaming-Whisper hat den finalen Text
|
||||
schon ermittelt — wir uebernehmen den Pfad ab broadcast-STT + brain.
|
||||
|
||||
@@ -3075,7 +3129,9 @@ class ARIABridge:
|
||||
selbst geht NICHT ans Brain, sondern broadcastet als project_changed-
|
||||
Event → App+Diagnostic wechseln den Focus.
|
||||
"""
|
||||
should_forward, cleaned, project_id, meta_action = self._apply_voice_router(text)
|
||||
should_forward, cleaned, project_id, meta_action = self._apply_voice_router(
|
||||
text, default_project_id=focused_project_id,
|
||||
)
|
||||
|
||||
if meta_action in ("back_to_main", "project_prefix"):
|
||||
# UI-Focus-Update broadcasten
|
||||
|
||||
@@ -1751,7 +1751,11 @@
|
||||
}
|
||||
|
||||
if (msg.type === 'chat_final') {
|
||||
addChat('received', msg.text || '', 'chat:final');
|
||||
// KEINE Bubble mehr rendern: ARIA-Antworten kommen ausschliesslich via
|
||||
// rvs_chat (traegt projectId → landet im richtigen Kontext). chat_final
|
||||
// stammt vom Gateway-Watch und hat KEINE projectId — wuerde also eine
|
||||
// untagged Duplikat-Bubble im Hauptchat erzeugen. Nur noch als
|
||||
// Aktivitaets-/Trace-Ende-Signal relevant (das macht der Server).
|
||||
return;
|
||||
}
|
||||
if (msg.type === 'file_from_aria') {
|
||||
|
||||
@@ -660,11 +660,11 @@ function handleGatewayMessage(msg) {
|
||||
broadcast({ type: "agent_activity", activity: "idle" });
|
||||
pendingMessageTime = 0; // Watchdog: Antwort erhalten
|
||||
updateAgentActivity();
|
||||
// Antwort in Backup-Log schreiben
|
||||
try {
|
||||
const entry = JSON.stringify({ ts: Date.now(), role: "assistant", text: text.slice(0, 2000), session: activeSessionKey }) + "\n";
|
||||
fs.appendFileSync("/shared/config/chat_backup.jsonl", entry);
|
||||
} catch {}
|
||||
// KEIN chat_backup-Write mehr hier: die Bridge (_process_core_response)
|
||||
// ist der massgebliche Writer und schreibt den Assistant-Eintrag MIT
|
||||
// project_id. Dieser Gateway-Watch-Pfad kennt die project_id nicht —
|
||||
// ein Write hier erzeugte ein untagged Duplikat, das beim Reload im
|
||||
// Hauptchat auftaucht (statt im Projekt).
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user