feat(chat): expand error handling for chat operations by introducing a passthrough code set, improving response management and user feedback

This commit is contained in:
Anish Sarkar 2026-04-30 16:20:14 +05:30
parent 1ce122cc99
commit 2a01711bc9
3 changed files with 26 additions and 15 deletions

View file

@ -8,13 +8,6 @@ Add thread-level fields to persist Auto (Fastest) model pinning metadata:
- pinned_llm_config_id: concrete resolved config id used for this thread
- pinned_auto_mode: auto policy identifier (currently "auto_fastest")
- pinned_at: timestamp when the pin was created/refreshed
Idempotent: this migration was originally numbered 134 on the
``feat/split-auto-free-premium`` branch and was renumbered to 138 during
the merge with ``upstream/dev`` (which claimed 134-137). Some databases
already have these columns/indexes from when the original 134 ran, so we
use ``IF NOT EXISTS`` to make re-application a no-op for those DBs while
still creating the schema on fresh databases.
"""
from __future__ import annotations

View file

@ -231,10 +231,18 @@ def test_network_send_failures_use_unified_retry_toast_message():
assert 'userMessage: "Message not sent. Please retry."' in classifier_source
assert 'userMessage: "Connection issue. Please try again."' in classifier_source
assert "tagPreAcceptSendFailure(error)" in page_source
assert 'existingCode === "THREAD_BUSY"' in page_source
assert 'existingCode === "AUTH_EXPIRED"' in page_source
assert 'existingCode === "UNAUTHORIZED"' in page_source
assert 'existingCode === "RATE_LIMITED"' in page_source
assert "const passthroughCodes = new Set([" in page_source
assert '"PREMIUM_QUOTA_EXHAUSTED"' in page_source
assert '"THREAD_BUSY"' in page_source
assert '"AUTH_EXPIRED"' in page_source
assert '"UNAUTHORIZED"' in page_source
assert '"RATE_LIMITED"' in page_source
assert '"NETWORK_ERROR"' in page_source
assert '"STREAM_PARSE_ERROR"' in page_source
assert '"TOOL_EXECUTION_ERROR"' in page_source
assert '"PERSIST_MESSAGE_FAILED"' in page_source
assert '"SERVER_ERROR"' in page_source
assert "passthroughCodes.has(existingCode)" in page_source
assert 'errorCode: "SEND_FAILED_PRE_ACCEPT"' in page_source
assert 'errorCode: "NETWORK_ERROR"' not in page_source
assert "Failed to start chat. Please try again." not in page_source

View file

@ -227,11 +227,21 @@ function tagPreAcceptSendFailure(error: unknown): unknown {
if (error instanceof Error) {
const withCode = error as Error & { errorCode?: string; code?: string };
const existingCode = withCode.errorCode ?? withCode.code;
const passthroughCodes = new Set([
"PREMIUM_QUOTA_EXHAUSTED",
"THREAD_BUSY",
"AUTH_EXPIRED",
"UNAUTHORIZED",
"RATE_LIMITED",
"NETWORK_ERROR",
"STREAM_PARSE_ERROR",
"TOOL_EXECUTION_ERROR",
"PERSIST_MESSAGE_FAILED",
"SERVER_ERROR",
]);
if (
existingCode === "THREAD_BUSY" ||
existingCode === "AUTH_EXPIRED" ||
existingCode === "UNAUTHORIZED" ||
existingCode === "RATE_LIMITED"
existingCode &&
passthroughCodes.has(existingCode)
) {
return Object.assign(error, { errorCode: existingCode });
}