Skip to content

(mcp): report the IDE emulation state that holds (#320) - #400

Merged
devsuitup merged 3 commits into
mainfrom
fix/320-ide-emulation-state
Oct 2, 2026
Merged

devsuitup merged 3 commits into
mainfrom
fix/320-ide-emulation-state

Conversation

@devsuitup

Copy link
Copy Markdown
Owner

Closes #320

What changed

The "IDE Emulation" label in the terminal header was driven by mcpActive, which only meant "an MCP server object exists". It now shows the state that holds for the session:

  • connected: the CLI has attached to the websocket. Label "IDE Emulation".
  • listening: server up, no CLI attached (never connected, or disconnected). Label "IDE Emulation: waiting for CLI".
  • failed: the server could not start. Label "IDE Emulation: failed", with the reason in the tooltip. This is the spawn-time catch that used to leave no trace outside the log.
  • off: no label.

How:

  • mcp-bridge.js: getMcpState(sessionId); mcp-status pushed to the renderer when the CLI attaches or leaves. startMcpServer now waits for the websocket server to be listening (a port already claimed used to be logged and the start reported as successful) and reads the lock file back after writing it; either failure rejects and cleans up. An optional 5th argument { port } lets a test claim a port.
  • main.js: open-terminal returns mcpState / mcpError instead of mcpActive, on spawn and on reattach. The error is kept on the session so a reattach still reports it.
  • Renderer: setSessionMcpActive becomes setSessionMcpState; onMcpStatus keeps the label current while the session runs.
  • docs/ide-emulation.md and the CHANGELOG describe the states.

Decision taken (conventional default): "show what is actually known" rather than hiding the label when not connected, as the issue discussion suggests.

Tests

  • test/mcp-bridge-status.test.js (new): off / listening / connected / back to listening, bad token stays listening, busy port rejects and leaves no lock file. Red before the change (getMcpState is not a function).
  • test/dom-ide-emulation-indicator.test.js (new): label text and tooltip per state, per-session status pushes. Red before the change (setSessionMcpState is not a function).
  • Mutations, each turning the named tests red and restored: dropping the mcp-status push on connect; dropping the wait for listening; rendering the listening state as connected / ignoring the failure reason.

Not verified

  • No live Electron run; main.js wiring (mcpState / mcpError in the open-terminal result) has no test of its own.
  • The lock-file read-back check is unmutated: no test can make a write succeed and read back different.
  • Whether a real CLI attaches and the label turns to "IDE Emulation" was not checked against a running claude.

…xists

The header label was driven by "a server object exists". It now reads
connected, waiting for CLI, or failed (with the reason), and is updated
as the CLI attaches and leaves. A server that cannot listen or whose lock
file does not read back rejects the start instead of being reported up.

Closes #320
@devsuitup

Copy link
Copy Markdown
Owner Author

Reviewing 8ee1829 (adversarial review in progress).

@devsuitup

Copy link
Copy Markdown
Owner Author

Adversarial review at 8ee1829: changes needed. Blocker: test/dom-sandbox-toggle.test.js "reports the sandbox state on both open-terminal returns" fails (1 !== 3) — its pattern expects the one-line return { ok: true, reattached: … } and the local reattach/spawn returns are now multi-line. Minors: .ai/contexts/ipc-bridge.md still documents mcpActive; two stale setSessionMcpActive stubs in tests. Checked and holding: startMcpServer cannot hang (listening or error), cleans up on rejection, and the session still opens without --ide; mcp-status checks isDestroyed() and ignores a replaced client; label via textContent/title; tests use port 0.

Update the sandbox-badge source check to the multi-line returns, rename
the stale setSessionMcpActive stubs, and document mcpState/mcpError.

Refs #320
@devsuitup

Copy link
Copy Markdown
Owner Author

Re-review at a6257fd: the blocker is closed — the sandbox-badge pattern accepts the multi-line returns and still asserts sandbox: on all three; ipc-bridge.md documents mcpState/mcpError; the stale stubs are renamed. Ready to merge once CI is green on a6257fd.

@devsuitup
devsuitup merged commit 883666a into main Oct 2, 2026
10 checks passed
@devsuitup
devsuitup deleted the fix/320-ide-emulation-state branch October 2, 2026 10:01
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.

(mcp): IDE emulation reports itself working when it is not

1 participant