Skip to content

Show controlled values unless the user has an unacknowledged edit - #97

Merged
andreamancuso merged 1 commit into
mainfrom
core/controlled-values
Nov 24, 2026
Merged

andreamancuso merged 1 commit into
mainfrom
core/controlled-values

Conversation

@andreamancuso

Copy link
Copy Markdown
Collaborator

Why

xframes-core lets the application model own what an input shows (xframes-core#24). The hard case is a commit and a user's edit crossing: the model applied "a", the user has since typed "ab", and a commit carrying "a" lands. Overwriting the input would lose the keystroke. Only the engine knows, when it applies a commit, whether the input was edited after the state the commit was built from.

What

  • XFrames::NoteWidgetEvent(id) numbers widget events and records each element's last edit that no commit has acknowledged. The shared C library calls it for every event it queues and stamps the sequence into polled events.
  • A commit may carry "eventsApplied": the last event applied to the state its tree was built from (a canonical uint64 decimal string, parsed like baseRevision).
  • Elements declare controlled properties (ControlledProps; input-text declares value). With eventsApplied, a commit stores them as the element's committed values instead of patching them. An element edited after eventsApplied keeps what the user typed. Any other patched, created or acknowledged element shows its committed values, even when the commit does not carry them, so a rejected or transformed edit converges.
  • Without eventsApplied, behavior is unchanged.
  • InputText reloads ImGui's edit buffer when a controlled value replaces its text while it is being edited, and reports its value in the diagnostics state. The commit state advertises controlledValues.

Tests

Five new tests: the feature and numbering; a value shown with no unacknowledged edit; an edit after eventsApplied kept, then restored by an acknowledging commit without a patch; values ignored without eventsApplied; destruction forgetting an edit. All 414 engine tests pass locally. Two hand mutations (no staleness check; no re-apply without a patch) were each caught.

xframes-core's checks against the shared library built from this commit also pass locally, including hidden-window crossing checks and check-native.ps1 -SoftwareRendering.

🤖 Generated with Claude Code

https://claude.ai/code/session_0186WhMU3KjnmjR7Y4r49GrT

An embedder numbers widget events with NoteWidgetEvent, and a commit may
carry "eventsApplied": the last event applied to the state its tree was
built from. Elements declare controlled properties (input-text: value).
With eventsApplied, a commit stores them as the element's committed
values. An element edited after eventsApplied keeps what the user typed;
any other patched, created or acknowledged element shows its committed
values, even when the commit does not carry them, so a rejected or
transformed edit converges. Without eventsApplied nothing changes.

InputText reloads ImGui's edit buffer when a controlled value replaces
the text while it is being edited, and its value is reported in the
diagnostics state. The commit state advertises controlledValues.

Five new unit tests; all 414 pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0186WhMU3KjnmjR7Y4r49GrT
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

Explain Change →

Caution

Review failed

The pull request is closed.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@andreamancuso
andreamancuso merged commit e9d4a5a into main Nov 24, 2026
0 of 9 checks passed

This branch was previously deployed

1 inactive deployment
github-pages — e9d4a5aa Deployed Nov 24, 2026 by andreamancuso via deploy #276
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant