Skip to content

Commit abaf637

Browse files
author
Tajudeen
committed
Add error handling to remaining React mount points
- Add try-catch to tooltipService.ts (tooltip mounting) - Add try-catch to cortexideOnboardingService.ts (onboarding mounting) - Add try-catch to cortexideSelectionHelperWidget.ts (selection helper mounting) - Add try-catch to cortexideCommandBarService.ts (command bar mounting) These are non-critical UI components, but error handling prevents silent failures and provides better diagnostics if issues occur.
1 parent 8b8b850 commit abaf637

File tree

5 files changed

+45
-25
lines changed

5 files changed

+45
-25
lines changed

build/gulpfile.reh.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,9 @@ function nodejs(platform, arch) {
243243
// Try unofficial builds site for riscv64
244244
const unofficialUrl = process.env['VSCODE_NODEJS_SITE'] || 'https://unofficial-builds.nodejs.org';
245245
log(`Attempting to download Node.js from ${unofficialUrl} for ${arch}...`);
246-
return fetchUrls(`/download/release/v${nodeVersion}/node-v${nodeVersion}-linux-${arch}.tar.gz`, {
247-
base: unofficialUrl,
248-
checksumSha256
246+
return fetchUrls(`/download/release/v${nodeVersion}/node-v${nodeVersion}-linux-${arch}.tar.gz`, {
247+
base: unofficialUrl,
248+
checksumSha256
249249
}).pipe(flatmap(stream => stream.pipe(gunzip()).pipe(untar())))
250250
.pipe(filter('**/node'))
251251
.pipe(util.setExecutableBit('**'))

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -572,14 +572,19 @@ class AcceptRejectAllFloatingWidget extends Widget implements IOverlayWidget {
572572
// Get a fresh accessor for mountVoidCommandBar - this accessor will be valid
573573
// during the synchronous execution of this function
574574
this.instantiationService.invokeFunction(accessor => {
575-
// mountVoidCommandBar will call _registerServices internally with this fresh accessor
576-
const res = mountVoidCommandBar(root, accessor, { uri, editor } satisfies CortexideCommandBarProps)
577-
if (!res) return
578-
this._register(toDisposable(() => res.dispose?.()))
579-
this._register(editor.onWillChangeModel((model) => {
580-
const uri = model.newModelUrl
581-
res.rerender({ uri, editor } satisfies CortexideCommandBarProps)
582-
}))
575+
try {
576+
// mountVoidCommandBar will call _registerServices internally with this fresh accessor
577+
const res = mountVoidCommandBar(root, accessor, { uri, editor } satisfies CortexideCommandBarProps)
578+
if (!res) return
579+
this._register(toDisposable(() => res.dispose?.()))
580+
this._register(editor.onWillChangeModel((model) => {
581+
const uri = model.newModelUrl
582+
res.rerender({ uri, editor } satisfies CortexideCommandBarProps)
583+
}))
584+
} catch (error) {
585+
console.error('[CortexideCommandBar] Failed to mount React command bar:', error);
586+
// Command bar failure is non-critical, just log the error
587+
}
583588
})
584589
})().catch(err => {
585590
console.error('Error mounting void command bar:', err);

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,14 @@ export class OnboardingContribution extends Disposable implements IWorkbenchCont
3333
const onboardingContainer = h('div.void-onboarding-container').root;
3434
workbench.appendChild(onboardingContainer);
3535
this.instantiationService.invokeFunction((accessor: ServicesAccessor) => {
36-
const result = mountVoidOnboarding(onboardingContainer, accessor);
37-
if (result && typeof result.dispose === 'function') {
38-
this._register(toDisposable(result.dispose));
36+
try {
37+
const result = mountVoidOnboarding(onboardingContainer, accessor);
38+
if (result && typeof result.dispose === 'function') {
39+
this._register(toDisposable(result.dispose));
40+
}
41+
} catch (error) {
42+
console.error('[OnboardingContribution] Failed to mount React onboarding:', error);
43+
// Onboarding failure is non-critical, just log the error
3944
}
4045
});
4146
// Register cleanup for the DOM element

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

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,21 @@ export class SelectionHelperContribution extends Disposable implements IEditorCo
6060

6161
// Initialize React component
6262
this._instantiationService.invokeFunction(accessor => {
63-
if (this._reactComponentDisposable) {
64-
this._reactComponentDisposable.dispose();
65-
}
66-
const res = mountVoidSelectionHelper(content, accessor);
67-
if (!res) return;
63+
try {
64+
if (this._reactComponentDisposable) {
65+
this._reactComponentDisposable.dispose();
66+
}
67+
const res = mountVoidSelectionHelper(content, accessor);
68+
if (!res) return;
6869

69-
this._reactComponentDisposable = res;
70-
this._rerender = res.rerender;
70+
this._reactComponentDisposable = res;
71+
this._rerender = res.rerender;
7172

72-
this._register(this._reactComponentDisposable);
73+
this._register(this._reactComponentDisposable);
74+
} catch (error) {
75+
console.error('[CortexideSelectionHelperWidget] Failed to mount React selection helper:', error);
76+
// Selection helper failure is non-critical, just log the error
77+
}
7378

7479

7580
});

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,14 @@ export class TooltipContribution extends Disposable implements IWorkbenchContrib
3535

3636
// Mount the React component
3737
this.instantiationService.invokeFunction((accessor: ServicesAccessor) => {
38-
const result = mountVoidTooltip(tooltipContainer, accessor);
39-
if (result && typeof result.dispose === 'function') {
40-
this._register(toDisposable(result.dispose));
38+
try {
39+
const result = mountVoidTooltip(tooltipContainer, accessor);
40+
if (result && typeof result.dispose === 'function') {
41+
this._register(toDisposable(result.dispose));
42+
}
43+
} catch (error) {
44+
console.error('[TooltipContribution] Failed to mount React tooltip:', error);
45+
// Tooltip failure is non-critical, just log the error
4146
}
4247
});
4348

0 commit comments

Comments
 (0)