Skip to content

Media editor: Define a named edit as session state the editor does not save - #85422

Closed
ramonjd wants to merge 1 commit into
trunkfrom
update/media-editor-named-edits-contract
Closed

ramonjd wants to merge 1 commit into
trunkfrom
update/media-editor-named-edits-contract

Conversation

@ramonjd

@ramonjd ramonjd commented Oct 23, 2026

Copy link
Copy Markdown
Member

What

Names what a named edit is today: session.edits, set with setEdit, is session state for the editor's own edit pipeline, not an extension API. Architecture notes, doc comments, one comment at the editor's unsaved-changes check, and a test that pins it. No behaviour change.

Why

A sidebar panel (#84664) can reach the session. If it called setEdit, Reset would enable but Save would not, the discard prompt would not fire, and nothing would be saved: isDirty counts named edits, hasOutputEdits does not, and neither the save hook nor the modal's modifier builder reads them. That has to be stated where the next reader looks before the session is exposed to plugins. Applying named edits to the output is the edit pipeline's job and a separate change.

What changed

  • architecture.md says what a named edit is and is not.
  • Doc comments on edits, setEdit and hasOutputEdits say the same.
  • A comment at hasChanges says why named edits are left out: counting them would enable Save for a change the save then drops.
  • A state test pins it: a named edit is dirty, not an output edit.

…t save

`session.edits`, set with `setEdit`, is undoable and cleared by Reset
because `isDirty` counts it, but `hasOutputEdits` does not, the editor's
unsaved-changes check and Save ignore it, and neither the save hook nor the
modal's modifier builder reads it. Say so in the architecture notes, the doc
comments and at `hasChanges`, and pin it with a state test, so a sidebar
panel reaching the session knows what setting one does before the session
is exposed to plugins. Applying named edits to the output is the edit
pipeline's job and a separate change.
@ramonjd ramonjd added the [Type] Developer Documentation Documentation for developers label Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

📦 Bundle size

Size Change: 0 B

Total Size: 9.06 MB

17f4d59 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 87b8440 trunk % Change
timeToFirstByte 57.65 ms +9.28% -3.73% 58.4 ms +6.76% -4.62% -1.28%
largestContentfulPaint 100 ms +0% -4% 100 ms +4% -4% 0%
lcpMinusTtfb 37.7 ms +16.05% -5.04% 41.6 ms +5.05% -15.02% -9.37%
wpBeforeTemplate 31.63 ms +14.35% -5% 30.98 ms +15.04% -3.91% 2.1%
wpTemplate 22.12 ms +5.02% -4.79% 22.25 ms +4.54% -3.01% -0.58%
wpTotal 53.69 ms +8.98% -3.8% 54.16 ms +7.09% -4.67% -0.87%
wpMemoryUsage 7.67 MB +0% -0% 7.64 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 87b8440 trunk % Change
timeToFirstByte 47.1 ms +3.72% -1.91% 49.15 ms +7.22% -2.95% -4.17%
largestContentfulPaint 104 ms +3.85% -1.92% 104 ms +5.77% -0% 0%
lcpMinusTtfb 56.95 ms +4.39% -2.55% 56.3 ms +3.64% -2.49% 1.15%
wpBeforeTemplate 27.17 ms +2.28% -1.32% 28.29 ms +12.12% -3.82% -3.96%
wpTemplate 16.59 ms +1.81% -3.07% 17.52 ms +5.59% -4.17% -5.31%
wpTotal 43.84 ms +4.27% -1.67% 45.99 ms +7.15% -3.15% -4.67%
wpMemoryUsage 6.36 MB +0% -0% 6.33 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 87b8440 trunk % Change
mediaProcessingJpeg 407 ms +0.34% -1.99% 404.77 ms +2.97% -0.41% 0.55%
mediaProcessingAvif 6148.11 ms +0.27% -0.32% 6163.45 ms +0.33% -0.38% -0.25%
mediaProcessingJpegToAvif 4237.11 ms +0.12% -0.56% 4233.7 ms +0.35% -0.1% 0.08%

media-upload

Metric 87b8440 trunk % Change
jpegUploadProcessing 1456.24 ms +1.62% -1.99% 1433.58 ms +2.59% -0.43% 1.58%
pngUploadProcessing 226.8 ms +2.37% -7.72% 219.41 ms +6.25% -11.93% 3.37%
largeJpegUploadProcessing 1467.45 ms +31.15% -1.96% 1444.8 ms +3.15% -2.31% 1.57%
multipleImageUploadProcessing 2072.73 ms +1.38% -0.67% 2069.17 ms +1.17% -6% 0.17%

post-editor

Metric 87b8440 trunk % Change
serverResponse 500.82 ms +7.07% -7.1% 505.21 ms +2.27% -7.53% -0.87%
firstPaint 484.09 ms +8.03% -41.6% 390.82 ms +31.88% -27.85% 23.87%
domContentLoaded 1220.21 ms +0.75% -2.58% 1195.05 ms +1.91% -2.63% 2.11%
loaded 1221.41 ms +0.75% -2.56% 1196.26 ms +1.87% -2.63% 2.1%
firstContentfulPaint 526.33 ms +2.07% -2.47% 521.34 ms +1.28% -2.82% 0.96%
firstBlock 3629.71 ms +1.16% -3.86% 3495.73 ms +2.73% -1.04% 3.83%
type 19.39 ms +4.95% -4.07% 17.36 ms +3.05% -4.44% 11.69%
typeWithoutInspector 17.55 ms +7.12% -2.79% 17.75 ms +7.32% -2.03% -1.13%
typeWithTopToolbar 23.73 ms +1.47% -4.93% 22.53 ms +7.81% -1.78% 5.33%
typeContainer 8.84 ms +4.3% -5.88% 8.86 ms +10.5% -8.92% -0.23%
focus 116.21 ms +4.01% -3.33% 113.68 ms +11.74% -2.6% 2.23%
firstFocus 236.08 ms +0% -0% 234.12 ms +0% -0% 0.84%
selectAll 601.89 ms +3.17% -5.75% 590.02 ms +3.56% -3.46% 2.01%
listViewOpen 81.69 ms +5.37% -12.13% 82.68 ms +3.57% -4.67% -1.2%
inserterOpen 43.48 ms +13.78% -10.44% 41.8 ms +11.46% -4.31% 4.02%
inserterHover 11.34 ms +17.11% -5.64% 12.21 ms +7.04% -7.7% -7.13%
inserterSearch 8.37 ms +19.71% -9.2% 8.26 ms +1.69% -10.77% 1.33%
loadPatterns 632.26 ms +3.29% -4.28% 635.46 ms +4.63% -2.14% -0.5%
wpTotal 490.16 ms +7.54% -7.12% 495.67 ms +2.39% -7.66% -1.11%
wpMemoryUsage 14.71 MB +0% -0% 14.67 MB +0% -0% 0.24%
wpDbQueries 54.5 +0.92% -0.92% 54.5 +0.92% -0.92% 0%

site-editor

Metric 87b8440 trunk % Change
serverResponse 235.86 ms +2.67% -9.83% 229.06 ms +4.73% -5.55% 2.97%
firstPaint 206.62 ms +33.65% -23.48% 165.61 ms +12.37% -17.99% 24.76%
domContentLoaded 707.58 ms +6.53% -3.91% 718.84 ms +0.5% -1% -1.57%
loaded 708.38 ms +6.51% -3.91% 719.56 ms +0.48% -0.99% -1.55%
firstContentfulPaint 297.37 ms +3.07% -8.26% 313.67 ms +4.73% -4.54% -5.2%
firstBlock 2604.35 ms +1.75% -2.67% 2541.77 ms +0.58% -0.69% 2.46%
type 12.09 ms +1.65% -1.9% 12.41 ms +3.06% -6.77% -2.58%
navigate 91.71 ms +4.87% -0.64% 91.05 ms +3.47% -6.59% 0.72%
loadPatterns 796.1 ms +7.87% -6.33% 743.46 ms +4.2% -12.32% 7.08%
loadPages 1000.1 ms +5.41% -4.12% 991.86 ms +2.26% -9.36% 0.83%
wpTotal 229.9 ms +2.71% -10.12% 223.16 ms +4.86% -5.74% 3.02%
wpMemoryUsage 12.72 MB +0% -0% 12.69 MB +0% -0% 0.27%
wpDbQueries 44.5 +1.12% -1.12% 45 +0% -2.22% -1.11%

17f4d59 Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Regression: updating a specific option will only change its value and will not corrupt others in /test/e2e/specs/editor/various/core-settings.spec.js, passed after 1 failed attempt.
Error: expect(received).toStrictEqual(expected) // deep equality

- Expected  - 1
+ Received  + 1

  Array [
    "rewrite_rules",
-   "SERIALIZED DATA",
+   "",
  ]
    at forEach (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:46:26)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/core-settings.spec.js:43:35

17f4d59 Run

@ramonjd ramonjd closed this Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant