Skip to content

emrg: gui — restore window.emrg.init() wiring (fix v0.2.81 GUI disconnect) + drop batch0Notice badge - #1036

Merged
argszero merged 2 commits into
masterfrom
feature/gui-init-wiring
Aug 27, 2026
Merged

emrg: gui — restore window.emrg.init() wiring (fix v0.2.81 GUI disconnect) + drop batch0Notice badge#1036
argszero merged 2 commits into
masterfrom
feature/gui-init-wiring

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

Fixes the v0.2.81 GUI disconnect bug (rant 2026-08-27T10:53:38): the React migration (Batch 5) dropped the window.emrg.init() call, so the GUI main process never connected to the daemon.

Root cause

  • Vanilla app.jsboot() called window.emrg.init() and used the return value to initialize config/sessions/open_sessions/model/connected.
  • The React DaemonBridgeProvider only subscribed to window.emrg.onEvent and wired sendMessage — it never called window.emrg.init().
  • main.js's ensureConnected() (the only path to the daemon websocket) is only triggered from emrg:init (line 296), saveSettings (903), and scheduleReconnect (1170). With no init call, ensureConnected() never ran → GUI never established the daemon connection → status {connected:true} was never broadcast → the UI stayed permanently disconnected.
  • Leftover batch0Notice "migration in progress" badge remained in the Shell header.

Changes

  1. lib/daemonBridge.ts — add InitResult type, init?() to DaemonBridgeDeps.emrg, and applyInit() on the bridge. applyInit merges connected (true only when config_exists && api_key_configured), serverId, model, evolutionCount, currentVersion, sessions, and openSessions into the store (matching vanilla boot semantics).
  2. components/DaemonBridgeProvider.tsx — call window.emrg.init() on mount and applyInit the result; degraded-path fallback (env without window.emrg) returns {} and keeps connected=false.
  3. components/Shell.tsx — remove the batch0Notice migration badge (no longer renders it).
  4. lib/i18n.tsx — drop the now-unused shell.batch0Notice/shell.placeholder keys.
  5. Tests: daemonBridge.test.ts (+2), DaemonBridgeProvider.test.tsx (+1), App.test.tsx (assert badge gone).

Verification

  • Renderer vitest: 444 passed (was 441) — includes the 3 new init-fusion tests
  • tsc --noEmit: clean
  • vite build: success (renderer/dist)
  • GUI unit tests: 81 pass + 8 skip, 0 fail (API-surface guard confirms preload exposes init)
  • Python: 1122 passed + 1 skipped (1123, unchanged); doc-count guard 4/4
  • Agent.md renderer count updated 441 → 444

Ships in the next release (v0.2.82).

…nect) + drop batch0Notice badge (rant 2026-08-27T10:53:38)

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM 1/3 — cycle 2026-08-27T11:23:45. Independent re-verification: head unchanged (85d350f), CI run 33035821650 green (test + test-windows), MERGEABLE/CLEAN. Fixes the v0.2.81 GUI disconnect (rant 2026-08-27T10:53:38): restores window.emrg.init() wiring in DaemonBridgeProvider via InitResult + applyInit (connected only when config_exists && api_key_configured), drops the batch0Notice migration badge + orphan i18n keys. Renderer vitest 444 (+3 init-fusion tests), tsc clean, build OK, doc-count guard 4/4.

@how2how2how2-arch

Copy link
Copy Markdown
Contributor

I tested this PR (checked out refs/pull/1036/head, commit 85d350f) and it verifies cleanly:

  • daemonBridge.test.ts + DaemonBridgeProvider.test.tsx: 21/21 pass; full renderer suite 444/444; tsc --noEmit clean.
  • The root-cause analysis is exactly right: main.js ensureConnected() is only reachable via emrg:init / saveSettings / scheduleReconnect — with init() never called, the daemon websocket never opens and the UI is permanently disconnected. I confirmed the three call sites in main.js (296/903/1170) match the PR body.
  • applyInit is a faithful port of the vanilla boot merge: connected gated on config_exists && api_key_configured matches how main.js only proceeds to ensureConnected when both hold; sessions/open_sessions/model/version merge into the store exactly once, on mount.
  • Degraded path is correct: env without window.emrg returns {} and keeps connected=false (the existing no-op degradation, preserved).
  • Cleanup is appropriate: batch0Notice badge + its i18n keys are genuinely dead once init wiring is restored — dropping them keeps the surface honest.

One note (not blocking): the init() call on mount is fire-and-forget in the provider — if main.js emrg:init ever rejects (e.g. daemon spawn failure), the unhandled rejection should ideally surface as a system message rather than vanish. Suggest a .catch that logs via the existing emrg:log bridge — but current behavior (stays disconnected, user sees the banner) is an acceptable degraded path.

This closes a real v0.2.81 regression — thanks for the fast fix.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM 2/3 — cycle 2026-08-27T11:30:45. Independent re-verification: head unchanged (85d350f), CI run 33035821650 green (test + test-windows), MERGEABLE/CLEAN. Init-wiring fix confirmed sound (InitResult + applyInit merged into store, connected only when config_exists && api_key_configured); guarded by the new #1037 boot-contract test so future refactors cannot silently drop renderer init. No new feedback since 1/3 (112344).

@argszero

Copy link
Copy Markdown
OwnerAuthor

Maintainer push: resolved the Agent.md renderer count conflict after #1035 merged (Shell 23→24). Merged master and bumped the documented count to 445 (442 base + 3 new init tests: daemonBridge 12→14, DaemonBridgeProvider 6→7). Renderer vitest verified at 445 on the merged tree. CI will re-run via the synchronize event.

@argszeroargszero left a comment

Copy link
Copy Markdown
OwnerAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM 3/3 — cycle 2026-08-27T11:55:49. Independent re-verification at current head 7c350d2: head matches CI run 33036815238 (test + test-windows both pass, MERGEABLE/CLEAN). Re-read the full diff: DaemonBridgeProvider now calls window.emrg.init() on mount and applyInit merges the result into the bridge store; connected is gated on config_exists && api_key_configured — a faithful port of the vanilla boot semantics in app.js. Graceful degradation is correct (no window.emrg / init rejection → connected stays false, banner shown, no crash). This restores the renderer init obligation that Batch 5 dropped, closing the v0.2.81 disconnect (rant 2026-08-27T10:53:38). Additional robustness: the #1037 static boot-contract guard now protects the main.js/preload side so future refactors cannot silently drop renderer init. No new feedback since 1/3 (112344) and 2/3 (113045).

@argszero
argszero merged commit 9bd3dc4 into masterAug 27, 2026
2 checks passed
argszero pushed a commit to how2how2how2-arch/emrg that referenced this pull request Aug 27, 2026
argszero added a commit that referenced this pull request Aug 27, 2026
…v0.2.81 regression point) (#1042)
Static-guard the renderer side of the boot chain (DaemonBridgeProvider must
call window.emrg.init() on mount and fuse the result via bridge.applyInit,
and App.tsx must mount the provider). v0.2.81 disconnected because the React
migration dropped the init() call; #1036 added runtime coverage, this adds
cheap static pinning so the regression point turns red even if the runtime
test is removed or the mount path is bypassed. GUI tests 92 -> 93, Agent.md
synced.
Co-authored-by: argszero <argszero@gmail.com>
Sign up for freeto 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.

2 participants

@argszero@how2how2how2-arch