Skip to content

fix(frontend): seed parameter defaults for custom URL workflows#4440

Merged
mmabrouk merged 2 commits into
feat/trace-observability-batchfrom
fix/playground-custom-url-defaults
May 27, 2026
Merged

fix(frontend): seed parameter defaults for custom URL workflows#4440
mmabrouk merged 2 commits into
feat/trace-observability-batchfrom
fix/playground-custom-url-defaults

Conversation

@mmabrouk
Copy link
Copy Markdown
Member

Summary

Custom URL workflows (those with a service URL but no agenta URI) had two issues that made the playground config form render empty even when their /openapi.json defined parameter defaults.

  • The openapi fallback in workflowEntityAtomFamily resolved the parameter schema but never seeded initial parameter values. The form iterates values, not schema properties, so the form rendered empty. The fix extracts defaults from the schema via extractDefaultsFromSchema (hoisted out of createFromTemplate.ts and re-exported from the workflow api barrel) and assigns them to resolvedParams. This mirrors the catalog template path, which already fills parameters from schema defaults at create time.
  • configurationSelectorAtomFamily and configurationAtomFamily read from workflowBaseEntityAtomFamily, which deliberately skips the inspect/openapi schema-resolution layer. That meant the form's values selector never saw the seeded defaults. Both selectors now read from the merged workflowEntityAtomFamily. All 17 callers are in playground or execution contexts where the merged atom is already in the dependency graph, so the swap adds no new schema-fetch subscriptions in practice. isDirty intentionally still reads from the base atom and is unaffected.

The merge guard is hardened to treat an empty object the same as "no stored params", so the seeding still applies if any future code path stores {} instead of leaving parameters undefined.

Lifecycle (documented in the seeding block)

The seeded defaults live only in the merged atom in memory. They are not persisted. On every playground open before the first save, the form re-renders with the openapi defaults. The first save commits them as a real revision; from then on the merge guard sees stored parameters and the seeding becomes a no-op, so subsequent opens read the saved values directly. This mirrors the catalog template behavior except that for custom URL apps we do it lazily on first open instead of eagerly at create time.

Files

  • web/packages/agenta-entities/src/workflow/api/createFromTemplate.ts — export extractDefaultsFromSchema; update docstring
  • web/packages/agenta-entities/src/workflow/api/index.ts — re-export extractDefaultsFromSchema from the workflow api barrel
  • web/packages/agenta-entities/src/workflow/state/store.ts — seed resolvedParams from openapi defaults; harden the merge guard; document lifecycle
  • web/packages/agenta-entities/src/workflow/state/molecule.ts — switch configurationSelectorAtomFamily to read from the merged entity atom
  • web/packages/agenta-entities/src/workflow/state/runnableSetup.ts — same switch for configurationAtomFamily

Test plan

  • Run pnpm lint-fix in web/ (passes on this branch)
  • Open a catalog template app (completion or chat) and confirm the config form renders unchanged with stored defaults
  • Create a fresh custom URL app pointing at an n8n workflow whose /openapi.json defines ag_config.properties.<key>.default
  • On first open the form shows the openapi defaults pre-filled
  • Save without editing; confirm a revision is committed with those defaults as data.parameters
  • Reopen the app; confirm the saved values display and the openapi defaults are not re-applied
  • Change the n8n default, reload the existing app; confirm the saved values are still used (no override)
  • Create a second fresh custom URL app pointing at the same n8n URL; confirm the new default is picked up

Custom URL workflows (those with a service URL but no agenta URI) had
two issues that made the playground config form render empty even when
their /openapi.json defined parameter defaults.

First, the openapi fallback in workflowEntityAtomFamily resolved the
parameter SCHEMA from appSchemas.parameters but never seeded initial
parameter VALUES. The form iterates parameter values, not schema
properties, so an empty values dict produces an empty form regardless
of how complete the schema is. The fix extracts defaults from the
schema via extractDefaultsFromSchema (hoisted out of createFromTemplate
and re-exported from the workflow api barrel) and assigns them to
resolvedParams. This mirrors the catalog template path, which already
fills parameters from schema defaults at create time. The merge guard
is hardened to also treat an empty object as 'no stored params', so
the seeding still applies if any future code path stores {} instead of
leaving parameters undefined.

Second, configurationSelectorAtomFamily and configurationAtomFamily
read from workflowBaseEntityAtomFamily, which deliberately skips the
inspect/openapi schema-resolution layer. That meant the form's values
selector never saw the seeded defaults even after the fix above. Both
selectors now read from workflowEntityAtomFamily (the merged atom).
All 17 callers are in playground or execution contexts where the
merged atom is already in the dependency graph, so the swap adds no
new schema-fetch subscriptions in practice. isDirty intentionally
still reads from the base atom and is unaffected.

The seeded defaults live only in the merged atom in memory and are
not persisted. On every playground open before the first save, the
form re-renders with the openapi defaults. The first save commits
them as a real revision; from then on the merge guard sees stored
parameters and the seeding is a no-op.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 26, 2026

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

Project Deployment Actions Updated (UTC)
agenta-documentation Ready Ready Preview, Comment May 26, 2026 9:53pm

Request Review

@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. Frontend labels May 26, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 26, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 4e06b8eb-8417-486e-987a-ec11e4268bdc

📥 Commits

Reviewing files that changed from the base of the PR and between 3c9b1db and 3071fc9.

📒 Files selected for processing (5)
  • web/packages/agenta-entities/src/workflow/api/createFromTemplate.ts
  • web/packages/agenta-entities/src/workflow/api/index.ts
  • web/packages/agenta-entities/src/workflow/state/molecule.ts
  • web/packages/agenta-entities/src/workflow/state/runnableSetup.ts
  • web/packages/agenta-entities/src/workflow/state/store.ts

📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Enhanced workflow configuration to properly preserve and apply default parameter values from schemas in configuration forms.

Walkthrough

This PR extends workflow configuration to populate parameter defaults from JSON Schema definitions. A utility function is exported, integrated into the workflow entity store to lazily seed missing parameters from OpenAPI schemas, and exposed through Jotai atoms so configuration forms receive the merged defaults.

Changes

Schema defaults integration

Layer / File(s) Summary
Export default extraction utility
web/packages/agenta-entities/src/workflow/api/createFromTemplate.ts, web/packages/agenta-entities/src/workflow/api/index.ts
extractDefaultsFromSchema is exported from createFromTemplate and re-exported through the workflow/api module to make it available to external consumers.
Integrate defaults into workflow entity store
web/packages/agenta-entities/src/workflow/state/store.ts
The extraction utility is imported and used to seed resolvedParams from OpenAPI schema default values when parameters are missing; merge guard logic is updated so empty stored parameters allow seeding to proceed.
Expose seeded defaults through configuration atoms
web/packages/agenta-entities/src/workflow/state/runnableSetup.ts, web/packages/agenta-entities/src/workflow/state/molecule.ts
Configuration atom families switch from the base entity to the fully merged entity so consumers see configuration values that include schema-seeded defaults.

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: seeding parameter defaults for custom URL workflows.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the issues, solutions, lifecycle, and test plan.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 60.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 fix/playground-custom-url-defaults

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 and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 26, 2026

Railway Preview Environment

Status Destroyed (PR closed)

Updated at 2026-05-27T08:04:21.277Z

@mmabrouk mmabrouk changed the base branch from main to feat/trace-observability-batch May 27, 2026 08:03
@mmabrouk mmabrouk merged commit 584ff4b into feat/trace-observability-batch May 27, 2026
31 of 32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants