Repository navigation
refactor: write component assets as single literals - #457
Merged
Merged
Conversation
citry format cannot read a template or js value that is built by implicit string concatenation or by adding a shared fragment, and the authoring rule asks for one triple-quoted literal. Write out the affected assets with identical string values. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Oct 28, 2026
Teach citry format the one-attribute-per-line house rule, with settings for the count and width
#492
Open
JuroOravec
added a commit
that referenced
this pull request
Oct 28, 2026
…cript Since #457 wrote these components' `js` as single string literals, the editor's TypeScript check reads them, and main's Ubuntu Python test jobs fail `test_citry_ui_components_have_no_typescript_or_ty_findings` with six ts2339 findings: - chover_card, cmulti_select, cpopover and ctooltip walk outward from an inline trigger to the nearest ancestor with a box of its own, stepping out of a shadow root with `box.getRootNode().host`. TypeScript types `getRootNode()` as returning a `Node`, which has no `host`. The walk now checks `instanceof ShadowRoot` first, the way `_anchored_layer.py` does, and types `box` as `Element`, because TypeScript types a shadow root's host as `Element`. A document root still ends the walk, as before. - cdisclosure keeps its browser-side state in `root.__citryUiDisclosureRuntime`. The root is now cast to an element type that declares that property, the way caccordion, clistbox, ctag and ctree already do. cmenu has the same walk in `_runtime_source`, which is built by concatenation, so TypeScript does not check it. It gets the same change so the inline copies match. cselect's copy in `runtime.source.js` keeps the old form, because changing it means rebuilding its minified file. Co-Authored-By: Claude Opus 5.5 <[email protected]>
2 tasks
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.
What changed
citry formatcannot read a componenttemplateorjsthat is builtby joining string pieces or by adding a shared fragment, and the
authoring rule in CLAUDE.md asks for one triple-quoted literal assigned
directly. This writes those assets out as single literals. Every string
value stays the same.
Converted:
cform_collection,ctransfer_list,benchmarks/web/apps/citry/app.py(two assets).ANCHORED_LAYER_RUNTIME_JS + r"""..."""(an 8-line fragment, writtenout):
cdisclosure,chover_card,cmulti_select,cpopover,ctooltip, andCMenuSubmenuincmenu.cformandctoggle(implicit concatenation injs).packages/py/citry/tests/test_secret.py: five class bodies usedjs = _COMPONENT_JS; they now hold the 3-line literal. The constantstays for the two dict-style class definitions.
Where a line is longer than 119 characters inside a string (
cform,cform_collection,ctoggle,ctransfer_list), the closing quotescarry
# noqa: E501so the value is not reflowed. The formatter willreflow them later.
Left as they are (computed by design)
cmenu:CMenu.jsis generated bybuild_shared_component_assets(runtime key, generation and a source fingerprint are filled in), and
_MENU_ITEM_JSis a 275-line script shared by three item components.cslider:_SLIDER_TEMPLATE(140 lines) and_SLIDER_JS(510 lines)are shared by
CSliderandCRangeSlider.calert_dialog:js = CDialog.jsreuses the 350-line Dialog script;its
Dependenciescome fromCDialog.Dependencies.docs_site/_internal/components/landing_composer.py:LandingRecipeBank.templateis generated from the_RECIPESdata ina loop.
ctable.pyis untouched (formatter bug, handled separately).Not touched, same pattern outside the listed files:
benchmarks/client_scenario.py,benchmarks/i18n.py(shared constants).Evidence
and compares every
template/js/cssclass attribute: all equal.The benchmark app was compared with
astthe same way.test_secret.pyliterals sit at the indentation of their class body,so they differ from
_COMPONENT_JSonly by indentation, which Citryremoves when it loads the asset. 69 tests pass.
packages/py/citry_ui/tests(no e2e): 941 passed. The type-check andJavaScript-name tests: 2 passed, 1 skipped.
calert_dialogandcslider: 52 passed.citry format --check --embedded offno longer reports an error forany changed file except
ctransfer_list: it now reports a differentproblem, a formatter invariant failure on its multi-line attribute
expressions (for example
c-aria-label="followed by an expression onthe next lines). A three-line example reproduces it. That is a
separate formatter bug, not part of this change. The others report
"would format" or unchanged.
ruff checkandruff format --checkpass on all changed files.differences.
No changelog entry: internal refactor.
🤖 Generated with Claude Code