fix(copilot): persist transient error markers and case-insensitive detection

- Append COPILOT_ERROR_PREFIX marker to session before yielding
  StreamError so the error card survives page refresh.
- Make frontend transient error detection case-insensitive.
This commit is contained in:
Zamil Majdy
2026-03-17 13:14:45 +07:00
parent 84f3ca9a62
commit 1d5598df3d
2 changed files with 21 additions and 7 deletions

View File

@@ -1055,13 +1055,19 @@ async def stream_chat_completion_sdk(
exc_info=True,
)
ended_with_stream_error = True
display = (
FRIENDLY_TRANSIENT_MSG
if is_transient
else f"SDK stream error: {stream_err}"
)
session.messages.append(
ChatMessage(
role="assistant",
content=f"{COPILOT_ERROR_PREFIX} {display}",
)
)
yield StreamError(
errorText=(
FRIENDLY_TRANSIENT_MSG
if is_transient
else f"SDK stream error: {stream_err}"
),
errorText=display,
code=(
"transient_api_error"
if is_transient
@@ -1112,6 +1118,12 @@ async def stream_chat_completion_sdk(
log_prefix,
)
ended_with_stream_error = True
session.messages.append(
ChatMessage(
role="assistant",
content=f"{COPILOT_ERROR_PREFIX} {FRIENDLY_TRANSIENT_MSG}",
)
)
yield StreamError(
errorText=FRIENDLY_TRANSIENT_MSG,
code="transient_api_error",

View File

@@ -104,7 +104,9 @@ export function MessagePartRenderer({
</div>
);
}
const isTransient = markerText.includes(TRANSIENT_ERROR_TEXT);
const isTransient = markerText
.toLowerCase()
.includes(TRANSIENT_ERROR_TEXT.toLowerCase());
return (
<ErrorCard
key={key}