mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-28 21:49:40 +02:00
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:
parent
1ce122cc99
commit
2a01711bc9
3 changed files with 26 additions and 15 deletions
|
|
@ -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_llm_config_id: concrete resolved config id used for this thread
|
||||||
- pinned_auto_mode: auto policy identifier (currently "auto_fastest")
|
- pinned_auto_mode: auto policy identifier (currently "auto_fastest")
|
||||||
- pinned_at: timestamp when the pin was created/refreshed
|
- 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
|
from __future__ import annotations
|
||||||
|
|
|
||||||
|
|
@ -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: "Message not sent. Please retry."' in classifier_source
|
||||||
assert 'userMessage: "Connection issue. Please try again."' in classifier_source
|
assert 'userMessage: "Connection issue. Please try again."' in classifier_source
|
||||||
assert "tagPreAcceptSendFailure(error)" in page_source
|
assert "tagPreAcceptSendFailure(error)" in page_source
|
||||||
assert 'existingCode === "THREAD_BUSY"' in page_source
|
assert "const passthroughCodes = new Set([" in page_source
|
||||||
assert 'existingCode === "AUTH_EXPIRED"' in page_source
|
assert '"PREMIUM_QUOTA_EXHAUSTED"' in page_source
|
||||||
assert 'existingCode === "UNAUTHORIZED"' in page_source
|
assert '"THREAD_BUSY"' in page_source
|
||||||
assert 'existingCode === "RATE_LIMITED"' 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: "SEND_FAILED_PRE_ACCEPT"' in page_source
|
||||||
assert 'errorCode: "NETWORK_ERROR"' not in page_source
|
assert 'errorCode: "NETWORK_ERROR"' not in page_source
|
||||||
assert "Failed to start chat. Please try again." not in page_source
|
assert "Failed to start chat. Please try again." not in page_source
|
||||||
|
|
|
||||||
|
|
@ -227,11 +227,21 @@ function tagPreAcceptSendFailure(error: unknown): unknown {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
const withCode = error as Error & { errorCode?: string; code?: string };
|
const withCode = error as Error & { errorCode?: string; code?: string };
|
||||||
const existingCode = withCode.errorCode ?? withCode.code;
|
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 (
|
if (
|
||||||
existingCode === "THREAD_BUSY" ||
|
existingCode &&
|
||||||
existingCode === "AUTH_EXPIRED" ||
|
passthroughCodes.has(existingCode)
|
||||||
existingCode === "UNAUTHORIZED" ||
|
|
||||||
existingCode === "RATE_LIMITED"
|
|
||||||
) {
|
) {
|
||||||
return Object.assign(error, { errorCode: existingCode });
|
return Object.assign(error, { errorCode: existingCode });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue