Skip to content
Merged
Show file tree
Hide file tree
Changes from 34 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5c979ad
feat(ci): run JS tests in CI, add `npm run check` in ws root
ethernet8023 Jul 3, 2026
0f8e26e
fix(js): fix long-time broken tests
ethernet8023 Jul 4, 2026
35ac92a
feat(agent): ban regex-scanning source code in tests
ethernet8023 Jul 8, 2026
644b3ef
test(desktop): extract hiddenWindowsChildOptions + stopBackendChild f…
ethernet8023 Jul 8, 2026
4b72620
test(desktop): extract Windows hermes-resolution helpers for real uni…
ethernet8023 Jul 8, 2026
ba56a3c
test(desktop): extract profile-delete routing decision for real unit …
ethernet8023 Jul 8, 2026
ea2cf4c
test(desktop): fix relative import in oauth-net-request.test.ts, drop…
ethernet8023 Jul 8, 2026
0e7b3b6
test(tui): extract cursor-layout + fast-echo helpers for real unit tests
ethernet8023 Jul 8, 2026
a343c7e
test(desktop): handful of broken tests changed to match intended beha…
ethernet8023 Jul 8, 2026
50f8425
cleanup(ci): make all tsbuildinfo gitignored
ethernet8023 Jul 9, 2026
269e9bf
test(desktop): rename panes test to describe its behavior
ethernet8023 Jul 8, 2026
24bb63e
change(desktop): add vitest config for the desktop app
ethernet8023 Jul 8, 2026
0d953a0
test(desktop): warn when using `document` in tsx tests
ethernet8023 Jul 8, 2026
525d0c0
test(desktop): fix attachment list test not querying the selector cor…
ethernet8023 Jul 8, 2026
d2f935d
test(desktop): stub CSS global in .test.tsx files
ethernet8023 Jul 8, 2026
d1b368f
test(desktop): fix session preview registry tests fails
ethernet8023 Jul 8, 2026
1b95673
cleanup(desktop): lint&fmt all
ethernet8023 Jul 9, 2026
90a3ad4
change(ci/desktop): move desktop app build into check job
ethernet8023 Jul 9, 2026
e227c42
cleanup(desktop): remove 'use strict' in ts & mjs
ethernet8023 Jul 9, 2026
f616c2a
cleanup(desktop): note that ts imports don't need extension in one co…
ethernet8023 Jul 9, 2026
94c8aa9
test(desktop): fix a handful of broken tests
ethernet8023 Jul 9, 2026
dc03b83
test(desktop): fix React act() warnings across all desktop test files
ethernet8023 Jul 9, 2026
65f73b3
fix(desktop): stage-native-deps falls back to electron-rebuild when n…
ethernet8023 Jul 9, 2026
79251d0
tests(tui): longer timeout for wrap ansi test
ethernet8023 Jul 9, 2026
bd0aba6
test(desktop): move node tests to vitest as well
ethernet8023 Jul 10, 2026
1b8f3f6
change(lint): don't ignore config files in eslint conf
ethernet8023 Jul 10, 2026
d8337da
test(desktop): replace windows-child-process.test.ts regex with real …
ethernet8023 Jul 10, 2026
176664f
feat(ci): load npm workspaces from package.json
ethernet8023 Jul 10, 2026
788d948
test(desktop): convert zoom source-regex test to behavior test
ethernet8023 Jul 10, 2026
a3cf203
test(desktop): fix remaining act() warnings in gateway-connecting-ove…
ethernet8023 Jul 10, 2026
8c94719
feat(ci): show passed/failed jobs in summary
ethernet8023 Jul 10, 2026
2af3df0
test(desktop): run scripts/ tests in vitest
ethernet8023 Jul 13, 2026
dcd21e7
fix(desktop): prevent staging wrong-platform node-pty binary for cros…
ethernet8023 Jul 13, 2026
08b8044
fix(ci): fail closed when workspace matrix discovery produces empty list
ethernet8023 Jul 13, 2026
ede5024
fix(desktop): recognize little-endian Mach-O magic in native binary c…
ethernet8023 Jul 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/detect-changes/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ outputs:
description: Run Python tests / ruff / ty / windows-footguns.
value: ${{ steps.classify.outputs.python }}
frontend:
description: Run the TypeScript typecheck matrix + desktop build.
description: Run the TypeScript testing matrix + desktop build.
value: ${{ steps.classify.outputs.frontend }}
docker_meta:
description: Docker setup and meta files have changed.
Expand Down
22 changes: 13 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ jobs:
with:
event_name: ${{ needs.detect.outputs.event_name }}

typecheck:
name: TypeScript
js-tests:
name: JS & TS checks
needs: detect
if: needs.detect.outputs.frontend == 'true'
uses: ./.github/workflows/typecheck.yml
uses: ./.github/workflows/js-tests.yml

docs-site:
name: Docs Site
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
needs:
- tests
- lint
- typecheck
- js-tests
- docs-site
- history-check
- contributor-check
Expand All @@ -154,14 +154,18 @@ jobs:
steps:
- name: Evaluate job results
env:
RESULTS: ${{ toJSON(needs.*.result) }}
NEEDS: ${{ toJSON(needs) }}
run: |
echo "$RESULTS" | python3 -c "
echo "$NEEDS" | python3 -c "
import json, sys
results = json.load(sys.stdin)
failed = [r for r in results if r == 'failure']
needs = json.load(sys.stdin)
failed = [name for name, info in needs.items() if info['result'] == 'failure']
for name, info in sorted(needs.items()):
result = info['result']
icon = '✅' if result in ('success', 'skipped') else '❌'
print(f'{icon} {name}: {result}')
if failed:
print(f'::error::{len(failed)} job(s) failed')
print(f'::error::{len(failed)} job(s) failed: {\", \".join(failed)}')
sys.exit(1)
print('All checks passed (or were skipped)')
"
Expand Down
49 changes: 49 additions & 0 deletions .github/workflows/js-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# .github/workflows/js-tests.yml
name: JS Tests

on:
workflow_call:

jobs:
workspaces:
name: List npm workspaces
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.set-matrix.outputs.packages }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
cache: npm
- uses: ./.github/actions/retry
with:
command: npm ci --ignore-scripts
- id: set-matrix
run: |
PACKAGES=$(npm query .workspace | jq -c '[.[].location]')
if [ "$PACKAGES" = "[]" ] || [ -z "$PACKAGES" ]; then
echo "::error::Workspace discovery produced an empty package list — refusing to emit a zero-length matrix (would skip all JS/TS checks silently)."
exit 1
fi
echo "packages=$PACKAGES" >> "$GITHUB_OUTPUT"

check:
name: Typecheck & Test
runs-on: ubuntu-latest
needs: workspaces
strategy:
matrix:
package: ${{ fromJson(needs.workspaces.outputs.packages) }}
fail-fast: false # report all failures, not just the first one
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
cache: npm
- uses: ./.github/actions/retry
with:
# --ignore-scripts: TS & tests don't need native deps
command: npm ci --ignore-scripts
- run: npm run --prefix ${{ matrix.package }} check
51 changes: 0 additions & 51 deletions .github/workflows/typecheck.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ hermes_cli/web_dist/
apps/desktop/build/
apps/desktop/dist/
apps/desktop/release/
apps/desktop/*.tsbuildinfo
*.tsbuildinfo

# Web UI assets — synced from @nous-research/ui at build time via
# `npm run sync-assets` (see web/package.json).
Expand Down
55 changes: 55 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1354,3 +1354,58 @@ not the specific names.

Reviewers should reject new change-detector tests; authors should convert
them into invariants before re-requesting review.

### Never read source code in tests

A test that reads a source file's text is testing *the shape of the
source code*, not its behavior. This is a hard antipattern, banned outright.
Any test that reads a .py, .ts, .tsx, etc., file is suspect.

**Why it's actively harmful, not just weak:**

- It passes when the implementation is subtly broken (the regex matches a
call site that exists but is wired wrong) and fails when a correct
refactor changes formatting, variable names, or control flow with
identical runtime behavior. Both directions of failure are wrong.
- It can't be run against a built/bundled/minified artifact, so it silently
stops testing anything the moment code moves, gets renamed, or a
dependency reformats it.
- It actively blocks refactors: reviewers see "keeps a pattern intact" tests
fail during pure structural cleanup with no behavior change, and either
hand-wave the failure (dangerous) or waste time updating regexes that add
nothing (waste).
- It gives false confidence. a green suite full of source-regex tests
looks like coverage but has never once executed the code path it claims
to guard.

**Do not write:**

```ts
const source = fs.readFileSync(path.join(__dirname, 'main.ts'), 'utf8')

test('backend spawn hides the Windows console', () => {
assert.match(source, /spawn\(\s*backend\.command,\s*backend\.args[\s\S]{0,300}hiddenWindowsChildOptions/)
})
```

**Do write — extract the logic into a small pure/DI-testable function and
call it for real:**

```ts
// backend-spawn.ts
export function hiddenWindowsChildOptions(options: SpawnOptionsLike = {}, isWindows = process.platform === 'win32') {
if (!isWindows || 'windowsHide' in options) return options
return { ...options, windowsHide: true }
}

// backend-spawn.test.ts
test('windowsHide defaults to true on Windows, is left alone elsewhere', () => {
assert.equal(hiddenWindowsChildOptions({}, true).windowsHide, true)
assert.equal(hiddenWindowsChildOptions({}, false).windowsHide, undefined)
assert.equal(hiddenWindowsChildOptions({ windowsHide: false }, true).windowsHide, false)
})
```

If the logic lives inline in a god-file (`main.ts`, `cli.py`,
`gateway/run.py`) and extracting it feels disruptive: that's the actual
signal to do the extraction, not to regex around it.
3 changes: 2 additions & 1 deletion apps/bootstrap-installer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"tauri:dev": "tauri dev",
"tauri:build": "tauri build",
"tauri:build:debug": "tauri build --debug",
"typecheck": "tsc -p . --noEmit"
"typecheck": "tsc -p . --noEmit",
"check": "npm run typecheck"
},
"dependencies": {
"@nous-research/ui": "0.16.0",
Expand Down
55 changes: 55 additions & 0 deletions apps/desktop/electron/backend-child.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* backend-child.ts
*
* Windows-aware teardown for the desktop's managed backend child process.
*
* Node's `child.kill()` only signals the direct child. On Windows a backend
* that spawned its own grandchildren (a `hermes` REPL, a pty terminal
* session, the gateway) survives a plain SIGTERM and keeps files (e.g. the
* venv shim) locked. So on Windows we tree-kill via `forceKillProcessTree`;
* everywhere else a plain SIGTERM is correct and sufficient (POSIX has no
* mandatory locks, and the backend is not spawned detached so there's no
* process-group to negative-pid-kill).
*
* Extracted into its own dependency-free module (no electron import) so the
* SIGTERM-vs-tree-kill branching can be asserted directly with a fake child
* object and a spy `forceKillProcessTree`, instead of grepping main.ts source
* text for the function body.
*/

