mirror of
https://github.com/stablyai/orca.git
synced 2026-10-05 16:02:22 +00:00
* refactor(host): route app paths and version through an AppEnvironment port
`app.getPath('userData')` is the single largest Electron coupling in the main
process — 37 call sites — and it is one of the things stopping the Orca runtime
from booting on plain Node. Give it the same treatment as SecretStore.
- `src/shared/app-environment.ts` — the port plus a settable registry, covering
the members the runtime's module graph actually reads: paths, app path,
version, packaged flag, shutdown hook, exit, and Chromium process metrics.
`getAppEnvironment()` throws until installed, for the same reason the secret
store does: a silent default resolves `userData` to the wrong directory and the
caller writes real state there before anyone notices. No `node:` imports,
because `src/shared/**` is in the web build graph.
- `src/main/host/electron-app-environment.ts` — the desktop adapter, a
pass-through to `electron.app`.
- 9 modules migrated: telemetry, opencode/mimo/pi hook services,
terminal-history-paths, terminal-scrollback-snapshots, cli-installer,
clipboard-image-temp-file, memory/collector.
Deliberately NOT migrated: `src/main/browser/**`. That cluster is Chromium-
adjacent by nature — cookie jars, download destinations, offscreen pages — and a
Node backend does not ship it at all, so porting it buys nothing and churns
heavily-mocked suites. Also left alone for now: the call sites that additionally
touch `app.asar` path literals or `app.setName`, which need more than a
mechanical swap.
`getAppMetrics` stays on the port rather than being injected because
memory/collector.ts is its only caller and reads it from module scope; a Node
host returns [], having no Chromium processes to measure.
Test wiring: the secret-store setup file becomes `vitest-host-ports-setup.ts` and
installs both ports, exporting `fakeAppEnvironment`/`installFakeAppEnvironment`
so suites needing one specific member state only that instead of restating all
seven — which is boilerplate, and had pushed one suite past the max-lines budget.
Verified: 159 files / 1651 tests pass across every touched area; `tsc` clean on
both the node and web projects; `oxlint` clean.
* fix(typecheck): list the vitest host-ports setup in the node project
Three suites import `installFakeAppEnvironment` from config/scripts, but that
directory is outside tsconfig.node.json's include list, so composite typecheck
failed with TS6307. Listing the one file matches how this config already pins
individual files it needs.
Local `tsc --composite false` does not reproduce this — only `pnpm typecheck`
does, which is what CI runs.
* refactor(host): drop two unused AppEnvironment exports
hasAppEnvironment() and resetAppEnvironmentForTests() had zero callers. The
secret-store equivalents are used, so these were mirror-symmetry rather than
need; add them back when something actually needs them.
* test(terminal-history): install the AppEnvironment fake instead of mocking electron
These three suites mocked `electron.app.getPath` to point at a fixture dir. The
production module now reads the port, so the mock was inert and the global test
default's temp dir won — which broke the WSL path assertions and every deletion
count.
Found by a full-suite run, not by the targeted checks around the migrated modules,
which is the argument for running the whole suite on a refactor this wide.
* test(host-ports): remove the per-environment temp dir on teardown
The setup allocated a mkdtemp directory at module scope, which vitest evaluates
once per test *environment* — one per test file, not one per worker. Nothing
removed them, so a full 6,000-file run left thousands behind.
Proven: with an isolated TMPDIR, a three-file run previously added directories and
now leaves zero.
* fix(app-environment): anchor the installed environment to a realm global
Same reason as the SecretStore: vi.resetModules() rebuilds the module registry,
and an environment installed before the reset read back as uninstalled.
43 lines
1.5 KiB
TypeScript
43 lines
1.5 KiB
TypeScript
import { resolve } from 'node:path'
|
|
import { defineConfig } from 'vitest/config'
|
|
|
|
const windowsTestWorkerOptions = process.platform === 'win32' ? { maxWorkers: 4 } : {}
|
|
|
|
export default defineConfig({
|
|
define: {
|
|
ORCA_FEATURE_WALL_ENABLED: 'true'
|
|
},
|
|
resolve: {
|
|
alias: {
|
|
'@renderer': resolve('src/renderer/src'),
|
|
'@': resolve('src/renderer/src')
|
|
}
|
|
},
|
|
test: {
|
|
environment: 'node',
|
|
// Why: Node 26's undefined Web Storage globals prevent Vitest from installing happy-dom's.
|
|
// Why --expose-gc: retention tests need a deterministic collection point to measure what a queue really holds.
|
|
execArgv: ['--no-experimental-webstorage', '--expose-gc'],
|
|
// Why: happy-dom drops MutationObserver callbacks on GC; keep them alive like a browser does.
|
|
setupFiles: [
|
|
resolve('config/scripts/happy-dom-mutation-observer-retention.ts'),
|
|
resolve('config/scripts/vitest-host-ports-setup.ts')
|
|
],
|
|
include: [
|
|
'src/**/*.test.ts',
|
|
'src/**/*.test.tsx',
|
|
'config/scripts/**/*.test.ts',
|
|
'config/scripts/**/*.test.mjs',
|
|
'tests/tools/**/*.test.mjs',
|
|
'tests/e2e/**/*.unit.test.ts'
|
|
],
|
|
// Why: the full suite runs heavy TS transforms plus real git/http fixtures;
|
|
// the Vitest 5s defaults are too tight for the slowest integration cases.
|
|
hookTimeout: 60_000,
|
|
testTimeout: 30_000,
|
|
// Why: Windows process and shell startup are slower under full-suite load;
|
|
// macOS/Linux keep Vitest's default worker parallelism.
|
|
...windowsTestWorkerOptions
|
|
}
|
|
})
|