1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
|
import { joinClassNames, sleep } from '@decky/ui';
import { FunctionComponent, useEffect, useReducer, useState } from 'react';
import { disablePlugin, uninstallPlugin } from '../plugin';
import { VerInfo, doRestart, doShutdown } from '../updater';
import { ValveReactErrorInfo, getLikelyErrorSourceFromValveReactError } from '../utils/errors';
import { useSetting } from '../utils/hooks/useSetting';
import { UpdateBranch } from './settings/pages/general/BranchSelect';
interface DeckyErrorBoundaryProps {
error: ValveReactErrorInfo;
errorKey: string;
identifier: string;
reset: () => void;
}
declare global {
interface Window {
SystemNetworkStore?: any;
}
}
const classes = {
root: 'deckyErrorBoundary',
likelyOccurred: 'likely-occured-msg',
panel: 'panel-section',
panelHeader: 'panel-header',
trace: 'trace',
rowList: 'row-list',
rowItem: 'row-item',
buttonDescRow: 'button-description-row',
flexRowWGap: 'flex-row',
marginBottom: 'margin-bottom',
swipePrompt: 'swipe-prompt',
};
const vars = {
scrollBarwidth: '18px',
rootMarginLeft: '15px',
panelXPadding: '20px',
};
export const startSSH = DeckyBackend.callable('utilities/start_ssh');
export const starrCEFForwarding = DeckyBackend.callable('utilities/allow_remote_debugging');
function ipToString(ip: number) {
return [(ip >>> 24) & 255, (ip >>> 16) & 255, (ip >>> 8) & 255, (ip >>> 0) & 255].join('.');
}
// Intentionally not localized since we can't really trust React here
const DeckyErrorBoundary: FunctionComponent<DeckyErrorBoundaryProps> = ({ error, identifier, reset }) => {
const [actionLog, addLogLine] = useReducer((log: string, line: string) => (log += '\n' + line), '');
const [actionsEnabled, setActionsEnabled] = useState<boolean>(true);
const [debugAllowed, setDebugAllowed] = useState<boolean>(true);
// Intentionally doesn't use DeckyState.
const [versionInfo, setVersionInfo] = useState<VerInfo>();
const [errorSource, wasCausedByPlugin, shouldReportToValve] = getLikelyErrorSourceFromValveReactError(error);
useEffect(() => {
if (!shouldReportToValve) DeckyPluginLoader.errorBoundaryHook.temporarilyDisableReporting();
DeckyPluginLoader.updateVersion().then(setVersionInfo);
}, []);
const [selectedBranch, setSelectedBranch] = useSetting<UpdateBranch>('branch', UpdateBranch.Stable);
const [isChecking, setIsChecking] = useState<boolean>(false);
const [updateProgress, setUpdateProgress] = useState<number>(-1);
const [versionToUpdateTo, setSetVersionToUpdateTo] = useState<string>('');
useEffect(() => {
const a = DeckyBackend.addEventListener('updater/update_download_percentage', (percentage) => {
setUpdateProgress(percentage);
});
const b = DeckyBackend.addEventListener('updater/finish_download', () => {
setUpdateProgress(-2);
});
return () => {
DeckyBackend.removeEventListener('updater/update_download_percentage', a);
DeckyBackend.removeEventListener('updater/finish_download', b);
};
}, []);
return (
<>
<style>
{`
*:has(> .${classes.root}) {
margin-top: var(--basicui-header-height);
overflow: scroll !important;
background: #000;
}
*:has(> .${classes.root})::-webkit-scrollbar {
display: initial !important;
width: ${vars.scrollBarwidth};
height: 0px;
}
*:has(> .${classes.root})::-webkit-scrollbar-thumb {
background: #4349535e;
}
.${classes.root} {
color: #93929e;
font-size: 15px;
margin: 10px 0px 40px ${vars.rootMarginLeft};
width: calc(100vw - ${vars.scrollBarwidth} - ${vars.rootMarginLeft});
overflow: visible;
}
.${classes.root} button,
.${classes.root} select {
border: none;
padding: 4px 16px !important;
background: #333;
color: #ddd;
font-size: 12px;
border-radius: 3px;
outline: none;
height: 28px;
}
.${classes.panel} {
background: #080808;
padding: 8px ${vars.panelXPadding};
border-radius: 3px;
/* box-shadow: 9px 9px 20px -5px rgb(0 0 0 / 89%); */
}
.${classes.panelHeader} {
font-size: 18px;
font-weight: bolder;
text-transform: uppercase;
}
.${classes.likelyOccurred} {
font-size: 22px;
font-weight: bold;
color: #588fb4;
}
.${classes.rowItem} {
position: relative;
}
.${classes.rowItem}:not(:last-child)::after {
content: '';
position: absolute;
bottom: -4.5px;
left: 5px;
right: 15px;
height: 0.5px;
background: #3c3c3c47;
}
.${classes.flexRowWGap},
.${classes.buttonDescRow},
.${classes.rowList},
.${classes.panel} {
display: flex;
}
.${classes.rowList},
.${classes.panel} {
flex-direction: column;
}
.${classes.flexRowWGap},
.${classes.rowList} {
gap: 8px;
}
.${classes.marginBottom} {
margin-bottom: 10px;
}
.${classes.buttonDescRow} {
justify-content: space-between;
align-items: center;
}
.${classes.swipePrompt} {
display: flex;
align-items: center;
text-align: center;
position: relative;
font-style: italic;
font-size: small;
margin: 16px 0;
}
.${classes.swipePrompt} span {
padding: 0 8px;
background-color: #000;
position: relative;
z-index: 1;
}
.${classes.swipePrompt}::before,
.${classes.swipePrompt}::after {
content: "";
flex-grow: 1;
border-bottom: 1px solid #474752;
top: 50%;
}
.${classes.swipePrompt}::before {
right: 50%;
margin-right: 8px;
}
.${classes.swipePrompt}::after {
left: 50%;
margin-left: 8px;
}
`}
</style>
<div className={classes.root}>
<div className={classes.marginBottom}>An error occurred while rendering this content.</div>
<pre className={joinClassNames(classes.marginBottom)} style={{ marginTop: '0px' }}>
<code>
{identifier && `Error Reference: ${identifier}`}
{versionInfo?.current && `\nDecky Version: ${versionInfo.current}`}
</code>
</pre>
<div className={joinClassNames(classes.likelyOccurred, classes.marginBottom)}>
This error likely occurred in {errorSource}.
</div>
{actionLog?.length > 0 && (
<pre>
<code>
Running actions...
{actionLog}
</code>
</pre>
)}
{actionsEnabled && (
<div className={classes.panel}>
<div className={classes.flexRowWGap} style={{ alignItems: 'center', marginBottom: '8px' }}>
<div className={classes.panelHeader}>Actions</div>
<div style={{ fontSize: 'small', fontStyle: 'italic' }}>
Use the touch screen. Solutions are listed in the recommended order. If you are still experiencing
issues, please post in the #loader-support channel at decky.xyz/discord.
</div>
</div>
<div className={classes.rowList}>
<div className={joinClassNames(classes.rowItem, classes.buttonDescRow)}>
Retry the action or restart
<div className={classes.flexRowWGap}>
<button onClick={reset}>Retry</button>
<button
onClick={() => {
addLogLine('Restarting Steam...');
SteamClient.User.StartRestart(false);
}}
>
Restart Steam
</button>
<button
onClick={async () => {
setActionsEnabled(false);
addLogLine('Restarting Decky...');
doRestart();
await sleep(2000);
addLogLine('Reloading UI...');
}}
>
Restart Decky
</button>
</div>
</div>
{wasCausedByPlugin && (
<div className={joinClassNames(classes.rowItem, classes.buttonDescRow)}>
Disable or uninstall the suspected plugin
<div className={classes.flexRowWGap}>
<button
onClick={async () => {
setActionsEnabled(false);
addLogLine(`Disabling ${errorSource}...`);
await disablePlugin(errorSource);
await sleep(1000);
addLogLine('Restarting Decky...');
doRestart();
await sleep(2000);
addLogLine('Restarting Steam...');
await sleep(500);
SteamClient.User.StartRestart(false);
}}
>
Disable {errorSource}
</button>
<button
onClick={async () => {
setActionsEnabled(false);
addLogLine(`Uninstalling ${errorSource}...`);
await uninstallPlugin(errorSource);
await DeckyPluginLoader.frozenPluginsService.invalidate();
await DeckyPluginLoader.hiddenPluginsService.invalidate();
await sleep(1000);
addLogLine('Restarting Decky...');
doRestart();
await sleep(2000);
addLogLine('Restarting Steam...');
await sleep(500);
SteamClient.User.StartRestart(false);
}}
>
Uninstall {errorSource}
</button>
</div>
</div>
)}
<div className={joinClassNames(classes.rowItem, classes.buttonDescRow)}>
Disable all plugins
<button
onClick={async () => {
setActionsEnabled(false);
addLogLine(`Disabling plugins...`);
await DeckyBackend.call('utilities/set_all_plugins_disabled');
await sleep(1000);
addLogLine('Restarting Decky...');
doRestart();
await sleep(2000);
addLogLine('Restarting Steam...');
await sleep(500);
SteamClient.User.StartRestart(false);
}}
>
Disable All Plugins
</button>
</div>
{
<div className={joinClassNames(classes.rowItem, classes.buttonDescRow)}>
{updateProgress > -1
? 'Update in progress... ' + updateProgress + '%'
: updateProgress == -2
? 'Update complete. Restarting...'
: 'Check for Decky updates'}
{
<div className={classes.flexRowWGap}>
{updateProgress == -1 && (
<>
<select
onChange={async (e) => {
const branch = parseInt(e.target.value);
setSelectedBranch(branch);
setSetVersionToUpdateTo('');
}}
>
<option value="0" selected={selectedBranch == UpdateBranch.Stable}>
Stable
</option>
<option value="1" selected={selectedBranch == UpdateBranch.Prerelease}>
Pre-Release
</option>
<option value="2" selected={selectedBranch == UpdateBranch.Testing}>
Testing
</option>
</select>
<button
disabled={updateProgress != -1 || isChecking}
onClick={async () => {
if (versionToUpdateTo == '') {
setIsChecking(true);
const versionInfo = (await DeckyBackend.callable(
'updater/check_for_updates',
)()) as unknown as VerInfo;
setIsChecking(false);
if (versionInfo?.remote && versionInfo?.remote?.tag_name != versionInfo?.current) {
setSetVersionToUpdateTo(versionInfo.remote.tag_name);
} else {
setSetVersionToUpdateTo('');
}
} else {
DeckyBackend.callable('updater/do_update')();
setUpdateProgress(0);
}
}}
>
{' '}
{isChecking
? 'Checking for updates...'
: versionToUpdateTo != ''
? 'Update to ' + versionToUpdateTo
: 'Check for updates'}
</button>
</>
)}
</div>
}
</div>
}
<div className={joinClassNames(classes.rowItem, classes.buttonDescRow)}>
Disable Decky until next boot
<button
onClick={async () => {
setActionsEnabled(false);
addLogLine('Stopping Decky...');
doShutdown();
await sleep(5000);
addLogLine('Restarting Steam...');
SteamClient.User.StartRestart(false);
}}
>
Disable Decky
</button>
</div>
{debugAllowed && (
<div className={joinClassNames(classes.rowItem, classes.buttonDescRow)}>
Enable remote debugging and SSH until next boot (for developers)
<button
onClick={async () => {
setDebugAllowed(false);
addLogLine('Enabling CEF debugger forwarding...');
await starrCEFForwarding();
addLogLine('Enabling SSH...');
await startSSH();
addLogLine('Ready for debugging!');
if (window?.SystemNetworkStore?.wirelessNetworkDevice?.ip4?.addresses?.[0]?.ip) {
const ip = ipToString(window.SystemNetworkStore.wirelessNetworkDevice.ip4.addresses[0].ip);
addLogLine(`CEF Debugger: http://${ip}:8081`);
addLogLine(`SSH: deck@${ip}`);
}
}}
>
Enable
</button>
</div>
)}
</div>
</div>
)}
{actionsEnabled && (
<div className={classes.swipePrompt}>
<span>Swipe to scroll</span>
</div>
)}
<div className={classes.panel}>
<div className={classes.panelHeader}>Trace</div>
<pre
style={{
margin: `8px calc(-1 * ${vars.panelXPadding})`,
userSelect: 'auto',
overflowX: 'scroll',
padding: `0px ${vars.panelXPadding}`,
maskImage: `linear-gradient(to right, transparent, black ${vars.panelXPadding}, black calc(100% - ${vars.panelXPadding}), transparent)`,
}}
>
<code>
{error.error.stack}
{'\n\n'}
Component Stack:
{error.info.componentStack}
</code>
</pre>
</div>
</div>
</>
);
};
export default DeckyErrorBoundary;
|