fix(voice): correct input accounting and session termination
Separate detected speech limits from continuous microphone silence while preserving transport bounds and absolute commit fencing. Handle verified OpenAI cancellation races and terminal items, preserve causal close outcomes, and share bounded cleanup ownership with safe diagnostics. Add regression coverage and align the API contract and frontend handoff. Validation: 61 focused unit tests passed; staged diff whitespace checks passed. Live browser acceptance remains outstanding.
This commit is contained in:
@@ -5,6 +5,7 @@ import json
|
||||
from uuid import UUID, uuid4
|
||||
from sqlalchemy import text
|
||||
from app.modules.knowledge.service import SearchInput, authority, transaction, KnowledgeError
|
||||
from app.modules.voice.diagnostics import terminal_failed
|
||||
|
||||
ACTIVE = ('creating', 'connecting', 'connected')
|
||||
TECHNICAL_ERRORS = frozenset(('SEARCH_TIMEOUT','SEARCH_FAILED','SEARCH_SATURATED',
|
||||
@@ -216,10 +217,15 @@ class LiveLifecycleService:
|
||||
dict(id=session_id, org=user.organization_id, owner=user.id)).mappings().first()
|
||||
if row is None:
|
||||
raise ValueError('SESSION_NOT_FOUND')
|
||||
if reason == "user_requested" and row["status"] in ACTIVE:
|
||||
from app.modules.voice.registry import failure_outcome
|
||||
causal_failure = failure_outcome(session_id)
|
||||
if causal_failure:
|
||||
reason, failed = causal_failure, terminal_failed(causal_failure)
|
||||
self._terminal(conn, session_id, reason, failed=failed)
|
||||
row = conn.execute(text('SELECT * FROM live_sessions WHERE id=:id'), {'id': session_id}).mappings().one()
|
||||
from app.modules.voice.registry import notify
|
||||
notify(session_id=session_id)
|
||||
notify(session_id=session_id, code="user_requested" if row["close_reason"] == "user_requested" else row["close_reason"])
|
||||
return dict(session_id=str(session_id), status=row['status'], close_reason=row['close_reason'])
|
||||
|
||||
def close_live_session(self, user, session_id, reason='user_requested'):
|
||||
|
||||
Reference in New Issue
Block a user