Skip to content

bl apps: create the static app on first deploy --dir - #53

Open
scottcrawford03 wants to merge 2 commits into
block:mainfrom
scottcrawford03:scrawford/apps-deploy-dir-create
Open

scottcrawford03 wants to merge 2 commits into
block:mainfrom
scottcrawford03:scrawford/apps-deploy-dir-create

Conversation

@scottcrawford03

Copy link
Copy Markdown
Contributor

Summary

Publishing a static site used to take two commands: bl apps create --runtime-profile static, then bl apps deploy --dir. Now one command does it:

bl apps deploy docs-site --dir dist

If you have no app with that ID, the deploy creates it as a static app and then deploys. It prints Created new app docs-site at <url> on stderr, and the JSON gains "created": true plus the creation result under create. Later deploys to the same ID update the app and report "created": false.

  • Someone else owns the ID: reservation fails (app_id_collision) and nothing is uploaded.
  • --private: a new app is made private before its first deploy. If the app already exists, --private only checks that it is already private. When it isn't, the command fails before uploading and points to bl apps visibility <id> private.
  • The first deploy fails after creation: the error says the app was created, and rerunning the same command deploys to it.
  • Prebuilt artifact.tar.gz deploys: unchanged. They still need bl apps create because the CLI can't tell their runtime. --private conflicts with an artifact path.

run_create's plan → reserve → visibility → initialize sequence moves into a shared create_app, so both commands use the same reservation reconciliation and private handling.

Testing

  • just lint and just test.
  • New process tests:
    • missing app → plan → reserve → deploy, checking that static is in the plan and reserve bodies;
    • --private on a new app → visibility before deploy;
    • collision → no deploy;
    • --private on an existing public app is refused before upload;
    • --private on an existing private app deploys;
    • a failed first deploy reports that rerunning will resume;
    • an artifact with --private is rejected.
  • Live on a staging control plane:
    • A new ID was created and deployed, and went ready.
    • A redeploy to the same ID reported created: false and went ready.
    • --private on that existing public app was refused.
    • --private on a new ID created the app with visibility restricted.

🤖 Generated with Claude Code

`bl apps deploy <id> --dir <dir>` now creates the app as a static app when
the caller has none with that ID, then deploys to it. Later deploys to the
same ID update it. An ID someone else owns fails at reservation and nothing
is deployed. `--private` makes a new app private before its first deploy;
for an existing app it only checks the app is already private.

Prebuilt artifact deploys are unchanged and still need `bl apps create`.
The create flow is shared with `bl apps create` through `create_app`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@scottcrawford03
scottcrawford03 requested a review from a team as a code owner November 17, 2026 18:20
Comment thread src/bl/apps.rs Outdated
CreateOptions {
private,
mysql_requested: false,
retry_command: "bl apps deploy",

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.

🤖 For a new app the server's plan always asks for initialize (Recommended: live == nil in compose internal/app/agent.go). If initialize fails after the reserve, this error tells the user to "retry the same bl apps deploy command to reconcile the reservation and continue initialization". On that rerun, though, get_app finds the reservation and returns Ok. So ensure_static_app skips create_app, the upload happens straight away, and initialize never runs. I couldn't confirm whether the server accepts a deploy to an uninitialized static app, but either way the message promises something the rerun doesn't do. Not blocking. Two options: have the Ok(_) branch re-plan and resume through create_app when initialize.required is still true, or point this message at bl apps initialize.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Fixed in f7c2ab2. For static plans the server never asks for initialize: the static branch in the plan handler overrides it to required: false, and both live staging creates came back initialized: false. So this path is unreachable today, but you were right that the message was wrong. Deploy-created apps now get their own recovery text. An initialize failure says nothing was deployed and to run bl apps initialize <id>, then the same bl apps deploy. A failure to make the app private now points at bl apps visibility <id> private, because a rerun on its own would just hit the existing-app check. I added a process test for the initialize case.

Comment thread src/bl/apps.rs
.get("external_url")
.and_then(Value::as_str)
.unwrap_or("");
eprintln!(

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.

🤖 Product tradeoff, not a bug. With this change, a typo in the app ID (bl apps deploy docs-stie --dir dist) creates a stray app instead of failing. That app counts against the app limit, and the only signal is this stderr line and created: true in the JSON. One-command deploys are probably worth it. If the typo case turns out to bite people, a confirmation on interactive terminals or a louder message could help.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

🤖 Agreed it's worth it. In f7c2ab2 the stderr line now says no app with that ID existed and that a typo can be undone with bl apps delete. The README tells people to check that line on first deploys. If typos start costing people app slots, we can add an interactive confirmation later.

Rerunning `bl apps deploy` after an interrupted create finds the reserved
app and only deploys, so it cannot finish a private or initialize step.
Point those failures at `bl apps visibility` and `bl apps initialize`
instead of promising the rerun reconciles them.

Also say plainly on stderr that no app with the ID existed and how to
remove one created by a typo.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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