You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
M4, #1747: a text layer's name follows the characters typed into it - #1900
A text layer's name is a snapshot of its characters taken when the layer is made (node.create names it after the first line) and nothing updates it afterwards. The Layers panel shows that name, so as soon as you type the panel and the canvas disagree: a layer that started as hello still reads hello in the panel after the canvas says hello there.
The target app's plugin API documents the rule this is missing, TextNode.autoRename:
Whether updating the characters in the text node should update the name of the node. If this is set to true, name will be auto-derived from characters.
This is automatically reset to false if name is modified in order to allow the node to keep the new name.
What this does
No new field and no file-format change: the flag is inferred, because a layer nobody has renamed is exactly one whose name is still the name its characters derive. cmd::props::text_layer_name states that derivation once (the first line, at most 64 characters, or None when blank), and textedit::edit_if — the one chokepoint every canvas mutation goes through — compares the name against it before the edit and re-derives it after:
So a name the author typed is never touched, and a layer renamed to something else stops following for good. Because the rename happens inside the same document mutation, it shares the edit's undo step.
The two creation paths leave a blank text layer named differently — the Text tool leaves the name empty and node.create names it Text, and the panel shows the layer's kind for either — so text_name_is_derived treats both as unnamed. Without that, the most common flow of all (pick the Text tool, click, type) would not have been covered: the layer's name is "", which matches no derived name. I only noticed because I added that flow to the test; the targeted control below pins it.
Only the editor follows the characters
Commands deliberately do not rename, and there is a test pinning that. Layer names are field keys: data.fill, component property bindings and the templates write characters into a layer named for its role and then look it up by that name again. I first applied the rule in node.set {characters} too, and datafill_tests::each_row_fills_a_copy_in_one_undo_step caught it — filling a layer named Title whose placeholder text is also Title renamed the field to Site em 7 dias and the next lookup found nothing. That is also why inferring the flag is safe only on the typing path: a name that matches the text is an auto-name when a human is typing, and a field key when a command is writing.
MCP and the control protocol reach textedit::insert/key, so an agent typing into a layer renames it exactly as a person typing does; node.set {characters} remains the way to set text without touching the name.
Tests
text_behaviour_tests::typing_renames_a_text_layer_that_still_carries_the_name_its_characters_gave_it — typing follows the name; a chosen name is kept; only the first line names the layer; emptied text goes back to having no name of its own; and the Text tool drawing a layer and typing into it names it.
text_behaviour_tests::setting_characters_as_a_command_never_renames_the_layer — the data.fill contract above.
Negative control, with the two-line rename removed and the tests kept:
assertion `left == right` failed: the name follows what is typed
left: ("hello there", "hello")
right: ("hello there", "hello there")
which is the reported symptom exactly: the characters move on, the name does not.
A second control, with only the unnamed-layer branch of text_name_is_derived returning false:
assertion `left == right` failed: the first word typed names it
left: ("Pricing", "")
right: ("Pricing", "Pricing")
so that branch is load-bearing for the Text-tool flow rather than belt-and-braces.
Gates
cargo test -p figcraft-engine: 1793 passed, 0 failed (1791 before, so the two new ones and no regressions). cargo fmt --check and cargo clippy -p figcraft-engine --all-targets clean. cargo xtask layers, cargo xtask assets and cargo xtask wasm: ok (wasm exits 0).
cargo xtask ci stops on one failure in figcraft-ui-egui (1005 passed, 1 failed): clipboard_fence_tests::a_synthetic_copy_shortcut_leaves_the_system_clipboard_alone. It fails the
same way on clean origin/main here, so it is this machine (no OS clipboard in my environment) and
not this change; I ran the steps after it by hand because ci skips them once something fails.
Revision-history rows added to docs/roadmap.md and docs/target-app-parity.md in the same commit; the grade is unchanged.
Not in this change
edit.findReplace already decides whether names change through its own layerNames option, so I left that path alone rather than giving it a second, implicit rule.
Summary by CodeRabbit
Bug Fixes
Text layer names now follow the first line of text as you type, as long as the name hasn’t been changed manually.
Manually chosen names are preserved, and clearing all text clears an automatically derived name.
Changing text through commands does not rename the layer, preserving names used as field keys.
Reviewing files that changed from the base of the PR and between 58af1a6 and 4e5f0f8.
Files selected for processing: 5
crates/engine/src/canvas/textedit.rs
crates/engine/src/cmd/props.rs
crates/engine/src/text_behaviour_tests.rs
docs/roadmap.md
docs/target-app-parity.md
Walkthrough
Text edits now update a text layer’s name when it still matches the name derived from the previous text. Manually changed names remain unchanged. Command-based character updates do not rename the layer.
Changes: Text-layer naming
Layer / File(s)
Summary
Derive and update text-layer names crates/engine/src/cmd/props.rs, crates/engine/src/canvas/textedit.rs
The first line supplies a derived name, limited to 64 characters. Successful edits update the name when it matches the previous derived name. Blank text produces an empty name.
Verify and document typing behavior crates/engine/src/text_behaviour_tests.rs, docs/roadmap.md, docs/target-app-parity.md
Tests cover typing, manual names, blank text, new text layers, and node.set character changes. Revision histories document the behavior.
Typing in a text layer now renames it while its name still follows its text. In a narrow case, a manually chosen name that happens to equal the text-derived name can still be renamed by later typing. This is a bounded edge case and the change is mergeable, but the author should be aware of it.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Linked Issues check
[#1747] Requirement: the Layers panel text and the canvas text stay in sync when a text element is created or updated, and "any changes to the text should be reflected consistently in both places."
M…
Resolve the conflict between #1747 and the field-key contract. Use one of these options: 1. Let command-driven character changes follow the derived-name rule. Mark field-key layers explicitly, for example with a binding or override marker, …
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title names the main change: a text layer's name now follows the characters typed into it. It also names issue #1747 and the milestone M4. The raw summary and objectives confirm that typing update…
Out of Scope Changes check
All changed paths relate to #1747 or to its documented verification. crates/engine/src/canvas/textedit.rs (+7 lines) is the rename hook in the editor mutation path. crates/engine/src/cmd/props.rs …
Docstring Coverage
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Full details: Title check
Explanation
The title names the main change: a text layer's name now follows the characters typed into it. It also names issue #1747 and the milestone M4. The raw summary and objectives confirm that typing updates a derived layer name, that manually chosen names are kept, and that command-based character edits do not rename the layer. The title is specific and matches the changeset.
Full details: Out of Scope Changes check
Explanation
All changed paths relate to #1747 or to its documented verification. crates/engine/src/canvas/textedit.rs (+7 lines) is the rename hook in the editor mutation path. crates/engine/src/cmd/props.rs (+24 lines) adds the shared derivation and the derived-name check. crates/engine/src/text_behaviour_tests.rs (+68 lines) adds the two tests the PR cites. docs/roadmap.md and docs/target-app-parity.md each add one revision-history row. These rows document the behavior change and are supporting documentation. The PR does not change edit.findReplace or any other command path. The clipboard_fence_tests failure is reported as environmental. It is not a code change in this diff.
Full details: Docstring Coverage
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 3 files. (2 skipped: 2 unsupported.)
Full details: Linked Issues check
Explanation
[#1747] Requirement: the Layers panel text and the canvas text stay in sync when a text element is created or updated, and "any changes to the text should be reflected consistently in both places."
Met for typing. crates/engine/src/canvas/textedit.rsedit_if now takes derived_before and derived_after with cmd::props::text_layer_name. It calls text_name_is_derived and sets n.name in the same document mutation. Typing hello then there gives the name hello there. Creation is covered too: the Text tool leaves "", and node.create names the layer Text. text_behaviour_tests::typing_renames_a_text_layer_that_still_carries_the_name_its_characters_gave_it asserts these cases.
Not met for other character changes. text_behaviour_tests::setting_characters_as_a_command_never_renames_the_layer pins that node.set {characters} changes the canvas text while the Layers panel name stays Title. The PR states this is intentional, because layer names act as field keys for data.fill, component bindings and templates. That is a real conflict with the issue text. The issue does not carve out command-driven updates. The PR also leaves edit.findReplace to its own layerNames option, so a replace that changes characters can also leave the panel out of sync. The PR does not show how the issue's "any changes" requirement is met on these paths.
Resolution
Resolve the conflict between #1747 and the field-key contract. Use one of these options:
Let command-driven character changes follow the derived-name rule. Mark field-key layers explicitly, for example with a binding or override marker, so data.fill and template lookups keep their names. Add a test that a layer without that marker renames on node.set {characters}, and that a field-key layer keeps its name.
Get maintainer agreement that #1747 covers only interactive typing. Record that decision in the issue, or in the PR description and docs, and update the linked issue scope to match. The PR's current evidence then satisfies the narrowed scope.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
The reason will be displayed to describe this comment to others. Learn more.
Additional comments: 1
crates/engine/src/canvas/textedit.rs-200-200: 1
200-200: Major · Data Integrity & Integration · Heavy lift
Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.
Preserve instance names when their text is overridden.
If an instance has a characters override but no name override, typing in its main component now changes the instance’s name while its characters stay unchanged. For example, a main layer named Title can rename an instance field to Title!, although the instance still contains its overridden text. Later name-based data fills can no longer find Title.
patch_copies propagates the name and characters groups independently in crates/engine/src/assets/components/patch.rs, Lines 423–443. Reconcile automatic renames with instance text overrides in both patch and rebuild paths. (raw.githubusercontent.com)
Reviewing files that changed from the base of the PR and between 0e86f35 and 58af1a6.
Files selected for processing: 5
crates/engine/src/canvas/textedit.rs
crates/engine/src/cmd/props.rs
crates/engine/src/text_behaviour_tests.rs
docs/roadmap.md
docs/target-app-parity.md
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Merged, thank you @Hamza0101! With this, a text layer's name in the Layers panel keeps up with what you type, unless you renamed it. It landed with your commits, with one small change of ours on top.
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
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.
Fixes #1747.
A text layer's name is a snapshot of its characters taken when the layer is made (
node.createnames it after the first line) and nothing updates it afterwards. The Layers panel shows that name, so as soon as you type the panel and the canvas disagree: a layer that started ashellostill readshelloin the panel after the canvas sayshello there.The target app's plugin API documents the rule this is missing,
TextNode.autoRename:What this does
No new field and no file-format change: the flag is inferred, because a layer nobody has renamed is exactly one whose name is still the name its characters derive.
cmd::props::text_layer_namestates that derivation once (the first line, at most 64 characters, or None when blank), andtextedit::edit_if— the one chokepoint every canvas mutation goes through — compares the name against it before the edit and re-derives it after:So a name the author typed is never touched, and a layer renamed to something else stops following for good. Because the rename happens inside the same document mutation, it shares the edit's undo step.
The two creation paths leave a blank text layer named differently — the Text tool leaves the name empty and
node.createnames itText, and the panel shows the layer's kind for either — sotext_name_is_derivedtreats both as unnamed. Without that, the most common flow of all (pick the Text tool, click, type) would not have been covered: the layer's name is"", which matches no derived name. I only noticed because I added that flow to the test; the targeted control below pins it.Only the editor follows the characters
Commands deliberately do not rename, and there is a test pinning that. Layer names are field keys:
data.fill, component property bindings and the templates writecharactersinto a layer named for its role and then look it up by that name again. I first applied the rule innode.set {characters}too, anddatafill_tests::each_row_fills_a_copy_in_one_undo_stepcaught it — filling a layer namedTitlewhose placeholder text is alsoTitlerenamed the field toSite em 7 diasand the next lookup found nothing. That is also why inferring the flag is safe only on the typing path: a name that matches the text is an auto-name when a human is typing, and a field key when a command is writing.MCP and the control protocol reach
textedit::insert/key, so an agent typing into a layer renames it exactly as a person typing does;node.set {characters}remains the way to set text without touching the name.Tests
text_behaviour_tests::typing_renames_a_text_layer_that_still_carries_the_name_its_characters_gave_it— typing follows the name; a chosen name is kept; only the first line names the layer; emptied text goes back to having no name of its own; and the Text tool drawing a layer and typing into it names it.text_behaviour_tests::setting_characters_as_a_command_never_renames_the_layer— thedata.fillcontract above.Negative control, with the two-line rename removed and the tests kept:
which is the reported symptom exactly: the characters move on, the name does not.
A second control, with only the unnamed-layer branch of
text_name_is_derivedreturningfalse:so that branch is load-bearing for the Text-tool flow rather than belt-and-braces.
Gates
cargo test -p figcraft-engine: 1793 passed, 0 failed (1791 before, so the two new ones and no regressions).cargo fmt --checkandcargo clippy -p figcraft-engine --all-targetsclean.cargo xtask layers,cargo xtask assetsandcargo xtask wasm: ok (wasm exits 0).cargo xtask cistops on one failure infigcraft-ui-egui(1005 passed, 1 failed):clipboard_fence_tests::a_synthetic_copy_shortcut_leaves_the_system_clipboard_alone. It fails thesame way on clean
origin/mainhere, so it is this machine (no OS clipboard in my environment) andnot this change; I ran the steps after it by hand because
ciskips them once something fails.Revision-history rows added to
docs/roadmap.mdanddocs/target-app-parity.mdin the same commit; the grade is unchanged.Not in this change
edit.findReplacealready decides whether names change through its ownlayerNamesoption, so I left that path alone rather than giving it a second, implicit rule.Summary by CodeRabbit