Repository navigation
Answer the create-a-workspace prompts with --org and --slug - #667
Conversation
Signing in needs no terminal thanks to the device grant, but the workspace fork is three Spectre prompts, and Spectre throws from inside one rather than returning. The flags go together: the slug is a permanent public hostname, and a collision cannot be re-asked for, so it ends the run naming the slug.
Only the zero-workspace fork consults the provisioner, so an account that already has one configures that workspace instead and exits 0. Argv gives the same trouble twice: `--org --slug acme` reads a flag as the name, and a blank value reads as absent. Every runtime hint names --no-prompt, without which the steps after creation throw on the session it was printed to.
Backing out of a prompt and having no terminal to prompt on are different reasons needing different follow-ups, and a bare null cannot carry which. So null now promises the picker has already said, and discovery adds no line — "no tenant selected" would otherwise land under guidance that just explained the session cannot prompt. Prompt capability is resolved once and handed to both.
The server names the workspace it creates and the profile is stamped from
that, so comparing against https://{slug}.kcap.ai would call a successful
create a failure the day those differ; a WorkOS profile is its slug either
way. The flags now also refuse the equals spelling, an invalid slug, and a
session that cannot answer the steps they leave unanswered.
PR Summary by QodoEnable unattended workspace creation during setup
AI Description
Diagram
High-Level Assessment
Files changed (20)
|
Code Review by Qodo
1.
|
`kcap setup <slug>` reads a positional as an existing server, so it resolves that host and never reaches creation — fine once a workspace is merely still building, useless for one that failed, was forbidden, or is unlinked, since none of those exist to point at.
realtonyyoung
left a comment
There was a problem hiding this comment.
Four P2 findings: the requested-workspace safety check occurs after auth/config publication, --no-prompt can still reach tenant selection, a present but valueless server flag can be ignored before creation, and retry guidance does not safely preserve the organization argument. Details are inline.
The check ran on a committed result, so an account that already belonged elsewhere kept the profile, stamp and tokens that commit had written; it moves onto the boundary's last cancellable step. --no-prompt now settles whether the picker may open, a valueless --server-url counts as the conflict it is, and no re-run command carries an organization name through a shell.
…on-interactive-workspace # Conflicts: # src/Capacitor.Cli/Commands/SetupCommand.cs
AI-2163
What & why
kcap setupcan authenticate anywhere since the device grant landed, but creating a workspace still needs a terminal: the zero-workspace fork asks three questions through Spectre prompts, and Spectre throws from inside a prompt rather than returning.--org "<name>" --slug <slug>supply those answers up front, so the fork raises nothing and the command is scriptable end to end.Both or neither — the slug becomes a permanent public hostname, so nothing derives one from the name in a run with nobody watching. Every combination that would take the flags and then not act on them is refused: alongside
--server-urlor a positional tenant, alongside--github, a value that is blank or is the next flag, the--org=spelling, a slug that could never be a hostname, and a non-interactive session without--no-prompt(which would create the workspace, then throw at the first step the flags do not answer).Where to look
WrongWorkspaceErrorcompares the landed workspace by slug, not by URL. Only the zero-workspace fork consults the provisioner, so an account that already has one never reaches it, and the run would otherwise configure a workspace nobody named — silently, with hooks and imports behind it. Profile names are the comparison because the server names the workspace it creates and the profile is stamped from the url it returns, which need not be the origin the CLI would guess.Two contract changes ride along.
ITenantPickerreturning null now means the picker has already said why, so discovery adds no second line of its own; without that, a headless run gets per-workspace guidance followed by a contradicting "No tenant selected." And a headless multi-workspace discovery declines with guidance instead of throwingNotSupportedException, which reacheskcap login --discovertoo.Verification
Suites run in the devcontainer:
SetupCommandTests69,SetupFacadeParityTests16,TenantProvisionerHeadlessTests16,SetupDecisionsTests22,LoginFacadeParityTests10,TenantPickerHeadlessTests2; Core auth 110,SetupFunnelTests7; AppWizardAuthBridgesTests25,SignInStepViewModelTests28.dotnet publish -c Releaseemits no IL2026/IL3050.Each guard was checked by breaking it and watching the named test fail: the slug comparison, the flag-value parse, the taken-slug exit, and both
RunDiscoveryAsyncwiring arguments — deleting either left the feature dead with the suite green until these tests existed.