mcp: fold Server.Session onto lp.ToolSession, bracket every isolate use - #3312
Merged
Conversation
Extract the Browser+Session+Notification+node Registry quartet, with its ordering-sensitive init/teardown and isolate enter/exit, into src/ToolSession.zig. mcp/Server.zig's sessions map now holds *lp.ToolSession directly; the session id lives only as the map key. Claude-Session: https://claude.ai/code/session_01M6WGk8wZSE28efFQkYT9SK
stdio kept the isolate permanently entered while HTTP parked it between requests, so a handler touching page JS without enterIsolate passed the stdio-mode tests and only failed under --port. Bracket unconditionally: stdio is the one-isolate case of the same discipline. The flag survives only as `multi_session`, which is what it always gated: the session tools need a transport that routes by id. Claude-Session: https://claude.ai/code/session_01M6WGk8wZSE28efFQkYT9SK
Two sessions on one thread, each entered only around its own use, with JS state proving the isolates are separate and a balanced park/enter/ deinit teardown. Pins what the C API relies on without Server in the loop. Claude-Session: https://claude.ai/code/session_01M6WGk8wZSE28efFQkYT9SK
Agent held the same Browser/Session/Notification/registry fields and teardown order as mcp/Server.zig, plus its own "enableConsoleCapture after every newSession" for /reset. ToolSession.restartSession() owns that now; init is written in terms of it. Claude-Session: https://claude.ai/code/session_01M6WGk8wZSE28efFQkYT9SK
This was referenced Aug 27, 2026
agent: fold the browser quartet onto lp.ToolSession
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up deferred from #3096: the c-api branch defines a
ToolSessioninline in lightpanda.zig for the Browser/Session/Notification/node Registry quartet, and mcp/Server.zig carries its own copy of the same init/teardown sequence. Landing the shared type on main first, so the c-api branch only drops its inline copy when it merges (same init/deinit/enterIsolate/exitIsolate API).src/ToolSession.zig: the quartet with its ordering-sensitive init/teardown and isolate enter/exit, re-exported aslp.ToolSession.Sessionwrapper.sessionsmaps straight to*lp.ToolSession, the id is only the map key.enterIsolatepassed the stdio-mode tests (56 of 57) and only failed under--port.park_isolatessurvives asmulti_session, which is what it actually gated: the session tools need a transport that routes byMcp-Session-Id.registry.register,frame.js) bracket the isolate;registercreates V8 handles.ToolSessiontest: two sessions on one thread, entered only around their own use, separate JS globals, balanced teardown. That is what c_api.zig relies on without Server in the loop.Not in this PR: Agent.zig, see #3313 (stacked on this one).
Verified: full suite (1282/1282);
lightpanda mcpover stdio with goto, evaluate, a refused session_new, clean exit.