From 1457904e8d6e86088e83498b239fce1b243bec5d Mon Sep 17 00:00:00 2001 From: chengyongru Date: Thu, 24 Sep 2026 13:07:13 +0800 Subject: [PATCH] fix(cli): shorten session storage startup guidance --- nanobot/cli/runtime_config.py | 27 +++++++++------------------ tests/cli/test_session_startup.py | 8 ++++---- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/nanobot/cli/runtime_config.py b/nanobot/cli/runtime_config.py index 8df50ff4b..5a71cb9b3 100644 --- a/nanobot/cli/runtime_config.py +++ b/nanobot/cli/runtime_config.py @@ -147,25 +147,16 @@ def _validate_session_storage(config: Config, *, workspace_override: str | None return source = "--workspace" if workspace_override else "agents.defaults.workspace" - console.print(Text("Cannot start: session storage must be outside the agent workspace.", style="red")) - console.print(Text(f"Config: {config_path}")) + console.print(Text("Cannot start: chat history must be outside the workspace.", style="red")) + console.print() console.print(Text(f"Workspace ({source}): {workspace}")) - console.print(Text(f"Sessions: {sessions}")) - console.print( - "Sessions are stored beside the active config file. --workspace overrides the " - "configured workspace; it does not move sessions." - ) - console.print( - "Stop this instance and back up its config directory and workspace. Move the " - "config file and its runtime data, including sessions, to a directory outside the " - "workspace, then restart with --config pointing to the moved config file." - ) - console.print("Example layout: bot/config.json, bot/sessions/, bot/workspace/.") - console.print( - "Keep the existing workspace path and its .nanobot/workspace-id to preserve " - "its session identity. See docs/troubleshooting.md#session-storage-overlaps-the-workspace " - "for layout and migration options." - ) + console.print(Text(f"Chat history: {sessions}")) + console.print() + console.print("To fix, keep the workspace in place:") + console.print(" 1. Stop the instance and back up its files.") + console.print(" 2. Move config.json and its runtime data outside the workspace.") + console.print(" 3. Restart with --config pointing to the moved config file.") + console.print("Migration help: docs/troubleshooting.md") raise typer.Exit(1) diff --git a/tests/cli/test_session_startup.py b/tests/cli/test_session_startup.py index ff7346a29..0af9ac445 100644 --- a/tests/cli/test_session_startup.py +++ b/tests/cli/test_session_startup.py @@ -46,8 +46,8 @@ def test_startup_rejects_nested_sessions_before_writing_files( output = "".join(result.stdout.splitlines()) assert result.exit_code == 1, result.output - assert "session storage must be outside" in output - assert str(config_path) in output + assert "chat history must be outside" in output + assert config_path.name in output assert str(workspace) in output assert str(config_path.parent / "sessions") in output source = "--workspace" if override else "agents.defaults.workspace" @@ -70,7 +70,7 @@ def test_startup_rejects_sessions_equal_to_workspace(tmp_path: Path) -> None: result = runner.invoke(app, ["gateway", "--config", str(config_path)]) assert result.exit_code == 1 - assert "session storage must be outside" in result.stdout + assert "chat history must be outside" in result.stdout assert not workspace.exists() @@ -106,6 +106,6 @@ def test_webui_checks_resolved_workspace_before_saving( result = runner.invoke(app, ["webui", "--config", str(config_path), "--yes", "--no-open"]) assert result.exit_code == 1 - assert "session storage must be outside" in result.stdout + assert "chat history must be outside" in result.stdout assert config_path.read_bytes() == before assert set(tmp_path.iterdir()) == {config_path}