Skip to content

Commit b3d6b66

Browse files
committed
fix(alter page): address tab pages by the name DESCRIBE prints
`alter page M.P { drop widget tabPage2 }`, `set Visible ... on tabPage2` and `set Class ... on tabPage2` all failed with `widget "tabPage2" not found. DataGrid2 columns are addressed by a derived name ...`, although DESCRIBE PAGE prints `tabpage tabPage2` and widgets inside the tab page resolved fine. The page mutator's finder, widget-scope collector and enclosing-datasource finder walked TabPages[].Widgets but never compared the tab page's own Name. They now search TabPages as a widget array, which matches the tab page and still descends into its children. With tab pages addressable, their invariants are enforced: - dropping the last tab page is refused (drop the tab container instead); - dropping or replacing the default tab page repoints DefaultPagePointer, which would otherwise dangle; - only tab pages may sit beside a tab page, and a tab page only in a tab container; INSERT INTO a tab container appends tab pages, INSERT INTO a tab page appends ordinary widgets; - set Class/Style/DynamicClasses on a tab page is refused (it has no Appearance; the setter reported success and wrote nothing); - set Caption on a Texts$Text caption now updates its Items translations instead of writing a stray Text key onto the Texts$Text. A top-level `tabpage` body in ALTER PAGE is now built and serialized (tabPageToGen, extracted from the TabContainer case). The not-found error now leads with `widget "X" not found` and keeps the DataGrid2 column addressing as a secondary hint. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 57259e8 commit b3d6b66

8 files changed

Lines changed: 615 additions & 52 deletions

File tree

‎.claude/skills/fix-issue/findings/mdl-backend.jsonl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,3 +126,4 @@
126126
{"area":"mdl/backend","date":"2026-09-22","symptom":"modelsdk/mpr/version.ProjectVersion declared its own struct with the same seven fields as mdl/types.ProjectVersion instead of aliasing it, so a *version.ProjectVersion could not be passed where a *types.ProjectVersion was wanted and vice versa — two unrelated Go types that both print as 'ProjectVersion'.","cause":"The deleted sdk/mpr/version aliased the canonical type (`type ProjectVersion = types.ProjectVersion`); this copy declared a duplicate. CLAUDE.md's shared-types rule asks for the alias, and nothing enforced it. The duplication survived the legacy-engine retirement because it compiles perfectly — the two declarations are field-for-field identical, so only an assignment ACROSS the boundary reveals them as different types.","file":"modelsdk/mpr/version/version.go","fix":"Made it an alias. The four methods it redeclared (IsAtLeast, IsAtLeastFull, String, IsMPRv2) were verified semantically identical to types' first — IsAtLeast differed only in early-return style, same truth table — and now come from types. IsSupported/SupportsFeature could not survive as methods on an aliased type and had ZERO callers anywhere (measured), so they went with Feature, MinVersion, featureVersions and SupportedVersionRange; that map called itself 'the fallback when the YAML registry is unavailable' and the live registry is sdk/versions/mendix-{9,10,11}.yaml via checkFeature.","insight":"A same-shape duplicate type is invisible to every signal except an assignment across the package boundary: it compiles, tests pass, and the error it eventually produces names the same type on both sides of 'want'. So the guard is a COMPILE-TIME assertion, not a runtime test — `var _ *types.ProjectVersion = (*version.ProjectVersion)(nil)` builds only under an alias and fails to build under a duplicate, which is strictly stronger than anything a test body can assert. Write it before the fix and watch it fail to compile; that failure IS the reproduction. Two measurements that made the cleanup safe rather than brave: diff the method BODIES before assuming the redeclarations are redundant (identical behaviour, different style, is the common case and the dangerous one is the near-miss), and count callers of anything the alias forces you to drop — here six exported symbols had zero. Unrelated trap hit while verifying: four cmd/mxcli tests that read skill files failed once in a full `go test ./...` interleaved with `make check-mdl`, which runs sync-skills (rsync --delete into cmd/mxcli/skills/). They pass in isolation, on clean main, and in an uninterleaved full run — do not attribute a skills-reading test failure to your change without re-running it alone."}
127127
{"area": "mdl/backend", "date": "2026-09-22", "symptom": "`create workflow … overview page X` reports `Created workflow` and exit 0 and stores NOTHING — the written unit carries no page reference and not even the page's qualified name as a string. `mx check` passes (a workflow with no overview page is valid) and `describe workflow` omits the clause, so nothing reveals the loss. Running `alter workflow … set overview page X` afterwards DOES write it, which is what makes the split visible", "cause": "Two fields for one concept, never joined: the executor set semantic `Workflow.OverviewPage` (`cmd_workflows_write.go:170`) and `workflowToGen` only ever read `Workflow.AdminPage`, which nothing set. The READ half was wrong in the mirror direction — `workflowFromGen` took `g.OverviewPageQualifiedName()`, so even the correctly-written ALTER read back empty and the catalog's overview-page reference edge never fired", "file": "`sdk/workflows/workflow.go` (the two fields collapsed to one), `mdl/backend/modelsdk/workflow_write.go` (`workflowToGen`), `mdl/backend/modelsdk/workflow_read.go` (`workflowOverviewPageName`)", "insight": "**The Model SDK's StructureVersionInfo settles which of two rival property names is real, in one grep**: `npm pack mendixmodelsdk` then `src/gen/workflows.js` gives `overviewPage: {deleted: \"9.11.0\"}` and `adminPage: {introduced: \"9.11.0\"}` — so AdminPage (a `Workflows$PageReference` CHILD, not a by-name string) is the stored property, and `generated/metamodel` agrees by declaring AdminPage and no OverviewPage. `modelsdk/gen` declares BOTH, which is how a reader and a writer ended up on opposite sides of a 9.11 rename inside one package. **The version branch CLAUDE.md's overlay rule would demand is dead here, and that is a measurement not an assumption**: `workflowToGen` writes `WorkflowV2`, introduced in 11.1.0, unconditionally — so no reachable project wants the pre-9.11 key. Write one spelling, READ both (a read fallback invents nothing). **The differential that proves it on a real build**: same script, same project, only the write suppressed — control 0 errors, fixed `CE7410 \"The selected page 'Overview' should accept a parameter of type 'Workflow'\"` on mxbuild 11.6.6. mxbuild can only validate a page it can see, so the error IS the evidence; with a valid overview page both variants are 0 errors, which is the usual weak-signal trap. Useful side-finding: an overview page takes **System.Workflow**, while a user task's page takes **System.WorkflowUserTask** — two pages, two parameters. NOT fixed: no check rule for CE7410 yet, and `WorkflowV2` being written unconditionally is questionable for a 10.x project. Same shape as the `create … comment 'text'` bug (findings/mdl-grammar.jsonl 2026-08-25): grep for `stmt.X = …` / `wf.X = …` with no matching read. Tests `mdl/backend/modelsdk/workflow_overview_page_test.go`; repro `mdl-examples/bug-tests/workflow-586b-overview-page-dropped.mdl`", "refs": ["ako/mxcli#586"], "ce": ["CE7410"]}
128128
{"area": "mdl/backend", "date": "2026-09-23", "symptom": "`describe java action` prints `ContextObject: entity <>` for a parameter declared `entity <pEntity> not null`; a bare type-parameter reference (`Obj: pEntity`, `returns pEntity`) reads back nameless too. The description no longer round-trips", "cause": "The stored parameter type (`CodeActions$EntityTypeParameterType` / `ParameterizedEntityType`) holds only a BY_ID pointer to the `CodeActions$TypeParameter`. `javaActionFromGen` carried the ID into the semantic type but never resolved it to the name, and the name is all the describer prints. `javascript_read.go` had always done this resolution pass; the Java reader was ported without it", "file": "`mdl/backend/modelsdk/java_read.go` (`resolveJavaActionTypeParameterNames`)", "insight": "The executor's `entity <>` fallback in `formatJavaActionType` is the tell: an empty name at DESCRIBE means the *reader* dropped a by-ID resolution, not that the writer lost it \u2014 the write path sets both ID and name, so a create\u2192read unit test in the backend reproduces it without any project. When a JS and a Java reader cover the same `CodeActions$` shapes, diff their post-processing first; any pass one has and the other lacks is a candidate. The write was never wrong (replaying the fixed description into a fresh project describes identically), so no `mx check` run is needed. Issue mendixlabs/mxcli#1034", "refs": ["mendixlabs/mxcli#1034"]}
129+
{"area": "mdl/backend", "date": "2026-09-23", "symptom": "`alter page M.P { drop widget tabPage2 }` (and `set Visible`/`set Class ... on tabPage2`) fails with `widget \"tabPage2\" not found. DataGrid2 columns are addressed by a derived name ...` although DESCRIBE PAGE prints `tabpage tabPage2`; a widget inside the tab page resolves fine", "cause": "The page mutator's finder (`findInWidgetChildren`), the widget-scope collector and the enclosing-datasource finder walked `TabPages[].Widgets` but never compared the tab page's own `Name`, so no tab page was ever addressable. The not-found message led with DataGrid2 column addressing whenever the page held any grid, so it misdiagnosed a plain miss. Two follow-on defects surfaced once tab pages resolved: `set Caption` wrote a stray `Text` key onto a `Texts$Text` (it looked for `Translations`, the real key is `Items`), and `set Class` on a tab page (no `Appearance`) reported success and wrote nothing", "file": "`mdl/backend/pagemutator/mutator.go` (`findInWidgetChildren`, `collectWidgetScopeInChildren`, `findNearestDSInChildren`, `setWidgetCaptionMut`, `widgetNotFoundError`), `mdl/backend/pagemutator/tabpages.go`", "insight": "Any container whose children sit one level below an intermediate *named* element (TabControl -> TabPage -> Widgets) needs the intermediate searched as a widget array, not skipped - `findInWidgetArray(wDoc, \"TabPages\", ...)` does both at once. Making the intermediate addressable brings its invariants with it: `DefaultPagePointer` is a binary $ID into TabPages (drop/replace of the default must repoint it), TabPages may hold only `Forms$TabPage`, and a TabControl needs at least one. Verified on a real 11.12.2 app: exec, then `mx check` error set identical to the untouched baseline"}

‎.claude/skills/mendix/alter-page/SKILL.md‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,17 @@ Inserted widgets use the same syntax as `create page`. Multiple widgets can be i
257257
only way to fill an **empty** container, and handy for adding to a container/dataview
258258
without needing a sibling to anchor to. Widgets inserted into a dataview take that
259259
dataview's entity as their context. Supported on simple containers (container,
260-
dataview, groupbox, scroll-container region); for a layout grid or tab container,
261-
insert relative to a widget inside the target column/tab instead.
260+
dataview, groupbox, scroll-container region, tab page); for a layout grid,
261+
insert relative to a widget inside the target column instead.
262+
263+
**Tab pages are addressable by the name DESCRIBE prints** (`tabPage2`): `drop
264+
widget`, `set Caption`/`Visible`, `insert into tabPage2 { … }`, and
265+
`insert before|after tabPage2 { tabpage tabNew (Caption: '…') { … } }`
266+
(`insert into tabContainer1 { tabpage … }` appends one). Only tab pages may sit
267+
beside a tab page, and a tab page nowhere else. Dropping the last tab page is
268+
refused (drop the tab container); dropping or replacing the default one moves
269+
the default to its successor. `set Class`/`Style` on a tab page is refused — it
270+
has no Appearance; use `Visible`, or style the tab container.
262271

263272
**The context comes from the nearest enclosing data source, whatever kind it is**
264273
— a database or association source, a microflow/nanoflow source (the entity is
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
-- ALTER PAGE could not address a tab page by the name DESCRIBE PAGE prints.
2+
--
3+
-- DESCRIBE shows `tabpage tabPage2 (Caption: 'Guests') { … }`, yet every one of
4+
-- alter page M.P { drop widget tabPage2 }
5+
-- alter page M.P { set Visible = 'false' on tabPage2 }
6+
-- alter page M.P { set Class = 'hidden' on tabPage2 }
7+
-- failed with `widget "tabPage2" not found. DataGrid2 columns are addressed by
8+
-- a derived name …` — while a widget INSIDE the tab page resolved fine.
9+
--
10+
-- Cause: the page mutator's finder descended into TabPages[].Widgets but never
11+
-- compared the tab page's own Name. The not-found message then led with
12+
-- DataGrid2 column addressing whenever the page happened to hold a data grid.
13+
--
14+
-- After the fix a tab page is addressable for DROP, SET Caption/Visible,
15+
-- INSERT BEFORE/AFTER (tab pages only), INSERT INTO (ordinary widgets), and
16+
-- REPLACE. Rules the mutator enforces, because each alternative is a document
17+
-- Studio Pro cannot open or a silent no-op:
18+
-- * dropping the LAST tab page is refused — drop the tab container instead;
19+
-- * dropping/replacing the DEFAULT tab page repoints DefaultPagePointer;
20+
-- * a tab page may only sit in a tab container, and a tab container holds
21+
-- only tab pages;
22+
-- * `set Class`/`Style`/`DynamicClasses` on a tab page is refused (a tab page
23+
-- has no Appearance; the setter used to report success and write nothing).
24+
--
25+
-- Verified: exec on a copy of a real 11.12.2 app, then `mx check` 0 errors.
26+
27+
create module TabAlter;
28+
29+
create persistent entity TabAlter.Group (
30+
"Name": String(100)
31+
);
32+
33+
create page TabAlter.Group_Detail (
34+
Title: 'Group',
35+
Layout: Atlas_Core.Atlas_Default,
36+
Params: { $Group: TabAlter.Group }
37+
) {
38+
dataview dvGroup (DataSource: $Group) {
39+
tabcontainer tabContainer1 {
40+
tabpage tabPage1 (Caption: 'Members') {
41+
dynamictext txtMembers (Content: 'Members')
42+
}
43+
tabpage tabPage2 (Caption: 'Guests') {
44+
dynamictext txtGuests (Content: 'Guests')
45+
}
46+
tabpage tabPage3 (Caption: 'Settings') {
47+
dynamictext txtSettings (Content: 'Settings')
48+
}
49+
}
50+
}
51+
}
52+
53+
-- Each of these reported `widget "tabPageN" not found` before the fix.
54+
alter page TabAlter.Group_Detail {
55+
set Visible = 'false' on tabPage3;
56+
set Caption = 'Visitors' on tabPage2;
57+
insert into tabPage2 {
58+
dynamictext txtGuestsNote (Content: 'Visitors can only read')
59+
}
60+
insert after tabPage2 {
61+
tabpage tabPage4 (Caption: 'History') {
62+
dynamictext txtHistory (Content: 'History')
63+
}
64+
}
65+
drop widget tabPage1
66+
};

‎mdl/backend/modelsdk/widget_write.go‎

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,41 @@ func init() {
285285
})
286286
}
287287

288+
// tabPageToGen converts a pages.TabPage to its Forms$TabPage gen element.
289+
func tabPageToGen(tp *pages.TabPage) (*genPg.TabPage, error) {
290+
tpg := genPg.NewTabPage()
291+
if tp.ID != "" {
292+
tpg.SetID(element.ID(tp.ID))
293+
}
294+
assignID(tpg)
295+
tpg.SetName(tp.Name)
296+
tpg.SetRefreshOnShow(tp.RefreshOnShow)
297+
// Caption defaults to the tab name when unset (matches legacy).
298+
capText := tp.Caption
299+
if capText == nil {
300+
capText = &model.Text{Translations: map[string]string{model.AuthoringLanguage(): tp.Name}}
301+
}
302+
tpg.SetCaption(captionToGen(capText))
303+
for _, c := range tp.Widgets {
304+
cg, err := widgetToGen(c)
305+
if err != nil {
306+
return nil, err
307+
}
308+
tpg.AddWidgets(cg)
309+
}
310+
return tpg, nil
311+
}
312+
288313
// widgetToGen converts a model widget to its gen element, recursing into
289314
// containers. Unsupported widget types are refused loudly (ADR-0005) so a page
290315
// is never written with a silently-dropped widget.
291316
func widgetToGen(w pages.Widget) (element.Element, error) {
292317
switch x := w.(type) {
318+
case *pages.TabPage:
319+
// A lone tab page: ALTER PAGE inserting or replacing one inside an
320+
// existing tab container. The mutator refuses it anywhere else.
321+
return tabPageToGen(x)
322+
293323
case *pages.Container:
294324
g := genPg.NewDivContainer()
295325
applyWidgetBase(g, &x.BaseWidget)
@@ -316,25 +346,9 @@ func widgetToGen(w pages.Widget) (element.Element, error) {
316346
g.SetActivePageOnChangeAction(noActionGen())
317347
var defaultID element.ID
318348
for i, tp := range x.TabPages {
319-
tpg := genPg.NewTabPage()
320-
if tp.ID != "" {
321-
tpg.SetID(element.ID(tp.ID))
322-
}
323-
assignID(tpg)
324-
tpg.SetName(tp.Name)
325-
tpg.SetRefreshOnShow(tp.RefreshOnShow)
326-
// Caption defaults to the tab name when unset (matches legacy).
327-
capText := tp.Caption
328-
if capText == nil {
329-
capText = &model.Text{Translations: map[string]string{model.AuthoringLanguage(): tp.Name}}
330-
}
331-
tpg.SetCaption(captionToGen(capText))
332-
for _, c := range tp.Widgets {
333-
cg, err := widgetToGen(c)
334-
if err != nil {
335-
return nil, err
336-
}
337-
tpg.AddWidgets(cg)
349+
tpg, err := tabPageToGen(tp)
350+
if err != nil {
351+
return nil, err
338352
}
339353
g.AddTabPages(tpg)
340354
if i == 0 {

0 commit comments

Comments
 (0)