Skip to content

feat(cli): prompt for worker name if not provided - #6349

Open
johnstonmatt wants to merge 2 commits into
developfrom
FUNC-840/select-workers-new-name
Open

feat(cli): prompt for worker name if not provided#6349
johnstonmatt wants to merge 2 commits into
developfrom
FUNC-840/select-workers-new-name

Conversation

@johnstonmatt

@johnstonmattjohnstonmatt commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Makes the name argument to supabase workers new optional and prompts for it
when it is omitted, so a bare supabase workers new walks through name, runtime
and size rather than failing the parse.

The name is the one input this command cannot default — it is the directory, the
[workers.<name>] key and the hostname all at once. So where the runtime and
size prompts fall back to a default when there is nowhere to ask, the name
prompt has nothing to fall back to: with -o json|yaml|toml|env or no
interactive terminal, the command fails with a new MissingWorkerNameError
pointing at supabase workers new api.

The prompt validates against everything the command would otherwise refuse a
moment later — a non-DNS-label name, and a name config.toml already records —
so a typo is corrected in place instead of ending the run. That also means the
project has to be loaded before the first prompt, and the machine-output check
moves up with it: -o leaves output.format as text, and Clack writes its
terminal UI to stdout, so a name prompt would land in front of the payload for
the same reason the runtime prompt would.

The handler's inline name validation is replaced by the shared
legacyValidateWorkerName, which the rest of the command family already uses,
so an explicitly-passed name and a prompted one are refused on identical terms.

mockOutput now records promptTextCalls so tests can assert on the prompt's
message and exercise its validate callback.

Stack 5, on top of workers list/status/delete (#6263).

Linked issue

FUNC-840 (Linear). Supabase maintainer, exempt from the open-for-contribution flow.

Checklist

@johnstonmattjohnstonmatt changed the title feat(workers): make worker name optional and prompt interactivelyfeat(cli): add supabase workers command familyAug 27, 2026
@johnstonmattjohnstonmatt changed the title feat(cli): add supabase workers command familyfeat(cli): prompt for worker name if not providedAug 27, 2026
@johnstonmatt
johnstonmatt marked this pull request as ready for review August 27, 2026 01:58
@johnstonmatt
johnstonmatt requested a review from a team as a code ownerAugust 27, 2026 01:58

@chatgpt-codex-connectorchatgpt-codex-connectorBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit:12693d1a8b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment threadapps/cli/src/legacy/commands/workers/new/new.handler.ts Outdated
@github-actions

github-actionsBot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Supabase CLI preview

npx --yes https://pkg.pr.new/supabase/cli/supabase@edc71990a255a0fd188063aa7f1ead65bcb9e998

Preview package for commit edc7199.

Base automatically changed from FUNC-753/workers-read to developAugust 27, 2026 17:10
@chatgpt-codex-connector

chatgpt-codex-connectorBot commented Aug 29, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

ReviewStatusCommitReview trigger
📝 Code ReviewCompleted2026-08-29T02:46:02.307063Zedc7199New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Makes the `name` argument to `supabase workers new` optional and prompts for it
when it is omitted, so a bare `supabase workers new` walks through name, runtime
and size rather than failing the parse.
The name is the one input this command cannot default — it is the directory, the
`[workers.<name>]` key and the hostname all at once. So where the runtime and
size prompts fall back to a default when there is nowhere to ask, the name
prompt has nothing to fall back to: with `-o json|yaml|toml|env` or no
interactive terminal, the command fails with a new `MissingWorkerNameError`
pointing at `supabase workers new api`.
The prompt validates against everything the command would otherwise refuse a
moment later — a non-DNS-label name, and a name `config.toml` already records —
so a typo is corrected in place instead of ending the run. That also means the
project has to be loaded before the first prompt, and the machine-output check
moves up with it: `-o` leaves `output.format` as `text`, and Clack writes its
terminal UI to stdout, so a name prompt would land in front of the payload for
the same reason the runtime prompt would.
The handler's inline name validation is replaced by the shared
`legacyValidateWorkerName`, which the rest of the command family already uses,
so an explicitly-passed name and a prompted one are refused on identical terms.
`mockOutput` now records `promptTextCalls` so tests can assert on the prompt's
message and exercise its `validate` callback.
@johnstonmatt
johnstonmattforce-pushed the FUNC-840/select-workers-new-name branch from fecde22 to d4e37d5CompareAugust 29, 2026 02:35
`output.interactive` is derived solely from `tty.stdoutIsTty`, so with stdin
piped or redirected and stdout still on a terminal it stayed true. A bare
`printf 'api\n' | supabase workers new` therefore opened Clack's name prompt and
read the worker name off the pipe instead of taking the documented
`MissingWorkerNameError` path — and the runtime and size prompts consumed
whatever followed rather than falling back to their defaults.
The three resolvers now share one `canPromptFor` decision, made once before the
first prompt, which pairs `output.interactive` with `tty.stdinIsTty` the way
`workers delete` already guards its confirmation. A prompt is only answerable
from a keyboard, so both streams have to be a terminal.
Sign up for freeto 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.

1 participant

@johnstonmatt