Skip to content

refactor: modularize main process, sessions, terminal, app store + cross-window panels & in-app update modal#352

Merged
Anton-Horn merged 4 commits into
mainfrom
refactor/modularize-main-and-cross-window-panels
Jun 9, 2026
Merged

refactor: modularize main process, sessions, terminal, app store + cross-window panels & in-app update modal#352
Anton-Horn merged 4 commits into
mainfrom
refactor/modularize-main-and-cross-window-panels

Conversation

@Anton-Horn

Copy link
Copy Markdown
Contributor

Summary

Large structural cleanup plus two user-facing features. Breaks the biggest monolith files into focused modules (net ~6k lines removed) and lands cross-window panel discovery and an in-app update-ready modal. No behavior loss in the refactored paths.

Modularization

  • main/index.ts (was 1820 lines) split into:
    • main/lifecycle/openPath, shutdown, telemetry
    • main/windows/windowFactory, crashRecovery, dockState, dragGhost, fullscreen, reveal
    • main/ipc/capture, dialogs, dockWindows, dragHandlers, panelWindows, windowControls, windowPanels, batchedDispatcher, handlerError
  • terminalRegistry.ts (-1376) split into terminalDom, terminalInput, terminalLifecycle, terminalSearch, terminalSettings, scrollbackCapture, captureAndSaveScrollback, registryState
  • workspace/session.ts (-1173) split into sessionLoad, sessionSave, sessionRestore, sessionSerialize, sessionAutosave, sessionStartup
  • stores/appStore.ts (-1558, deleted) replaced by stores/appStore/ slices: workspaceSlice, panelSlice, remoteSlice, syncSlice, worktreeSlice + shared helpers/types
  • preload/index.ts trimmed
  • Companion transports now share a transport.ts base; SSH/WSL/local differ only at bootstrap/launch
  • Themes share scaffolding via oneDarkShared.ts

Cross-window panels

Main now maintains the union of panels across all windows and broadcasts it, so every window's overview and Cmd+K can find and reveal panels that live in other windows.

  • New windowPanelStore, windowPanelSync, main-side windowPanels
  • New IPC: WINDOW_PANELS_CHANGED, WINDOW_PANELS_REPORT, FOCUS_WINDOW_PANEL, REVEAL_PANEL_IN_WINDOW
  • Removes the standalone NodeSwitcher in favor of the unified command palette

In-app update modal

  • New UpdateReadyDialog driven by UPDATE_STATUS broadcasts
  • UPDATE_QUIT_AND_INSTALL (restart + apply) and UPDATE_GET_STATUS (for modals that mount after the download-finished event)

Tests

Added coverage for window panels, session hydration, panel transfer, detached dock placement, and the new terminal/dom helpers.

Notes

Mostly mechanical extraction. Worth a focused look at the cross-window panel sync and the appStore slice boundaries.

… add cross-window panels and in-app update modal

Breaks up the largest monolith files into focused modules and lands two
user-facing features (cross-window panel discovery, in-app update-ready
modal). Net -6000 lines with no behavior loss in the refactored paths.

Modularization
- main/index.ts (1820 lines): extracted lifecycle (openPath, shutdown,
  telemetry), windows (windowFactory, crashRecovery, dockState, dragGhost,
  fullscreen, reveal), and IPC handlers (capture, dialogs, dockWindows,
  dragHandlers, panelWindows, windowControls, windowPanels, batchedDispatcher,
  handlerError).
- terminalRegistry.ts (-1376): split into terminalDom, terminalInput,
  terminalLifecycle, terminalSearch, terminalSettings, scrollbackCapture,
  captureAndSaveScrollback, registryState.
- workspace/session.ts (-1173): split into sessionLoad, sessionSave,
  sessionRestore, sessionSerialize, sessionAutosave, sessionStartup.
- stores/appStore.ts (-1558): replaced by appStore/ slices (workspace, panel,
  remote, sync, worktree) plus shared helpers/types.
- preload/index.ts trimmed; companion transports share a transport.ts base so
  SSH/WSL/local only differ at bootstrap.
- themes: shared scaffolding pulled into oneDarkShared.ts.

Cross-window panels
- Main keeps the union of panels across all windows and broadcasts it, so every
  window's overview and Cmd+K can find and reveal panels living in other
  windows. New windowPanelStore, windowPanelSync, main windowPanels, and IPC
  (WINDOW_PANELS_CHANGED/REPORT, FOCUS_WINDOW_PANEL, REVEAL_PANEL_IN_WINDOW).
- Removes the separate NodeSwitcher in favor of the unified palette.

In-app update modal
- UpdateReadyDialog driven by UPDATE_STATUS broadcasts, with
  UPDATE_QUIT_AND_INSTALL and UPDATE_GET_STATUS for restart and late mounts.

Adds tests for window panels, session hydration, panel transfer, detached dock
placement, and the new terminal/dom helpers.
…rktree accent on detached rows

Detached rows (panels living in another window) now render with the same
data as local rows. Agent state/name and listening-port presence are stamped
by the owner window on the cross-window union (the owner is the only window
that receives a panel's activity scan), and worktreeId rides along too.

- WindowPanelInfo/WindowPanelReport carry worktreeId, agentState, agentName,
  hasPorts.
- windowPanelSync stamps agent info + ports per panel, re-reporting on a cheap
  status signature so the 1s activity poll doesn't trigger needless canvas-map
  rebuilds.
- WorkspaceTab renders terminal/agent detached rows through TerminalPanelRow
  (shimmer/await/logo/port dot/worktree accent), with a titleHint noting the
  panel lives in another window.
Consolidate detached panel handling into dock windows, add dock window
scrollback sync, extract platform and jsonProjection helpers, slim the
preload IPC bridge, and update session restore/save accordingly.
@Anton-Horn Anton-Horn merged commit deef162 into main Jun 9, 2026
3 checks passed
@Anton-Horn Anton-Horn deleted the refactor/modularize-main-and-cross-window-panels branch June 9, 2026 11:06
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.

1 participant