Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(e2e): split three-end reset modes

cyhhao9490163094ad
diff --git a/docs/three-end-regression/README.md b/docs/three-end-regression/README.md
index 7527ea0dd..46396f3d5 100644
--- a/docs/three-end-regression/README.md
+++ b/docs/three-end-regression/README.md
@@ -34,7 +34,7 @@ Channel IDs are optional. If you leave them empty, the containers still start an
## Usage
-The default command rebuilds the image, resets generated state, and recreates all three containers:
+The default command rebuilds the image, preserves your current regression state, and recreates all three containers:
```bash
./scripts/run_three_regression.sh
@@ -44,14 +44,20 @@ Common commands:
```bash
./scripts/run_three_regression.sh --no-build
-./scripts/run_three_regression.sh --reset-state
+./scripts/run_three_regression.sh --reset-config
+./scripts/run_three_regression.sh --reset-all
./scripts/run_three_regression.sh --status
./scripts/run_three_regression.sh --logs
./scripts/run_three_regression.sh --logs slack
./scripts/run_three_regression.sh --down
```
-Use `--reset-state` only when you want to wipe the generated container state and re-seed it from `.env.three-regression`.
+Reset modes:
+
+- `--reset-config`: re-seed `config/`, `state/`, and `runtime/` from `.env.three-regression`, while preserving `workdir/`, `attachments/`, and `logs/`
+- `--reset-all`: wipe the full per-service state directory, including `workdir/`, then re-seed from `.env.three-regression`
+
+`--reset-state` remains available as a backward-compatible alias for `--reset-all`.
## What You Get
@@ -63,7 +69,7 @@ Discord -> http://127.0.0.1:15132
Feishu -> http://127.0.0.1:15133
```
-On first startup, or when you run with `--reset-state`, the runner seeds these files for every service:
+On first startup, or when you run with `--reset-config` / `--reset-all`, the runner seeds these files for every service:
- `config/config.json`
- `state/settings.json`
@@ -71,6 +77,12 @@ On first startup, or when you run with `--reset-state`, the runner seeds these f
The generated state lives under `_tmp/three-regression/`, which keeps each regression environment isolated while preserving your later modifications by default.
+Persistence rules:
+
+- `./scripts/run_three_regression.sh` preserves UI changes, sessions, and files under `workdir/`
+- `--reset-config` preserves `workdir/` files but resets service config/state
+- `--reset-all` clears everything under each service directory
+
## Configuration Rules
- The Slack container always runs Slack platform config.
diff --git a/scripts/prepare_three_regression.py b/scripts/prepare_three_regression.py
index 5df038918..8a06bb02b 100755
--- a/scripts/prepare_three_regression.py
+++ b/scripts/prepare_three_regression.py
@@ -36,6 +36,7 @@ SERVICE_DEFS = {
}
SUPPORTED_BACKENDS = {"opencode", "claude", "codex"}
+RESET_MODES = {"none", "config", "all"}
def _env(key: str, default: str = "") -> str:
@@ -236,9 +237,19 @@ def _write_text(path: Path, content: str) -> None:
path.write_text(content, encoding="utf-8")
-def _ensure_service_dir(service_dir: Path, reset_state: bool = False) -> None:
- if reset_state and service_dir.exists():
+def _ensure_service_dir(service_dir: Path, reset_mode: str = "none") -> None:
+ if reset_mode not in RESET_MODES:
+ allowed = ", ".join(sorted(RESET_MODES))
+ raise SystemExit(f"reset_mode must be one of: {allowed}")
+
+ if reset_mode == "all" and service_dir.exists():
shutil.rmtree(service_dir)
+ elif reset_mode == "config" and service_dir.exists():
+ for subdir in ("config", "state", "runtime"):
+ target = service_dir / subdir
+ if target.exists():
+ shutil.rmtree(target)
+
for subdir in ("config", "state", "logs", "runtime", "attachments", "workdir"):
(service_dir / subdir).mkdir(parents=True, exist_ok=True)
@@ -359,7 +370,7 @@ def _write_shared_agent_configs(output_root: Path) -> None:
_write_json(shared_root / ".config" / "opencode" / "opencode.json", _build_opencode_payload())
-def prepare(output_root: Path, reset_state: bool = False) -> None:
+def prepare(output_root: Path, reset_mode: str = "none") -> None:
_require_envs(("ANTHROPIC_API_KEY", "OPENAI_API_KEY"))
_write_shared_agent_configs(output_root)
@@ -367,17 +378,17 @@ def prepare(output_root: Path, reset_state: bool = False) -> None:
for service_name, service in SERVICE_DEFS.items():
_require_envs(service["required_envs"])
service_dir = output_root / service_name
- _ensure_service_dir(service_dir, reset_state=reset_state)
+ _ensure_service_dir(service_dir, reset_mode=reset_mode)
config_path = service_dir / "config" / "config.json"
settings_path = service_dir / "state" / "settings.json"
sessions_path = service_dir / "state" / "sessions.json"
- if reset_state or not config_path.exists():
+ if reset_mode in {"config", "all"} or not config_path.exists():
_write_json(config_path, _build_config_payload(service_name))
- if reset_state or not settings_path.exists():
+ if reset_mode in {"config", "all"} or not settings_path.exists():
_write_json(settings_path, _build_settings_payload(service_name))
- if reset_state or not sessions_path.exists():
+ if reset_mode in {"config", "all"} or not sessions_path.exists():
_write_json(sessions_path, {})
summary.append(
@@ -386,7 +397,7 @@ def prepare(output_root: Path, reset_state: bool = False) -> None:
platform=service["platform"],
channel=_summary_channel(service),
backend=_env(f"{_service_prefix(service_name)}_BACKEND"),
- state="reset" if reset_state else "preserved",
+ state=reset_mode if reset_mode != "none" else "preserved",
)
)
@@ -402,14 +413,15 @@ def main() -> int:
help="Directory that will hold generated per-service state",
)
parser.add_argument(
- "--reset-state",
- action="store_true",
- help="Reset service config/state directories before generating files",
+ "--reset-mode",
+ choices=sorted(RESET_MODES),
+ default="none",
+ help="Reset scope before generating files: none, config, or all",
)
args = parser.parse_args()
try:
- prepare(Path(args.output_root).resolve(), reset_state=args.reset_state)
+ prepare(Path(args.output_root).resolve(), reset_mode=args.reset_mode)
except SystemExit as exc:
print(str(exc), file=sys.stderr)
return 1
diff --git a/scripts/run_three_regression.sh b/scripts/run_three_regression.sh
index 3be38faf0..107e600d2 100755
--- a/scripts/run_three_regression.sh
+++ b/scripts/run_three_regression.sh
@@ -17,14 +17,15 @@ fi
MODE="up"
BUILD_FLAG="--build"
LOGS_SERVICE=""
-RESET_STATE=false
+RESET_MODE="none"
usage() {
cat <<'EOF'
Usage:
./scripts/run_three_regression.sh
./scripts/run_three_regression.sh --no-build
- ./scripts/run_three_regression.sh --reset-state
+ ./scripts/run_three_regression.sh --reset-config
+ ./scripts/run_three_regression.sh --reset-all
./scripts/run_three_regression.sh --down
./scripts/run_three_regression.sh --status
./scripts/run_three_regression.sh --logs [slack|discord|feishu]
@@ -64,8 +65,16 @@ while [ $# -gt 0 ]; do
BUILD_FLAG=""
shift
;;
+ --reset-config)
+ RESET_MODE="config"
+ shift
+ ;;
+ --reset-all)
+ RESET_MODE="all"
+ shift
+ ;;
--reset-state)
- RESET_STATE=true
+ RESET_MODE="all"
shift
;;
-h|--help)
@@ -168,9 +177,7 @@ docker compose -p "$PROJECT_NAME" -f "$COMPOSE_FILE" down --remove-orphans >/dev
echo "Preparing generated config and state..."
PREPARE_ARGS=(--output-root "$OUTPUT_ROOT")
-if [ "$RESET_STATE" = true ]; then
- PREPARE_ARGS+=(--reset-state)
-fi
+PREPARE_ARGS+=(--reset-mode "$RESET_MODE")
"$PYTHON_BIN" "$REPO_ROOT/scripts/prepare_three_regression.py" "${PREPARE_ARGS[@]}"
echo "Starting three-end regression containers..."
diff --git a/tests/test_prepare_three_regression.py b/tests/test_prepare_three_regression.py
index ea946e917..c35312116 100644
--- a/tests/test_prepare_three_regression.py
+++ b/tests/test_prepare_three_regression.py
@@ -114,7 +114,7 @@ def test_prepare_allows_missing_channel_ids(tmp_path: Path, monkeypatch: pytest.
monkeypatch.delenv("THREE_REGRESSION_DISCORD_CHANNEL", raising=False)
monkeypatch.delenv("THREE_REGRESSION_FEISHU_CHAT_ID", raising=False)
- module.prepare(tmp_path, reset_state=True)
+ module.prepare(tmp_path, reset_mode="config")
slack_settings = json.loads((tmp_path / "slack" / "state" / "settings.json").read_text(encoding="utf-8"))
discord_settings = json.loads((tmp_path / "discord" / "state" / "settings.json").read_text(encoding="utf-8"))
@@ -132,3 +132,34 @@ def test_prepare_requires_supported_backend(monkeypatch: pytest.MonkeyPatch, tmp
with pytest.raises(SystemExit, match="THREE_REGRESSION_SLACK_BACKEND"):
module.prepare(tmp_path)
+
+
+def test_prepare_reset_config_preserves_workdir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
+ module = _load_module()
+ _set_required_env(monkeypatch)
+
+ workdir = tmp_path / "discord" / "workdir"
+ workdir.mkdir(parents=True)
+ (workdir / "keep.txt").write_text("keep-me", encoding="utf-8")
+ config_dir = tmp_path / "discord" / "config"
+ config_dir.mkdir(parents=True)
+ (config_dir / "config.json").write_text('{"stale": true}', encoding="utf-8")
+
+ module.prepare(tmp_path, reset_mode="config")
+
+ assert (workdir / "keep.txt").read_text(encoding="utf-8") == "keep-me"
+ refreshed = json.loads((config_dir / "config.json").read_text(encoding="utf-8"))
+ assert refreshed["agents"]["default_backend"] == "codex"
+
+
+def test_prepare_reset_all_clears_workdir(tmp_path: Path, monkeypatch: pytest.MonkeyPatch):
+ module = _load_module()
+ _set_required_env(monkeypatch)
+
+ workdir = tmp_path / "discord" / "workdir"
+ workdir.mkdir(parents=True)
+ (workdir / "drop.txt").write_text("remove-me", encoding="utf-8")
+
+ module.prepare(tmp_path, reset_mode="all")
+
+ assert not (workdir / "drop.txt").exists()