Skip to content

feat: launch the backend silently at startup, drop the visible startup tab - #1

Merged
Cle2ment merged 1 commit into
masterfrom
feat/silent-startup-launch
Oct 25, 2026
Merged

Cle2ment merged 1 commit into
masterfrom
feat/silent-startup-launch

Conversation

@Cle2ment

@Cle2ment Cle2ment commented Oct 25, 2026 •

Copy link
Copy Markdown
Owner

Description

Every backend launch — the startup health-check launch and every 60s-supervision (re)launch alike — now spawns node directly on the resolved CLI entry. The visible Windows Terminal startup tab (wt.exe -w 0 nt --title agentmemory …) is removed.

 launch(reason)                      // startup | recovery
   resolve newest dist/cli.mjs (npx cache / global install)
-  if win32 && startup: spawnVisibleTab(wt.exe … node cli)   // visible, takes focus once
-  else:               spawnSilent(node cli)                 // detached, stdio ignore, windowsHide
+  spawnSilent(node cli)                                      // both modes, identical, always silent

Why the 4.2.0 rollback to a visible tab was misattributed. The console flashes seen at OpenCode startup come from OpenCode's own local-MCP spawn mechanism, not from this plugin:

  • Live process-tree audit of a running OpenCode server on Windows: every local MCP server is spawned as cmd.exe /d /s /c "npx …" with its own conhost.exe (sciverse, playwright, @agentmemory/mcp, zai-vision, codegraph, rea, officecli, uvx ×2, …), and every OpenCode server instance spawns the whole local fleet → repeated console-window allocations at startup and on MCP restarts.
  • The backend this plugin spawns (node → cli.mjs → iii.exe, direct child of opencode.exe) has no cmd.exe and no conhost anywhere in its tree — this launch path cannot allocate a window.
  • Upstream confirmation (anomalyco/opencode, verified at v2.1.4 and dev): local MCP servers spawn through cross-spawn (packages/util/src/cross-spawn-spawner.ts), which rewrites npx → cmd.exe /d /s /c "npx …". The background service opencode.exe serve --service is started detached and ends up without a console, so every console-subsystem child allocates a NEW console on start — windowsHide on the child spawn does not prevent that allocation. Open upstream issues with matching traces: #51887 · #52266 · #52281 · #56704; the fix PR #52594 ("give the Windows service a hidden console") was closed unmerged on 2026-10-12, so v2.1.4 still ships the behavior.

Startup launches still do not count toward the failure backoff (a failed startup is retried ~90s later, not 180s). Launch diagnostics move entirely to the plugin warn log plus npx @agentmemory/agentmemory doctor (the tab's closeOnExit: graceful error-visibility is gone with the tab).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Chore (build, CI, dependencies)

Checklist

  • npm run typecheck passes
  • npm run build succeeds
  • Documentation has been updated (if applicable)
  • I have read the CONTRIBUTING.md guidelines
  • My commits follow the Conventional Commits format

Evidence

Before (4.2.1): a startup launch (backend down when the plugin loads) runs wt.exe -w 0 nt --title agentmemory … node <cli> → a visible Windows Terminal tab appears and takes focus once.

After (this branch) — backend stopped via npx @agentmemory/agentmemory stop, then the freshly built plugin loaded through a standalone harness:

[harness] loaded dist/agentmemory-launcher.js, id=agentmemory-launcher
[agentmemory-launcher] info: health-check loop started
[agentmemory-launcher] info: launching backend silently via 0.9.30 (…\@agentmemory\agentmemory\dist\cli.mjs)
HARNESS node.exe [52248]
  node.exe [37964] node …\dist\cli.mjs        ← no cmd.exe, no conhost in the tree
    iii.exe  [52076] …iii.exe --config …      ← spawned hidden by the CLI itself
→ GET /agentmemory/livez = 200 (backend restored)
[harness] cleanup done, exiting                // unload cleanup exercised

Merge danger: two-way door — revert restores the 4.2.x two-mode behavior; no persisted state changes. Blast radius is the Windows launch UX only: supervision loop, lock/backoff logic, and non-Windows paths are untouched (spawnSilent is the recovery path already shipped since 4.1.0).

Related Issues

Upstream (root cause of the flashing this PR's history was blamed on): anomalyco/opencode #51887 · #52266 · #52281 · #56704 · closed-unmerged fix PR #52594.

Screenshots (if applicable)

N/A — evidence is process-tree based (no window is the point).

…p tab

The startup health-check launch now takes the exact path recovery launches
have used since 4.1.0: resolve the newest dist/cli.mjs and spawn node
directly on it - no wt.exe, no terminal tab, no focus steal, ever.

The 4.2.0 rollback to a visible startup tab was triggered by console
flashes at OpenCode startup that are actually caused by OpenCode's own
local-MCP spawns (cmd.exe /d /s /c npx ... allocates a console per
server, and every OpenCode server instance spawns the whole local
fleet). Live process-tree audits show the plugin's spawned tree
(node -> cli.mjs -> iii.exe) carries no cmd.exe/conhost at all.

Startup launches still do not count toward the failure backoff, and
launch diagnostics stay in the plugin log (warn) plus agentmemory doctor.
@Cle2ment
Cle2ment merged commit 24ea7aa into master Oct 25, 2026
3 checks passed
@Cle2ment
Cle2ment deleted the feat/silent-startup-launch branch October 25, 2026 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant