Skip to content

chore: Phase 2c - Insomnia facade, consumed via React Router context - #10340

Draft
gatzjames wants to merge 1 commit into
arch-phase-2c-rename-workspace-use-casefrom
arch-phase-2c-insomnia-facade
Draft

chore: Phase 2c - Insomnia facade, consumed via React Router context#10340
gatzjames wants to merge 1 commit into
arch-phase-2c-rename-workspace-use-casefrom
arch-phase-2c-insomnia-facade

Conversation

@gatzjames

Copy link
Copy Markdown
Contributor

No description provided.

Replaces the ad-hoc per-use-case bootstrap exports (one bound function
per use-case) with a single Insomnia facade, namespaced by aggregate
(insomnia.workspace.renameById(...)), constructed once and threaded
through apps via dependency injection rather than imported piecemeal.

- application/src/insomnia.ts - the Insomnia class + InsomniaDependencies
  interface. Framework-agnostic: takes repository ports (from domain),
  never a concrete infrastructure class, so application stays usable by
  any app.
- application/src/workspace/workspace.module.ts - WorkspaceModule wraps
  the existing renameWorkspace use-case as a method. One module per
  aggregate; renameWorkspace itself is unchanged and still independently
  exported/unit-tested.
- apps/desktop/src/common/application-bootstrap.ts - constructs the one
  Insomnia instance (wiring nedbWorkspaceRepository in), and defines the
  InsomniaContext React Router context token. The token lives here, not
  in application: react-router is a desktop-specific framework
  dependency, and application must stay usable by apps/cli and any
  future app that isn't built on react-router at all.
- apps/desktop/src/entry.client.tsx - wires the Insomnia instance into
  <HydratedRouter> via getContext, using RouterContextProvider. This
  works today under clientLoader/clientAction (SPA mode) because
  react-router.config.ts already has future.v8_middleware: true enabled
  - confirmed by reading react-router's own type definitions before
  building on it, since context/middleware is a relatively new,
  easy-to-get-wrong API. No SSR or Phase 6 dependency.
- workspace.update.tsx - reads the facade via
  context.get(InsomniaContext).workspace.renameById(...) instead of
  importing a bound function.

apps/cli has no router at all, so none of the context plumbing applies
there - it would construct `new Insomnia(...)` once in its own bootstrap
and call methods on it directly from command handlers, same as any other
plain object.

Verified: lint, type-check, check-boundaries, and the full test suite all
pass clean (application now has 2 test files / 3 tests, including a
dedicated test for the facade's delegation). Re-ran the actual desktop
app via the project's Playwright/Electron smoke-test harness -
dashboard-interactions.test.ts's rename test passed again, confirming
the context wiring works end-to-end in the real running app, not just
against fakes.
@github-actions

github-actions Bot commented Aug 6, 2026

Copy link
Copy Markdown

✅ Circular References Report

Generated at: 2026-08-06T11:17:25.703Z
Status: ✅ NO CHANGE

Summary

Metric Base (arch-phase-2c-rename-workspace-use-case) PR Change
Total Circular References 13 13 0 (0.00%)
Click to view all circular references in PR (13)
../apps/desktop/src/common/render.ts -> ../apps/desktop/src/network/network.ts
../apps/desktop/src/network/network.ts -> ../apps/desktop/src/network/concurrency.renderer.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
../packages/insomnia-scripting-environment/src/objects/collection.ts -> ../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts
../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts
../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts -> ../packages/insomnia-scripting-environment/src/objects/insomnia.ts
../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts -> ../packages/insomnia-scripting-environment/src/objects/insomnia.ts -> ../packages/insomnia-scripting-environment/src/objects/send-request.ts
desktop/src/main/prompt-bridge.ts -> desktop/src/main/window-utils.ts -> desktop/src/main/plugin-window.ts
desktop/src/main/window-utils.ts -> desktop/src/main/plugin-window.ts
desktop/src/network/network.ts -> desktop/src/common/render.ts
desktop/src/ui/components/settings/import-export.tsx -> desktop/src/ui/components/modals/export-requests-modal.tsx
desktop/src/ui/components/tabs/tab-list.tsx -> desktop/src/ui/components/tabs/tab.tsx
desktop/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> desktop/src/ui/components/templating/external-vault/external-vault-form.tsx
desktop/src/ui/components/viewers/response-viewer.tsx -> desktop/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (13)
../apps/desktop/src/common/render.ts -> ../apps/desktop/src/network/network.ts
../apps/desktop/src/network/network.ts -> ../apps/desktop/src/network/concurrency.renderer.ts -> insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts
../packages/insomnia-scripting-environment/src/objects/collection.ts -> ../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts
../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts
../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts -> ../packages/insomnia-scripting-environment/src/objects/insomnia.ts
../packages/insomnia-scripting-environment/src/objects/response.ts -> desktop/src/network/network.ts -> ../packages/insomnia-scripting-environment/src/objects/index.ts -> ../packages/insomnia-scripting-environment/src/objects/insomnia.ts -> ../packages/insomnia-scripting-environment/src/objects/send-request.ts
desktop/src/main/prompt-bridge.ts -> desktop/src/main/window-utils.ts -> desktop/src/main/plugin-window.ts
desktop/src/main/window-utils.ts -> desktop/src/main/plugin-window.ts
desktop/src/network/network.ts -> desktop/src/common/render.ts
desktop/src/ui/components/settings/import-export.tsx -> desktop/src/ui/components/modals/export-requests-modal.tsx
desktop/src/ui/components/tabs/tab-list.tsx -> desktop/src/ui/components/tabs/tab.tsx
desktop/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> desktop/src/ui/components/templating/external-vault/external-vault-form.tsx
desktop/src/ui/components/viewers/response-viewer.tsx -> desktop/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

No Change: This PR does not introduce or remove any circular references.


This report was generated automatically by comparing against the arch-phase-2c-rename-workspace-use-case branch.

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