Skip to content

fix(playground): improve default argument inputs - #4270

Merged
sxlijin merged 5 commits into
canaryfrom
sam/b-1054
Jul 29, 2026
Merged

sxlijin merged 5 commits into
canaryfrom
sam/b-1054

Conversation

@sxlijin

@sxlijin sxlijin commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • keep required and defaulted argument inputs aligned in a shared column to the right of their argument names
  • use a checkbox to toggle between the declared default and an explicitly entered value, with hover help explaining both modes and a bare SquarePen icon beside the input
  • carry the exact unevaluated default expression from the source map to the playground and display it as the disabled control placeholder

Root cause

The typed args form represented a default only as hasDefault. When the argument was omitted, the form replaced its control with explanatory text, and no source expression was available for a useful placeholder.

Playground UI

Before

Before: defaulted inputs are replaced by omission text

After

After: checkbox toggles explicit values, SquarePen is decorative, and inputs align to the right

Validation

  • cargo test -p baml_project param_schema --lib (22 passed)
  • cargo test -p bridge_wasm schema_twins_serialize_identically_to_source_types --lib
  • pnpm --dir typescript2 format:ci --since=origin/canary
  • pnpm --dir typescript2 --filter @b/pkg-playground typecheck
  • pnpm --dir typescript2 --filter @b/pkg-playground test (137 passed)
  • browser validation of horizontal alignment, disabled exact-default placeholders, checkbox hover help, and explicit/default payload behavior

Linear: B-1054

Summary by CodeRabbit

  • New Features

    • Parameter schemas now expose the exact source text for declared default values.
    • Playground forms clearly indicate when a parameter uses its default, with checkbox controls and tooltip guidance.
    • Inputs display helpful default-value placeholders and consistently support disabled states across field types.
  • Bug Fixes

    • Improved parameter form rendering and validation behavior for optional, numeric, union, list, map, and JSON inputs.
    • Updated schema serialization to keep default-expression data consistent across supported environments.

@linear

linear Bot commented Jul 29, 2026

Copy link
Copy Markdown

B-1054

@vercel

vercel Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
beps Ready Ready Preview, Comment Jul 29, 2026 6:42am
promptfiddle Ready Ready Preview, Comment Jul 29, 2026 6:42am
promptfiddle2 Ready Ready Preview, Comment Jul 29, 2026 6:42am

Request Review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The change adds exact unevaluated parameter default expressions to Rust, WASM, and TypeScript schemas, then uses them in the playground argument form as placeholders for omitted defaults with disabled-field and tooltip behavior.

Changes

Default argument UI

Layer / File(s) Summary
Extract default expressions
baml_language/crates/baml_project/src/param_schema.rs, baml_language/crates/baml_project/src/symbols.rs
Parameter schema generation receives function locations, extracts default source spans, populates defaultExpression, and validates structured JSON output.
Transport parameter metadata
baml_language/crates/bridge_wasm/src/wasm_playground.rs, typescript2/pkg-playground/src/worker-protocol.ts, typescript2/pkg-playground/src/__fixtures__/param-schema-golden.json
WASM and TypeScript schemas serialize optional default expressions, while protocol shapes and golden schema data are updated.
Render defaulted arguments
typescript2/pkg-playground/src/ArgsForm.tsx
The argument form detects native default placeholders, displays default controls and tooltips, and disables omitted parameter fields.
Propagate field state through widgets
typescript2/pkg-playground/src/ArgsForm.tsx
Primitive, enum, class, list, map, optional, union, and raw JSON fields forward placeholder and disabled state through their editing controls.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant BAMLFunction
  participant ParamSchema
  participant WASMBridge
  participant WorkerProtocol
  participant ArgsForm
  BAMLFunction->>ParamSchema: provide function source and default span
  ParamSchema->>WASMBridge: serialize defaultExpression
  WASMBridge->>WorkerProtocol: transport parameter schema
  WorkerProtocol->>ArgsForm: provide defaultExpression
  ArgsForm->>ArgsForm: render placeholder and disabled omitted field
Loading

Possibly related PRs

  • BoundaryML/baml#3935: Extends the same schema-driven playground argument form and parameter schema infrastructure.

Suggested reviewers: rossirpaulo

Poem

A rabbit found defaults in code,
And carried their text along the road.
The fields now sleep, disabled and bright,
With tooltips guiding hops just right.
“Uncheck,” said Bun, “to edit with delight!”

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main playground UX change around default argument inputs.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sam/b-1054

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

⏭️ Performance benchmarks were skipped

Perf benchmarks (CodSpeed) are opt-in on pull requests — they no longer run on every push. They always run automatically after merge to canary/main.

To run them on this PR, do any of the following, then push a commit (or re-run CI):

  • Add RUN_CODSPEED=1 to the PR description, or
  • Include run-perf or /perf in the PR title or any commit message.

@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 04:29 Inactive
@sxlijin
sxlijin marked this pull request as ready for review July 29, 2026 04:29
@sxlijin

sxlijin commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 04:30 Inactive

@chatgpt-codex-connector chatgpt-codex-connector Bot 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: 3d50920668

ℹ️ 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".

@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 04:34 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 04:36 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 04:38 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 29, 2026 04:46 Inactive
@github-actions

github-actions Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Binary size checks passed

✅ 7 passed

Artifact Platform File Gzip Gated on Baseline Delta Status
✅ baml-cli Linux 🔒 27.4 MB 11.7 MB file 27.3 MB +118.1 KB (+0.4%) OK
✅ packed-program Linux 🔒 17.8 MB 7.3 MB file 17.7 MB +30.6 KB (+0.2%) OK
✅ baml-cli macOS 🔒 21.3 MB 10.2 MB file 21.2 MB +99.3 KB (+0.5%) OK
✅ packed-program macOS 🔒 13.9 MB 6.4 MB file 13.9 MB +48 B (+0.0%) OK
✅ baml-cli Windows 🔒 23.0 MB 10.4 MB file 22.9 MB +116.7 KB (+0.5%) OK
✅ packed-program Windows 🔒 14.8 MB 6.5 MB file 14.8 MB +15.2 KB (+0.1%) OK
✅ bridge_wasm WASM 16.8 MB 🔒 4.6 MB gzip 4.5 MB +48.3 KB (+1.1%) OK

🔒 = the size this artifact is GATED on (ceiling + delta). Binaries gate on file size (installed binary); WASM gates on gzip (download size). The other size is shown for information only.


Generated by cargo size-gate · workflow run

@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 05:06 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 29, 2026 05:13 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 29, 2026 05:26 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 05:35 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 05:38 Inactive
@sxlijin
sxlijin enabled auto-merge July 29, 2026 05:40
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 29, 2026 05:46 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 29, 2026 05:59 Inactive
@vercel
vercel Bot temporarily deployed to Preview – beps July 29, 2026 06:21 Inactive
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle2 July 29, 2026 06:29 Inactive
@sxlijin
sxlijin added this pull request to the merge queue Jul 29, 2026
Merged via the queue into canary with commit 5318b3c Jul 29, 2026
85 of 86 checks passed
@sxlijin
sxlijin deleted the sam/b-1054 branch July 29, 2026 06:40
@vercel
vercel Bot temporarily deployed to Preview – promptfiddle July 29, 2026 06:42 Inactive

This branch was previously deployed

3 inactive deployments
Preview – promptfiddle — d4e21555 Deployed Jul 29, 2026 by vercel[bot]
Preview – promptfiddle2 — d4e21555 Deployed Jul 29, 2026 by vercel[bot]
Preview – beps — d4e21555 Deployed Jul 29, 2026 by vercel[bot]
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.

1 participant