(mcp): report the IDE emulation state that holds (#320) - #400
Conversation
…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
|
Reviewing |
|
Adversarial review at |
Update the sandbox-badge source check to the multi-line returns, rename the stale setSessionMcpActive stubs, and document mcpState/mcpError. Refs #320
|
Re-review at |
# Conflicts: # CHANGELOG.md
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-timecatchthat used to leave no trace outside the log.off: no label.How:
mcp-bridge.js:getMcpState(sessionId);mcp-statuspushed to the renderer when the CLI attaches or leaves.startMcpServernow 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-terminalreturnsmcpState/mcpErrorinstead ofmcpActive, on spawn and on reattach. The error is kept on the session so a reattach still reports it.setSessionMcpActivebecomessetSessionMcpState;onMcpStatuskeeps the label current while the session runs.docs/ide-emulation.mdand 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).mcp-statuspush on connect; dropping the wait forlistening; rendering the listening state as connected / ignoring the failure reason.Not verified
main.jswiring (mcpState/mcpErrorin theopen-terminalresult) has no test of its own.claude.