fix(views): register a fallback default view container so contributed views don't crash registration#805
Conversation
|
Thanks! it would probably better to be in viewCommon though, so that it also impacts the workbench service override |
| order: 0 | ||
| }, | ||
| ViewContainerLocation.Sidebar, | ||
| { isDefault: true } |
There was a problem hiding this comment.
Does it really need to mimick the explorer settings, and any other value would be fine (except isDefault: true and the ViewContainerLocation)?
There was a problem hiding this comment.
Ok I've just checked the code, and it seems that workbench.view.explorer is required :)
a2f0be0 to
06f6b77
Compare
VS Code's `views` extension-point resolves a contributed view's target as
`container ?? getDefaultViewContainer()`, where getDefaultViewContainer() returns
`viewContainersRegistry.get('workbench.view.explorer')`. In a partial setup
without the files explorer that is undefined, and addViews then reads
`.extensionId` off it — an uncaught TypeError that aborts the entire
contributes.views pass, so every extension's contributed sidebar views fail to
register. Register a minimal hidden-when-empty default Sidebar container under
that id when none exists so the fallback resolves and views degrade gracefully.
Placed in viewCommon so it also covers the workbench service override.
Refs CodinGame#804
06f6b77 to
091ec54
Compare
|
Moved it to On the null-guard alternative from #804 — I agree it'd be cleaner/less hacky, but it'd live as a |
|
Thanks for the pointer! I tried to take the guard route, but I can't reproduce your In case it's quick for you, here's exactly where it throws — in const l = this.getViewContainer(key) // undefined for an unknown container id
l || collector.warn(/* "… added to 'Explorer'." */)
const d = l ?? this.getDefaultViewContainer() // getDefaultViewContainer() => viewContainersRegistry.get('workbench.view.explorer')
// …later, in the per-view loop:
… d.extensionId … // TypeError when d is undefined (no target container AND no Explorer)So the guard would be: when if (d == null) {
collector.warn(/* container '{key}' not found and no default view container is registered */)
continue
}Totally your call on which you prefer — the guard (you'd own the |
|
What about #806 ? |
|
Superseded by #806 — CGNonofr's source-level guard in viewsExtensionPoint.addViews is the cleaner fix. Thanks! |
What
Register a minimal default Sidebar view container (
workbench.view.explorer) inside the views service-override when none exists, so VS Code'sviewsextension-point fallback resolves instead of throwing.Why
In a partial setup that doesn't include the files explorer,
ViewsExtensionHandler.addViewsresolves a contributed view's target container ascontainer ?? getDefaultViewContainer(), wheregetDefaultViewContainer()isviewContainersRegistry.get('workbench.view.explorer'). With no Explorer registered that'sundefined, and the next line reads.extensionIdoff it → an uncaughtTypeError, which aborts the entirecontributes.viewspass. The net effect: every extension's contributed sidebar views silently fail to register (hit withanthropic.claude-codeandopenai.chatgpt, but it's generic —ms-vscode.js-debugcontributing into the missingdebugcontainer triggers it too).Stack:
Full investigation + traces: #804.
Change
ensureDefaultViewContainer()insrc/service-override/views.ts, called at the top ofgetServiceOverride(). It registers ahideIfEmptydefault Sidebar container only ifworkbench.view.explorerisn't already registered, so setups that DO include the explorer (or already register it) are unaffected. This mirrors the workaround discussed in #804.Notes
viewsExtensionPoint.addViews(avscode-patch) so the fallback degrades without throwing even when no default container exists at all — happy to switch to that approach instead if you'd prefer it.extensionIdcrash drops to 0 and contributed sidebar views register + render (a remote extension's sidebar webview-view now shows). I was not able to run the full repo build locally (it pulls the VS Code sources viainstall-vscode), so please rely on CI / a quick local check for the build.Refs #804