Skip to content

unify schema-driven settings forms#2510

Open
juliusmarminge wants to merge 2 commits intomainfrom
t3code/c7b9a307
Open

unify schema-driven settings forms#2510
juliusmarminge wants to merge 2 commits intomainfrom
t3code/c7b9a307

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented May 5, 2026

Summary

  • add a dedicated @t3tools/contracts/schemaForm contract module that owns the schema-form annotation vocabulary and the single effect/Schema module augmentation
  • move settings schemas to the shared schemaForm / schemaFormSchema annotations instead of main/provider-specific annotation names
  • infer controls from schema shape: booleans become switches, literal unions become selects, strings become text inputs, with explicit control overrides still available
  • add typed schemaFormOptionLabels(...) so literal select labels must cover every literal member statically
  • centralize web schema-form derivation in one pipeline for labels, descriptions, ordering, visibility, defaults, control inference, select options, and clear-empty behavior
  • centralize primitive field rendering/value normalization in shared schema form controls, leaving main/provider forms as thin adapters for their persistence and row layout differences

Validation

  • bun fmt
  • bun lint (passes with existing unrelated warnings)
  • bun typecheck
  • cd apps/web && bun run test MainSettingsForm.test.ts ProviderSettingsForm.test.ts

Note

Medium Risk
Refactors how both main and provider settings UIs are derived/rendered from schemas, which could change field ordering, defaults, and persistence/clear-empty behavior. While mostly internal plumbing, mistakes could lead to incorrect settings being displayed or saved.

Overview
Unifies settings UI generation around a shared schema-form contract and derivation pipeline. Adds @t3tools/contracts/schemaForm (new exported module) to define schemaForm/schemaFormSchema annotations and typed schemaFormOptionLabels(...) for select labels.

Moves settings metadata into schemas and reworks the web settings panels to consume it. ClientSettingsSchema, ServerSettings, and provider settings schemas now carry titles/descriptions/order/reset labels/placeholders and control overrides (including a custom textGenerationModelSelection control), and SettingsPanels renders General settings via a new MainSettingsForm instead of hand-authored rows.

Centralizes field inference and rendering. Introduces apps/web schemaForm.ts to derive ordered, filtered field models (including control inference from schema AST and boolean defaults) and SchemaFormControl.tsx to normalize values and render controls, with ProviderSettingsForm simplified to use the shared pipeline and components.

Reviewed by Cursor Bugbot for commit a02ed3d. Bugbot is set up for automated code reviews on this repo. Configure here.

Note

Unify settings forms to use a schema-driven field rendering system

  • Introduces a shared schema-form framework in schemaForm.ts and schemaForm.ts that derives UI field models (control type, labels, order, defaults) from Effect schema annotations and AST inference.
  • Replaces bespoke per-field rendering in GeneralSettingsPanel and ProviderSettingsFieldRow with a unified SchemaFormFieldControl component that handles switches, selects, text/password, and textareas.
  • Adds MainSettingsForm for general settings with per-field dirty state tracking, reset buttons, and a custom-control injection point (used for the text generation model picker).
  • Migrates schema annotations in settings.ts from provider-specific keys (providerSettingsForm, providerSettingsFormSchema) to the new unified schemaForm/schemaFormSchema keys.
  • Behavioral Change: useSettingsRestore now derives changed-setting labels from schema annotations rather than a hardcoded list, so any field missing an annotation will no longer appear in the restore confirmation.

Macroscope summarized a02ed3d.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 5, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 74b388cd-d833-47e0-9b0c-24afb4d09896

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/c7b9a307

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

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 changed lines (additions + deletions). labels May 5, 2026
@github-actions github-actions Bot added size:XXL 1,000+ changed lines (additions + deletions). and removed size:XL 500-999 changed lines (additions + deletions). labels May 5, 2026
Comment thread apps/web/src/components/settings/MainSettingsForm.test.ts Outdated
@juliusmarminge juliusmarminge changed the title schema-drive main settings form unify schema-driven settings forms May 5, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is ON. A cloud agent has been kicked off to fix the reported issue. You can view the agent here.

Reviewed by Cursor Bugbot for commit a02ed3d. Configure here.

Comment thread apps/web/src/components/settings/schemaForm.ts
@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 5, 2026

Approvability

Verdict: Needs human review

This refactoring PR has an unresolved high-severity review comment identifying a potential bug where settings fields may not render due to AST inference failing on schema-wrapped types. This substantive concern requires human verification.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL 1,000+ changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant