Skip to content

feat: move plugins/index.ts out of renderer bundle (PR C)#9961

Draft
jackkav wants to merge 11 commits into
developfrom
feat/plugins-index-renderer-cleanup
Draft

feat: move plugins/index.ts out of renderer bundle (PR C)#9961
jackkav wants to merge 11 commits into
developfrom
feat/plugins-index-renderer-cleanup

Conversation

@jackkav
Copy link
Copy Markdown
Contributor

@jackkav jackkav commented May 26, 2026

Summary

  • src/plugins/create.ts → main IPC: moves the full createPlugin implementation (fs/path) to src/main/create-plugin.ts; exposes it as window.main.createPlugin() via IPC handler + preload entry
  • Inline call sites: replaces the createPlugin(...) import in create-plugin-modal.tsx and root.tsx with direct window.main.createPlugin(...) calls; deletes src/plugins/create.ts
  • utils/plugin.ts cleanup: moves getSafePluginDir (which owned the fs/path calls) into src/main/create-plugin.ts where it belongs; utils/plugin.ts now exports only pure validatePluginName — no Node builtins
  • Remove INSOMNIA_ENABLE_PLUGIN_BRIDGE fallback: renderer-bridge.ts now always delegates through window.main.plugins.* IPC; the invoke-method.ts import (and its transitive plugins/index.ts import) are gone from the renderer bundle
  • network.ts lazy require: replaces import * as plugins from '../plugins/index' with require('../plugins/index') calls inside process.type !== 'renderer' guards, breaking the last static renderer path to plugins/index.ts
  • Baseline shrinks by 6 entries: src/plugins/create.ts (fs, path), src/plugins/index.ts (fs, path), src/utils/plugin.ts (fs, path)

Context

