Skip to content

Commit 8b8b850

Browse files
author
Tajudeen
committed
Fix blank screen issues: Add comprehensive error handling
- Remove hardcoded React chunk names from import map (chunks use relative imports) - Add error handling for React component mounting in: - sidebarPane.ts (main sidebar) - cortexideSettingsPane.ts (settings pane) - editCodeService.ts (Ctrl+K editor) - Show user-friendly error messages instead of blank screens - Prevents module loading failures from causing complete UI failure This addresses the blank screen issue that occurred when: 1. Hardcoded chunk names didn't match dynamically generated chunks 2. React component mounting failed without error handling
1 parent cf20dd8 commit 8b8b850

3 files changed

Lines changed: 51 additions & 28 deletions

File tree

src/vs/workbench/contrib/cortexide/browser/cortexideSettingsPane.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,16 @@ class CortexideSettingsPane extends EditorPane {
9191

9292
// Mount React into the scrollable content
9393
this.instantiationService.invokeFunction(accessor => {
94-
const disposeFn = mountVoidSettings(settingsElt, accessor)?.dispose;
95-
this._register(toDisposable(() => disposeFn?.()))
94+
try {
95+
const result = mountVoidSettings(settingsElt, accessor);
96+
if (result?.dispose) {
97+
this._register(toDisposable(() => result.dispose()));
98+
}
99+
} catch (error) {
100+
console.error('[CortexideSettingsPane] Failed to mount React settings:', error);
101+
// Show error message to user instead of blank screen
102+
settingsElt.innerHTML = '<div style="padding: 20px; color: var(--vscode-errorForeground);">Failed to load settings. Please check the console for details.</div>';
103+
}
96104

97105
// setTimeout(() => { // this is a complete hack and I don't really understand how scrollbar works here
98106
// this._scrollbar?.scanDomNode();

src/vs/workbench/contrib/cortexide/browser/editCodeService.ts

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -406,32 +406,39 @@ class EditCodeService extends Disposable implements IEditCodeService {
406406
// mount react
407407
let disposeFn: (() => void) | undefined = undefined
408408
this._instantiationService.invokeFunction(accessor => {
409-
disposeFn = mountCtrlK(domNode, accessor, {
409+
try {
410+
const result = mountCtrlK(domNode, accessor, {
410411

411-
diffareaid: ctrlKZone.diffareaid,
412+
diffareaid: ctrlKZone.diffareaid,
412413

413-
textAreaRef: (r) => {
414-
textAreaRef.current = r
415-
if (!textAreaRef.current) return
414+
textAreaRef: (r) => {
415+
textAreaRef.current = r
416+
if (!textAreaRef.current) return
416417

417-
if (!(ctrlKZone.diffareaid in this.mostRecentTextOfCtrlKZoneId)) { // detect first mount this way (a hack)
418-
this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] = undefined
419-
setTimeout(() => textAreaRef.current?.focus(), 100)
420-
}
421-
},
422-
onChangeHeight(height) {
423-
if (height === 0) return // the viewZone sets this height to the container if it's out of view, ignore it
424-
viewZone.heightInPx = height
425-
// re-render with this new height
426-
editor.changeViewZones(accessor => {
427-
if (zoneId) accessor.layoutZone(zoneId)
428-
})
429-
},
430-
onChangeText: (text) => {
431-
this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] = text;
432-
},
433-
initText: this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] ?? null,
434-
} satisfies QuickEditPropsType)?.dispose
418+
if (!(ctrlKZone.diffareaid in this.mostRecentTextOfCtrlKZoneId)) { // detect first mount this way (a hack)
419+
this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] = undefined
420+
setTimeout(() => textAreaRef.current?.focus(), 100)
421+
}
422+
},
423+
onChangeHeight(height) {
424+
if (height === 0) return // the viewZone sets this height to the container if it's out of view, ignore it
425+
viewZone.heightInPx = height
426+
// re-render with this new height
427+
editor.changeViewZones(accessor => {
428+
if (zoneId) accessor.layoutZone(zoneId)
429+
})
430+
},
431+
onChangeText: (text) => {
432+
this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] = text;
433+
},
434+
initText: this.mostRecentTextOfCtrlKZoneId[ctrlKZone.diffareaid] ?? null,
435+
} satisfies QuickEditPropsType);
436+
disposeFn = result?.dispose;
437+
} catch (error) {
438+
console.error('[EditCodeService] Failed to mount Ctrl+K React component:', error);
439+
// Show error message in the editor instead of blank area
440+
domNode.innerHTML = '<div style="padding: 10px; color: var(--vscode-errorForeground); font-size: 12px;">Failed to load editor. Please check the console.</div>';
441+
}
435442
})
436443

437444
// cleanup

src/vs/workbench/contrib/cortexide/browser/sidebarPane.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,17 @@ class SidebarViewPane extends ViewPane {
7979

8080
// gets set immediately
8181
this.instantiationService.invokeFunction(accessor => {
82-
// mount react
83-
const disposeFn: (() => void) | undefined = mountSidebar(parent, accessor)?.dispose;
84-
this._register(toDisposable(() => disposeFn?.()));
82+
try {
83+
// mount react
84+
const result = mountSidebar(parent, accessor);
85+
if (result?.dispose) {
86+
this._register(toDisposable(() => result.dispose()));
87+
}
88+
} catch (error) {
89+
console.error('[SidebarViewPane] Failed to mount React sidebar:', error);
90+
// Show error message to user instead of blank screen
91+
parent.innerHTML = '<div style="padding: 20px; color: var(--vscode-errorForeground);">Failed to load sidebar. Please check the console for details.</div>';
92+
}
8593
});
8694
}
8795

0 commit comments

Comments
 (0)