Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(agent-accounts): carry first-run markers so signed-in accounts skip the wizard

rubenluetke10-beep53396b26de0e
diff --git a/jarvis/agent_config_parity.py b/jarvis/agent_config_parity.py
index dbdb62bdeb..b060ea7492 100644
--- a/jarvis/agent_config_parity.py
+++ b/jarvis/agent_config_parity.py
@@ -217,7 +217,20 @@ USER_SETUP: dict[Platform, tuple[Shared, ...]] = {
#: Keys merged out of a document that also holds identity. See :class:`MergedKey`.
MERGED_KEYS: dict[Platform, tuple[MergedKey, ...]] = {
- "claude": (MergedKey(".claude.json", "mcpServers"),),
+ "claude": (
+ MergedKey(".claude.json", "mcpServers"),
+ # The CLI's first-run wizard is keyed on these markers, NOT on the
+ # credentials: an account that is fully signed in but lacks them still
+ # boots every new pane into "Select login method" (2026-08-08 report —
+ # the user read a healthy account as a failed login). Carrying the
+ # user's own markers makes a pane on an added account start where their
+ # ordinary terminal starts. `_merge_key` never overwrites a value the
+ # account already holds, so an account that walked the wizard itself
+ # keeps its own record.
+ MergedKey(".claude.json", "hasCompletedOnboarding"),
+ MergedKey(".claude.json", "lastOnboardingVersion"),
+ MergedKey(".claude.json", "theme"),
+ ),
# Codex's mcp_servers live in config.toml, which is shared whole above.
"codex": (),
}
diff --git a/jarvis/agent_login_flow.py b/jarvis/agent_login_flow.py
index 5bbd493ee1..862a541cd0 100644
--- a/jarvis/agent_login_flow.py
+++ b/jarvis/agent_login_flow.py
@@ -169,7 +169,48 @@ def _connected(account: AgentAccount) -> bool:
return False
+def _mark_onboarded(account: AgentAccount) -> None:
+ """Record in the account's own config that first-run setup is behind it.
+
+ Claude Code's wizard is keyed on ``hasCompletedOnboarding``, not on the
+ credentials — without this, a freshly signed-in account still boots every
+ new pane into "Select login method", which reads exactly like the login
+ having failed (2026-08-08 report). Config parity carries the user's own
+ marker across too; this stamp is for the machine where no native setup
+ exists to carry it FROM. Only ever ADDS the key — a value the CLI wrote
+ itself is never touched — and never fails the flow: the login is real
+ whether or not this cosmetic marker could be written.
+ """
+ if account.platform != "claude":
+ return
+ import json
+
+ from jarvis.agent_config_parity import setup_lock
+
+ path = account.config_dir / ".claude.json"
+ try:
+ with setup_lock(account.config_dir):
+ try:
+ data = json.loads(path.read_text(encoding="utf-8-sig") or "{}")
+ except (OSError, ValueError):
+ data = {}
+ if not isinstance(data, dict) or data.get("hasCompletedOnboarding"):
+ return
+ data["hasCompletedOnboarding"] = True
+ tmp = path.with_name(f"{path.name}.{uuid4().hex[:8]}.tmp")
+ tmp.write_text(json.dumps(data, indent=2, ensure_ascii=False), encoding="utf-8")
+ import os
+
+ os.replace(tmp, path)
+ except OSError as exc:
+ logger.debug("Guided login: onboarding marker not written: {}", exc)
+
+
def _finish(flow: _Flow, status: str, message: str) -> None:
+ # BEFORE the status flips: anything that reacts to "success" — the dialog's
+ # next poll, a pane respawn — must already find the marker on disk.
+ if status == "success":
+ _mark_onboarded(flow.account)
with flow.lock:
if flow.status in _FINISHED:
return
@@ -209,8 +250,7 @@ def _ingest(flow: _Flow, data: str) -> None:
# one; an unrelated later URL never replaces the sign-in link.
candidate = _scan_for_url(cleaned)
if candidate is not None and (
- flow.url is None
- or (candidate.startswith(flow.url) and len(candidate) > len(flow.url))
+ flow.url is None or (candidate.startswith(flow.url) and len(candidate) > len(flow.url))
):
flow.url = candidate
if not flow.code_expected and _CODE_PROMPT_RE.search(cleaned):
diff --git a/tests/unit/test_agent_config_parity.py b/tests/unit/test_agent_config_parity.py
index ae59c8713a..04bf482661 100644
--- a/tests/unit/test_agent_config_parity.py
+++ b/tests/unit/test_agent_config_parity.py
@@ -318,9 +318,7 @@ def test_a_plugin_tree_the_cli_half_filled_is_replaced_as_a_whole(native: Path)
stale.mkdir(parents=True)
ensure_parity("claude", account.id)
assert (account.config_dir / "plugins" / "installed_plugins.json").exists()
- assert (
- account.config_dir / ("plugins" + agent_config_parity.SUPERSEDED_SUFFIX)
- ).is_dir()
+ assert (account.config_dir / ("plugins" + agent_config_parity.SUPERSEDED_SUFFIX)).is_dir()
def test_the_superseded_copy_is_only_moved_aside_once(native: Path) -> None:
@@ -465,9 +463,12 @@ def test_panes_provisioning_one_account_at_once_do_not_race(native: Path) -> Non
# Same entries every time — no thread saw a half-provisioned directory.
assert {tuple(sorted(r)) for r in results} == {tuple(sorted(results[0]))}
assert (account.config_dir / "skills" / "git-rescue" / "SKILL.md").is_file()
- assert json.loads(
- (account.config_dir / agent_config_parity.STATE_FILE).read_text(encoding="utf-8")
- )["version"] == agent_config_parity.STATE_VERSION
+ assert (
+ json.loads(
+ (account.config_dir / agent_config_parity.STATE_FILE).read_text(encoding="utf-8")
+ )["version"]
+ == agent_config_parity.STATE_VERSION
+ )
def test_the_setup_lock_is_one_per_account_and_re_entrant(tmp_path: Path) -> None:
@@ -494,3 +495,45 @@ def test_it_never_raises_on_a_host_that_refuses_everything(
report = ensure_parity("claude", account.id)
assert report.redirected is True
assert report.skipped # honestly reported, not silently empty
+
+
+# ------------------------------------------------------- the first-run markers
+
+
+def test_the_onboarding_markers_are_carried_so_a_pane_skips_the_wizard(
+ native: Path,
+) -> None:
+ """2026-08-08: a fully signed-in added account still booted every pane into
+ "Select login method", because the wizard is keyed on these markers rather
+ than on the credentials — and the user read that as a failed login."""
+ (native / ".claude.json").write_text(
+ json.dumps(
+ {
+ "hasCompletedOnboarding": True,
+ "lastOnboardingVersion": "2.1.220",
+ "userID": "user-1",
+ }
+ ),
+ encoding="utf-8",
+ )
+ account = _account()
+ ensure_parity("claude", account.id)
+ doc = json.loads((account.config_dir / ".claude.json").read_text(encoding="utf-8"))
+ assert doc["hasCompletedOnboarding"] is True
+ assert doc["lastOnboardingVersion"] == "2.1.220"
+ assert "userID" not in doc # identity stays the account's own
+
+
+def test_a_marker_the_account_wrote_itself_is_never_overwritten(
+ native: Path,
+) -> None:
+ (native / ".claude.json").write_text(
+ json.dumps({"lastOnboardingVersion": "2.1.220"}), encoding="utf-8"
+ )
+ account = _account()
+ (account.config_dir / ".claude.json").write_text(
+ json.dumps({"lastOnboardingVersion": "2.1.226"}), encoding="utf-8"
+ )
+ ensure_parity("claude", account.id)
+ doc = json.loads((account.config_dir / ".claude.json").read_text(encoding="utf-8"))
+ assert doc["lastOnboardingVersion"] == "2.1.226"
diff --git a/tests/unit/test_agent_login_flow.py b/tests/unit/test_agent_login_flow.py
index 6c29be4f9a..2549544bba 100644
--- a/tests/unit/test_agent_login_flow.py
+++ b/tests/unit/test_agent_login_flow.py
@@ -250,3 +250,17 @@ def test_a_second_start_for_the_same_account_cancels_the_first(
assert first["flow_id"] != second["flow_id"]
_wait_for(lambda: first_handle.terminated)
assert _state(second["flow_id"])["status"] == "starting"
+
+
+def test_success_stamps_the_onboarding_marker_into_the_account_config(
+ monkeypatch: pytest.MonkeyPatch, tmp_path: Path
+) -> None:
+ """Without the marker a signed-in account still boots panes into the CLI's
+ first-run wizard — which reads exactly like the login having failed."""
+ import json
+
+ handle, _backend, state = _start(monkeypatch, tmp_path, [])
+ monkeypatch.setattr(agent_login_flow, "_connected", lambda account: True)
+ _wait_for(lambda: _state(state["flow_id"])["status"] == "success")
+ doc = json.loads((tmp_path / "seat" / ".claude.json").read_text(encoding="utf-8"))
+ assert doc["hasCompletedOnboarding"] is True