From 90d2649a5f57945eb580907ada3db9004e5de35d Mon Sep 17 00:00:00 2001 From: Nick Shirokov Date: Sat, 13 Jun 2026 15:04:33 +0300 Subject: [PATCH] =?UTF-8?q?fix(form-compile):=20companion=20=D0=BD=D0=B0?= =?UTF-8?q?=D1=81=D0=BB=D0=B5=D0=B4=D0=BE=D0=B2=D0=B0=D0=BB=20DisplayImpor?= =?UTF-8?q?tance=20=D0=B2=D0=BB=D0=B0=D0=B4=D0=B5=D0=BB=D1=8C=D1=86=D0=B0?= =?UTF-8?q?=20(PowerShell=20dynamic=20scope)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Emit-Companion / Emit-CompanionPanel вызывали DI-Attr $el, но $el НЕ их параметр — PowerShell брал его из родительского скоупа (эмитируемого элемента). Поэтому авто-генерируемые companion (ExtendedTooltip/ContextMenu/AutoCommandBar с name="@") наследовали DisplayImportance владельца (CheckBoxField/UsualGroup/Table), которого в оригинале у них нет → ложный ADDED. Корпус: ExtendedTooltip/ContextMenu НИКОГДА не несут DisplayImportance, AutoCommandBar — только element-level (11), не companion. Фикс: DI-Attr от СОБСТВЕННОГО объекта компаньона ($content / $panel), не от ambient $el. Python не имел dynamic-scope-бага (di_attr на companion не эмитил вовсе), но для паритета добавлен di_attr(content/panel) — оба рантайма теперь идентичны (companion без собственного DI → пусто). Выборка 19 форм (СостоянияОригиналовПервичныхДокументов acc+erp, + формы с DisplayImportance-владельцами): match 18, ADDED DisplayImportance исчез. ps1==py байт-в-байт. Регресс 43/43. Co-Authored-By: Claude Opus 4.8 (1M context) --- .claude/skills/form-compile/scripts/form-compile.ps1 | 8 +++++--- .claude/skills/form-compile/scripts/form-compile.py | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.claude/skills/form-compile/scripts/form-compile.ps1 b/.claude/skills/form-compile/scripts/form-compile.ps1 index fa3a8097..4fe62c53 100644 --- a/.claude/skills/form-compile/scripts/form-compile.ps1 +++ b/.claude/skills/form-compile/scripts/form-compile.ps1 @@ -1,4 +1,4 @@ -# form-compile v1.159 — Compile 1C managed form from JSON or object metadata +# form-compile v1.160 — Compile 1C managed form from JSON or object metadata # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills param( [string]$JsonPath, @@ -2606,7 +2606,9 @@ function Emit-Companion { return } $inner = "$indent`t" - X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $el)>" + # DI-Attr берём от СОБСТВЕННОГО объекта компаньона ($content), НЕ от ambient $el родителя + # (PowerShell dynamic scope — иначе companion наследует DisplayImportance владельца: баг). + X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $content)>" if (Test-CompanionStructured $content) { # структурированная форма (own-content). Порядок как у платформы: own-content (флаги/hyperlink/ # layout/оформление) ПЕРЕД Title (в корпусе layout-first 582 vs 10). @@ -2649,7 +2651,7 @@ function Emit-CompanionPanel { X "$indent<$tag name=`"$name`" id=`"$id`"/>" return } - X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $el)>" + X "$indent<$tag name=`"$name`" id=`"$id`"$(DI-Attr $panel)>" if ($halign) { X "$indent`t$halign" } if ($emitAfFalse) { X "$indent`tfalse" } if ($hasChildren) { diff --git a/.claude/skills/form-compile/scripts/form-compile.py b/.claude/skills/form-compile/scripts/form-compile.py index 61ef25da..45ce8f35 100644 --- a/.claude/skills/form-compile/scripts/form-compile.py +++ b/.claude/skills/form-compile/scripts/form-compile.py @@ -1,5 +1,5 @@ #!/usr/bin/env python3 -# form-compile v1.159 — Compile 1C managed form from JSON or object metadata +# form-compile v1.160 — Compile 1C managed form from JSON or object metadata # Source: https://github.com/Nikolay-Shirokov/cc-1c-skills import argparse import copy @@ -2628,7 +2628,8 @@ def emit_companion(lines, tag, name, indent, content=None): lines.append(f'{indent}<{tag} name="{name}" id="{cid}"/>') return inner = f'{indent}\t' - lines.append(f'{indent}<{tag} name="{name}" id="{cid}">') + # DI-Attr от собственного объекта компаньона (не от владельца) — зеркало ps1 + lines.append(f'{indent}<{tag} name="{name}" id="{cid}"{di_attr(content if isinstance(content, dict) else None)}>') if isinstance(content, dict) and any(k in content for k in COMPANION_STRUCT_KEYS): # own-content ПЕРЕД Title (в корпусе layout-first 582 vs 10). emit_common_flags(lines, content, inner) @@ -2669,7 +2670,7 @@ def emit_companion_panel(lines, tag, name, indent, panel): if not emit_af_false and not has_children and not halign: lines.append(f'{indent}<{tag} name="{name}" id="{cid}"/>') return - lines.append(f'{indent}<{tag} name="{name}" id="{cid}">') + lines.append(f'{indent}<{tag} name="{name}" id="{cid}"{di_attr(panel if isinstance(panel, dict) else None)}>') if halign: lines.append(f'{indent}\t{halign}') if emit_af_false: