Repository navigation
fix(sections-editor): fill union branch fields the depth cap emptied in a deep Flag<T> - #8438
Merged
viniciusventura29 merged 2 commits intoNov 10, 2026
Merged
Conversation
A multivariate field built its inner form from the variant value schema, which sits 3 levels deeper than plainSchema. Deep in a form, the depth cap leaves the branches of a type-discriminated union in T without a schema, so picking a branch drew no fields. Prefer plainSchema, the same T built outside the depth cap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
plainSchema and the variant value come from separate raw definitions of the same type, and the generator can emit them differently (an inline list in one, a loader picker in the other). Preferring plainSchema wholesale turned such a picker into a list editor. Keep the variant value and take from plainSchema only the type-discriminated branches that resolved without a schema. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
viniciusventura29
deleted the
viniciusventura29/flag-plainschema-depth
branch
November 10, 2026 23:21
decocms Bot
pushed a commit
that referenced
this pull request
Nov 10, 2026
PR: #8438 fix(sections-editor): fill union branch fields the depth cap emptied in a deep Flag<T> Bump type: patch - decocms (apps/api/package.json): 4.570.0 -> 4.570.1 Deploy-Scope: web
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resumo da mudança
Num campo com variantes (
Flag<T>) aninhado fundo no form, os ramos de um union discriminado portypedentro deTvoltam a mostrar seus campos. Hoje o select mostra o ramo escolhido, mas nenhum campo dele. Os demais campos com variantes não mudam.1. Problema
Quem é afetado?
Quem edita no Studio um bloco em que um prop
Flag<T>fica fundo no form (ex.: uma lista de itens dentro de um loader), eTtraz um union discriminado portype(ex.:Media = Video | Image | NoMedia, ouBanner = NoBanner | SingleBanner | DoubleBanner).Como são afetados?
A pessoa escolhe "Imagem" no select do union e nenhum campo aparece (Imagem, Largura, Altura, Texto alternativo). Não dá para preencher pelo form, nem num item novo nem num já preenchido.
Por que isso acontece?
apps/web/src/components/sections-editor/schema-form.tsx:325: o ramoisMultivariateBlockRefmonta o form interno a partir dovariantValueSchema(anyOfRefs[0].schema.properties.variants.items.properties.value).plainSchema(ref →variants→items→value). Num caminho comoloader → lista[] → content (flag) → variants[].value → desktop.media, os ramos do union passam doMAX_BUILD_PROPERTY_DEPTH = 8(resolve-schema.ts:144, aplicado emresolve-schema.ts:637) e chegam comschema: undefined.typenão tem resolução lazy, então oAnyOfFieldfica comnestedSchemanull e não desenha nada.plainSchema(o ramo deTsem a flag) tem esses ramos completos, mas não dá para trocar um pelo outro no atacado. Os dois saem de definições brutas separadas do mesmo tipo, e o gerador pode emiti-las de jeitos diferentes. Num caso real,Product[]vem como seletor de loader numa e como lista inline na outra. A primeira versão deste PR preferia oplainSchemainteiro e transformava esse seletor num editor de lista.2. Evidências visuais
3. Cenários validados
renderField – multivariate object fills depth-capped union branches: falha noorigin/main(ramos[]) e passa com o fix (bun test src/components/sections-editor/schema-form.test.ts).fillDepthCappedBranchesemfields/resolved-schema-cache.test.ts: preenche ramos discriminados vazios; mantém o que o schema já resolveu (seletor de loader × lista inline); não toca ramos vazios de union por módulo, que têm resolução lazy; devolve o mesmo objeto para as mesmas entradas.sections-editor: 1716 pass, 0 fail (bun test src/components/sections-editor/)./deco/metapúblico). Rodei oresolveSchemadesta branch em todos os blocos do manifest e comparei, em cada campo com variantes, o schema interno antes e depois:plainSchemainteiro), o mesmo site tinha 4 campos com forma diferente: o seletor de loader virava lista. A versão atual zera isso.bun run fmt,bun run lint,bun run knip: exit 0.tsc --noEmitdoapps/web(bun run check): exit 0.bun run testdo monorepo inteiro: rodada só na primeira versão, que saiu com exit 1 porECONNREFUSEDem:5432/:4222(Postgres e NATS fora do ar nesta máquina) eEMFILEdo--parallel, nenhuma falha nosections-editor. Não reproduzi noorigin/main. Fica com o CI.4. Resultado
Flag<T>profundo chegam sem schema, e o form não mostra os campos do ramo escolhido.fillDepthCappedBranches(fields/resolved-schema-cache.ts) mantém ovariantValueSchemacomo base e copia doplainSchemasó os ramos de union discriminado portypeque chegaram sem schema. O resultado fica em cache por par de nós (WeakMap) e devolve o próprio schema quando não há ramo vazio.plainSchema, o que ainda é melhor que nenhum campo. Ficaram de fora a checagem manual no Studio, as screenshots e a suíte completa com Postgres/NATS (seção 3).🤖 Generated with Claude Code