Fix dialog title bars and env-switch crash from the Electron 42 / TS6 migration#1022
Merged
krassowski merged 2 commits intoJul 3, 2026
Conversation
themedwindow injects the compiled dialogtitlebar into a data: URL page as an inline ES module, but tsconfig module: nodenext emits that file as CommonJS, so it references exports, throws "exports is not defined", and aborts before customElements.define runs. Every ThemedWindow dialog then loses its title bar and close button. Define the CommonJS globals ahead of the injected script so the registration side effect runs. Moving these dialogs off the data: URL is the real fix and is tracked for later. Add an e2e test that opens a dialog and asserts the title bar element registers, so this regression class is caught next time. Built with Claude Code; verified against the running app and the full e2e suite locally, and confirmed the new test fails on the pre-fix build.
…date The window and titlebar 'focus' handlers dereferenced a labView captured in the closure. On an env switch the old labView is disposed and, under WebContentsView, its webContents goes undefined, so the stale handler threw "Cannot read properties of undefined (reading 'focus')". Register the two handlers once and dereference the current this._labView instead, which also stops them accumulating on the persistent window and titlebar emitters on every switch. Guard the post-resize invalidate() against an already-closed webContents in the resize then dispose race. Built with Claude Code; verified by switching environments in the running app and against the full e2e suite locally.
krassowski
approved these changes
Jul 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes both dialog and session window regressions from #1021. Both come from the Electron 42 (#988) and TypeScript 6 (#978) migrations, not from anything in JupyterLab.
Dialog title bars (all ThemedWindow dialogs)
dialogtitlebar.tsis injected into adata:URL page as an inline module, but tsconfigmodule: nodenextemits it as CommonJS, soexports is not definedthrows beforecustomElements.defineruns and the element never registers. The first commit defines the CommonJS globals ahead of the injected script so it registers again. This is the surgical fix. Moving these dialogs off thedata:URL toloadFileor a privileged scheme, which also lets a real CSP apply, is the proper follow up and I have it noted for a later PR.Env switch crash and listener leak
The window and titlebar
focushandlers closed over a stalelabView; after an env switch itswebContentsis undefined underWebContentsViewand the handler threwCannot read properties of undefined (reading 'focus'). The second commit registers the two handlers once and reads the currentthis._labView, which also stops them accumulating on the persistent emitters, and guards the post-resizeinvalidate()against a closedwebContents.Testing
Added
test/e2e/dialog-titlebar.test.ts, which opens a dialog and asserts the title bar custom element registers and renders its close button. I confirmed it fails on the pre-fix build and passes after. The full e2e suite is green (11 of 11) including the session window tests, and type-check and build are clean.Closes #1021
I put this together and traced it with Claude Code, and verified everything against the running app and the local e2e suite before opening this.