feat(mobile): correlate voice tasks and recover results on reconnect
This commit is contained in:
1 parent
9f9f3226a1
commit
b66daed07a
17 files changed
+308
-48
No files matched your search
@@ -335,6 +335,13 @@ def _(rid, params: dict) -> dict:
|
||||
session, err = _sess_nowait(params, rid)
|
||||
if err:
|
||||
return err
|
||||
client_task_id = params.get('client_task_id')
|
||||
if client_task_id is not None:
|
||||
import re
|
||||
if not isinstance(client_task_id, str) or not re.fullmatch(r'[a-zA-Z0-9_.:-]{1,160}', client_task_id):
|
||||
return _err(rid, 4004, 'invalid client_task_id')
|
||||
if not isinstance(text, str) or not text.strip() or len(text) > 48000:
|
||||
return _err(rid, 4004, 'invalid tracked task text')
|
||||
hosted_task = params.get("_hosted_task")
|
||||
hosted_terminal_callback = params.get("_hosted_terminal_callback")
|
||||
internal_hosted_submit = hosted_task is not None or hosted_terminal_callback is not None
|
||||
@@ -488,7 +495,8 @@ def _(rid, params: dict) -> dict:
|
||||
break
|
||||
busy_response = _handle_busy_submit(
|
||||
rid, sid, session, text, busy_transport,
|
||||
queued=bool(params.get("queued")),
|
||||
queued=bool(params.get("queued")) or client_task_id is not None,
|
||||
**({'client_task_id': client_task_id} if client_task_id else {}),
|
||||
)
|
||||
if busy_response is not None:
|
||||
return busy_response
|
||||
@@ -931,7 +939,8 @@ def _(rid, params: dict) -> dict:
|
||||
|
||||
if turn_isolation:
|
||||
isolated_response = _submit_prompt_to_compute_host(
|
||||
rid, sid, session, text, display_kind=display_kind
|
||||
rid, sid, session, text, display_kind=display_kind,
|
||||
**({'client_task_id': client_task_id} if client_task_id else {}),
|
||||
)
|
||||
if not isolated_response.get("error"):
|
||||
if survivor_user_row_ids is not None and requested_rebind_ids is None:
|
||||
@@ -1008,6 +1017,8 @@ def _(rid, params: dict) -> dict:
|
||||
# only errors when the build itself fails or the bounded cap expires.
|
||||
err = _wait_agent_for_prompt(session, rid, sid)
|
||||
if err:
|
||||
if client_task_id:
|
||||
_emit('task.complete', sid, {'task_id': client_task_id, 'status': 'error', 'text': 'IDE modeli başlatılamadı.'})
|
||||
# Terminal frame + retained snapshot (not a bare "error" event +
|
||||
# cleared inflight): if the client is disconnected right now, the
|
||||
# retained snapshot is the only way resume can show this failure.
|
||||
@@ -1026,6 +1037,8 @@ def _(rid, params: dict) -> dict:
|
||||
return
|
||||
with session["history_lock"]:
|
||||
if session.get("_turn_cancel_requested") or not session.get("running"):
|
||||
if client_task_id:
|
||||
_emit('task.complete', sid, {'task_id': client_task_id, 'status': 'interrupted', 'text': 'Görev başlamadan iptal edildi.'})
|
||||
session["running"] = False
|
||||
_clear_inflight_turn(session)
|
||||
# Surface the cancellation to the client. Without this emit the
|
||||
@@ -1051,6 +1064,7 @@ def _(rid, params: dict) -> dict:
|
||||
text,
|
||||
display_kind=display_kind,
|
||||
terminal_callback=hosted_terminal_callback,
|
||||
**({'client_task_id': client_task_id} if client_task_id else {}),
|
||||
)
|
||||
|
||||
run_thread = threading.Thread(target=run_after_agent_ready, daemon=True)
|
||||
|
||||
Reference in new issue
Block a user