Skip to content

fix: sweep P0s: auto-compile, test wait exit codes, help examples, list flags, forms, -o table, error hints - #57

Open
Bradenream wants to merge 10 commits into
braden/teach-errorsfrom
braden/sweep-p0
Open

Bradenream wants to merge 10 commits into
braden/teach-errorsfrom
braden/sweep-p0

Conversation

@Bradenream

@Bradenream Bradenream commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Stacked on #56, which is stacked on #55. The base is braden/teach-errors, so this diff shows only these 10 commits. Retarget once #56 merges.

These are the top-priority fixes from the usability sweeps. Commits 8–10 fix what the third sweep found in this stack. Each commit builds and passes CI on its own, and each has a test that fails without its fix.

# Commit What it fixes
1 fix(test): wait and wait-suite exit non-zero unless every run passed test run wait and wait-suite exited 0 on failed runs, so CI went green on failing tests
2 fix(flagutil): list flags take a JSON array, and lists of IDs take commas --run-ids '["a","b"]' (the help's own syntax) sent one ID, ["a","b"]
3 fix(cli): every help example runs as written 78 examples named commands that don't exist (vf query …, vf run wait). Others left out a required flag
4 fix(interactive): a long description no longer hides a field's input Below ~100 columns, forms hid the input line or options, so people typed blind
5 fix(output): -o table shows the rows a response wraps, or says why not -o table failed on most lists, and transcript search -o table exited 0 with no rows
6 fix(output): point an API error's hints at the real cause Hints blamed the wrong flag, told people to retry input errors, and contradicted the server
7 feat(conversation): compile the draft before a conversation runs it After an edit, conversations silently ran the old build until environment compile
8 fix(cli): an unknown short flag suggests what it means elsewhere Every unknown short flag got "Did you mean --jq?" (from #56)
9 fix(flagutil): body flags turn stdin off on whole-body union commands too On 16 commands whose whole body is a union, body flags still read stdin, so sleep 15 | vf test turn create … waited 10s and failed
10 fix(cli): help examples give a whole-body union one of its forms 7 examples still failed as written with "the body is none of its forms"

Details

1. test run wait exits 1 unless every run passed

  • The result is printed first, as before. Then the command exits 1 if a run:
    • failed or was canceled
    • was still going when the wait stopped
    • wasn't found
  • The error says which, with the command to read the run's logs or keep waiting:
    Error: 1 of 2 runs did not pass (1 failed, 0 canceled)
      - Read a run's logs: vf test run get --project-id p1 --environment-alias main --run-id 6b05bb
    
  • Works the same with -o json and --jq, which skip decoding the response. The verdict reads the raw body and puts it back unchanged.
  • wait-suite uses the same suiteOutcome as create-suite --wait, so the three commands now agree.

2. List flags take JSON arrays and commas

  • A value that starts with [ is read as a JSON array of strings. [] sends an empty list, as --expected-actions asks for.
  • Lists of IDs or names also split on commas: --*-ids, --exclude-id, --*-order, --expected-steps, --kinds, --levels.
  • Lists of free text keep their commas: --exclude (URL patterns) and --remove (written words).
  • Every list flag's help says how to pass several values.

3. Help examples

  • A startup hook (examplehelp.go) rewrites every generated example:
    • The command words become the command's real path.
    • A multi-word value is quoted.
    • A flag left with no value gets a placeholder.
    • Missing required flags are added. Of a union's variants, only the first is added.
  • A test parses every example in the tree (~264) with its own command and checks each required flag.

4. Forms

  • Cause: huh v0.6 doesn't wrap descriptions. The form wrapped them after drawing the ┃ border, so the field was taller than the form allowed for, and the bottom got cut off.
  • Fix: the theme wraps descriptions to the field's inner width. A select's height now counts its title and description.
  • Checked in a real pty at 60–72 columns:
    • event create's --goes-to shows all its options.
    • secret create shows its input line.
    • "Fill in N optional field(s)?" shows Yes/No.

5. -o table

  • A response holding one list prints the list as rows, with its other plain fields under them.
  • A wrapper around one record prints the record.
  • A response holding several lists fails, names them, and points to -o json.

6. Error hints

  • A 404 names the resource's own ID flag first: Check --event-id ev1: it may be wrong, or not be in --project-id p1, --environment-alias main.
  • Cannot PATCH /v1/… is now unsupported_command: the server has no such route. This is what function patch-code hits every time.
  • A 500 with a specific message no longer says "usually temporary, run it again". Generic and timeout-like 500s still do.
  • A 409 or 403 with a reason of its own no longer gets "name already taken" or "your account isn't allowed".
  • List hints and the next steps after a create carry -p/-e, so they run when pasted.
  • MCP tool names in server messages become vf commands: search_instructions → vf agent search-instructions.

7. Conversations compile the draft first

  • Problem: a conversation runs the last compiled build, and nothing compiled it after an edit. agent update then run-script talked to the old agent. The only sign was needsRecompile: true at the top of hundreds of lines.
  • Fix: no API call says the draft is stale before a run, so vf compiles whenever a conversation with the draft starts:
    • before every run-script
    • before a send with a launch action
  • Later send turns keep their build. If a turn still ran a stale one (an edit mid-conversation, or a conversation that opened with text), vf compiles right after the answer and warns, so the next turn runs the edits. Works with -o json and --jq.
  • --no-compile talks to the last build as it is. The published version is never compiled.
  • A draft that won't compile stops before any credits are spent:
    Error: Couldn't compile the draft, so the conversation didn't run | HTTP 422 Unprocessable Entity
      - Playbook 'Returns' has no instructions, so the agent can't be compiled.
        Something in the agent's draft keeps it from compiling.
      Next:
        Fix what the message names in the agent, then run it again
        Add '--no-compile' to talk to the last build instead
    
  • At a terminal, ✓ Compiled the draft of main (1.2s), so this runs your latest edits. Agent mode stays quiet on success.
  • The README's quickstart notes say how this works.

8. Unknown short flags

  • Cause: a typo may change at most two letters, and any one-letter name is within two edits of jq.
  • Fix: a typo may now change at most half a name. An unknown -p suggests the long flag that -p stands for on other commands, if this command has it:
    Error: vf agent update has no flag -p
      Next:
        Did you mean `--project-id`?
    
  • -z, which stands for nothing, suggests nothing.

9. Stdin on whole-body unions

  • bodyFlagsGiven only looked at flags under the body (Body.…). A body that is a union as a whole is filled by a flag whose field is Body itself, so --body-param.user … didn't count.
  • Affects 16 commands, including test turn create, test check create, workflow update-step, evaluation create and the *-tool-message commands.
  • sleep 12 | vf test turn create … --body-param.user '{…}' --dry-run: 10.0s before, 0.03s after.

10. Examples for whole-body unions

  • These unions aren't marked required: any one of several flags fills them. So fix: enrich docs for every operation, not the first three paths (COR-13588) #3's fix added nothing, and vf test check create --project-id <id> --environment-alias <value> failed.
  • RegisterFlags now marks a union that isn't optional (unionform.go, a one-line hook in metadata.go). The example gets its first form: a field of the variant where there is one, else the variant as JSON:
    vf test check create --project-id <id> --environment-alias <value> --body-param.response <value>
    vf workflow update-branch … --body-param.condition <value>
    
  • TestEveryExampleRunsAsWritten now fails when a union that needs a form has none. Without the fix it names exactly the 7 commands.

With #30 and #35

Testing

  • Each of the 10 commits passes:
    • go build, gofmt (1.25 and 1.27), scripts/vet.sh, go test ./...
    • the 138 TS behaviour tests and yarn oxlint
    • an unchanged go.mod/go.sum
  • Each fix's test fails without the fix. Checked by reverting each hook.
  • Checked by hand against a local fake API:
    • test run wait in pretty, -o json, --jq and agent mode
    • -o table
    • the forms in a pty
    • a compile failure in human and agent mode
  • Not checked against the live API: how long a compile takes, and what the runtime does on a text-first conversation. The tests cover the order of requests.

Not in this PR

  • conversation send: {"type":"end"} is mangled, there's no --message, and it prints hundreds of trace lines.
  • -o yaml: changes key names.
  • docs/: was already behind the command tree before this PR. Regenerating it touches 104 files of earlier work, so it's left for its own change.
  • API-side bugs: in Linear COR-16384.

`vf test run wait` and `vf test run wait-suite` printed the runs' results
and exited 0 whatever they were, while `create-suite --wait` exits 1 when a
run fails. A pipeline that started runs and then waited for them went green
on failing tests.

Now, once the result is printed, the command exits 1 when a run failed or
was canceled, a run was still going when the wait stopped, or a run ID wasn't
found. The error says which, with the command to read a failed run's logs or
keep waiting. -o json and --jq skip decoding the response, so the verdict
reads the raw body and puts it back to be printed unchanged. wait-suite is
judged by the same suiteOutcome as create-suite --wait.
…mmas

A list flag took each value as is. But the generated examples write lists
as JSON (`--run-ids '["a","b"]'`), `--expected-actions` says "Send [] when
it has none", and `test run create-suite --test-ids` splits commas. So
`--run-ids '["a"]'` sent the one ID `["a"]` and `--run-ids a,b` the one ID
`a,b`. The server answered that none existed, and the error blamed the
project ID.

Now a value that starts with [ is read as a JSON array of strings, and `[]`
sends an empty list, even to a required flag. A list of IDs or names
(--*-ids, --exclude-id, --*-order, --expected-steps, --kinds, --levels...)
also splits on commas. Lists of free text (URL patterns, written words) keep
their commas. Every list flag's help says how to pass several values.
The generator builds an example from the SDK's resource name, not from the
command's place in the tree. So the 78 commands three levels down showed
commands that don't exist: `vf query project-transcript-count`, `vf run
wait`, `vf function-variable create`. Some examples left out a required flag
(document create-text's --file), left a flag with no value (workflow
delete-block's --expected-steps), or ran a multi-word value on unquoted
(agent add-workflow's --description).

fixExamples rewrites each example once, at startup: the command words become
the command's real path, a multi-word value is quoted, a flag with no value
gets a placeholder, and each required flag missing is added. Of a union's
variants, which are all marked required but are alternatives, only the first
is added, and none when the example already sets the union. A test parses
every example in the tree with its own command.
huh v0.6 doesn't wrap a field's description. The form's viewport wrapped it
after the field's border was drawn, so the extra lines lost the border, and
the form, sized by the unwrapped lines, cut off the bottom of the field. At
72 columns `event create` showed --goes-to's description and none of its
options, `secret create` hid its input line, and "Fill in N optional
field(s)?" hid Yes and No. Keys still reached the hidden field, so people
typed blind and a hidden select submitted its first option.

The theme now wraps descriptions to the width a field has inside its border.
A select's height, which huh counts from the top of its title, now includes
the title and description lines, so all the options it was sized for show.
Almost every response wraps its data in an object: {"environments": [...]},
{"project": {...}}, {"transcripts": [...], "returned": 1, "hasMore": false}.
The table printer only knew a bare list, record or map, so `environment
list -o table` and `project get -o table` failed with "no displayable fields
found", and `transcript search -o table` printed returned and hasMore and
exited 0 without a single transcript.

Now a response holding one list prints it as rows, with its other plain
fields under them. A wrapper around one record prints the record. A response
holding several lists fails and names them, and every table error says to
use -o json or -o yaml, so no rows are dropped unseen.
explainAPI starts from what each status usually means. The usability sweep
found five places where that sent people the wrong way:

- A 404 blamed only the scope flags, never the ID of the thing looked up.
  `event get --event-id <typo>` said to check --project-id, and `test run
  wait --run-ids <bad>` blamed the project. Now the resource's own ID flags
  come first: "Check --event-id ev1: it may be wrong, or not be in
  --project-id p1, --environment-alias main."
- A 404 whose body is "Cannot PATCH /v1/..." is a route the server doesn't
  have, not a wrong ID. `function patch-code` failed that way every time and
  said to recheck three correct IDs. It is now unsupported_command, says the
  server has no such route, and blames no flag.
- A 500 that said what was wrong with the input ("Could not resolve 'nope'
  environment alias") said "It's usually temporary. Run it again in a
  minute". A 500 with a specific message now says it will likely fail the
  same way. A generic or passing one (timeout, unavailable) still says to
  retry.
- A 409 or 403 with its own reason ("oldString was not found in the current
  text", "Main environment cannot be deleted") got "a name that's already
  taken" or "your account isn't allowed". The stock text now only appears
  when the message is about a name or about access.
- The commands in hints left out the scope flags they need, so pasting
  `vf event list` or `vf event get --event-id ev1` asked for a project. Both
  the 404/409 list hint and the next steps after a create now carry the -p
  and -e they were given, outside the home prompt where context fills them.

A server message that names an MCP tool beside the command
(search_instructions) now names the vf command (`vf agent
search-instructions`).
Copilot AI balanced review requested due to automatic review settings November 30, 2026 15:43

Copilot AI 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.

🟡 Changes recommended

Unresolved correctness issues break JSON-array flags, silently omit table data and required parent IDs in follow-up commands, and let wait commands exit successfully after response-decoding failures.

5 open issues
6 files not reviewed
  • internal/cli/root.go: Generated file
  • internal/cli/test/run/wait.go: Generated file
  • internal/cli/test/run/waitsuite.go: Generated file
  • internal/flagutil/metadata.go: Generated file
  • internal/interactive/interactive.go: Generated file
  • internal/output/output.go: Generated file
What changed in this PR

This PR follows up on #55 and #56 with usability fixes for the Voiceflow CLI, focusing on reliable CI results, usable command examples, and clearer terminal output.

Changes:

  • Makes test-wait commands return failure when runs do not pass and adds JSON-array/comma parsing for list flags.
  • Repairs generated help examples and adjusts forms to keep inputs visible beneath long descriptions.
  • Adds table support for wrapped responses and makes error hints and suggested commands more specific.
File Description
internal/​output/​tableview.go Adds table handling for wrapped lists and records.
internal/​output/​tableview_test.go Tests supported wrappers and multiple-list errors.
internal/​output/​output.go Routes table output through the new handler.
internal/​output/​hintfit.go Adds resource-aware hints and scoped command suggestions.
internal/​output/​hintfit_test.go Tests hint accuracy and scope propagation.
internal/​output/​explain.go Integrates more specific API-error explanations.
internal/​output/​created.go Carries scope flags into post-create suggestions.
internal/​interactive/​pickers.go Accounts for headings when sizing selection fields.
internal/​interactive/​interactive.go Applies description wrapping and selection sizing.
internal/​interactive/​formwrap.go Calculates description width and selection height.
internal/​interactive/​formwrap_test.go Checks input and option visibility beneath long descriptions.
internal/​flagutil/​metadata.go Integrates list parsing and list-format help.
internal/​flagutil/​listflags.go Parses JSON arrays and selected comma-separated lists.
internal/​flagutil/​listflags_test.go Tests list parsing, empty arrays, and help text.
internal/​cli/​waitexit_test.go Tests wait-command outcomes across output formats.
internal/​cli/​test/​run/​waitsuite.go Returns the suite verdict after printing results.
internal/​cli/​test/​run/​wait.go Returns the run verdict after printing results.
internal/​cli/​test/​run/​wait_exit.go Evaluates outcomes while preserving raw response output.
internal/​cli/​tableview_test.go Tests wrapped table responses through CLI commands.
internal/​cli/​root.go Registers startup repair of help examples.
internal/​cli/​examplehelp.go Repairs command paths, quoting, and required flags.
internal/​cli/​examplehelp_test.go Checks example parsing and rewrite behavior.

Review effort: Balanced

Comment thread internal/cli/test/run/wait_exit.go Outdated
return false
}
res.Body = io.NopCloser(bytes.NewReader(raw))
return json.Unmarshal(raw, v) == nil

func buildStringArrayField(cmd *cobra.Command, v reflect.Value, m FlagMeta) error {
val, changed := GetStringArrayFlag(cmd, m.FlagName)
val, explicit, err := ListValues(m.FlagName, val) // listflags.go: JSON arrays and commas
if err != nil || target == nil {
return next
}
for _, name := range scopeFlags {
names[i] = jsonName(v.Type().Field(field))
}
return fmt.Errorf("-o table shows one list, and this response holds %d: %s. Use -o json or -o yaml to see them all", len(lists), strings.Join(names, ", "))
case len(lists) == 1:
}
return fmt.Errorf("-o table shows one list, and this response holds %d: %s. Use -o json or -o yaml to see them all", len(lists), strings.Join(names, ", "))
case len(lists) == 1:
if err := tableError(printTableRows(out, v.Field(lists[0]))); err != nil {
A conversation runs the environment's last compiled build, and nothing
compiled it after an edit. So `agent update` then `conversation run-script`
talked to the old agent. In the usability sweep, agents and newcomers alike
read the old replies as "my prompt and tool don't work", and spent credits
finding out. The only sign was `needsRecompile: true` atop hundreds of lines.

Nothing says the draft is stale before a run, so vf now compiles it whenever
a conversation with the draft starts: before every `run-script`, and before
a `send` with a launch action. A later `send` keeps its build, but if its
turn still ran a stale one (an edit mid-conversation, or a conversation
started with text), vf compiles right after the answer is printed and warns,
so the next turn runs the edits. The answer is read before it is printed,
from the raw body under -o json and --jq.

- `--no-compile` talks to the last build as it is.
- The published version is a release, and is never compiled.
- A draft that won't compile stops the conversation before it spends
  credits, and says to fix the agent or add --no-compile.
- At a terminal, "✓ Compiled the draft of main (1.2s), so this runs your
  latest edits" says it happened. Agent mode stays quiet on success.

The body-peeking helper the wait verdict used moves to output.PeekJSON so
both share it.
@Bradenream Bradenream changed the title fix: sweep P0s: test wait exit codes, help examples, list flags, forms, -o table, error hints fix: sweep P0s: auto-compile, test wait exit codes, help examples, list flags, forms, -o table, error hints Nov 30, 2026
Every unknown short flag got "Did you mean `--jq`?". The suggestion
compared names by edit distance, and a one-letter name is within two
edits of "jq". Eight of the round-3 sweep's testers hit it, mostly as
`-p` or `-e` on a command that has only --project-id or
--environment-alias. Plain master printed cobra's "unknown shorthand
flag", so this was a regression from the usage-error explanations.

A short flag is now looked up by what that letter stands for on vf's
other commands: `vf agent update -p` suggests --project-id. When the
command has no such flag, nothing is suggested. A typo in a long name
now changes at most half of it, so `--pi` no longer suggests --jq
either.
… too

Sixteen commands take a body that is a union as a whole: `test turn
create`, `test check create`, `workflow update-step`, `agent
add-tool-message` and others. Their flag, --body-param, fills the body
itself, so its field path is "Body", and the check for body flags only
counted fields under "Body.". Given --body-param.user, those commands
still read stdin: `sleep 15 | vf test turn create …` waited 10s and
failed, and a `while read` loop ran once, because vf swallowed its
remaining lines. The round-3 sweep's fix verifier found it.

The body's own field now counts as a body flag.
Seven examples failed as written with "the body is none of its forms":
test check create/update, test turn update, tool create/update,
evaluation update and workflow update-branch. Their whole body is a union,
and its flag isn't marked required, because any one of several flags fills
it. So fixExamples added nothing.

RegisterFlags now marks a union that isn't optional (unionform.go), and
the example gets that union's first form: a field of the variant where
there is one, or the variant as JSON.
Bradenream added a commit that referenced this pull request Nov 30, 2026
"That compile is required … Nothing errors" and "the step is yours to
remember" stop being true once vf compiles the draft before a conversation
(#57). Keep the step and the reason for it, which hold either
way: a conversation runs the draft as last compiled, and a missed compile
looks like a successful edit.
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