mirror of
https://github.com/NeuralNomadsAI/CodeNomad.git
synced 2026-11-17 05:49:28 +00:00
## Summary Updates the Tauri desktop host from 2.10 to the current 2.12 release. The crate family (tauri, tauri-build, tauri-runtime-wry, wry, tao and the plugins) and `@tauri-apps/*` are aligned; the exact versions are in `packages/tauri-app/Cargo.toml`, `Cargo.lock` and the `package.json` files. `Cargo.toml` minimums now equal the qualified versions. Crates that follow the updated family also move: webview2-com (was pinned exactly) and windows-core with Wry, rfd with the dialog plugin. A Dependabot `cargo` entry for `/packages/tauri-app` now proposes Tauri crate updates weekly against `dev`. It allows `tauri`, `tauri-build`, `tauri-plugin-*`, `tauri-runtime*` (including the refcount test fixture's direct requirements) and `wry` (lock-only); minor and patch updates arrive grouped, each major separately. Tao is excluded, because it is vendored and patched. A new check fails a PR whose lock no longer resolves a vendored copy, so an update can't silently drop the local fixes. ## Changes that apply - **tauri-macros 2.7, second hidden macro per command:** `client_state.rs` re-exports commands explicitly and now also re-exports the new names. - **Tao 0.37, logout exit:** Tao calls `std::process::exit(0)` when its hidden window receives `WM_ENDSESSION`. Windows can deliver it there before our window, which would skip the logout flush. Session-end handling moved to `windows_session_end.rs` and is installed on Tao's hidden window too, so client state is flushed and the backend stopped before Tao exits. - **Tauri 2.12.2, macOS restart through `open -n`:** that path drops the environment, so a launch pinned with `CODENOMAD_PROFILE` or `CLI_CONFIG` would restart in another profile after a developer-mode, profile or update restart. The macOS restart now launches the bundle's executable directly at the same point (`macos_relaunch.rs`), keeping the environment. Like Tauri's own fallback, it takes the executable name from `Info.plist` (`CFBundleExecutable`), so an update that renames the executable still restarts. It uses the current binary outside a bundle or when that value is missing or unsafe. - **Tao 0.36, IME rewrite:** the IME scenario of the input-deadlock regression no longer applies and is removed. - **Tauri 2.11, macOS renderer termination:** when the app registers no `on_web_content_process_terminate` hook, as here, the runtime reloads a crashed macOS renderer itself. The reload goes through the page-load path, which resets the badge count; `NOTIFICATION_BADGES.md` and `notification_badge_lifetime.rs` describe this. The notification plugin's Windows permission fix needs no change here. The other 2.11–2.12 changes (ACL and scope fixes, `on_new_window` threading, window creation from other threads, asset protocol, updater `allowDowngrades` and stricter signature checks, fs plugin fixes) were checked and don't affect this code. ## Vendored crates - **tao:** the upstream releases now include the input-deadlock fix (tao#1215) and the macOS zoom fix (tao#1182), so those backports are gone. The Windows runner refcount correction is still needed (tauri#15408 open, tao#1290/#1334 declined), so it is re-applied to the new Tao with its SHA-256 and patch. Its negative control still crashes; the corrected build passes 5/5. - **tauri-plugin-updater:** the new release still releases client state before `ShellExecuteW`, so the success-only handoff is re-applied. Cargo can't test a patched crate with dev-dependencies, so CI's `cargo test -p tauri-plugin-updater` step is replaced by `scripts/test-tauri-updater-handoff.mjs`, which tests a temporary copy with the crate's own lockfile. - `packages/tauri-app/scripts/vendored-patches.test.mjs` (CI Linux job) fails when `Cargo.lock` no longer resolves a vendored copy. The regression scripts read the vendored Tao version from `cargo metadata`. The input-deadlock and macOS window negative controls pin the last unfixed Tao; the runner-refcount negative control reverts the counter in a temporary copy of the vendored Tao. ## Docs `dev-docs/RUNTIME_MAINTENANCE.md` (Dependabot for the Tauri crates, re-qualifying vendored crates, system-managed WebView2/WKWebView/WebKitGTK, `@tauri-apps/*` kept on the crates' minor), `TAURI_UPDATER.md`, `DESKTOP_DATA_PROFILES.md`, `NOTIFICATION_BADGES.md` and `vendor/README.md`. `docs/help` is unchanged; nothing user-facing changes. ## Validation - **Windows:** - `cargo check --workspace --all-targets`, and `cargo test --locked -- --test-threads=1` in `src-tauri`: 313 pass, including the CLI-signed updater download and tamper rejection. - Input deadlock: 4/4 reproduced on the old Tao, 4/4 pass on the new one. Refcount: reproduced, then 5/5 pass. Updater handoff and zoom (17/17) pass. - Packaging invariants 27/27; UI and root typechecks clean. - The release `npm run build` produces the NSIS installer, and `smoke:resources` passes. - Hidden smoke: the release executable ran on a separate, never-shown desktop with its own profile. It reached ready, and a simulated logout flushed client state, stopped the backend and exited 0. - **Ubuntu 24.04 VM:** `cargo test` 303 pass. The CI-style AppImage launches, renders the UI, and on close stops the backend and unmounts cleanly. - **macOS Intel VM:** `cargo test` 302 pass, including the `Info.plist` relaunch resolution tests; the window regression and its negative control pass. - **Not run end to end:** a real Windows logout, a signed-installer update, and a packaged macOS restart (the restart is unit-tested). Apple Silicon is covered by CI only.
100 lines
5.8 KiB
JavaScript
100 lines
5.8 KiB
JavaScript
// Real Wry handle cloning. No CodeNomad profile, backend, page or shared daemon.
|
|
import assert from "node:assert/strict"
|
|
import { spawnSync } from "node:child_process"
|
|
import { cp, mkdir, mkdtemp, readFile, rm, writeFile } from "node:fs/promises"
|
|
import os from "node:os"
|
|
import path from "node:path"
|
|
import { fileURLToPath } from "node:url"
|
|
|
|
assert.equal(process.platform, "win32", "Run this native regression on Windows")
|
|
const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..")
|
|
const workspace = path.join(root, "packages/tauri-app")
|
|
const fixture = "tests/windows-runner-refcount"
|
|
const target = path.resolve(process.env.CARGO_TARGET_DIR || path.join(workspace, "target"))
|
|
const env = { ...process.env, CARGO_TARGET_DIR: target }
|
|
delete env.NODE_OPTIONS
|
|
delete env.CODENOMAD_NATIVE_PARENT
|
|
const binary = path.join(target, "release/codenomad-windows-runner-fixture.exe")
|
|
|
|
function cargo(args, cwd = workspace) {
|
|
const result = spawnSync("cargo", args, { cwd, env, encoding: "utf8", timeout: 600_000, maxBuffer: 8 * 1024 * 1024, windowsHide: true })
|
|
assert.equal(result.error, undefined, String(result.error))
|
|
assert.equal(result.status, 0, result.stdout + result.stderr)
|
|
return result.stdout
|
|
}
|
|
function run(fixed, count) {
|
|
let crashes = 0
|
|
for (let index = 0; index < count; index++) {
|
|
const result = spawnSync(binary, [], { env, encoding: "utf8", timeout: 35_000, windowsHide: true })
|
|
assert.equal(result.error, undefined, String(result.error))
|
|
assert.match(result.stdout, /START: concurrent Tauri runtime handle cloning/)
|
|
if (fixed) {
|
|
assert.equal(result.status, 0, result.stdout + result.stderr)
|
|
assert.match(result.stdout, /PASS: 800000 runtime handle clones and clean teardown/)
|
|
} else if (result.status !== 0) {
|
|
// Native heap/access failures, Rust's abort on an invalid Rc refcount, and
|
|
// the same faults raised inside a window-procedure callback (0xc000041d).
|
|
assert.ok([0xc000001d, 0xc0000005, 0xc0000374, 0xc0000409, 0xc000041d].includes(result.status >>> 0),
|
|
`Expected the native refcount failure, got ${result.status}: ${result.stdout}${result.stderr}`)
|
|
crashes++
|
|
} else {
|
|
// A refcount race can leak rather than free early. One surviving process
|
|
// is not a clean baseline; the series looks for a crash below.
|
|
assert.match(result.stdout, /PASS: 800000 runtime handle clones and clean teardown/)
|
|
}
|
|
console.log(`${fixed ? "fixed PASS" : result.status === 0 ? "negative control survived" : "negative control crash reproduced"} ${index + 1}/${count}: 0x${(result.status >>> 0).toString(16)} (${machine})`)
|
|
// One crash proves the reverted counter races on this machine.
|
|
if (!fixed && crashes) return
|
|
}
|
|
if (fixed) return
|
|
// The race is timing-dependent: some GitHub runners never hit it, so CI only
|
|
// warns. The counter-boundary and vendored-Tao checks still guard the fix, but
|
|
// corrected runs on such a machine are no timing evidence. Locally it fails.
|
|
const message = `Negative control did not reproduce the native race in ${count} processes (${machine})`
|
|
if (process.env.GITHUB_ACTIONS === "true") console.log(`::warning::${message}; corrected runs here are no timing evidence`)
|
|
else assert.fail(message)
|
|
}
|
|
const machine = `${os.cpus()[0]?.model.trim() ?? "unknown CPU"}, ${os.availableParallelism()} threads`
|
|
function replaceOnce(source, before, after) {
|
|
assert.equal(source.split(before).length, 2, `Expected one counter boundary: ${before}`)
|
|
return source.replace(before, after)
|
|
}
|
|
|
|
const metadata = JSON.parse(cargo(["metadata", "--locked", "--format-version", "1"]))
|
|
const tao = metadata.packages.filter(item => item.name === "tao")
|
|
assert.equal(tao.length, 1)
|
|
const vendoredTao = path.join(workspace, `vendor/tao-${tao[0].version}`)
|
|
assert.equal(path.resolve(tao[0].manifest_path), path.join(vendoredTao, "Cargo.toml"))
|
|
for (const name of ["tauri-runtime", "tauri-runtime-wry"]) {
|
|
assert.equal(metadata.packages.filter(item => item.name === name).length, 1, `The fixture must exercise the application's ${name}`)
|
|
}
|
|
|
|
if (process.argv.includes("--baseline")) {
|
|
const temporaryRoot = path.join(os.tmpdir(), "opencode")
|
|
await mkdir(temporaryRoot, { recursive: true })
|
|
const baseline = await mkdtemp(path.join(temporaryRoot, "tauri-runner-baseline-"))
|
|
try {
|
|
await cp(path.join(workspace, fixture), path.join(baseline, fixture), { recursive: true })
|
|
await cp(vendoredTao, path.join(baseline, "tao"), { recursive: true })
|
|
await cp(path.join(workspace, "Cargo.lock"), path.join(baseline, "Cargo.lock"))
|
|
const manifest = "src-tauri/examples/window_constraints_windows.manifest"
|
|
await mkdir(path.dirname(path.join(baseline, manifest)), { recursive: true })
|
|
await cp(path.join(workspace, manifest), path.join(baseline, manifest))
|
|
await writeFile(path.join(baseline, "Cargo.toml"), `[workspace]\nmembers = ["${fixture}"]\nresolver = "2"\n[patch.crates-io]\ntao = { path = "tao" }\n`)
|
|
// Reverse only this correction in a temporary copy. The rest of Tao, the
|
|
// dependencies and the public Wry API exercised remain identical.
|
|
const runner = path.join(baseline, "tao/src/platform_impl/windows/event_loop/runner.rs")
|
|
let source = await readFile(runner, "utf8")
|
|
source = replaceOnce(source, " sync::Arc,", " rc::Rc,")
|
|
source = replaceOnce(source, "= Arc<EventLoopRunner<T>>;", "= Rc<EventLoopRunner<T>>;")
|
|
await writeFile(runner, source)
|
|
const loopFile = path.join(baseline, "tao/src/platform_impl/windows/event_loop.rs")
|
|
await writeFile(loopFile, replaceOnce(await readFile(loopFile, "utf8"),
|
|
"let runner_shared = Arc::new(", "let runner_shared = std::rc::Rc::new("))
|
|
cargo(["build", "--release", "-p", "codenomad-windows-runner-fixture"], baseline)
|
|
run(false, 50)
|
|
} finally { await rm(baseline, { recursive: true, force: true }) }
|
|
}
|
|
|
|
cargo(["build", "--locked", "--release", "-p", "codenomad-windows-runner-fixture"])
|
|
run(true, 5)
|