Skip to content

feat: error boundary support in widget3#7468

Open
Rathoz wants to merge 7 commits into
mainfrom
widget3-error-boundry
Open

feat: error boundary support in widget3#7468
Rathoz wants to merge 7 commits into
mainfrom
widget3-error-boundry

Conversation

@Rathoz
Copy link
Copy Markdown
Collaborator

@Rathoz Rathoz commented May 6, 2026

Summary

Creates error boundary support in Widget3

How did you test this change?

attached test cases

Base automatically changed from widget30 to main May 7, 2026 08:56
@Rathoz Rathoz force-pushed the widget3-error-boundry branch from 805be0a to a1cd50a Compare May 12, 2026 08:36
@Rathoz Rathoz force-pushed the widget3-error-boundry branch from c69e4bf to e5571a1 Compare May 12, 2026 10:35
@Rathoz Rathoz marked this pull request as ready for review May 12, 2026 10:51
@Rathoz Rathoz requested a review from a team as a code owner May 12, 2026 10:51
Copilot AI review requested due to automatic review settings May 12, 2026 10:51
@Rathoz Rathoz requested a review from a team as a code owner May 12, 2026 10:51
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds an Error Boundary concept to the Widget3 renderer so that rendering errors can be caught and replaced with fallback output (instead of failing the whole render), and applies it to squad player rendering.

Changes:

  • Added ERROR_BOUNDARY type and an ErrorBoundary Widget3 component.
  • Updated Widget/Renderer.render to handle error boundary VNodes via Logic.tryOrElseLog with optional fallback rendering.
  • Wrapped SquadPlayerDisplay rendering in an ErrorBoundary and added new specs for the behavior.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
lua/wikis/commons/Widget/Types.lua Adds the ERROR_BOUNDARY render type constant.
lua/wikis/commons/Widget/Renderer.lua Implements error-boundary rendering using Logic.tryOrElseLog and ErrorDisplay.
lua/wikis/commons/Widget/ErrorBoundary.lua Introduces the ErrorBoundary component that emits an ERROR_BOUNDARY VNode.
lua/wikis/commons/Widget/Component.lua Adds LLS type aliases for the new ErrorBoundary VNode/component props.
lua/wikis/commons/Squad/Controller.lua Wraps per-player rendering in an error boundary with a table-row fallback.
lua/spec/components_spec.lua Adds specs for ErrorBoundary behavior (currently inconsistent with implementation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread lua/wikis/commons/Widget/Component.lua Outdated
Comment thread lua/wikis/commons/Widget/Renderer.lua Outdated
Comment thread lua/spec/components_spec.lua Outdated
Comment thread lua/spec/components_spec.lua Outdated
Comment thread lua/wikis/commons/Widget/ErrorBoundary.lua Outdated
---@alias ContextDef<T> {defaultValue: T}
---@alias ContextParam<T> {def: ContextDef<T>, value: T, children?: Renderable|Renderable[]}
---@alias HtmlParam {classes?: string[], css?: table, attributes?: table, children?: Renderable|Renderable[]}
---@alias ErrorParam {children?: Renderable|Renderable[], fallback?: fun(error: Error, context: Context?): Renderable}
Copy link
Copy Markdown
Collaborator

@mbergen mbergen May 12, 2026

Choose a reason for hiding this comment

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

According to the implementation in Renderer, fallback can also be a Renderable, right?
Or was that one of the cases the annotations cannot express (i remember there being some issues around function annotations)?

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.

Suggested change
---@alias ErrorParam {children?: Renderable|Renderable[], fallback?: fun(error: Error, context: Context?): Renderable}
---@alias ErrorParam {children?: Renderable|Renderable[], fallback?: (fun(error: Error, context: Context?): Renderable) | Renderable}

Copy link
Copy Markdown
Collaborator

@mbergen mbergen left a comment

Choose a reason for hiding this comment

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

Besides comment about annotation, very nice feature!

Copy link
Copy Markdown
Collaborator

@hjpalpha hjpalpha left a comment

Choose a reason for hiding this comment

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

lgtm modulo open comment

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.

5 participants