export interface StopBackendChildDeps {
/** Defaults to the real platform check; injectable for tests. */
isWindows?: boolean
/** Windows tree-kill implementation (real: taskkill /T /F via execFileSync). */
forceKillProcessTree: (pid: number) => void
}

export interface KillableChild {
pid?: number | null
killed?: boolean
kill: (signal: string) => void
}

/**
* Stop a managed child process, choosing the right strategy for the platform.
* No-ops silently if `child` is falsy, already killed, or the kill attempt
* throws (the process may already be gone) -- mirrors the original inline
* best-effort semantics in main.ts.
*/
export function stopBackendChild(child: KillableChild | null | undefined, deps: StopBackendChildDeps) {
if (!child || child.killed) {
return
}

const isWindows = deps.isWindows ?? process.platform === 'win32'

try {
if (isWindows && Number.isInteger(child.pid)) {
deps.forceKillProcessTree(child.pid as number)
} else {
child.kill('SIGTERM')
}
} catch {
// Already gone.
}
}
5 changes: 2 additions & 3 deletions apps/desktop/electron/backend-command.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'

import assert from 'node:assert/strict'
import test from 'node:test'

import { test } from 'vitest'

import { dashboardFallbackArgs, serveBackendArgs, sourceDeclaresServe } from './backend-command'

Expand Down
2 changes: 0 additions & 2 deletions apps/desktop/electron/backend-command.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict'

// Backend subcommand routing for the desktop-managed Hermes process.
//
// The desktop app launches its own headless backend via `hermes serve` — it
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/electron/backend-env.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import assert from 'node:assert/strict'
import path from 'node:path'
import test from 'node:test'

import { test } from 'vitest'

import {
appendUniquePathEntries,
Expand Down
3 changes: 3 additions & 0 deletions apps/desktop/electron/backend-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ function appendUniquePathEntries(entries, { delimiter = path.delimiter } = {}) {
if (!entry) {
continue
}

const parts = Array.isArray(entry) ? entry : String(entry).split(delimiter)

for (const part of parts) {
if (!part || seen.has(part)) {
continue
}

seen.add(part)
ordered.push(part)
}
Expand Down Expand Up @@ -77,6 +79,7 @@ function normalizeHermesHomeRoot(hermesHome, { pathModule = pathModuleForPlatfor
if (!hermesHome) {
return hermesHome
}

const resolved = pathModule.resolve(String(hermesHome))
const parent = pathModule.dirname(resolved)

Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/electron/backend-probes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import assert from 'node:assert/strict'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import test from 'node:test'

import { test } from 'vitest'

import { canImportHermesCli, hermesRuntimeImportProbe, verifyHermesCli } from './backend-probes'

Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/electron/backend-ready.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { EventEmitter } from 'node:events'
import fs from 'node:fs'
import os from 'node:os'
import path from 'node:path'
import test from 'node:test'

import { test } from 'vitest'

import {
DEFAULT_PORT_ANNOUNCE_TIMEOUT_MS,
Expand Down
4 changes: 4 additions & 0 deletions apps/desktop/electron/backend-ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ function waitForDashboardPort(child, timeoutMs = resolvePortAnnounceTimeoutMs())
if (done) {
return
}

done = true
clearTimeout(timer)
child.stdout.off('data', onData)
Expand Down Expand Up @@ -130,12 +131,14 @@ function waitForDashboardReadyFile(readyFile, child, timeoutMs = resolvePortAnno
if (done) {
return
}

done = true
clearTimeout(timer)

if (interval) {
clearInterval(interval)
}

child.off('exit', onExit)
child.off('error', onError)
}
Expand Down Expand Up @@ -171,6 +174,7 @@ function waitForDashboardReadyFile(readyFile, child, timeoutMs = resolvePortAnno
if (typeof interval.unref === 'function') {
interval.unref()
}

check()
})
}
Expand Down
3 changes: 2 additions & 1 deletion apps/desktop/electron/bootstrap-platform.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import assert from 'node:assert/strict'
import test from 'node:test'

import { test } from 'vitest'

import {
bundledRuntimeImportCheck,
Expand Down
Loading
Loading