fix(playground): hoist enterQueryEdit out of its value-receiver returns - #89
Merged
Conversation
enterQueryEdit has a pointer receiver and mutates the model (editing, and status on the no-store path), but four call sites returned it inline as `return m, m.enterQueryEdit()` from value-receiver methods. Go only orders function calls left-to-right; the plain read of m relative to that call is unspecified, so the model bubbletea receives back could be the pre-mutation copy. It worked under the current compiler, which is why it went unnoticed. This is the same class the confirm modal was already hoisted for, and it gains the same refactor guards.
sergiught
force-pushed
the
fix/query-edit-eval-order
branch
from
July 31, 2026 12:37
7fae23a to
2eaedfe
Compare
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.
📝 Summary
enterQueryEdithas a pointer receiver and mutates the model — it setsediting, and setsstatuson the no-store path. Four call sites returned it inline from value-receiver methods:Go only orders function calls left-to-right relative to each other; the plain read of
mrelative to that call is unspecified. So the model bubbletea receives back may be the pre-mutation copy — the query form would fail to open, or the "select a store first" status would be silently dropped.It works under the current compiler, which is why it went unnoticed. This is the same hazard the confirm modal was already hoisted for (the codebase calls it TUI-F8, see the
Hoisted:comments insection_keys.go), so this brings the last four sites in line and gives them the same refactor guards.Sites fixed:
section_keys.goi/enter,tab,shift+tab, andupdate.go'sonEnterSectionsecQuery branch.🏷 Type of change
🔗 Related issues
None. Found during review of #86 / #87; deliberately split out because it is pre-existing and unrelated to either.
✅ How to verify
make check # fmt, vet, lint, testThe new guards in
query_edit_eval_order_test.goassert the mutation is observable on the returned model. To confirm they actually bite, make one site return the pre-mutation copy:TestQueryEditKeyAppliesMutation/i,/enter, andTestQueryEditWithoutStoreAppliesStatusall fail; revert and they pass.📋 Checklist
--helpexamples) if behavior changed — no user-visible behavior changemake checkpasses locallyNotes for review
No behavior change under the current compiler — this closes an unspecified-behavior hole rather than fixing an observed misbehavior. The guards are the durable part: they make a future re-inlining fail loudly instead of silently.
Branches from
mainand touches neither #86's nor #87's areas.