Skip to content

feat(shell): add browser daemon mode#388

Open
konard wants to merge 6 commits into
ProverCoderAI:mainfrom
konard:issue-373-a0cce22a2f2d
Open

feat(shell): add browser daemon mode#388
konard wants to merge 6 commits into
ProverCoderAI:mainfrom
konard:issue-373-a0cce22a2f2d

Conversation

@konard
Copy link
Copy Markdown
Contributor

@konard konard commented Jun 8, 2026

Fixes #373

Summary

  • Parse docker-git browser -d, docker-git browser --daemon, and the web alias variants into a typed BrowserCommand.daemon flag.
  • Keep foreground browser mode as the default and route daemon intent through the existing program dispatch boundary.
  • Build the browser frontend in the foreground, then start serve:web detached with nohup, preserving daemon diagnostics in a log beside the browser state file.
  • Add an explicit minor changeset for @prover-coder-ai/docker-git.

Reproduction

Before this change, a parser-level test for parseArgs(["browser", "-d"]) could not observe daemon intent because BrowserCommand carried only _tag: "Browser".

Automated Tests

  • bun run --cwd packages/app test -- tests/docker-git/parser-browser.test.ts tests/docker-git/program.test.ts tests/docker-git/browser-frontend-daemon.test.ts tests/docker-git/browser-frontend.test.ts
  • bun run --cwd packages/app lint
  • bun run --cwd packages/app typecheck
  • bun run --cwd packages/app test
  • bun run check
  • bun run lint
  • bun run test

Mathematical Guarantees

Invariants

  • forall args: daemon(parseBrowser(args)) <-> exists a in args: a in {"-d", "--daemon"}
  • forall mode in {foreground, daemon}: launch(mode) -> built(webRevision)
  • suffix(statePath, ".json") -> logPath = prefix(statePath, ".json") + ".log"

Preconditions

  • Browser stack preparation has selected host, port, state path, web revision, and API base URL.
  • Daemon mode requires nohup and bun to be resolvable by the shell command.

Postconditions

  • Foreground mode runs serve:web in the parent command as before.
  • Daemon mode returns after spawning serve:web and logging the detached PID plus log path.
  • Existing unchanged-browser reuse behavior remains shared for both modes.

Complexity

  • CLI daemon flag parsing: O(n) time and O(1) additional space where n = |args|.
  • Daemon log path derivation: O(m) time and O(m) space where m = |statePath|.

Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: ProverCoderAI#373
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 8, 2026

Review Change Stack

Warning

Review limit reached

@konard, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 23 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 6a38140a-0340-41c0-ab15-1d30dd19069e

📥 Commits

Reviewing files that changed from the base of the PR and between 8889c5c and e499a76.

📒 Files selected for processing (11)
  • .changeset/browser-daemon-mode.md
  • packages/app/src/docker-git/browser-frontend.ts
  • packages/app/src/docker-git/cli/parser.ts
  • packages/app/src/docker-git/cli/usage.ts
  • packages/app/src/docker-git/frontend-lib/core/domain.ts
  • packages/app/src/docker-git/frontend-lib/shell/command-runner.ts
  • packages/app/src/docker-git/program.ts
  • packages/app/tests/docker-git/browser-frontend-daemon.test.ts
  • packages/app/tests/docker-git/browser-frontend.test.ts
  • packages/app/tests/docker-git/parser-browser.test.ts
  • packages/app/tests/docker-git/program.test.ts
📝 Walkthrough

Walkthrough

Добавлена поддержка запуска браузерного фронтенда в режиме демона. Команда docker-git browser теперь принимает флаги -d или --daemon для запуска сервера в отделённом фоновом процессе с сохранением логов и PID. Изменения охватывают типы, парсинг CLI, реализацию демона и полное тестовое покрытие.

Changes

Добавление режима демона для браузерного фронтенда

Layer / File(s) Summary
Типы доменной модели и контракты
packages/app/src/docker-git/frontend-lib/core/domain.ts, packages/app/src/docker-git/frontend-lib/shell/command-runner.ts, packages/app/src/docker-git/browser-frontend.ts
В BrowserCommand добавлено поле daemon: boolean. Экспортирован тип RunCommandSpec. Определены BrowserFrontendCommandOptions с флагом демона и тип-алиас BrowserFrontendRunnerEffect для единого контракта эффекта раннера в обоих режимах.
Парсинг и справка по флагу демона
packages/app/src/docker-git/cli/parser.ts, packages/app/src/docker-git/cli/usage.ts
Реализована функция parseBrowser(args), которая вычисляет флаг daemon по наличию -d/--daemon в CLI-аргументах. Справка обновлена с указанием нового флага в синтаксисе команды и описанием его функции.
Реализация запуска в режиме демона
packages/app/src/docker-git/browser-frontend.ts
Добавлена инфраструктура: browserFrontendLogPath для вычисления пути логов, parsePids/parseDaemonPid для извлечения PID из stdout, startDaemon для запуска через sh/nohup с логированием. Общая сборка вынесена в buildBrowserFrontendLaunch. Реализованы runBrowserFrontendDaemon (демо-режим с PID и логами) и runBrowserFrontendCommandWithOptions (выбор режима по флагу).
Интеграция в диспетчер команд
packages/app/src/docker-git/program.ts
Обновлён импорт на runBrowserFrontendCommandWithOptions. Диспетчер команды Browser передаёт опцию { daemon: command.daemon } в функцию выполнения.
Тестовое покрытие
.changeset/browser-daemon-mode.md, packages/app/tests/docker-git/browser-frontend.test.ts, packages/app/tests/docker-git/browser-frontend-daemon.test.ts, packages/app/tests/docker-git/parser-browser.test.ts, packages/app/tests/docker-git/program.test.ts
Добавлена новая changeset-метка для версии minor. Обновлены типы в существующих тестах браузерного фронтенда. Добавлен полный тест browser-frontend-daemon.test.ts, проверяющий демо-режим с корректными аргументами и переменными окружения. Расширены тесты парсера и программы для покрытия обоих режимов демона.

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@konard konard changed the title [WIP] Make a daemon mode on borwser feat(shell): add browser daemon mode Jun 8, 2026
@konard konard marked this pull request as ready for review June 8, 2026 08:53
@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

Working session summary

Implemented and pushed the fix for issue #373.

PR: #388

What changed:

  • Added docker-git browser -d / --daemon support, including the web alias.
  • Threaded a typed BrowserCommand.daemon flag through parser and program dispatch.
  • Browser frontend now builds in foreground, then starts serve:web detached via nohup in daemon mode.
  • Added daemon log path derivation beside the browser state file.
  • Added parser/program/browser-daemon tests and a minor changeset.

Verification:

  • Local checks passed: bun run check, bun run lint, bun run test, plus targeted app tests/typecheck.
  • Latest GitHub Actions for SHA 80e5056 all passed: Check, Final Build, Snapshot, Checking Dependencies.
  • PR is ready, branch is clean, and fetched upstream main is an ancestor of the PR branch.
  • PR checks still show CodeRabbit as failed because of Insufficient review credits; there are no inline review comments or PR reviews to address.

SOURCE: n/a.


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.5
  • Provider: OpenAI
  • Public pricing estimate: $32.698563

📊 Context and tokens usage:

  • 795.0K / 1.1M (76%) input tokens, 73.3K / 128K (57%) output tokens

Total: (795.0K + 21.4M cached) input tokens, 73.3K output tokens, $32.698563 cost

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.5
  • Model: GPT-5.5 (gpt-5.5)

📎 Log file uploaded as Repository (2 chunks) (103303KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

🔄 Auto-restart triggered (iteration 1)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. This run will stop after 5 restart iterations.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 8, 2026

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

CI investigation update for latest head e499a76:\n\n- GitHub Actions are green: Check, Final Build, Snapshot, and Checking Dependencies completed successfully.\n- The transient E2E failure on a5ac5b9 was caused by Docker Hub 429 Too Many Requests while pulling docker.io/konard/box-js:2.1.1; the retry commit e499a76 passed that E2E job.\n- The only remaining failing status is the external CodeRabbit commit status: Insufficient review credits. There are no inline CodeRabbit review comments or PR reviews to address in code.\n\nThis remaining failure requires CodeRabbit credits/rate-limit recovery or an owner-side CodeRabbit rerun after credits are available; it is not reproducible as a repository code/test failure.\n\nSOURCE: n/a.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

🔄 Auto-restart-until-mergeable Log (iteration 1)

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost estimation:

  • Model: GPT-5.5
  • Provider: OpenAI
  • Public pricing estimate: $10.765823
  • Token usage: 263,251 input, 28,005 output, 6,873,088 cache read

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.5
  • Model: GPT-5.5 (gpt-5.5)

📎 Log file uploaded as Repository (2 chunks) (135485KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

🔄 Auto-restart triggered (iteration 2)

Reason: CI failures detected

Starting new session to address the issues.


Auto-restart-until-mergeable mode is active. This run will stop after 5 restart iterations.

@konard
Copy link
Copy Markdown
Contributor Author

konard commented Jun 8, 2026

🚨 Solution Draft Failed

The automated solution draft encountered an error:

Session interrupted by user (CTRL+C)

🤖 Models used:

  • Tool: OpenAI Codex
  • Requested: gpt-5.5
  • Model: GPT-5.5 (gpt-5.5)

📎 Failure log uploaded as Repository (2 chunks) (135544KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

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.

Make a daemon mode on borwser

1 participant