---
id: 12462
title: 'Bridge daemon: instance-addressed wakes lose focus to same-bundle sibling'
state: CLOSED
labels:
  - bug
  - ai
  - architecture
assignees: []
createdAt: '2026-06-04T00:49:52Z'
updatedAt: '2026-06-04T01:04:36Z'
githubUrl: 'https://github.com/neomjs/neo/issues/12462'
author: neo-claude-opus
commentsCount: 0
parentIssue: null
subIssues: []
subIssuesCompleted: 0
subIssuesTotal: 0
blockedBy: []
blocking: []
closedAt: '2026-06-04T01:04:36Z'
---
# Bridge daemon: instance-addressed wakes lose focus to same-bundle sibling

## Context

`#11822/#12399` (instance-addressable wake routing) replaced the robust `tell application "<App>" to activate` foregrounding with `set frontmost of (first process whose unix id is <pid>) to true` for any `--user-data-dir` harness instance. `#12424` then added a strict `assertTargetFrontmost` guard that aborts delivery on any focus mismatch. Combined, instance-addressed wakes (e.g. `@neo-claude-opus`'s Neo Claude instance) **fail whenever a same-bundle sibling holds the foreground**: `set frontmost of unix id` alone cannot switch between two same-bundle Electron instances from the headless daemon, so the guard hard-drops the wake.

**Evidence:** the Neo instance (pid 92897) failed delivery **16× on 06-03 + 21× on 06-04** (`Target app lost frontmost status after activation (pid 91267 != 92897)`), interleaved with successes only when the sibling (91267, default Claude) was *already* frontmost. Empirically (osascript probes on the host): `activate` + `set frontmost` raises the target reliably; `set frontmost` alone loses to a frontmost sibling; `AXRaise` **de-raises** the target (rejected).

## The Architectural Reality

- `ai/daemons/bridge/daemon.mjs` `deliverDigest` — the `activateLine` (instance path) + the `assertTargetFrontmost` guard (`#12424`) + the poll-re-activate loop (`#12460`).
- `instanceResolver.mjs` — resolves the correct pid (works; the resolution is NOT the bug — the *raise* is).

## The Fix

Restore `activate` as the foregrounding primitive, then `set frontmost of unix id` for instance precision. Each poll iteration: `tell application "<App>" to activate` (reclaims the bundle to front — works from the headless daemon) → `set frontmost of (process whose unix id is <pid>)` (disambiguate to the right instance). Single-instance/no-userDataDir path keeps `activate` only (unchanged). Keeps `#11822`'s instance precision + `#12424`'s safety guard; restores `#11822`-pre robustness.

## Acceptance Criteria

- [ ] Instance-addressed (`--user-data-dir`) wakes foreground via `activate` + `set frontmost`; single-instance path unchanged.
- [ ] `AXRaise` is NOT used (empirically de-raises).
- [ ] **(post-deploy, the real test)** the Neo instance's wakes (`WAKE_SUB:84dfc4da`) deliver while the default Claude sibling is frontmost — verified in `bridge.log` (no `91267 != 92897` drops).
- [ ] No regression for non-Claude harnesses (Codex/Antigravity — different bundles, already work).

## Out of Scope

- The non-focus delivery channel (the durable fix; → #12440).

## Decision Record impact

`none` — restores a pre-`#11822` mechanism; tactical wake-substrate fix.

## Related

- Regression source: **#11822/#12399** (`set frontmost` swap), **#12424** (strict guard). Prior mitigation: **#12459/#12460** (retry — insufficient alone). Durable fix: **#12440**.

## Origin Session ID

`3ecb40bf-bfef-40b1-8693-a8aae5afa1b7`

## Handoff Retrieval Hints

- `query_raw_memories`: "bridge daemon instance wake activate foregrounding same-bundle sibling".

## Timeline

- 2026-06-04T00:49:53Z @neo-claude-opus added the `bug` label
- 2026-06-04T00:49:53Z @neo-claude-opus added the `ai` label
- 2026-06-04T00:49:53Z @neo-claude-opus added the `architecture` label
- 2026-06-04T01:01:42Z @neo-claude-opus cross-referenced by PR #12463
- 2026-06-04T01:04:36Z @tobiu referenced in commit `c5e0c44` - "fix(bridge-daemon): activate-foreground before instance set-frontmost for same-bundle wakes (#12462) (#12463)

#11822 swapped the robust 'tell application to activate' for 'set frontmost of unix id'
on the instance-addressed path; that cannot switch between two same-bundle Electron
instances from the headless daemon, so #12424's frontmost guard hard-drops the wake when
a same-bundle sibling holds the foreground (Neo instance 92897 lost 16x on 06-03, 21x on
06-04 to the default Claude 91267).

Restore activate as the foregrounding primitive (reclaims the bundle to front from the
daemon AND over a sibling), then set frontmost of the resolved unix id for instance
precision. Single-instance / no-userDataDir path keeps activate only. AXRaise empirically
de-raises the target and is NOT used.

Co-authored-by: tobiu <tobiasuhlig78@gmail.com>"
- 2026-06-04T01:04:36Z @tobiu closed this issue
- 2026-06-04T01:16:57Z @neo-opus-ada cross-referenced by #12464
- 2026-06-04T01:36:45Z @neo-gpt cross-referenced by PR #12468

