Skip to content

feat(desktop): multi-window support with per-window panel selection - #5170

Closed
adelin-b wants to merge 4 commits into
ParadevAI:mainfrom
adelin-b:feat/desktop-multi-window
Closed

adelin-b wants to merge 4 commits into
ParadevAI:mainfrom
adelin-b:feat/desktop-multi-window

Conversation

@adelin-b

@adelin-b adelin-b commented Jun 7, 2026 •

Copy link
Copy Markdown

What

You can now open the same workspace in several windows and keep a different tab focused in each one. Tab structure (create, close, rename, layout) stays in sync between windows; which tab you're looking at does not.

Two new entry points: right-click a workspace in the sidebar for "Open in New Window", or right-click a tab for "Open Tab in New Window", which opens the new window already focused on that tab. Cmd+Shift+N still works as before. Each window can also sit on a different workspace entirely, and sidebar/panel visibility is per-window.

Why

The tabs store keys selection by workspace (activeTabIds[workspaceId]), and the whole state persists as a single blob with no change notifications between windows. Open the same workspace twice and both windows boot with identical state, then silently overwrite each other's writes. In practice a second window was useless: same panel everywhere, and closing a tab in one window could resurrect it from the other window's stale write.

How

  • Selection stays in each window's own renderer and never syncs. The persisted values only seed the first paint.
  • uiState.tabs.set now broadcasts each write through a new uiState.tabs.onChange subscription (observable, per the trpc-electron constraint), tagged with the source webContents id. Windows merge remote structure and keep local selection. If a remote close orphans the focused tab, the existing MRU resolver picks the replacement.
  • The storage adapter drops echo writes during a remote merge, including a pre-merge local write still waiting in the debounce window. That stale-flush case is what used to resurrect closed tabs, and it now has unit tests (trpc-storage-adapter.test.ts). The adapter moved to its own file so those tests don't pull in the electron client.
  • window.self and window.openWorkspaceWindow are new tRPC procedures; focusTabId rides the window query string next to workspaceId.

There's also a small fix in windows/manager.ts: the closed handler read window.webContents after destruction, which throws in real Electron. The id is now captured at registration.

Known limitation

Persistence is still an unversioned full snapshot, so two structural edits from different windows inside the same 300ms debounce can lose one write. Structural edits are human-paced so I've accepted this for now; the plan doc (apps/desktop/plans/20260607-per-window-panel-selection-and-sync.md) describes a basedOnVersion scheme if it ever becomes a problem.

Testing

  • bun test for the desktop app: 454 pass under the touched trees (merge logic, adapter suppression, window manager), 0 fail. Three pre-existing shell-wrappers failures reproduce on a clean checkout and are unrelated.
  • tsc --noEmit and Biome clean.
  • Verified live with two windows on one workspace over CDP: independent active tabs, tab create/close propagating both ways with selection preserved, and per-window workspace routing.

Open in Stage

Summary by cubic

Enables true multi-window use in the desktop app. Open the same workspace in several windows with independent tab focus; tab/pane structure stays in sync across windows. Recent changes harden persistence and IPC for reliability.

  • New Features

    • Open multiple windows for the same or different workspaces; each window keeps its own active tab, pane focus, and sidebar/panel visibility.
    • Live cross-window sync of tab/pane structure; selection stays local per window. Echoes are filtered by window identity via window.self.
    • New entry points: “Open in New Window” on a workspace, “Open Tab in New Window” on a tab, and Cmd/Ctrl+Shift+N. New windows can target a specific tab.
  • Bug Fixes

    • Prevents closed tabs from “resurrecting” by suppressing stale/echoed writes during remote merges. trpc-storage-adapter now writes via tRPC before bumping the local snapshot version to avoid masking failed writes.
    • Avoids “Object has been destroyed” errors by capturing the caller webContentsId once and using it in window.self and uiState.tabs.set, and by capturing ids before window cleanup.

Written for commit 58794a1. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

Release Notes

  • New Features
    • Added multi-window support—open workspaces in separate Electron windows via the Window menu's "New Window" option (⌘⇧N) or context menu actions for workspaces and tabs
    • Cross-window tab synchronization—pane structure syncs seamlessly across all open workspace windows while preserving independent tab selection per window

adelin-b added 3 commits June 6, 2026 19:04
Allows opening multiple Superset windows simultaneously, one per
workspace, so several projects can be viewed side-by-side.

Main process:
- New windows/manager.ts registry tracking every BrowserWindow with its
  workspaceId and focus recency; replaces the single-window assumption.
- MainWindow() accepts { workspaceId, stagger } and per-key persisted
  window state (window-state.json is now a keyed map with automatic
  migration from the legacy single-state shape; no cross-key fallback).
- App-level singletons lifted out of the window lifecycle into
  lib/app-services.ts: notifications HTTP server (single port bind),
  NotificationManager, terminal-exit forwarder. Window close handlers
  now only clean up their own panes and IPC binding.
- tRPC createContext resolves the calling window per IPC event via the
  manager (walking webview hostWebContents), so procedures act on the
  window that actually issued the call.
- BrowserManager.unregisterAllForWindow() scopes pane cleanup to the
  closing window using webContents.hostWebContents ownership.
- Deep links, OAuth callback fallback, tray, and macOS activate now
  route through the manager instead of getAllWindows()[0].
- "New Window" menu item (Cmd/Ctrl+Shift+N) spawns a staggered window.

Renderer:
- Window URLs carry ?workspaceId= in the hash; the root route validates
  it and navigates straight to /workspace/$workspaceId without touching
  lastViewedWorkspaceId, so secondary windows don't hijack restore.