Stacks on top of feat/network-timeline-ipc-bridge (PR #9945). This is PR C of the nodeIntegration: false renderer migration plan described in NODE_INTEGRATION_MIGRATION_PR_PLAN.md.

Test plan

  • npm run type-check -w packages/insomnia — passes (0 errors)
  • npm run lint -w packages/insomnia — passes
  • npm test -w packages/insomnia — 107 test files, 1921 tests pass
  • npm run check:renderer-node-imports — baseline no longer contains src/plugins/index.ts, src/plugins/create.ts, or src/utils/plugin.ts
  • Manual: create a new plugin via Settings → Plugins → Create Plugin
  • Manual: install a theme via drag-and-drop; confirm theme-* plugin is created
  • Manual: send a request with a plugin that has request/response hooks; confirm hooks fire

🤖 Generated with Claude Code

@jackkav jackkav marked this pull request as draft May 26, 2026 13:43
@jackkav jackkav force-pushed the feat/network-timeline-ipc-bridge branch from 7fa4b33 to a3746cf Compare May 27, 2026 04:43
@jackkav jackkav force-pushed the feat/plugins-index-renderer-cleanup branch from 8a3448d to 7a542ec Compare May 27, 2026 07:33
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 27, 2026

✨ Circular References Report

Generated at: 2026-05-27T10:20:01.770Z
Status: ✨ IMPROVED

Summary

Metric Base (develop) PR Change
Total Circular References 18 17 -1 (-5.56%)

✨ Circular References Removed (1)

Click to expand/collapse
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
Click to view all circular references in PR (17)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts -> insomnia/src/scripting/require-interceptor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/concurrency.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/templating/base-extension-worker.ts -> insomnia/src/templating/worker.ts
insomnia/src/templating/index.ts -> insomnia/src/templating/base-extension.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/templating/types.ts -> insomnia/src/templating/utils.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx
Click to view all circular references in base branch (18)
insomnia-inso/src/db/models/types.ts -> insomnia-inso/src/db/types.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/cancellation.ts -> insomnia/src/script-executor.ts -> insomnia/src/scripting/require-interceptor.ts
insomnia-scripting-environment/src/objects/index.ts -> insomnia-scripting-environment/src/objects/collection.ts -> insomnia-scripting-environment/src/objects/response.ts -> insomnia/src/network/network.ts -> insomnia/src/network/concurrency.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts
insomnia/src/network/network.ts -> insomnia/src/common/render.ts -> insomnia/src/templating/index.ts -> insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/context/app.ts -> insomnia/src/templating/types.ts -> insomnia/src/plugins/context/store.ts
insomnia/src/plugins/index.ts -> insomnia/src/plugins/misc.ts
insomnia/src/templating/base-extension-worker.ts -> insomnia/src/templating/worker.ts
insomnia/src/templating/index.ts -> insomnia/src/templating/base-extension.ts
insomnia/src/templating/types.ts -> insomnia/src/plugins/context/network.ts
insomnia/src/templating/types.ts -> insomnia/src/templating/utils.ts
insomnia/src/ui/components/settings/import-export.tsx -> insomnia/src/ui/components/modals/export-requests-modal.tsx
insomnia/src/ui/components/tabs/tab-list.tsx -> insomnia/src/ui/components/tabs/tab.tsx
insomnia/src/ui/components/templating/tag-editor-arg-sub-form.tsx -> insomnia/src/ui/components/templating/external-vault/external-vault-form.tsx
insomnia/src/ui/components/viewers/response-viewer.tsx -> insomnia/src/ui/components/viewers/response-multipart-viewer.tsx

Analysis

Great Job! This PR removes 1 circular reference. Keep up the good work!


This report was generated automatically by comparing against the develop branch.

Base automatically changed from feat/network-timeline-ipc-bridge to develop May 27, 2026 09:44
jackkav and others added 11 commits May 27, 2026 12:07
Removes `node:fs` and `node:path` from the renderer-reachable
`src/network/network.ts`. Three timeline-path constructions and two
`appendFile` calls are replaced with narrow `window.main.timeline.getPath`
(sync IPC) and `window.main.timeline.appendToFile` (async IPC) helpers
that live in main, where Node builtins belong.

Path validation in `appendToTimeline` mirrors `writeResponseBodyToFile`:
only paths inside the `responses/` directory ending in `.timeline` are
accepted, preventing a compromised renderer from writing arbitrary files.

Updates `config/renderer-node-import-baseline.json` to remove the two
`src/network/network.ts` entries — the baseline shrinks as intended.

Part of the nodeIntegration: false migration (PR B).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e adapter modules

Eliminates all runtime process.type and typeof window checks by introducing
network-adapter.renderer.ts and network-adapter.node.ts. Vite and Vitest resolve
the import to the renderer adapter; inso esbuild resolves to the node adapter.
No branching code remains in network.ts itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Array-form alias with find:'~' was not matching prefix imports like
~/common/insomnia-fetch in the react-router production build. Object
form behaves correctly in Vite 7.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…md indented tree

- logger.ts: keep LogType (consola v3 casing), drop duplicate conflict markers
- cli.ts: remove stashed duplicate LogLevels import from conflict block
- AGENTS.md: restore indented hierarchy in Repository Structure and Data Model sections

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…om renderer bundle

- Move createPlugin implementation from src/plugins/create.ts to src/main/create-plugin.ts; expose via window.main.createPlugin IPC handler
- Inline window.main.createPlugin() at both call sites (create-plugin-modal.tsx, root.tsx); delete src/plugins/create.ts
- Extract getSafePluginDir from utils/plugin.ts into src/main/create-plugin.ts (main-only logic); utils/plugin.ts now exports only pure validatePluginName with no Node builtins
- Remove INSOMNIA_ENABLE_PLUGIN_BRIDGE fallback from renderer-bridge.ts: bridge is always on, so invoke-method.ts (and transitively plugins/index.ts) are no longer statically bundled in the renderer
- Replace static import of plugins/index in network.ts with lazy require() inside process.type !== 'renderer' guards, removing the last static renderer path to plugins/index.ts
- Shrinks renderer-node-import-baseline.json by 6 entries: plugins/create.ts (×2), plugins/index.ts (×2), utils/plugin.ts (×2)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The timeline IPC bridge introduced window.main.timeline.getPath and
window.main.timeline.appendToFile calls without guarding against the
inso CLI context, where window is not defined.

- getTimelinePath: check typeof window before using IPC; fall back to
  the electron shim (aliased in the inso bundle to os.tmpdir()) path
- defaultSendActionRuntime.appendTimeline: fall back to fs.promises.appendFile
- tryToExecutePreRequestScript catch block: skip IPC appendToFile in
  Node.js context (timeline loss on pre-request script error is acceptable)
- Bump insomnia-inso consola from ^2.15.3 to ^3.0.0 so the bundle
  resolves the v3 createConsola API used since dc8d805

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e adapter modules

Eliminates all runtime process.type and typeof window checks by introducing
network-adapter.renderer.ts and network-adapter.node.ts. Vite and Vitest resolve
the import to the renderer adapter; inso esbuild resolves to the node adapter.
No branching code remains in network.ts itself.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…reatePlugin in main.ts

After rebasing onto feat/network-timeline-ipc-bridge, two rebase artifacts remained:
- renderer-node-import-baseline.json lost the plugins/index.ts entries (fs, path) prematurely; plugins/index.ts is still statically bundled in the renderer via har.ts/misc.ts/theme.ts
- main.ts had a duplicate createPlugin interface member and ipcMainHandle registration (one from PR 9941 merge, one re-applied by the rebase)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@jackkav jackkav force-pushed the feat/plugins-index-renderer-cleanup branch from 7c7a218 to e7f844d Compare May 27, 2026 10:17
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