Skip to content

fix: show chat parse error stack in the stack trace modal - #1652

Open
SameDesu123 wants to merge 1 commit into
kwaroran:mainfrom
SameDesu123:fix/chat-parse-error-stacktrace
Open

SameDesu123 wants to merge 1 commit into
kwaroran:mainfrom
SameDesu123:fix/chat-parse-error-stacktrace

Conversation

@SameDesu123

@SameDesu123 SameDesu123 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Checklist

  • Required Checks
    • Have you added type definitions?
    • Have you tested your changes?
    • Have you checked that it won't break any existing features?
  • If your PR uses models1, check the following: N/A.
    • Have you checked if it works normally in all models?
    • Have you checked if it works normally in all web, local, and node-hosted versions? If it doesn't, have you blocked it in those versions?
  • If your PR is highly AI generated2, check the following:
    • Have you understood what the code does?
    • Have you cleaned up any unnecessary or redundant code?
    • Is it not a huge change?
      • We currently do not accept highly AI generated PRs that are large changes.

Summary

Show the stack of a chat message parsing error in the stack trace panel of the error alert instead of in the alert body.

Related Issues

Fixes #1653

Changes

  • markParsing in ChatBody.svelte passed alertError a single string that combined the message and error.stack. alertError only separates the stack into stackTrace when it receives an Error, so the full stack was printed in the alert body and the "Show error details" panel never appeared.
  • Wrap the message in a new Error, copy the original stack onto it, and pass that to alertError. The stack now goes to the existing details panel, where the source map translation and copy features apply.
  • Remove the translated flag from the message. It showed up as a meaningless true, / false, in the alert.

Impact

  • The alert body now shows only Error while parsing chat message: <message> plus the existing submessage (for example, the network hint for Failed to fetch, which is still matched against the message).
  • If the thrown value is not an Error, only the message is shown and the details button stays hidden, same as other alerts without a stack.

Additional Notes

  • pnpm check: 0 errors

Footnotes

  1. Modifies the behavior of prompting, requesting, or handling responses from AI models. ↩

  2. Over 80% of the code is AI generated. ↩

Pass an Error to alertError instead of concatenating the stack into the
message string, so the stack goes to the details panel rather than the
alert body. Also drop the leaked translated flag from the message.
@SameDesu123

SameDesu123 commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author
latest commit of main fix applied
nvisdfawewerweqrtwt0 nvisdfawewerweqrtwt1

I tested this with google translation option. (By force blocking their domain)

@cubicj cubicj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went through 1f8180c on this. On main the whole stack is folded into the one string handed to alertError, so it lands in the alert body and stackTrace stays empty, which is why the details button never shows up. With the wrapped Error the body is down to the message, the Failed to fetch hint still matches, and the original stack goes to the details panel. I ran the main and head catch blocks side by side against a few thrown values, and a thrown null, which made the main catch block throw on .message, now ends in the parse alert as well. pnpm check, pnpm test, and pnpm build are clean on this head.

Approving — thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chat parse error alert shows the stack trace in the alert body

2 participants