memorix icon indicating copy to clipboard operation
memorix copied to clipboard

Windows: console window popup/flicker on every CLI invocation (v1.3.0)

Open skywalker-35 opened this issue 4 months ago • 2 comments

Summary

On Windows, every memorix CLI invocation causes multiple console window popups that flash and close instantly. This is disruptive when agents call memorix memory store frequently.

Environment

  • OS: Windows 11 (win32)
  • Node: v22.x (ESM)
  • memorix: 1.3.0 (installed via npm install -g memorix)
  • Shell: PowerShell 7 (pwsh)

Root Cause

There are two distinct causes of window popups:

1. Missing windowsHide: true on execSync calls (multiple locations)

Multiple execSync/spawnSync calls in dist/cli/index.js lack the windowsHide: true option. On Windows, execSync with a string command runs through cmd.exe, which creates a visible console window.

Key offenders observed during memorix memory store (traced via child_process monkey-patch):

Line (approx) Call Times per memory store
~13211 execSync("git ... remote get-url origin") 8 times
~13182 execSync("git ... rev-parse --show-toplevel") 1+
~49689 execSync3("git ls-files ...") varies
~49724 execSync3("git log ...") varies
~89186 execSync8("git rev-parse ...") varies
~35553 execSync2("pwsh --version") 1
~82492-82543 execSync4(git ...) (4 calls) varies
~83618/83654 execSync5("taskkill ...") varies
~5 (entry point) spawnSync heap-size restart every invocation

2. detached: true + windowsHide: true conflict in launchDetachedVectorBackfill

dist/cli/index.js line ~27033:

const child = spawn2(process.execPath, [runnerPath], {
  detached: true,
  stdio: "ignore",
  windowsHide: true   // ← has no effect with detached: true on Windows
});

On Windows, detached: true passes DETACHED_PROCESS to CreateProcess, which creates a new console for the child. windowsHide: true passes CREATE_NO_WINDOW, which tries to suppress console creation. These two flags conflict — the detached process still gets a visible console window that flashes briefly.

Reproduction

memorix memory store --text "test"

Observe: 7-8 console windows flash open and close instantly.

Running memorix status or memorix memory recent also triggers popups (fewer, but still present).

Impact

Agents that call memorix memory store frequently cause dozens of window popups per session, making the desktop experience very disruptive on Windows.

Suggested Fix

  1. Add windowsHide: true to ALL child_process calls — audit every execSync, spawnSync, spawn, exec, execFile call in the codebase
  2. For launchDetachedVectorBackfill: On Windows (process.platform === 'win32'), either:
    • Remove detached: true and rely on stdio: 'ignore' + child.unref() alone, or
    • Use windowsHide: true WITHOUT detached: true on Windows
  3. For the entry-point restart (line 5): Add windowsHide: true to the options

skywalker-35 avatar Jul 31 '26 08:07 skywalker-35

Thanks for the very thorough report. You were right about both root causes. I audited Memorix and bundled memcode process launches instead of only patching the Git calls you listed.

On Windows, normal child processes now hide their windows, and the vector backfill plus local background service no longer use detached Windows processes that can create a second console. The durable queue still keeps retry behavior intact.

This is out in 1.3.1 now, with Windows-specific regression coverage and a full Windows CI run. Please update with:

npm install -g [email protected]

and let me know if you can still reproduce any flash.

AVIDS2 avatar Jul 31 '26 10:07 AVIDS2

Confirmed fixed in 1.3.1 on Windows 11. No more console window popups during \memorix memory store. Thanks for the fast fix and the Windows CI addition!

skywalker-35 avatar Aug 01 '26 08:08 skywalker-35