268268
269269${ renderAgentLaunch ( config ) }
270270) &`
271- // CHANGE: start the external Rust browser module from the project entrypoint .
272- // WHY: issue #347 moves browser ownership to ProverCoderAI/rust-browser-connection while keeping docker-git as caller .
271+ // CHANGE: leave browser start/reuse ownership with the external Rust MCP module.
272+ // WHY: issue #347 moves browser lifecycle to ProverCoderAI/rust-browser-connection; docker-git only wires MCP config and cleanup .
273273// QUOTE(ТЗ): "Вынести noVNC + MCP Playright в единый модуль."
274274// REF: issue-347
275275// SOURCE: n/a
276- // FORMAT THEOREM: MCP_PLAYWRIGHT_ENABLE=1 -> eventually running (DOCKER_GIT_BROWSER_CONTAINER_NAME)
276+ // FORMAT THEOREM: MCP_PLAYWRIGHT_ENABLE=1 -> browser-connection owns start/reuse (DOCKER_GIT_BROWSER_CONTAINER_NAME)
277277// PURITY: SHELL
278- // EFFECT: generated bash calls docker-git-browser-connection, which calls Docker.
279- // INVARIANT: browser shares the project container network namespace, so CDP is http://127.0.0.1:9223 from agents.
280- // COMPLEXITY: O(1) entrypoint orchestration; Docker build/run is delegated to Rust.
281- const renderEntrypointRustBrowserConnectionStart = ( ) : ReadonlyArray < string > => [
282- "# Unified Rust browser connection (noVNC + CDP) for MCP Playwright + Hermes — per #347." ,
283- "# Defaults are safe no-ops unless MCP Playwright is enabled." ,
284- "docker_git_start_rust_browser_connection() {" ,
285- " if [[ \"${MCP_PLAYWRIGHT_ENABLE:-0}\" != \"1\" ]]; then" ,
286- " return 0" ,
287- " fi" ,
288- "" ,
289- " local browser_bin=\"\"" ,
290- " local candidate" ,
291- " for candidate in /usr/local/bin/docker-git-browser-connection /root/.cargo/bin/docker-git-browser-connection /usr/local/cargo/bin/docker-git-browser-connection $(command -v docker-git-browser-connection 2>/dev/null || true); do" ,
292- " if [[ -x \"$candidate\" ]]; then" ,
293- " browser_bin=\"$candidate\"" ,
294- " break" ,
295- " fi" ,
296- " done" ,
297- "" ,
298- " if [[ -z \"$browser_bin\" ]]; then" ,
299- " echo \"[browser] WARNING: docker-git-browser-connection not found; Playwright MCP browser is unavailable\" >&2" ,
300- " MCP_PLAYWRIGHT_ENABLE=0" ,
301- " export MCP_PLAYWRIGHT_ENABLE" ,
302- " return 0" ,
303- " fi" ,
304- "" ,
305- " local project_container=\"${DOCKER_GIT_PROJECT_CONTAINER_NAME:-$(hostname)}\"" ,
306- " local network_mode=\"container:${project_container}\"" ,
307- " mkdir -p /var/log" ,
308- " \"$browser_bin\" start --project \"$project_container\" --network \"$network_mode\" >> /var/log/docker-git-browser.log 2>&1 || {" ,
309- " echo \"[browser] WARNING: Rust browser connection failed; see /var/log/docker-git-browser.log\" >&2" ,
310- " MCP_PLAYWRIGHT_ENABLE=0" ,
311- " export MCP_PLAYWRIGHT_ENABLE" ,
312- " return 0" ,
313- " }" ,
314- " echo \"[browser] Rust browser connection is ready via $browser_bin on $network_mode\"" ,
315- "}"
316- ]
317-
278+ // EFFECT: generated bash calls docker-git-browser-connection stop during teardown.
279+ // INVARIANT: docker-git entrypoint never eagerly starts the browser; browser-connection starts/reuses it on demand.
280+ // COMPLEXITY: O(1) cleanup orchestration; Docker lifecycle is delegated to Rust.
318281const renderEntrypointRustBrowserConnectionStop = ( ) : ReadonlyArray < string > => [
282+ "# Rust browser connection cleanup only; browser-connection owns start/reuse on demand." ,
283+ "# Do not call docker-git-browser-connection start here, or lifecycle ownership is duplicated." ,
319284 "docker_git_stop_playwright_browser() {" ,
320285 " if [[ \"${MCP_PLAYWRIGHT_ENABLE:-0}\" != \"1\" ]]; then" ,
321286 " return 0" ,
@@ -341,9 +306,5 @@ const renderEntrypointRustBrowserConnectionStop = (): ReadonlyArray<string> => [
341306
342307export const renderEntrypointRustBrowserConnection = ( ) : string =>
343308 [
344- ...renderEntrypointRustBrowserConnectionStart ( ) ,
345- "" ,
346- ...renderEntrypointRustBrowserConnectionStop ( ) ,
347- "" ,
348- "docker_git_start_rust_browser_connection"
309+ ...renderEntrypointRustBrowserConnectionStop ( )
349310 ] . join ( "\n" )
0 commit comments