diff --git a/surfsense_backend/alembic/versions/138_add_thread_auto_model_pinning_fields.py b/surfsense_backend/alembic/versions/138_add_thread_auto_model_pinning_fields.py index 6e4b77cc7..1ea549975 100644 --- a/surfsense_backend/alembic/versions/138_add_thread_auto_model_pinning_fields.py +++ b/surfsense_backend/alembic/versions/138_add_thread_auto_model_pinning_fields.py @@ -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 diff --git a/surfsense_backend/tests/unit/test_stream_new_chat_contract.py b/surfsense_backend/tests/unit/test_stream_new_chat_contract.py index 9f4280063..86ea7edd1 100644 --- a/surfsense_backend/tests/unit/test_stream_new_chat_contract.py +++ b/surfsense_backend/tests/unit/test_stream_new_chat_contract.py @@ -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 diff --git a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx index f21a0a30b..239afaf73 100644 --- a/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx +++ b/surfsense_web/app/dashboard/[search_space_id]/new-chat/[[...chat_id]]/page.tsx @@ -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 }); }