Something went wrong. Try again.
personal memory agent
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146# SPDX-License-Identifier: AGPL-3.0-only# Copyright (c) 2026 sol pbc
from __future__ import annotations
import jsonimport refrom pathlib import Pathfrom typing import Any
INIT_HTML = ( Path(__file__).resolve().parents[1] / "solstone" / "convey" / "templates" / "init.html")
def _render_init(convey_env_setup_pending) -> str: env = convey_env_setup_pending() response = env.client.get("/init") assert response.status_code == 200 return response.get_data(as_text=True)
def _read_config(journal: Path) -> dict[str, Any]: return json.loads((journal / "config" / "journal.json").read_text())
def _write_config(journal: Path, config: dict[str, Any]) -> None: (journal / "config" / "journal.json").write_text(json.dumps(config, indent=2))
def _commit_journal_identity() -> None: from solstone.think.link.ca import load_or_generate_ca from solstone.think.link.paths import ca_dir
load_or_generate_ca(ca_dir())
def _finalize_body() -> dict[str, Any]: return { "name": "Setup Test", "preferred": "", "timezone": "UTC", "retention_mode": "keep", "retention_days": None, }
def test_init_provider_section_is_basics_only(convey_env_setup_pending) -> None: html = _render_init(convey_env_setup_pending)
assert 'id="provider-lanes"' in html assert "LANE_GLYPHS = { local: '⌂', confidential: '◎', byo: '⚿' }" in html assert "how should sol think?" in html assert ( "when you finish, <b>thinking</b> opens to the lane you picked. " "the fork lives in thinking from here on — switch anytime." in html ) assert "skip for now" not in html assert "not thinking yet — set this up later in thinking" in html assert "LOCAL_REQUIREMENTS_URL" in html assert "gemini-key" not in html assert "gemini-validate" not in html assert "provider-key-block" not in html assert "password-toggle" not in html assert "validate-provider" not in html assert "scout-setup" not in html assert "data-scout-state" not in html assert "enableScout" not in html assert "subscribeScoutStream" not in html assert "/init/services/scout" not in html assert ".portal-unreachable" not in html assert "portal-unreachable" not in html
def test_init_template_style_uses_tokens() -> None: raw_template = INIT_HTML.read_text(encoding="utf-8") style_start = raw_template.index("<style>") style_end = raw_template.index("</style>", style_start) style_slice = raw_template[style_start:style_end]
assert '<link rel="stylesheet" href="/static/tokens.css">' in raw_template assert "@font-face" not in raw_template assert re.search(r"#[0-9a-fA-F]{3,8}", style_slice) is None assert "rgba(" not in style_slice
def test_init_scout_stubs_removed(convey_env_setup_pending) -> None: html = _render_init(convey_env_setup_pending) raw_template = INIT_HTML.read_text(encoding="utf-8")
assert "retention-prefill-hint" not in html assert "L11-stub: retention-prefill-hint" not in html assert "L11-stub: signed-in retention pre-fill" not in html assert "L11-stub: portal-unreachable" not in html assert "{% if false %}" not in raw_template
def test_finalize_preserves_existing_provider_and_scout_config( convey_env_setup_pending,) -> None: env = convey_env_setup_pending() config = _read_config(env.journal) scout_block = {"account_id": "x", "enrolled_at_ms": 1} config.setdefault("env", {})["GOOGLE_API_KEY"] = "SCOUT_FIXTURE" config.setdefault("services", {})["scout"] = scout_block.copy() _write_config(env.journal, config) before = _read_config(env.journal) before_env = json.dumps(before["env"], sort_keys=True) before_scout = json.dumps(before["services"]["scout"], sort_keys=True) _commit_journal_identity()
response = env.client.post( "/init/finalize", json=_finalize_body(), content_type="application/json", )
assert response.status_code == 200 assert response.get_json()["success"] is True saved = _read_config(env.journal) assert json.dumps(saved["env"], sort_keys=True) == before_env assert json.dumps(saved["services"]["scout"], sort_keys=True) == before_scout
# Folded in from the retired solstone/convey/tests/test_init_html.py (2026-07-24).# Its provider-key / scout-deep-link assertions duplicated# test_init_provider_section_is_basics_only above; only these two were unique.
def test_result_display_ms_constant_present(): text = INIT_HTML.read_text(encoding="utf-8")
assert text.count("RESULT_DISPLAY_MS = 1200") == 1
def test_wizard_self_contained(): text = INIT_HTML.read_text(encoding="utf-8")
assert text.count('<link rel="stylesheet"') == 1 assert '<link rel="stylesheet" href="/static/tokens.css">' in text assert text.count("<script src=") == 2