Commit 917bf6a
committed
Fix: Improve webview rendering robustness and error handling
This change addresses potential grey/blank screen or crashing issues in the webview by:
1. **Adding an ErrorBoundary:** I introduced an `ErrorBoundary` component at the root of `webview-ui/src/App.tsx`. This component catches JavaScript rendering errors in its children, displaying a user-friendly fallback UI instead of a blank or broken screen. It also logs the error to the console for easier debugging.
2. **Implementing Loading/Timeout Logic:** I modified `webview-ui/src/App.tsx` to:
* Display a "Loading..." message while the initial extension state (`didHydrateState`) is being processed.
* Implement a 10-second timeout. If state hydration doesn't complete within this period, an error message is shown, guiding you to try reloading or checking for updates. This provides better feedback than a persistent blank screen.
3. **Adding Unit Tests:**
* I created tests for the `ErrorBoundary` to ensure it correctly catches errors and renders the fallback UI or child components as expected.
* I created tests for the `App.tsx` loading and timeout logic to verify that loading indicators and error messages are displayed appropriately under different hydration scenarios.
These changes aim to make the webview more resilient to rendering errors and provide better feedback to you during initialization, improving the overall user experience and aiding in diagnosing future issues.1 parent ea93cea commit 917bf6a
File tree
4 files changed
+311
-203
lines changed- webview-ui/src
- __tests__
- components/common
- __tests__
4 files changed
+311
-203
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
30 | 31 | | |
31 | 32 | | |
32 | 33 | | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
105 | | - | |
106 | | - | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
107 | 140 | | |
108 | 141 | | |
109 | 142 | | |
110 | 143 | | |
111 | 144 | | |
112 | 145 | | |
113 | 146 | | |
114 | | - | |
| 147 | + | |
115 | 148 | | |
116 | 149 | | |
117 | 150 | | |
| |||
132 | 165 | | |
133 | 166 | | |
134 | 167 | | |
135 | | - | |
| 168 | + | |
136 | 169 | | |
137 | 170 | | |
138 | 171 | | |
| |||
0 commit comments