Skip to content

feat: add persistent startup command hook - #40

Merged
PabloZaiden merged 5 commits into
mainfrom
feat/startup-command-hook
Sep 9, 2026
Merged

PabloZaiden merged 5 commits into
mainfrom
feat/startup-command-hook

Conversation

@PabloZaiden

Copy link
Copy Markdown
Owner

Summary

  • add --startup-command <command> for up and rebuild
  • persist the command in workspace state so later external invocations and devbox arise reuse it
  • execute the command with devcontainer exec after container setup, independently of bundled SSH
  • add --no-startup-command to clear the persisted hook
  • document the lifecycle and raw Docker restart behavior

This is intended for container-local services such as a Clanky worker. The command should be idempotent and daemonize long-running processes; raw docker restart is intentionally not covered, matching the existing Devbox SSH runner lifecycle.

Validation

  • bun run typecheck
  • bun run test
  • bun run build

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 9, 2026 03:18
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

An invalid persisted startupCommand currently causes state loading to fail in a way that can prevent users from recovering/clearing the setting via the CLI.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds a new, persisted “post-start” hook that runs a user-specified shell command inside the devcontainer after successful devbox up / devbox rebuild, with CLI flags to set or clear it and documentation/tests to cover the lifecycle.

Changes:

  • Add --startup-command <command> / --no-startup-command to up and rebuild, persisting the value in workspace state.
  • Execute the persisted command via devcontainer exec ... sh -lc <command> after container setup completes.
  • Extend tests and README to document and validate persistence and execution behavior.
File summaries
File Description
tests/runtime.test.ts Adds unit coverage for startup-command script normalization/rejection.
tests/examples.test.ts Adds an end-to-end simulated-host test ensuring the command runs and persists across up/rebuild, and can be cleared.
tests/core.test.ts Adds CLI arg parsing and state-loading coverage for startup command options and persistence.
src/runtime.ts Introduces runStartupCommand and buildStartupCommandScript and runs it via devcontainer exec sh -lc.
src/core.ts Extends args/state schema with startupCommand and parsing helpers, including persisted-state validation.
src/cli.ts Wires startup command selection/clearing into the up/rebuild lifecycle and persists it to state.
README.md Documents the new flags, lifecycle behavior, and state file field.
Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/core.ts Outdated
PabloZaiden and others added 3 commits September 9, 2026 03:26
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@PabloZaiden
PabloZaiden merged commit 4ed53eb into main Sep 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants