Populate error state in UI when agent communication fails#1150
Populate error state in UI when agent communication fails#1150zeroasterisk wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the A2UILayoutEditor to manage an internal error state, ensuring it is reset before a request and populated upon failure. A review comment suggests using 'instanceof Error' for safer error handling to avoid potential runtime crashes when non-Error objects are caught.
samples/client/lit/shell/app.ts
Outdated
| return response; | ||
| } catch (err) { | ||
| this.snackbar(err as string, SnackType.ERROR); | ||
| this.#error = (err as Error).message || String(err); |
There was a problem hiding this comment.
The type assertion err as Error is potentially unsafe because in JavaScript/TypeScript, any value can be thrown (including strings, null, or undefined). If err is null or undefined, accessing .message will cause a runtime TypeError, crashing the error handler itself. Using instanceof Error is a safer and more idiomatic way to handle unknown errors.
| this.#error = (err as Error).message || String(err); | |
| this.#error = err instanceof Error ? err.message : String(err); |
0eff472 to
303b1a6
Compare
ditman
left a comment
There was a problem hiding this comment.
I actually removed the whole snackbar shebang when migrating the shell app to lit v0.9, so this won't land cleanly. If we want this, we need to restore the snackbar into the (new) shell app. Sorry!
This PR improves error handling in the shell client by populating the existing #error state when agent communication fails, making errors visible in the main UI.