Repository navigation
DevTools: save unsaved edits to the right element and make Restore reliable - #1162
Zach Teutsch (zateutsch) wants to merge 6 commits into
Conversation
- Save the focused editor before the selection changes or the pane is rebuilt, and ignore late focus-out events from removed editors, so an unsaved edit is written to the element it was made on. - Keep one edit record per element and property for the session, holding the value from before the first edit. Restore puts that back: a value is written, a value that came from a style or default is cleared, and a resource reference is re-linked. Clear counts as an edit. - Drop the record when the app changes the value after the edit, and say so in the row, instead of offering a Restore that would undo the app. - Show a hint in the multi-line editor that Enter adds a new line. Fixes #1142 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78fc45e1-7d89-4a89-bb28-898e906b0a15
… resource restore recovery - Record the element theme with each baseline, so a theme switch takes a new baseline instead of hiding or faking app changes. - Read values before and right after each write, so app changes to other properties are caught and DevTools' own side effects are not. - Re-editing after an app change records the app's value as the original. - A failed resource Restore puts back the previous value and keeps the record. - Leaving an element keeps its editors live so a late focus-out still saves. - Remove dead g_editRows code. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78fc45e1-7d89-4a89-bb28-898e906b0a15
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78fc45e1-7d89-4a89-bb28-898e906b0a15
There was a problem hiding this comment.
🟡 Changes recommended
Restore can still overwrite newer app values or restore the wrong property source because original-state capture and read-back handling remain incomplete.
5 open issues
Preserve current local state when recording app resource changes · New Refresh stale app-change entries before restoring values · New Read back captured elements after late-save rebaselining · New Preserve exact attached-property names in pre-write checks · New Carry complete original property records through late saves · New
What changed in this PR
This PR addresses #1142 in the native DevTools properties pane by saving edits before selection changes and keeping Restore records per element across the session.
Changes:
- Tracks original values, property sources, and app changes to guide Restore.
- Adds editor flushing and stale-callback guards around pane rebuilds and selection changes.
- Adds regression tests and a multiline-editor hint explaining Enter-to-apply and Shift+Enter-to-insert.
| File | Description |
|---|---|
src/winapp-devtools/test/window-runtime-tests.cpp |
Tests edit records, Restore, app changes, and editor lifetime. |
src/winapp-devtools/test/binding-editor-semantics-tests.cpp |
Tests rejection of Apply from another element’s editor. |
src/winapp-devtools/native/WinApp.DevTools.Native/xaml-window/window-shell.xaml |
Adds the multiline keyboard hint. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.State.inc |
Defines session-wide edit and app-change records. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.SourceAndResources.inc |
Updates an ownership comment only. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.PropsPane.inc |
Flushes editors and preserves records across selections. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.PaneSinks.inc |
Tracks editors, commit outcomes, and late saves. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.LiveProps.inc |
Checks edited properties against live values and themes. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.KindModel.inc |
Implements original-state capture, reconciliation, Clear, and Restore. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.Expansion.inc |
Displays Restore state and app-change messages. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.Editors.inc |
Registers editors, guards callbacks, and adds keyboard help. |
src/winapp-devtools/native/WinApp.DevTools.Native/DevToolsWindow.cpp |
Imports automation peers for save notifications. |
Review effort: Balanced
Build Metrics ReportValidation passed. All required build and validation jobs succeeded. Binary Sizes
.NET Test Results (TRX reports)Other suites are reflected in the overall validation status above. ✅ 10669 passed, 43 skipped out of 10712 tests in 1880.8s (+5 tests, -703.5s vs. baseline) Test Coverage✅ 87.4% line coverage, 81.5% branch coverage · ✅ no change vs. baseline CLI Startup Time77ms median (x64, Try This BuildInstalls the MSIX for your architecture, replacing any previously installed build. Needs the GitHub CLI — the command offers to install it and sign you in if it is missing. & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) 1162Switching between builds often?Put the tool on your PATH once: & ([scriptblock]::Create((irm https://raw.githubusercontent.com/microsoft/winappCli/main/scripts/winapp-pr.ps1))) -AddToPathThen this build is just: winapp-pr 1162Run Updated 2026-10-22 23:12:26 UTC · commit |
Restore now uses the app's latest value after an app change, keeps whether a late-saved original was set on the element, reads a late-saved element back right away, and asks for attached properties by their full name. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78fc45e1-7d89-4a89-bb28-898e906b0a15
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78fc45e1-7d89-4a89-bb28-898e906b0a15
…the pane Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 78fc45e1-7d89-4a89-bb28-898e906b0a15

What and why
Three problems in the DevTools properties pane:
In the multiline editor, Enter adds a new line. A hint under the box shows how to save.
Fixes #1142
Before / after
Before: select a TextBlock, type
Helloin Text, then click a Button in the tree without pressing Enter. The Button's Text becomesHello, and the TextBlock's Restore is gone when you come back to it.After: the TextBlock gets
Hello, the Button is unchanged, and the TextBlock's Text row still offers Restore when you come back to it.No screenshot or recording yet; see below.
Not tested / risks
Checklist
Notes for reviewers
Padding.Leftalso changesPadding) don't look like app changes.