Debugging and hot reload
The plugin debugging harness lets you debug plugin logic in a plain browser (Chromium) without starting Tauri or the Rust backend.Quick start
Recommended: just useqomicex dev (plugins inside the repo automatically use harness mode):
InIf Playwright is not installed, you are prompted to install it:pnpm run harness -- hello-plugin, the--forwards arguments to pnpm; you can also runnode scripts/harness/run.mjs hello-plugindirectly.
Architecture
Components
Stub endpoints
Custom mock data
settings, systemInfo, proxyResponse, modpackInstall, downloadStart, downloadProgress, fileRead, execCommand, wasmList, pluginStates ({ "插件id": "active" }).
Breakpoint debugging
pnpm run harness -- hello-plugin --headed(headed mode)- Press F12 in the browser to open DevTools
- The plugin renders inside an iframe (sandbox
sandbox="allow-scripts", opaque origin) — select the iframe in the DevTools Elements panel, then switch the Console context dropdown to that iframe’s document and call__PLUGIN_API__.call('getSettings')directly to verify the bridge and the stub return value - In the Sources panel, set a breakpoint on
handleApiCallinsrc/plugins/sandbox.tsto step through the whole__PLUGIN_API__postMessage →executePluginMethod→createPluginBridgechain
codegen does not inject the Tauri mock, so it only suits inspecting page rendering or exercising UI interactions; to verify bridge APIs, use the harness.
Hot reload
- Watches
src/,index.html,theme.css,overlay.html, andvite.config.tsunderplugins-dev/{pluginId}/ - A change → 400ms debounce → run the build command in the plugin directory (defaults to
pnpm run build, override with--build-cmd) → on a successful build →page.reload()reloads the whole page and remounts the plugin iframe - A failed build does not reload the page; stderr goes to the terminal, so you can keep editing and watching
CLI integration
Inside the repo,qomicex dev detects the harness and invokes it (see qomicex CLI reference):
Limitations and caveats
- Chromium ≠ WebView2: rendering and compositing can differ (backdrop-filter, for example), so web debugging conclusions need re-checking in real Tauri/WebView2
- The harness is a read-only sandbox: every stub returns fake data or 400 for real data writes, instance launches, and real downloads; do not trigger real business actions from a plugin
- Exit cleanup: after
Ctrl+C, run.mjs kills the stub and Vite it spawned; if you started Vite(:1420) yourself first (pnpm run dev), the harness reuses it and does not kill that process on exit - iframe sandbox:
sandbox="allow-scripts"withoutallow-same-origin, so a synchronouswhile(true)inside the iframe can still block the shared renderer process (matching real WebView2 behavior) - Plugins depend on
@qomicex/plugin-ui, so itsdist/must already be built (pnpm --filter @qomicex/plugin-ui build)