:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(devbox): create boxes with automatic updates (#117735)
Raúl Negrón-Otero27b29345d837
diff --git a/.agents/skills/setting-up-devbox/SKILL.md b/.agents/skills/setting-up-devbox/SKILL.mdindex 9ef5b009b1b2..09038cdad415 100644--- a/.agents/skills/setting-up-devbox/SKILL.md+++ b/.agents/skills/setting-up-devbox/SKILL.md@@ -148,7 +148,7 @@ Pass `--port 8011` when a local stack already uses 8010.- **Tokens on the box:** store them as Coder user secrets, which reach every box the user owns. `hogli devbox:secret:set GH_TOKEN` reads the value from a hidden prompt or from `--file`. Never put a token on a command line or in the conversation. A secret reaches only boxes started after it is set, so run `hogli devbox:restart` on a running box. The template documents `CLAUDE_CODE_OAUTH_TOKEN`, `GH_TOKEN`, `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, and `POSTHOG_GIT_SIGNING_KEY`, which `hogli devbox:setup --configure-git-signing` sets. `devbox:secret:list` shows names, env vars, and descriptions, never values.- **A second box with the same state:** `hogli devbox:clone --as <label>` copies a running box's full disk, including any secrets on it, into `devbox-<coder-user>-<label>` in the source box's region. Stop the stack on the source first for a consistent copy. It asks for confirmation, so pass `-y` only after the user agrees. Only the owner can clone a box.-- **Template updates:** `hogli devbox:update` applies the latest template when the box is outdated.+- **Template updates:** `hogli devbox:update` applies the latest template when the box is outdated. `devbox:start` also updates an outdated box when it starts it. Boxes that `devbox:start` and `devbox:clone` create have Coder's automatic updates on, so they also move to the latest template when they start from the web UI or autostart, and on `hogli devbox:restart`. Coder never updates a box while it keeps running, but a restart of an outdated box is a full template update and can trigger the one-time dependency re-install that `devbox:update` warns about.- **Disk full:** `hogli devbox:cleanup:disk -n <label>` cleans a labeled box. With no workspace it cleans this machine instead, and the default box has no label, so clean the default box with `hogli devbox:exec -- bash -lc 'cd ~/posthog && ./bin/hogli devbox:cleanup:disk'`. `--docker` also prunes stopped containers, and `--cargo` also removes Rust build output, which forces a full rebuild.- **Pairing:** `hogli devbox:share --user <coder-user> --role use` grants access, and `devbox:users` lists usernames. `devbox:unshare` removes access only after `hogli devbox:restart`.- **Build and agent logs:** `hogli devbox:logs -f`.diff --git a/tools/hogli-commands/hogli_commands/devbox/coder.py b/tools/hogli-commands/hogli_commands/devbox/coder.pyindex c5c424d6474a..3704704fcbce 100644--- a/tools/hogli-commands/hogli_commands/devbox/coder.py+++ b/tools/hogli-commands/hogli_commands/devbox/coder.py@@ -48,6 +48,9 @@ NO_PRESET = "none"# from a prebuild warm pool (a Coder premium feature). Pass `--preset <name>` to# select a template preset explicitly where one is defined.DEFAULT_PRESET = NO_PRESET+# Coder applies the active template version only when a workspace starts, never+# to a running one, so template fixes reach a box without rebuilding it mid-run.+AUTOMATIC_UPDATES_ARGS = ("--automatic-updates", "always")BREW_PACKAGE = "coder/coder/coder"RUNTIME_SETUP_HINT = "Run `hogli devbox:setup`."_MANAGED_CODER_DIR = Path.home() / ".hogli" / "bin"@@ -1354,6 +1357,7 @@ def create_workspace("--preset",resolved_preset,"--use-parameter-defaults",+ *AUTOMATIC_UPDATES_ARGS,"--yes",]result = _run_with_param_retry(base_args, parameters, verbose=verbose)@@ -1450,6 +1454,7 @@ def clone_workspace("--preset",NO_PRESET,"--use-parameter-defaults",+ *AUTOMATIC_UPDATES_ARGS,"--yes",],{@@ -1487,8 +1492,14 @@ def stop_workspace(name: str, *, verbose: bool = False) -> None:def restart_workspace(name: str, *, verbose: bool = False) -> None:- """Restart a running workspace."""- result = _run_build(["coder", "restart", name, "--yes"], verbose=verbose)+ """Restart a running workspace.++ With automatic updates on, a restart of an outdated workspace is a template+ update, and Coder prompts for any new parameter. ``_run_build`` captures the+ output, so the prompt would hang unseen; ``--use-parameter-defaults`` takes+ the template default instead.+ """+ result = _run_build(["coder", "restart", name, "--use-parameter-defaults", "--yes"], verbose=verbose)if result.returncode != 0:raise SystemExit(result.returncode)diff --git a/tools/hogli-commands/hogli_commands/tests/test_devbox.py b/tools/hogli-commands/hogli_commands/tests/test_devbox.pyindex 4b619afeccf3..486792dbb62d 100644--- a/tools/hogli-commands/hogli_commands/tests/test_devbox.py+++ b/tools/hogli-commands/hogli_commands/tests/test_devbox.py@@ -1096,6 +1096,7 @@ class TestWorkspaceCreation:# prompt interactively for a preset, which `--yes` does not bypass.assert _flag_value(args, "--preset") == expected_presetassert "--use-parameter-defaults" in args+ assert _flag_value(args, "--automatic-updates") == "always"assert "--yes" in args# Security invariant: the Claude OAuth token is a Coder user secret# (env-injected at workspace start); it must never be forwarded as a@@ -1119,6 +1120,24 @@ class TestWorkspaceCreation:else:coder.update_workspace("devbox-test-user")+ def test_clone_workspace_forwards_source_and_creation_flags(self, monkeypatch: pytest.MonkeyPatch) -> None:+ captured: dict[str, object] = {}+ monkeypatch.setattr(coder, "_run_build", _fake_run_build_capturing(captured))++ coder.clone_workspace("devbox-test-user-copy", source_instance_id="i-0abc", disk_size=200, region="us-east-1")++ args = captured["args"]+ assert args[:3] == ["coder", "create", "devbox-test-user-copy"]+ assert _flag_value(args, "--preset") == "none"+ assert "--use-parameter-defaults" in args+ assert _flag_value(args, "--automatic-updates") == "always"+ assert "--yes" in args+ assert _parse_parameter_flags(args) == {+ "clone_source_instance_id": "i-0abc",+ "disk_size": "200",+ "workspace_region": "us-east-1",+ }+@pytest.mark.parametrize("start_app, expected",[(True, "true"), (False, "false"), (None, None)],