Window management, dialogue system, IPC and logging rewrite #8

Merged
mburchard merged 61 commits from feature/window-manager into main 2026-02-27 23:20:23 +00:00
Owner

Complete rewrite of the Electron backend architecture, replacing the ad-hoc window and IPC handling with a structured, testable system.

Window Management

New WindowController with pack mode (auto-sizing to content), declarative WindowPlacement, display awareness for multi-monitor setups, and a deferred whenWindowReady lifecycle hook. WindowManager handles window creation and registry.

Dialogue System

Custom dialogue windows replacing native Electron dialogs. Five visual types (confirm, error, info, success, warning), configurable buttons with variants, backend-owns-close principle, and lifecycle hooks. Convenience functions showInfo, showSuccess, showWarning, showError for common single-button dialogues. Full API reference in documentation/dialog-system.md.

Type-safe IPC

Four communication patterns (request-response, fire-and-forget, broadcast, targeted send) over typed IpcChannels. Preload exposes a minimal window.backend API via contextBridge.

Logging Pipeline

PipelineAppender merging backend and frontend events chronologically, RotatingFileAppender for daily log files, BackendForwardingAppender for renderer-to-main forwarding. Source map support in production builds.

Core/Demo Separation

Demo code isolated in demo/ subdirectories within each module, deletable for a clean starter template.

Testing and Tooling

156 tests across 9 suites covering WindowController, DialogService, IPC, preload, PipelineAppender, RotatingFileAppender, and shared utilities. Vite 7, TypeScript 5.9, ESLint 10 with antfu config, Vitest 4, separate tsconfig for build vs typecheck.

Complete rewrite of the Electron backend architecture, replacing the ad-hoc window and IPC handling with a structured, testable system. ### Window Management New `WindowController` with pack mode (auto-sizing to content), declarative `WindowPlacement`, display awareness for multi-monitor setups, and a deferred `whenWindowReady` lifecycle hook. `WindowManager` handles window creation and registry. ### Dialogue System Custom dialogue windows replacing native Electron dialogs. Five visual types (confirm, error, info, success, warning), configurable buttons with variants, backend-owns-close principle, and lifecycle hooks. Convenience functions `showInfo`, `showSuccess`, `showWarning`, `showError` for common single-button dialogues. Full API reference in `documentation/dialog-system.md`. ### Type-safe IPC Four communication patterns (request-response, fire-and-forget, broadcast, targeted send) over typed `IpcChannels`. Preload exposes a minimal `window.backend` API via `contextBridge`. ### Logging Pipeline `PipelineAppender` merging backend and frontend events chronologically, `RotatingFileAppender` for daily log files, `BackendForwardingAppender` for renderer-to-main forwarding. Source map support in production builds. ### Core/Demo Separation Demo code isolated in `demo/` subdirectories within each module, deletable for a clean starter template. ### Testing and Tooling 156 tests across 9 suites covering WindowController, DialogService, IPC, preload, PipelineAppender, RotatingFileAppender, and shared utilities. Vite 7, TypeScript 5.9, ESLint 10 with antfu config, Vitest 4, separate tsconfig for build vs typecheck.
- Electron: 34.1.0
 - Vite: 6.1.0
 - remove unused glob
 - add onlyBuiltDependencies for pnpm
This reverts commit 99e7faa35b.
This reverts commit ed06a72ce2.
- pnpm 10.5.1
 - vite 6.2.0
 - and more...
- LogLevel has changed in bit-log
- Upgrade to Node 24, Electron 40.6.1, ESLint 10, @antfu/eslint-config 7.6.1,
  Vitest 4, TypeScript 5.9.3, Vite 7.3.1, pnpm 10.30.1
- Upgrade bit-log to 1.2.1 with explicit source map resolver via
  configureSourceMapResolver() and @jridgewell/trace-mapping
- Replace dual Console + File logging with unified PipelineAppender that
  merges backend and frontend events into a single chronologically sorted
  log file with origin prefixes
- Extract logging into logging/ subdirectory with PipelineAppender module
- Refactor TypeScript configs: extract shared settings into tsconfig.base.json,
  replace tsconfig.vitest.json with flat tsconfig.typecheck.json
- Add pnpm-workspace.yaml with trust policy and build dependency whitelist
- Add .node-version (24), add doc comments, update screenshots
- Add tests: IpcChannels validation, file-utils, PipelineAppender
  (buffer, flush, timer, origin prefix, path shortening)
- Simplify getLogPath() to use app.getPath('logs') directly
- Rewrite README with tech stack, feature overview, and logging docs
- Bump version to 0.3.0
- Align with project convention: test files use .spec.ts suffix
- Update vitest.config.ts include pattern accordingly
- Replace FileAppender with RotatingFileAppender that rotates on date change and file size
  limit, with automatic archive cleanup
- Bring PipelineAppender and file-utils up to project guidelines
- Add v8 ignore comments (with @preserve) for untestable defensive error handlers
- Rewrite PipelineAppender tests (26 tests) and extend file-utils tests (4 tests) for full
  coverage
- Add tsconfig.test.json as project reference so IDEs resolve test imports correctly
- Add @vitest/coverage-v8 as dev dependency
- Add file header comments (@file, @author) to all modules
- Add block-format JSDoc with @param/@returns to all functions, classes and interfaces
- Fix Oxford British English: initialisation -> initialization, visualise -> visualize
- Fix '/n' typo in WindowManager error log (was literal string, now '\n')
- Reflow JSDoc comments in ipc.ts and preload.ts to remove old {type} annotations
- Fix key ordering in tsconfig.test.json (references before include)
- Rename IPC functions to Electron-aligned terminology:
  registerFrontendHandler -> handleFromRenderer,
  registerFrontendListener -> onFromRenderer,
  unregisterFrontendListener -> offFromRenderer,
  sendFrontend -> broadcast, emit -> send
- Rename interfaces: FrontendIpcHandler -> RendererHandler,
  FrontendIpcListener -> RendererListener
- Add window registry with auto-cleanup on window close
- Add sendToRenderer for targeted single-window messaging
- Add onceFromRenderer as dedicated function (replaces boolean param)
- Add once() to preload Backend interface (ipcRenderer.once)
- Add comprehensive file-header documentation with all 4 IPC patterns
- Add preload.spec.ts with 16 tests covering invoke, send, on/off,
  once, convenience wrappers, and DOMContentLoaded side effect
- Add jsdom dev dependency for preload test environment
- Add @common alias to vitest.config.ts for cross-module resolution
- Update README IPC section to reflect all 4 communication patterns
- Update all callers: main.ts, logging/index.ts, WindowManager.ts,
  app/index.ts
- Remove source-map-resolver test errors from main.ts and
  app/index.ts
Window Management
- Replace monolithic WindowManager.ts with windowMgt/ module
- WindowController: pack mode, placement, display-awareness, show timeout
- createWindow is now synchronous; async part in loadAndShow()
- whenWindowReady deferred pattern replaces onReady callback
- Auto-resize via ResizeObserver in preload (50ms debounce, --auto-resize arg)

Dialog System (replaces Popup)
- DialogService with typed config, lifecycle hooks, backend-owned close logic
- Five visual types: confirm, error, info, success, warning
- Configurable buttons with variants (primary, secondary, danger)
- DialogIpc handles renderer intents (opened/shown/action/dismissed)
- popup.ts + popup.html removed, replaced by dialog.ts + dialog.html

Core/Demo Separation
- Shared types split into common/src/core/ (ipc, versions, window)
- Dialog contracts in common/src/dialog/ (types, ipc, lifecycle)
- Demo code isolated in demo/ subdirectories (deletable for clean starter)
- definitions.ts retained as backward-compatible aggregate

Preload Logging
- Own configureLogging in preload (Console + BackendForwardingAppender)
- BackendForwardingAppender moved to common/src/logging/ with DI-based sender
- Old app/src/BackendForwardingAppender.ts removed

Utilities and Infrastructure
- debounce() and throttle() in common/src/utils.ts
- CSS rewrite: template_root.css, buttons.css, dialog.css, demo CSS separated
- project.config.ts updated for new page structure
vite.config.ts
- Add file header, section comments, and JSDoc on all functions
- Rename starteElectron -> startElectron, hasBeenBuild -> hasBeenBuilt
- Enable minification for production builds (was disabled with && false)

Preload
- Remove includeCallSite from logging config (no source map resolver
  available in preload context, produced unhelpful bundle line numbers)
- Add showInfo, showSuccess, showWarning, showError convenience functions with SimpleDialogOptions
  for common single-button dialogues
- Refactor displayDemo to use convenience functions instead of manual openDialogWindow calls for
  follow-up dialogues
- Fix show timeout not being cleared when window becomes visible (WindowController)
- Add comprehensive DialogService test suite (35 tests covering lifecycle, hooks, idempotency,
  error scenarios, button behaviour, programmatic close, setDialogMessage, convenience functions)
- Add Dialog System API Reference (documentation/dialog-system.md) with full type documentation,
  lifecycle diagram, and usage patterns
- Link API reference from README
- Normalise dialog/dialogue spelling across touched files
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
mburchard/vite-electron-starter!8
No description provided.