The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
feat(onboarding): leaving the intro is kept on the run, so a relaunch skips the demo
alt-glitchc798b37aa184
diff --git a/agent/onboarding_record.py b/agent/onboarding_record.pyindex 16d7ee5e9ec..baf7188f47d 100644--- a/agent/onboarding_record.py+++ b/agent/onboarding_record.py@@ -114,6 +114,16 @@ def active_session_id(db) -> str | None:return next(iter(open_session_ids(db)), None)+def intro_seen(db, session_id: str | None) -> bool:+ return bool((_read(db, session_id) or {}).get("intro_seen")) if session_id else False+++def mark_intro_seen(db, session_id: str) -> None:+ """Kept on the run, so a rerun plays the intro again."""+ db.update_session_model_config_value(+ session_id, KEY, lambda current: {**current, "intro_seen": True} if isinstance(current, dict) else current)++def observe_tool_result(agent, name: str, args: Mapping[str, Any], result: Any) -> Any:"""Settle a beat from a general tool's result (``set_theme``, ``manage_connections`` display,``gui_tour``). Runs for every tool result; only an onboarding chat (one whose agent carriesdiff --git a/apps/desktop/src/store/onboarding-run.test.ts b/apps/desktop/src/store/onboarding-run.test.tsindex 525985dd69a..6c5b2bd125f 100644--- a/apps/desktop/src/store/onboarding-run.test.ts+++ b/apps/desktop/src/store/onboarding-run.test.ts@@ -134,7 +134,7 @@ describe('onboarding run', () => {$introView.set('ended')$introView.set('off')- expect(calls.filter(method => method === 'onboarding.mark_seen')).toHaveLength(1)+ expect(calls.filter(method => method === 'onboarding.intro_seen')).toHaveLength(1)})it('keeps the run when the backend refuses the skip', async () => {diff --git a/apps/desktop/src/store/onboarding-run.ts b/apps/desktop/src/store/onboarding-run.tsindex 1e07e0eebd1..3fb88660cb8 100644--- a/apps/desktop/src/store/onboarding-run.ts+++ b/apps/desktop/src/store/onboarding-run.ts@@ -11,8 +11,7 @@import type {MachineFactsResult,OnboardingRunStateResult,- OnboardingStartResult,- OnboardingStateResult+ OnboardingStartResult} from '@hermes/shared'import { atom, computed } from 'nanostores'@@ -131,7 +130,7 @@ interface StartOptions {/** Points the window's gateway at the profile onboarding runs in (`store/profile.ts::ensureGatewayProfile`). */ensureProfile?: (profile: string) => Promise<void>intro?: OnboardingIntroHooks- /** The user left the intro on an earlier launch (`onboarding.mark_seen`). */+ /** The user left this run's intro on an earlier launch (`onboarding.intro_seen`). */introSeen?: booleanrerun?: boolean}@@ -208,7 +207,7 @@ function markSeenOnLeave(request: OnboardingRequest): void {stop()if (view === 'ended' && $onboardingPhase.get() === 'shown') {- void request('onboarding.mark_seen').catch(error => console.warn('[onboarding] mark_seen failed', error))+ void request('onboarding.intro_seen').catch(error => console.warn('[onboarding] intro_seen failed', error))}})}@@ -247,12 +246,10 @@ export function decideOnboarding(async function readAndStart(request: OnboardingRequest, resume: OnboardingResume, options?: StartOptions): Promise<void> {try {- const state = await request<OnboardingRunStateResult & Partial<Pick<OnboardingStateResult, 'intro'>>>(- 'onboarding.state'- )+ const state = await request<OnboardingRunStateResult>('onboarding.state')if (state.run && state.eligible) {- await startOnboarding(request, resume, { ...options, introSeen: state.intro === 'seen' })+ await startOnboarding(request, resume, { ...options, introSeen: state.intro_seen })}} catch (error) {console.warn('[onboarding] state could not be read', error)diff --git a/apps/shared/src/gateway-contract.generated.ts b/apps/shared/src/gateway-contract.generated.tsindex 99fac2ecd2b..0a90e632572 100644--- a/apps/shared/src/gateway-contract.generated.ts+++ b/apps/shared/src/gateway-contract.generated.ts@@ -2203,11 +2203,12 @@ export interface OnboardingStateResult {profile?: string | null}export type OnboardingIntro = 'unseen' | 'seen'-/** ``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh install). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``). ``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it. */+/** ``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh install). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``). ``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it. ``intro_seen``: the user left that run's intro once, so a relaunch reopens it as a normal chat. */export interface OnboardingRunStateResult {run: booleaneligible: booleansession_id?: string | null+ intro_seen?: boolean}/** ``mark_profile_offered`` also latches ``onboarding.seen.profile_build_offered`` in the root config, so the first chat after onboarding gets the plain intro instead of the profile offer. */export interface OnboardingSetRunParams {@@ -5400,6 +5401,8 @@ export interface RpcMethods {/** Create-or-read the backend-owned setup profile; the backend picks the name. */'onboarding.ensure_setup_profile': { params: Params; result: OnboardingEnsureSetupProfileResult }'onboarding.ensure_setup_session': { params: OnboardingEnsureSetupSessionParams; result: OnboardingEnsureSetupSessionResult }+ /** Record that the user left the intro of the run in progress; returns onboarding.state. */+ 'onboarding.intro_seen': { params: Params; result: OnboardingRunStateResult }'onboarding.mark_seen': { params: Params; result: OnboardingStateResult }'onboarding.record_failed_start': { params: Params; result: OnboardingStateResult }/** Restore the setup profile to its created state in place (soul, memories, skills, sessions). */@@ -5813,6 +5816,7 @@ export const RPC_METHODS = ['model.save_key','onboarding.ensure_setup_profile','onboarding.ensure_setup_session',+ 'onboarding.intro_seen','onboarding.mark_seen','onboarding.record_failed_start','onboarding.reset_setup_profile',diff --git a/apps/shared/src/gateway-contract.openrpc.json b/apps/shared/src/gateway-contract.openrpc.jsonindex 9d972fcdd58..4a596cbcdcc 100644--- a/apps/shared/src/gateway-contract.openrpc.json+++ b/apps/shared/src/gateway-contract.openrpc.json@@ -2058,6 +2058,24 @@}}},+ {+ "name": "onboarding.intro_seen",+ "summary": "Record that the user left the intro of the run in progress; returns onboarding.state.",+ "params": [+ {+ "name": "params",+ "schema": {+ "$ref": "#/components/schemas/Params"+ }+ }+ ],+ "result": {+ "name": "result",+ "schema": {+ "$ref": "#/components/schemas/OnboardingRunStateResult"+ }+ }+ },{"name": "onboarding.mark_seen","summary": "",@@ -20523,7 +20541,7 @@},"OnboardingRunStateResult": {"additionalProperties": false,- "description": "``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh\ninstall). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``).\n``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it.",+ "description": "``run``: onboarding opens on this launch (root config ``onboarding.run``, else a fresh\ninstall). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``).\n``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it.\n``intro_seen``: the user left that run's intro once, so a relaunch reopens it as a normal chat.","properties": {"run": {"title": "Run",@@ -20544,6 +20562,11 @@],"default": null,"title": "Session Id"+ },+ "intro_seen": {+ "default": false,+ "title": "Intro Seen",+ "type": "boolean"}},"required": [diff --git a/tests/tui_gateway/test_onboarding_session.py b/tests/tui_gateway/test_onboarding_session.pyindex 17768f2b712..42d8aeca5ae 100644--- a/tests/tui_gateway/test_onboarding_session.py+++ b/tests/tui_gateway/test_onboarding_session.py@@ -73,6 +73,16 @@ def test_start_creates_one_onboarding_chat_and_plays_the_opening_once(client):assert _call("onboarding.start", {"rerun": True})["result"]["stored_session_id"] != stored+def test_leaving_the_intro_is_kept_on_the_run_and_a_rerun_plays_it_again(client):+ _call("onboarding.start")+ assert _call("onboarding.state")["result"]["intro_seen"] is False+ assert _call("onboarding.intro_seen")["result"]["intro_seen"] is True+ assert _call("onboarding.state")["result"]["intro_seen"] is True++ _call("onboarding.start", {"rerun": True})+ assert _call("onboarding.state")["result"]["intro_seen"] is False++def test_a_restart_before_the_opening_turn_plays_the_opening_on_relaunch(client, monkeypatch):def lost_submit(rid, params):client.append(("lost", params))@@ -339,7 +349,7 @@ def test_the_first_state_read_after_the_quiet_spell_says_do_not_run(root):record = onboarding_record.load(db, "onb")db.patch_session_model_config("onb", {"onboarding_run": {**record, "updated_at": record["updated_at"] - QUIET_COMPLETE_S}})- assert _call("onboarding.state")["result"] == {"run": False, "eligible": False, "session_id": None}+ assert _call("onboarding.state")["result"] == {"run": False, "eligible": False, "session_id": None, "intro_seen": False}def test_the_onboarding_facts_are_read_in_the_default_profile(root, client, monkeypatch):diff --git a/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py b/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.pyindex cdfa29db2f1..59f7f5fd3ae 100644--- a/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py+++ b/tui_gateway/contracts/profiles_vault_complete_foreign_subagents.py@@ -401,15 +401,19 @@ method("onboarding.mark_seen", params=Params, result=OnboardingStateResult)class OnboardingRunStateResult(Result):"""``run``: onboarding opens on this launch (root config ``onboarding.run``, else a freshinstall). ``eligible``: the free tier is on for this backend (``anon_auth.guest_enabled``).- ``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it."""+ ``session_id``: the stored id of the onboarding chat still in progress, so a relaunch reopens it.+ ``intro_seen``: the user left that run's intro once, so a relaunch reopens it as a normal chat."""run: booleligible: boolsession_id: str | None = None+ intro_seen: bool = Falsemethod("onboarding.state", params=Params, result=OnboardingRunStateResult,doc="Whether desktop first-run onboarding is due, and the chat in progress; reads the root profile's config.")+method("onboarding.intro_seen", params=Params, result=OnboardingRunStateResult,+ doc="Record that the user left the intro of the run in progress; returns onboarding.state.")class OnboardingSetRunParams(Params):diff --git a/tui_gateway/methods_onboarding.py b/tui_gateway/methods_onboarding.pyindex ea28a1aff41..f42ab80cf5f 100644--- a/tui_gateway/methods_onboarding.py+++ b/tui_gateway/methods_onboarding.py@@ -71,9 +71,23 @@ def _(rid, params: dict) -> dict:def _run_state() -> dict:from hermes_cli.anon_auth import guest_enabledfrom hermes_cli.onboarding_run import should_run++ from agent.onboarding_record import active_session_id, intro_seen# The lookup ends a run whose quiet spell ran out and closes the flag, so it goes first.- session_id = _active_onboarding_session()- return {"run": should_run(), "eligible": guest_enabled(), "session_id": session_id}+ with _profile_db(_ONBOARDING_PROFILE, writer=True) as db:+ session_id = None if db is None else active_session_id(db)+ seen = db is not None and intro_seen(db, session_id)+ return {"run": should_run(), "eligible": guest_enabled(), "session_id": session_id, "intro_seen": seen}+++@method("onboarding.intro_seen")+def _(rid, params: dict) -> dict:+ from agent.onboarding_record import active_session_id, mark_intro_seen+ with _profile_db(_ONBOARDING_PROFILE, writer=True) as db:+ session_id = None if db is None else active_session_id(db)+ if session_id is not None:+ mark_intro_seen(db, session_id)+ return _ok(rid, _run_state())# ── first-run onboarding: one chat in the default profile, driven by setup_beat ───────────────