feat: add persistent startup command hook - #40
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟡 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-commandtoupandrebuild, 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.
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--startup-command <command>forupandrebuilddevbox arisereuse itdevcontainer execafter container setup, independently of bundled SSH--no-startup-commandto clear the persisted hookThis is intended for container-local services such as a Clanky worker. The command should be idempotent and daemonize long-running processes; raw
docker restartis intentionally not covered, matching the existing Devbox SSH runner lifecycle.Validation
bun run typecheckbun run testbun run build