Skip to content

Commit 7132f70

Browse files
Ahsaan-Ullahclaude
andcommitted
Fix the silent first CloakBrowser launch; version 0.2.1
The app now fetches CloakBrowser's ~560 MB browser on first start with progress and retries, launch logs are line-buffered and show engine download progress, and the start watchdog only stops launches that make no progress for 5 minutes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 04b6720 commit 7132f70

9 files changed

Lines changed: 116 additions & 11 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ Format based on [Keep a Changelog](https://keepachangelog.com/).
44

55
## [Unreleased]
66

7+
## [0.2.1] - 2026-10-26
8+
9+
### Fixed
10+
- **First launch on CloakBrowser looked dead.** The first `cloak` launch
11+
silently downloads CloakBrowser's browser (about 560 MB), so nothing opened
12+
for minutes, the launch log stayed empty (the app's child processes buffered
13+
their output), and the 5-minute start watchdog could stop a download that was
14+
still going. Now the app downloads CloakBrowser on its first start, in its
15+
window, with progress and up to 3 retries; launch logs are written as they
16+
happen and show engine download progress; and the watchdog only stops a launch
17+
that has made no progress for 5 minutes.
18+
719
## [0.2.0] - 2026-10-25
820

921
### Added

‎dashboard/package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "persona-dashboard",
33
"private": true,
4-
"version": "0.2.0",
4+
"version": "0.2.1",
55
"type": "module",
66
"description": "Web dashboard for the Persona anti-detect browser profile manager.",
77
"scripts": {

‎dashboard/src/App.jsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2488,7 +2488,7 @@ function SettingsView({ live, config, engines, defaultEngine, onChangeEngine, pa
24882488
<div className="ps-set-h"><Info size={15} color={T.violet} /> About</div>
24892489
<div className="ps-set-row">
24902490
<div className="ps-set-label">Persona Studio</div>
2491-
<span className="ps-pill" style={{ background: T.violetDim, color: T.lilac }}>v{config?.version || "0.2.0"}</span>
2491+
<span className="ps-pill" style={{ background: T.violetDim, color: T.lilac }}>v{config?.version || "0.2.1"}</span>
24922492
</div>
24932493
<div className="ps-set-note" style={{ marginTop: 6 }}>Open-source, self-hosted anti-detect browser &amp; profile manager. {live ? "Engine connected." : "Running in demo mode — start persona serve to go live."}</div>
24942494
</div>

‎engine/persona/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .fingerprint import generate, validate, sec_ch_ua
2121
from .store import ProfileStore
2222

23-
__version__ = "0.2.0"
23+
__version__ = "0.2.1"
2424

2525
__all__ = [
2626
"Fingerprint",

‎engine/persona/app.py‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,38 @@ def _install_chromium() -> None:
4949
subprocess.run([node, cli, "install", "chromium"], env=get_driver_env(), check=False)
5050

5151

52+
def _cloak_ready() -> bool:
53+
try:
54+
from cloakbrowser.config import get_binary_path
55+
return get_binary_path().exists()
56+
except Exception:
57+
return True # not bundled: nothing to fetch
58+
59+
60+
def _install_cloak(attempts: int = 3) -> None:
61+
"""First run: fetch CloakBrowser's patched Chromium (about 560 MB) here,
62+
with progress, rather than silently inside the first profile launch."""
63+
import logging
64+
from cloakbrowser.download import ensure_binary
65+
log = logging.getLogger("cloakbrowser")
66+
if not log.handlers:
67+
h = logging.StreamHandler(sys.stdout)
68+
h.setFormatter(logging.Formatter(" %(message)s"))
69+
log.addHandler(h)
70+
log.setLevel(logging.INFO)
71+
log.propagate = False
72+
print(" First run: downloading the CloakBrowser engine (about 560 MB)...")
73+
for i in range(1, attempts + 1):
74+
try:
75+
ensure_binary()
76+
print(" CloakBrowser is ready.")
77+
return
78+
except Exception as e: # noqa: BLE001 - retry, then let launches try again
79+
print(f" Download attempt {i} failed: {e}")
80+
print(" Couldn't download CloakBrowser now. Profiles on the 'cloak' engine will")
81+
print(" try again when they launch; Playwright profiles work meanwhile.")
82+
83+
5284
def _open(url: str) -> None:
5385
if not os.environ.get("PERSONA_NO_BROWSER"): # e.g. on a server
5486
webbrowser.open(url)
@@ -71,6 +103,8 @@ def run_app() -> int:
71103
return 0
72104
if not _chromium_installed():
73105
_install_chromium()
106+
if not _cloak_ready():
107+
_install_cloak()
74108
print(f" Dashboard: {URL}")
75109
print(" Keep this window open while you use Persona. Close it to stop.\n")
76110
threading.Thread(target=_open_when_up, daemon=True).start()

‎engine/persona/cli.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,29 @@ def build_parser() -> argparse.ArgumentParser:
11901190
return p
11911191

11921192

1193+
def _show_engine_progress() -> None:
1194+
"""Engines report slow first-run work (CloakBrowser downloads ~560 MB of
1195+
browser) through logging. Show it, so a launch log says what's happening
1196+
instead of staying empty for minutes."""
1197+
import logging
1198+
for name in ("cloakbrowser",):
1199+
log = logging.getLogger(name)
1200+
if not log.handlers:
1201+
h = logging.StreamHandler(sys.stdout)
1202+
h.setFormatter(logging.Formatter("%(message)s"))
1203+
log.addHandler(h)
1204+
log.setLevel(logging.INFO)
1205+
log.propagate = False
1206+
1207+
11931208
def main(argv: Optional[list[str]] = None) -> int:
1209+
# Line-buffered even into a log file (the dashboard reads launch logs live).
1210+
for stream in (sys.stdout, sys.stderr):
1211+
try:
1212+
stream.reconfigure(line_buffering=True)
1213+
except (AttributeError, ValueError):
1214+
pass
1215+
_show_engine_progress()
11941216
parser = build_parser()
11951217
args = parser.parse_args(argv)
11961218
store = ProfileStore(args.data_dir, password=args.password)

‎engine/persona/server.py‎

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,25 +736,35 @@ def launch_profile(pid: str):
736736
def _watch_start(pid: str, proc: subprocess.Popen) -> None:
737737
"""Watchdog for one launch. The launcher marks the session lock ready
738738
once its window exists; a launch still not up after START_SLOW gets a
739-
warning in the activity log, and after START_LIMIT it's stopped with an
740-
error, instead of the profile spinning as "running" forever."""
739+
warning in the activity log, and one that has made no progress for
740+
START_LIMIT is stopped with an error, instead of the profile spinning as
741+
"running" forever. Progress is the launch log growing: a first-run
742+
engine download (CloakBrowser's is ~560 MB) keeps writing to it."""
741743
ud = engine_store.userdata_dir / pid
744+
log_path = _launch_log(pid)
742745
started, warned = time.time(), False
746+
last_size, last_change = -1, started
743747
while proc.poll() is None and running.get(pid) is proc:
744748
info = locks.read(ud) or {}
745749
if info.get("pid") == proc.pid and info.get("ready"):
746750
return
747-
waited = time.time() - started
751+
try:
752+
size = log_path.stat().st_size
753+
except OSError:
754+
size = 0
755+
if size != last_size:
756+
last_size, last_change = size, time.time()
757+
waited = time.time() - last_change
748758
if waited > START_LIMIT:
749759
_stop(pid)
750760
stored = dash.get(pid)
751761
if stored is not None:
752-
stored["_launchError"] = (f"The browser didn't start within "
753-
f"{START_LIMIT // 60} minutes, so it was stopped.")
762+
stored["_launchError"] = (f"The browser made no progress for "
763+
f"{START_LIMIT // 60} minutes, so the launch was stopped.")
754764
dash.save(stored)
755765
_log_activity(pid, "start-timeout", f"{START_LIMIT}s")
756766
return
757-
if waited > START_SLOW and not warned:
767+
if time.time() - started > START_SLOW and not warned:
758768
warned = True
759769
_log_activity(pid, "slow-start", f"not up after {START_SLOW}s")
760770
time.sleep(1)

‎engine/pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "persona-engine"
7-
version = "0.2.0"
7+
version = "0.2.1"
88
description = "Coherent browser fingerprint & profile engine for Persona."
99
readme = "README.md"
1010
requires-python = ">=3.9"

‎engine/tests/test_lifecycle.py‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,33 @@ def test_launch_watchdog_stops_a_launch_that_never_comes_up(tmp_path, monkeypatc
152152
break
153153
time.sleep(0.2)
154154
assert row["status"] == "stopped"
155-
assert "didn't start within 5 minutes" in row["launchError"]
155+
assert "made no progress for 5 minutes" in row["launchError"]
156156
kinds = [e["kind"] for e in c.get(f"/api/profiles/{pid}/activity").json()["activity"]]
157157
assert "start-timeout" in kinds
158+
159+
160+
def test_watchdog_spares_a_launch_that_is_still_making_progress(tmp_path, monkeypatch):
161+
# A first-run engine download takes minutes but keeps writing progress to
162+
# the launch log; it must not be stopped as "never came up".
163+
pytest.importorskip("fastapi")
164+
pytest.importorskip("httpx")
165+
from fastapi.testclient import TestClient
166+
from persona import server
167+
168+
app = server.create_app(str(tmp_path), start_scheduler=False)
169+
c = TestClient(app, base_url="http://localhost", headers={server.TOKEN_HEADER: app.state.api_token})
170+
pid = c.post("/api/profiles", json={"name": "x", "os": "Windows"}).json()["id"]
171+
chatty = ("import sys, time\n"
172+
"for i in range(200):\n"
173+
" print('Download progress', i, flush=True); time.sleep(0.1)")
174+
real_popen = subprocess.Popen
175+
monkeypatch.setattr(server.subprocess, "Popen",
176+
lambda *a, **k: real_popen([sys.executable, "-c", chatty],
177+
stdout=k.get("stdout"), stderr=k.get("stderr")))
178+
c.post(f"/api/profiles/{pid}/launch")
179+
t0 = time.time()
180+
monkeypatch.setattr(server.time, "time", lambda: t0 + 10_000) # far past the limit
181+
time.sleep(3)
182+
row = next(p for p in c.get("/api/profiles").json() if p["id"] == pid)
183+
assert row["status"] == "running"
184+
c.post(f"/api/profiles/{pid}/stop")

0 commit comments

Comments
 (0)