Tests: window-state keyed map + migration, window manager registry,
browser-manager per-window pane ownership.
…ndows

Accessing window.webContents inside the 'closed' handler throws
"Object has been destroyed" because the window is already gone by the
time the event fires. Capture the webContents id at registration and use
it for cleanup instead. The fakes in manager.test.ts kept webContents
readable after close, which is why the existing test missed this; a new
test makes the getter throw the way real Electron does.
Two windows on the same workspace used to mirror each other: tab/pane
selection is keyed by workspace in the persisted tabs state, and the
whole blob is written last-writer-wins, so concurrent windows clobbered
each other's structure.

Selection (activeTabIds, focusedPaneIds, history) now stays local to
each window. The persisted values only act as a seed at boot. Structure
stays consistent through a new uiState.tabs.onChange subscription: every
persisted write is broadcast with the source webContents id, other
windows merge the remote tabs/panes while keeping their own selection,
and the storage adapter drops the echo write (including any stale local
write still sitting in the debounce window, which would otherwise
resurrect a remotely-closed tab). Dangling selection after a remote
close is repaired through the existing MRU resolver.

New ways to get a second window: "Open in New Window" on the workspace
context menu and "Open Tab in New Window" on the tab strip, backed by a
window.openWorkspaceWindow mutation and a focusTabId query param so the
new window lands on the right tab. window.self exposes the caller's
identity for the echo filtering.

Known limitation, documented in the plan doc: persistence is still an
unversioned full snapshot, so two structural edits inside the same 300ms
debounce window can lose one write. Structural edits are human-paced, so
this is accepted for now; the plan sketches a versioning scheme if it
ever matters.

The storage adapter moved to trpc-storage-adapter.ts so the suppression
path could get unit tests without dragging in the electron client.
@coderabbitai

coderabbitai Bot commented Jun 7, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR implements multi-window support for the Superset desktop app by introducing a managed window registry, refactoring tRPC routers to use request context instead of injected callbacks, migrating to per-window keyed state persistence, moving app services to boot-time initialization, and adding cross-window tab-state synchronization with renderer storage suppression.

Changes

Multi-window per-workspace architecture

Layer / File(s) Summary
Architecture planning documents
apps/desktop/plans/*
Design docs specify multi-window per-workspace acceptance criteria, module-level architectural changes, router refactoring, state persistence, notifications routing, deep-link behavior, and verification steps.
Window management registry and tracking
apps/desktop/src/main/windows/manager.ts, apps/desktop/src/main/windows/manager.test.ts
New ManagedWindow interface and registry functions to register, lookup, track focus/workspace, and filter destroyed windows; unit tests verify registration, focus selection, and workspace updates.
tRPC context typing and router factory
apps/desktop/src/lib/trpc/index.ts, apps/desktop/src/lib/trpc/routers/index.ts
Exports TrpcContext with window field, updates tRPC to context-typed initialization, refactors createAppRouter to zero-argument factory creating sub-routers without getWindow callbacks.
tRPC sub-router refactoring to use ctx.window
apps/desktop/src/lib/trpc/routers/notifications.ts, apps/desktop/src/lib/trpc/routers/projects/projects.ts, apps/desktop/src/lib/trpc/routers/ringtone/index.ts, apps/desktop/src/lib/trpc/routers/window.ts, apps/desktop/src/lib/trpc/routers/ui-state/index.ts
Updates all routers to use ctx.window for dialog/window operations; adds window.self query, window.openWorkspaceWindow mutation, and tabs.onChange subscription with cross-window TabsStateChangeEvent broadcast.
Multi-window keyed window state persistence
apps/desktop/src/main/lib/window-state/window-state.ts, apps/desktop/src/main/lib/window-state/window-state-map.test.ts, apps/desktop/src/main/lib/window-state/index.ts
Refactors persistence from single global to per-window keyed map with atomic write; supports legacy migration; adds loadWindowStateForKey/saveWindowStateForKey; tests cover key independence, migration, and corruption recovery.
Main window creation with options and scoped lifecycle
apps/desktop/src/main/windows/main.ts
Refactors MainWindow to accept options (workspaceId, stagger, focusTabId), compute workspace-scoped stateKey, implement one-time GPU/menu initialization, pass query params to renderer, use per-event IPC context, scope cleanup to host window, removing app-wide teardown.
App-level notifications and service lifecycle
apps/desktop/src/main/lib/app-services.ts
Introduces initAppServices/disposeAppServices for boot/shutdown; initializes HTTP notifications server with EADDRINUSE handling; constructs NotificationManager with click routing, visibility context, DB workspace name resolution, and terminal exit forwarding.
Main entry point and deep-link routing with managed windows
apps/desktop/src/main/index.ts
Updates deep-link navigation to use managed-window helpers; targets focused or first managed window; creates MainWindow when none exist; calls initAppServices on boot; extends before-quit to disposeAppServices.
Supporting infrastructure updates
apps/desktop/src/lib/electron-app/factories/app/setup.ts, apps/desktop/src/lib/window-loader.ts, apps/desktop/src/main/lib/menu.ts, apps/desktop/src/main/lib/browser/browser-manager.ts, apps/desktop/src/main/lib/notifications/server.ts, apps/desktop/src/lib/electron-app/factories/windows/create.ts
App activation restores/focuses windows; window-loader passes query params; menu adds "New Window" item; browser-manager adds unregisterAllForWindow; notifications/server uses managed-window helpers.
Cross-window tab state synchronization
apps/desktop/src/renderer/stores/tabs/merge-remote-state.ts, apps/desktop/src/renderer/stores/tabs/merge-remote-state.test.ts, apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts, apps/desktop/src/renderer/stores/tabs/remote-apply.ts
Implements mergeRemoteTabsState to merge remote structure while preserving local selection/focus/history; implements cross-window subscription with self-origin filtering, catch-up, and error backoff, deferring until hydration; exports remote-apply guard for write suppression.
tRPC-backed Zustand storage with write suppression
apps/desktop/src/renderer/lib/trpc-storage-adapter.ts, apps/desktop/src/renderer/lib/trpc-storage-adapter.test.ts
Creates localStorage-backed storage adapter with debounced tRPC writes and shouldSuppressWrite callback to skip writes during remote application; flushPendingWrite handles in-flight reschedules; comprehensive tests cover suppression, debounce, and stale prevention.
Renderer boot and storage integration
apps/desktop/src/renderer/index.tsx, apps/desktop/src/renderer/lib/trpc-storage.ts
Calls startCrossWindowTabsSync on boot; wires tabs storage with shouldSuppressWrite callback sourced from remote-apply guard.
UI entry points for multi-window operations
apps/desktop/src/renderer/routes/page.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsx, apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx
Route parses workspaceId/focusTabId and applies initial focus; workspace and tab context menus add "Open in New Window" items invoking window.openWorkspaceWindow mutation.
Browser manager cleanup tests and API
apps/desktop/src/main/lib/browser/browser-manager.ts, apps/desktop/src/main/lib/browser/browser-manager.test.ts
Adds unregisterAllForWindow to BrowserManager for cleaning up panes by host window ID; unit tests verify selective removal and mid-teardown handling.

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

🐰 Many windows bloom in harmony,
Each workspace finds its sacred screen,
While tabs waltz cross the digital sea,
State synced where no ghost tabs are seen.
A rabbit's multi-pane dream, now real! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 32.65% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main feature: multi-window support with independent per-window tab/panel selection.
Description check ✅ Passed The description is comprehensive, covering what changed (multi-window with per-window selection), why (to fix tab resurrection and enable truly independent windows), and how (local selection, cross-window sync, storage adapter changes, new tRPC procedures). All major sections are present.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ghost

ghost commented Jun 7, 2026 •

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts (1)

56-63: ⚡ Quick win

Type cast obscures structural intent; consider explicit field selection.

Lines 59 and 73 cast TabsState to RemoteTabsState via as unknown as. This works because mergeRemoteTabsState only reads .tabs and .panes, ignoring selection fields. However, the cast silences TypeScript's detection of the mismatch between what the tRPC endpoint returns (full state) and what the merge semantically expects (structure only).

♻️ Suggested refactor to make intent explicit

Option 1: Destructure only the fields needed:

 .query()
-.then((state) =>
-  applyRemoteTabsState(state as unknown as RemoteTabsState),
-)
+.then((state) => {
+  const { tabs, panes } = state;
+  applyRemoteTabsState({ tabs, panes });
+})

Apply the same pattern on line 73:

-applyRemoteTabsState(event.state as unknown as RemoteTabsState);
+const { tabs, panes } = event.state;
+applyRemoteTabsState({ tabs, panes });

Option 2: Change RemoteTabsState to TabsState and document that merge ignores selection fields (though option 1 is clearer).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts` around lines 56 -
63, The code currently uses a double-cast (as unknown as RemoteTabsState) when
calling electronTrpcClient.uiState.tabs.get.query and then applyRemoteTabsState,
which hides a structural mismatch between the endpoint's TabsState and the merge
routine's expected shape; instead, explicitly pick the fields the merge needs
(e.g., destructure { tabs, panes } from the fetched state) before passing them
to applyRemoteTabsState or mergeRemoteTabsState, or alternatively update
RemoteTabsState to match TabsState with clear documentation — locate the call to
electronTrpcClient.uiState.tabs.get.query and replace the cast with an explicit
selection of the required properties (tabs, panes) and pass that object into
applyRemoteTabsState/mergeRemoteTabsState.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/lib/trpc/routers/ui-state/index.ts`:
- Around line 263-272: The tabs.set mutation builds a TabsStateChangeEvent using
ctx.window?.webContents.id without checking window lifetime; update the code to
safely obtain a webContentsId by first checking ctx.window exists and
!ctx.window.isDestroyed() (or better: capture webContentsId in the request
context during createContext and use that value here) and use null if the window
is missing/destroyed; apply the same defensive pattern used in other routers
(e.g., window router/self) to avoid reading webContents.id from a destroyed
BrowserWindow when constructing the TabsStateChangeEvent in the mutation.

In `@apps/desktop/src/main/windows/main.ts`:
- Around line 201-210: Update the comment in createContext to accurately reflect
that TrpcContext.window can be null instead of claiming it "always resolves" to
a BrowserWindow; mention that we walk to hostWebContents to prefer resolving the
owning BrowserWindow (and that dialog procedures are no-ops when it remains
null). Reference the createContext function and TrpcContext.window (ctx.window)
in the comment so readers know the code prefers senderManaged?.window or
BrowserWindowCtor.fromWebContents(host) but still may yield null.

In `@apps/desktop/src/renderer/lib/trpc-storage-adapter.ts`:
- Around line 119-120: The version is being persisted to localStorage before
awaiting the tRPC write (localStorage.setItem is called before await
config.set), which can leave version/state inconsistent if the mutation fails;
change the sequence in the flush handler so you first await
config.set(parsed.state) (the existing config.set call in this function), then
on success assign lastFlushedValue = parsed.state (or the existing
lastFlushedValue update), and only after those succeed call
localStorage.setItem(`${name}:version`, String(parsed.version)); this ensures
localStorage version is updated only after a confirmed successful write (refer
to localStorage.setItem, config.set, and lastFlushedValue in the function).

---

Nitpick comments:
In `@apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts`:
- Around line 56-63: The code currently uses a double-cast (as unknown as
RemoteTabsState) when calling electronTrpcClient.uiState.tabs.get.query and then
applyRemoteTabsState, which hides a structural mismatch between the endpoint's
TabsState and the merge routine's expected shape; instead, explicitly pick the
fields the merge needs (e.g., destructure { tabs, panes } from the fetched
state) before passing them to applyRemoteTabsState or mergeRemoteTabsState, or
alternatively update RemoteTabsState to match TabsState with clear documentation
— locate the call to electronTrpcClient.uiState.tabs.get.query and replace the
cast with an explicit selection of the required properties (tabs, panes) and
pass that object into applyRemoteTabsState/mergeRemoteTabsState.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed66f0ad-2c81-4645-88fe-0bc4a4121a63

📥 Commits

Reviewing files that changed from the base of the PR and between 23cf3c1 and 9a50c4c.

📒 Files selected for processing (35)
  • apps/desktop/plans/20260517-multi-window-per-workspace.md
  • apps/desktop/plans/20260607-per-window-panel-selection-and-sync.md
  • apps/desktop/src/lib/electron-app/factories/app/setup.ts
  • apps/desktop/src/lib/electron-app/factories/windows/create.ts
  • apps/desktop/src/lib/trpc/index.ts
  • apps/desktop/src/lib/trpc/routers/index.ts
  • apps/desktop/src/lib/trpc/routers/notifications.ts
  • apps/desktop/src/lib/trpc/routers/projects/projects.ts
  • apps/desktop/src/lib/trpc/routers/ringtone/index.ts
  • apps/desktop/src/lib/trpc/routers/ui-state/index.ts
  • apps/desktop/src/lib/trpc/routers/window.ts
  • apps/desktop/src/lib/window-loader.ts
  • apps/desktop/src/main/index.ts
  • apps/desktop/src/main/lib/app-services.ts
  • apps/desktop/src/main/lib/browser/browser-manager.test.ts
  • apps/desktop/src/main/lib/browser/browser-manager.ts
  • apps/desktop/src/main/lib/menu.ts
  • apps/desktop/src/main/lib/notifications/server.ts
  • apps/desktop/src/main/lib/window-state/index.ts
  • apps/desktop/src/main/lib/window-state/window-state-map.test.ts
  • apps/desktop/src/main/lib/window-state/window-state.ts
  • apps/desktop/src/main/windows/main.ts
  • apps/desktop/src/main/windows/manager.test.ts
  • apps/desktop/src/main/windows/manager.ts
  • apps/desktop/src/renderer/index.tsx
  • apps/desktop/src/renderer/lib/trpc-storage-adapter.test.ts
  • apps/desktop/src/renderer/lib/trpc-storage-adapter.ts
  • apps/desktop/src/renderer/lib/trpc-storage.ts
  • apps/desktop/src/renderer/routes/page.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceListItem/WorkspaceContextMenu.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/GroupStrip/GroupItem.tsx
  • apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts
  • apps/desktop/src/renderer/stores/tabs/merge-remote-state.test.ts
  • apps/desktop/src/renderer/stores/tabs/merge-remote-state.ts
  • apps/desktop/src/renderer/stores/tabs/remote-apply.ts

Comment on lines +263 to 272
.mutation(async ({ ctx, input }) => {
appState.data.tabsState = input;
await appState.write();
const event: TabsStateChangeEvent = {
state: input,
sourceWebContentsId: ctx.window?.webContents.id ?? null,
};
tabsStateEvents.emit(TABS_STATE_CHANGED, event);
return { success: true };
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check if other routers guard webContents access
rg -n -C3 'webContents\.id' --type=ts -g 'apps/desktop/src/lib/trpc/routers/**'

Repository: superset-sh/superset

Length of output: 1284


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Search for webContents id access patterns (guards/cached IDs) =="
rg -n --type=ts \
  '(webContents\.id|webContents\?\.id|isDestroyed\(\)|getWebContents.*Id|sourceWebContentsId)' \
  apps/desktop/src/lib/trpc/routers

echo
echo "== Search for isDestroyed() usage in the Electron desktop code (broader) =="
rg -n --type=ts 'isDestroyed\(\)' apps/desktop/src

Repository: superset-sh/superset

Length of output: 2202


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Locate where trpc ctx.window is created/typed =="
# Find the ctx builder (common names vary); start with window in ctx type usages.
rg -n --type=ts 'ctx\.window|window\?: .*webContents|type .*Ctx|createTRPC' apps/desktop/src/lib/trpc

echo
echo "== Also check for router context factory outside lib/trpc =="
rg -n --type=ts 'createContext|createTRPCContext|getTRPCContext|ctx\W*=\W*' apps/desktop/src/main apps/desktop/src/lib/trpc

Repository: superset-sh/superset

Length of output: 4986


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== apps/desktop/src/main/windows/main.ts around createContext =="
nl -ba apps/desktop/src/main/windows/main.ts | sed -n '160,260p'

echo
echo "== apps/desktop/src/lib/trpc/index.ts ctx.window docs/types =="
nl -ba apps/desktop/src/lib/trpc/index.ts | sed -n '1,220p'

echo
echo "== apps/desktop/src/lib/trpc/routers/ui-state/index.ts around tabsState mutation (approx) =="
nl -ba apps/desktop/src/lib/trpc/routers/ui-state/index.ts | sed -n '230,330p'

echo
echo "== apps/desktop/src/lib/trpc/routers/window.ts around webContentsId read =="
nl -ba apps/desktop/src/lib/trpc/routers/window.ts | sed -n '1,120p'

Repository: superset-sh/superset

Length of output: 190


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== apps/desktop/src/main/windows/main.ts around createContext =="
cat -n apps/desktop/src/main/windows/main.ts | sed -n '160,260p'

echo
echo "== apps/desktop/src/lib/trpc/index.ts ctx.window docs/types =="
cat -n apps/desktop/src/lib/trpc/index.ts | sed -n '1,220p'

echo
echo "== apps/desktop/src/lib/trpc/routers/ui-state/index.ts around tabsState mutation (approx) =="
cat -n apps/desktop/src/lib/trpc/routers/ui-state/index.ts | sed -n '230,330p'

echo
echo "== apps/desktop/src/lib/trpc/routers/window.ts around webContentsId read =="
cat -n apps/desktop/src/lib/trpc/routers/window.ts | sed -n '1,140p'

Repository: superset-sh/superset

Length of output: 14525


Guard ctx.window?.webContents.id in tabs.set (UI-state router)

apps/desktop/src/lib/trpc/routers/ui-state/index.ts reads ctx.window?.webContents.id when building TabsStateChangeEvent. ctx.window is resolved from the IPC sender in apps/desktop/src/main/windows/main.ts with no isDestroyed()/lifetime guard, so if the window is destroyed mid-mutation this could still be a risk. Also, apps/desktop/src/lib/trpc/routers/window.ts (self) reads ctx.window.webContents.id without isDestroyed(), reinforcing the need for a consistent defensive pattern (e.g., capture webContentsId in createContext, or guard with ctx.window.isDestroyed() before reading).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/lib/trpc/routers/ui-state/index.ts` around lines 263 - 272,
The tabs.set mutation builds a TabsStateChangeEvent using
ctx.window?.webContents.id without checking window lifetime; update the code to
safely obtain a webContentsId by first checking ctx.window exists and
!ctx.window.isDestroyed() (or better: capture webContentsId in the request
context during createContext and use that value here) and use null if the window
is missing/destroyed; apply the same defensive pattern used in other routers
(e.g., window router/self) to avoid reading webContents.id from a destroyed
BrowserWindow when constructing the TabsStateChangeEvent in the mutation.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 58794a1. Captured webContentsId once in createContext (added to TrpcContext) — the one moment the sender is provably alive — and tabs.set now reads ctx.webContentsId. Also applied to window.ts self for the consistent defensive pattern you flagged. Reading .webContents off a stored BrowserWindow later (the destroyed-mid-mutation case) is now avoided entirely.

Comment on lines +201 to +210
createContext: async ({ event }) => {
// IPC may originate from a <webview> pane, not the host renderer.
// Walk to hostWebContents so ctx.window always resolves to the
// owning BrowserWindow (otherwise dialog procedures no-op).
const host = event.sender.hostWebContents ?? event.sender;
const senderManaged = getManagedWindowByWebContents(host.id);
const senderWindow =
senderManaged?.window ?? BrowserWindowCtor.fromWebContents(host);
return { window: senderWindow };
},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for TrpcContext type definition to confirm window field type

rg -n -A5 -B2 'type TrpcContext|interface TrpcContext' --type=ts

Repository: superset-sh/superset

Length of output: 502


Clarify ctx.window nullability in createContext

TrpcContext.window is typed as BrowserWindow | null, so the comment wording “ctx.window always resolves to the owning BrowserWindow” is inaccurate even though dialog procedures no-op when it can’t be resolved.

Doc fix
-// Walk to hostWebContents so ctx.window always resolves to the
-// owning BrowserWindow (otherwise dialog procedures no-op).
+// Walk to hostWebContents to find the owning BrowserWindow.
+// If not found, ctx.window will be null and dialog procedures no-op.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/main/windows/main.ts` around lines 201 - 210, Update the
comment in createContext to accurately reflect that TrpcContext.window can be
null instead of claiming it "always resolves" to a BrowserWindow; mention that
we walk to hostWebContents to prefer resolving the owning BrowserWindow (and
that dialog procedures are no-ops when it remains null). Reference the
createContext function and TrpcContext.window (ctx.window) in the comment so
readers know the code prefers senderManaged?.window or
BrowserWindowCtor.fromWebContents(host) but still may yield null.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 58794a1. Comment now says we walk to hostWebContents to prefer resolving the owning BrowserWindow, and that ctx.window stays null (dialog procedures no-op) when it can't be resolved.

Comment on lines +119 to +120
localStorage.setItem(`${name}:version`, String(parsed.version));
await config.set(parsed.state);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Move version persistence after successful state write.

The version is written to localStorage at line 119 before awaiting the config.set() call at line 120. If the tRPC mutation fails, the catch block at line 130 will skip setting lastFlushedValue (line 121), but the version in localStorage will already have been incremented. On the next getItem() call, the canonical snapshot will combine the new version from localStorage with the old state from config.get(), creating a version/state mismatch that could mask persistence failures.

🛡️ Proposed fix: persist version only after successful write
 		isFlushing = true;
 		try {
 			const parsed = JSON.parse(valueToFlush) as {
 				state: unknown;
 				version: number;
 			};
-			// Persist version in localStorage, bare state via tRPC.
-			localStorage.setItem(`${name}:version`, String(parsed.version));
 			await config.set(parsed.state);
+			// Persist version in localStorage only after successful tRPC write.
+			localStorage.setItem(`${name}:version`, String(parsed.version));
 			lastFlushedValue = valueToFlush;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
localStorage.setItem(`${name}:version`, String(parsed.version));
await config.set(parsed.state);
isFlushing = true;
try {
const parsed = JSON.parse(valueToFlush) as {
state: unknown;
version: number;
};
await config.set(parsed.state);
// Persist version in localStorage only after successful tRPC write.
localStorage.setItem(`${name}:version`, String(parsed.version));
lastFlushedValue = valueToFlush;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/lib/trpc-storage-adapter.ts` around lines 119 -
120, The version is being persisted to localStorage before awaiting the tRPC
write (localStorage.setItem is called before await config.set), which can leave
version/state inconsistent if the mutation fails; change the sequence in the
flush handler so you first await config.set(parsed.state) (the existing
config.set call in this function), then on success assign lastFlushedValue =
parsed.state (or the existing lastFlushedValue update), and only after those
succeed call localStorage.setItem(`${name}:version`, String(parsed.version));
this ensures localStorage version is updated only after a confirmed successful
write (refer to localStorage.setItem, config.set, and lastFlushedValue in the
function).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 58794a1. Moved localStorage.setItem(version) to after await config.set(state). On a rejected write the version now stays at its prior value, so the next getItem() rebuilds a consistent version+state snapshot instead of masking the failure.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 35 files

Architecture diagram
sequenceDiagram
    participant R1 as Renderer Window A
    participant R2 as Renderer Window B
    participant TRPC as tRPC Router
    participant Main as Main Process
    participant Mgr as Window Manager
    participant State as appState (lowdb)
    participant Adapter as Storage Adapter
    participant Sync as Cross-Window Sync
    participant Merge as Merge Remote State

    Note over R1,Merge: Multi-window tabs sync flow

    R1->>R1: User creates/renames/closes tab
    R1->>Adapter: setItem(tabs, snapshot)
    Adapter->>Adapter: Debounce 300ms
    Adapter->>TRPC: uiState.tabs.set(state)
    TRPC->>State: Write to lowdb
    TRPC->>TRPC: Emit TABS_STATE_CHANGED event
    TRPC-->>Main: Broadcast {state, sourceWebContentsId}

    Note over Main,Sync: Cross-window broadcast

    Main->>Sync: uiState.tabs.onChange subscription
    Sync->>TRPC: window.self query (identity)
    TRPC-->>Sync: {webContentsId, workspaceId}
    Sync->>Merge: applyRemoteTabsState(remoteState)
    Merge->>Merge: Only structure (tabs, panes) from remote
    Merge->>R2: setState({tabs, panes})
    R2->>R2: Keep local activeTabIds, focusedPaneIds

    alt Focused tab closed remotely
        Merge->>R2: Reconcile: fallback to MRU
        R2->>R2: Set activeTabId from tabHistoryStacks
    else Focused pane closed remotely
        Merge->>R2: Reconcile: fallback to first pane in tab
    end

    Note over R2,Adapter: Echo suppression

    R2->>Adapter: setItem(tabs, value) [from remote apply]
    Adapter->>Adapter: shouldSuppressWrite() returns true
    Adapter->>Adapter: Drop write, cancel pending flush

    alt Stale local write in debounce window
        Note over R1,Adapter: Before remote apply, R1 had pending write
        R1->>Adapter: setItem(tabs, staleLocalValue)
        R1->>R1: Remote merge applied
        R1->>Adapter: setItem(tabs, sameAsRemote)
        Adapter->>Adapter: Identical to lastFlushedValue → skip
    end

    Note over R1,R2: New window creation

    R1->>R1: Right-click workspace → "Open in New Window"
    R1->>TRPC: window.openWorkspaceWindow({workspaceId, focusTabId})
    TRPC->>Main: Import MainWindow, create window
    Main->>Mgr: registerWindow(window, {workspaceId})
    Main->>R2: Load URL with ?workspaceId&focusTabId
    R2->>R2: Apply focusTabId after hydration

    Note over R1,Mgr: Per-window selection

    R1->>TRPC: uiState.tabs.get (catch-up on subscribe)
    TRPC-->>R1: Current persisted state
    R1->>R1: Seed initial paint, keep local selection

    Note over Mgr,State: Window state persistence

    Main->>Mgr: Window close
    Mgr->>State: saveWindowStateForKey(workspaceId, bounds)
    State->>State: Write to window-state.json (keyed map)
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds multi-window support to the desktop app: each window can display a different workspace and maintain independent tab selection, while tab/pane structure (create, close, rename) stays in sync across windows via a new uiState.tabs.onChange tRPC subscription.

  • Core sync mechanism: A module-level EventEmitter in the main process broadcasts every tabs-state write tagged with sourceWebContentsId; renderer windows subscribe, skip their own echoes, and merge only structure while keeping selection local. The storage adapter gains a shouldSuppressWrite flag that cancels any pre-merge debounced local writes — the key fix for the tab-resurrection bug described in the PR.
  • Window management: A new manager.ts registry replaces the old currentWindow singleton; createContext in the IPC handler resolves ctx.window per-call by walking hostWebContents, so all existing dialog and focus procedures correctly target the calling window without changes to their logic.
  • Window state: Persisted bounds migrate from a single bare object to a keyed map (workspaceId → WindowState), with a legacy-shape migration path for existing installs.

Confidence Score: 3/5

Two real defects in newly-introduced code paths should be fixed before shipping: a null-dereference crash (silently caught but mislogged) in the cross-window catch-up, and a read-modify-write race in window-state persistence that can silently drop one window's saved bounds when two workspace windows close at the same time.

The cross-window sync catch-up in cross-window-sync.ts calls mergeRemoteTabsState without guarding for a null result from appState.data.tabsState, producing a silent TypeError that is caught and mislogged. Separately, saveWindowStateForKey in window-state.ts performs an unguarded read-modify-write: two windows closing within the same millisecond window each read the pre-write map, patch only their own key, and the second writer silently discards the first window's bounds. Both issues are in code paths directly exercised by the core feature of this PR.

apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts (null guard), apps/desktop/src/main/lib/window-state/window-state.ts (concurrent-write safety)

Important Files Changed

Filename Overview
apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts New cross-window subscription module; unguarded null in catch-up fetch causes a silent merge crash when no tabs state is persisted yet.
apps/desktop/src/main/lib/window-state/window-state.ts Migrated to keyed map storage; the read-modify-write in saveWindowStateForKey is not atomic between concurrent callers, risking one window's bounds being silently dropped when two windows close at the same time.
apps/desktop/src/renderer/lib/trpc-storage-adapter.ts Extracted storage adapter with suppression flag for remote-apply writes; logic is correct and well-tested.
apps/desktop/src/renderer/stores/tabs/merge-remote-state.ts Well-implemented merge function; preserves local selection and MRU history while taking remote structure, with comprehensive unit test coverage.
apps/desktop/src/main/windows/manager.ts New window registry; correctly captures webContentsId at registration to avoid destroyed-window access in the closed handler.
apps/desktop/src/main/lib/app-services.ts Correctly lifts notification server, NotificationManager, and terminal-exit listener out of MainWindow into an app-level singleton that survives any single window's lifecycle.
apps/desktop/src/main/windows/main.ts Refactored to support multiple windows with per-workspace state keys, stagger logic, and ctx-based IPC routing; context factory correctly walks hostWebContents for webview callers.
apps/desktop/src/lib/trpc/routers/ui-state/index.ts Adds tabs.onChange subscription using EventEmitter with echo suppression via sourceWebContentsId; max-listeners set to 100 to avoid spurious warnings.
apps/desktop/src/lib/trpc/routers/window.ts Refactored from getWindow closure to ctx.window; adds window.self and openWorkspaceWindow procedures for multi-window support.
apps/desktop/src/renderer/routes/page.tsx Adds workspaceId and focusTabId query param handling; focusTabApplied module-level guard is correct per-renderer-process.

Sequence Diagram

sequenceDiagram
    participant WA as Window A (renderer)
    participant Main as Main Process (tRPC/appState)
    participant WB as Window B (renderer)

    Note over WA,WB: Window B opens — catches up
    WB->>Main: uiState.tabs.onChange.subscribe()
    WB->>Main: uiState.tabs.get (catch-up)
    Main-->>WB: "TabsState {tabs, panes}"
    WB->>WB: "mergeRemoteTabsState(local, remote) structure=remote, selection=local"

    Note over WA,WB: Window A closes a tab
    WA->>WA: store.setState → closeTab
    WA->>Main: uiState.tabs.set (debounced 300ms)
    Main->>Main: appState.write()
    Main->>Main: "tabsStateEvents.emit TABS_STATE_CHANGED sourceWebContentsId=A"
    Main-->>WA: "onChange event (sourceWebContentsId=A)"
    WA->>WA: drop (own echo)
    Main-->>WB: "onChange event (sourceWebContentsId=A)"
    WB->>WB: runWithRemoteTabsApply → mergeRemoteTabsState suppress echo write
    WB->>WB: if activeTab was closed → MRU fallback
Loading
Prompt To Fix All With AI
Fix the following 2 code review issues. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 2
apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts:56-63
**Unguarded null in catch-up apply crashes silently**

The catch-up query result is cast directly to `RemoteTabsState` without a null guard. When `appState.data.tabsState` is null (fresh install, corrupted state file, or a second window opened before any tabs have been written), `mergeRemoteTabsState` immediately throws `TypeError: Cannot read properties of null (reading 'panes')` at the first `Object.entries(remote.panes)` call. The error is caught by `.catch` and mislogged as "catch-up fetch failed" — a network-error label for what is actually a null-dereference crash in the merge function. The window silently skips the structural catch-up and may show stale tab structure until the next write from another window arrives.

The fix is a one-line null guard in the `.then` callback: `.then((state) => { if (state) applyRemoteTabsState(state as unknown as RemoteTabsState); })`.

### Issue 2 of 2
apps/desktop/src/main/lib/window-state/window-state.ts:102-110
**Read-modify-write race on concurrent window closes**

`saveWindowStateForKey` reads the entire map, patches one key, and writes the file back. When two keyed windows close within the same ~few-millisecond window (e.g. the user quits the app with two workspace windows open, or rapidly closes two windows), both read the pre-write map, each patches only its own key, and the second write discards the first window's key entirely. The individual write is atomic (temp + rename) but the read-modify-write cycle is not. The affected window's bounds revert to defaults on next launch. Introducing a write-lock or using a `Map` kept in memory (written on every save, read only on first access) would avoid the race.

Reviews (1): Last reviewed commit: "feat(desktop): per-window panel selectio..." | Re-trigger Greptile

Comment on lines +56 to +63
electronTrpcClient.uiState.tabs.get
.query()
.then((state) =>
applyRemoteTabsState(state as unknown as RemoteTabsState),
)
.catch((err) => {
console.error("[cross-window-sync] catch-up fetch failed:", err);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unguarded null in catch-up apply crashes silently

The catch-up query result is cast directly to RemoteTabsState without a null guard. When appState.data.tabsState is null (fresh install, corrupted state file, or a second window opened before any tabs have been written), mergeRemoteTabsState immediately throws TypeError: Cannot read properties of null (reading 'panes') at the first Object.entries(remote.panes) call. The error is caught by .catch and mislogged as "catch-up fetch failed" — a network-error label for what is actually a null-dereference crash in the merge function. The window silently skips the structural catch-up and may show stale tab structure until the next write from another window arrives.

The fix is a one-line null guard in the .then callback: .then((state) => { if (state) applyRemoteTabsState(state as unknown as RemoteTabsState); }).

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/renderer/stores/tabs/cross-window-sync.ts
Line: 56-63

Comment:
**Unguarded null in catch-up apply crashes silently**

The catch-up query result is cast directly to `RemoteTabsState` without a null guard. When `appState.data.tabsState` is null (fresh install, corrupted state file, or a second window opened before any tabs have been written), `mergeRemoteTabsState` immediately throws `TypeError: Cannot read properties of null (reading 'panes')` at the first `Object.entries(remote.panes)` call. The error is caught by `.catch` and mislogged as "catch-up fetch failed" — a network-error label for what is actually a null-dereference crash in the merge function. The window silently skips the structural catch-up and may show stale tab structure until the next write from another window arrives.

The fix is a one-line null guard in the `.then` callback: `.then((state) => { if (state) applyRemoteTabsState(state as unknown as RemoteTabsState); })`.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 58794a1, with a correction. The runtime null-deref you describe can't actually occur: appState.data.tabsState is typed BaseTabsState (non-null) and defaulted on load (...(data.tabsState ?? {}) with tabs: [], panes: {}), so get never returns null and mergeRemoteTabsState never sees null panes. The real issue was the one CodeRabbit flagged on the same lines — the as unknown as RemoteTabsState cast was hiding a genuine structural mismatch (persisted tabs type is BaseTab[], no layout). Replaced both casts with a documented toRemoteStructure() helper that selects { tabs, panes } and downcasts BaseTab[] -> Tab[] (layout is guaranteed at runtime by tabsStateSchema).

Comment on lines +102 to +110
export function saveWindowStateForKey(
key: string,
state: WindowState,
filePath: string = WINDOW_STATE_PATH,
): void {
const map = readWindowStateMap(filePath);
map[key] = state;
writeWindowStateMap(map, filePath);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Read-modify-write race on concurrent window closes

saveWindowStateForKey reads the entire map, patches one key, and writes the file back. When two keyed windows close within the same ~few-millisecond window (e.g. the user quits the app with two workspace windows open, or rapidly closes two windows), both read the pre-write map, each patches only its own key, and the second write discards the first window's key entirely. The individual write is atomic (temp + rename) but the read-modify-write cycle is not. The affected window's bounds revert to defaults on next launch. Introducing a write-lock or using a Map kept in memory (written on every save, read only on first access) would avoid the race.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop/src/main/lib/window-state/window-state.ts
Line: 102-110

Comment:
**Read-modify-write race on concurrent window closes**

`saveWindowStateForKey` reads the entire map, patches one key, and writes the file back. When two keyed windows close within the same ~few-millisecond window (e.g. the user quits the app with two workspace windows open, or rapidly closes two windows), both read the pre-write map, each patches only its own key, and the second write discards the first window's key entirely. The individual write is atomic (temp + rename) but the read-modify-write cycle is not. The affected window's bounds revert to defaults on next launch. Introducing a write-lock or using a `Map` kept in memory (written on every save, read only on first access) would avoid the race.

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked into this — it's not a race, and I added a comment in 58794a1 explaining why. saveWindowStateForKey is fully synchronous: readWindowStateMap uses readFileSync and writeWindowStateMap uses writeFileSync+renameSync, with no await anywhere between read and write. Both call sites (close/resize handlers in main.ts) invoke it synchronously too. Node runs each call to completion before any other JS, so two windows closing 'simultaneously' queue their handlers — the second call's read only runs after the first's write has landed. No key is dropped. The added comment documents this invariant so a future async refactor doesn't silently reintroduce the race you'd otherwise be right about.

- ctx.webContentsId: capture the sender's webContents id once in
  createContext (when the window is provably alive) and add it to
  TrpcContext. tabs.set and window.self now read ctx.webContentsId
  instead of ctx.window.webContents.id, which could throw "Object has
  been destroyed" if the window closed mid-mutation.
  (coderabbit, cubic)

- trpc-storage-adapter: write state via config.set() before bumping the
  localStorage version. Persisting the version first meant a failed
  config.set left a bumped version paired with stale state on the next
  getItem(), masking the failure. (coderabbit, critical)

- cross-window-sync: replace the opaque `as unknown as RemoteTabsState`
  casts with a documented toRemoteStructure() helper that selects
  tabs+panes and downcasts BaseTab[] -> Tab[] (layout is guaranteed at
  runtime by tabsStateSchema). Makes the structural intent explicit.
  (coderabbit nitpick, greptile)

- createContext: correct the comment to say ctx.window may be null
  rather than "always resolves". (coderabbit)

- saveWindowStateForKey: document the synchronous read-modify-write
  invariant. The flagged "concurrent close race" cannot occur — the
  function is fully synchronous (readFileSync -> writeFileSync) so Node
  runs each call to completion with no interleaving. Comment guards
  against a future async refactor reintroducing the race. (greptile)
@Kitenite

Copy link
Copy Markdown
Member

Closing: main already ships this. b9d851f (#5337) shipped multi-window. Thanks for the PR; if you think the shipped version misses a case, open an issue and link this.

@Kitenite Kitenite closed this Aug 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants