Repository navigation
fix(editor): mounted checks, load-failure close and Edit tab label in the Gallery editor - #7429
Merged
alteixeira20 merged 6 commits intoDec 2, 2026
Merged
Conversation
…ry-editor descendant _buildEditor() replaces the container's class with `gallery-editor`, so the `#gallery-editor-container .gallery-editor` descendant checks in gallery.js, galleryEditor.js and ui.js never matched. They only behaved because isEditorOpen() or __galleryEditLive sat next to them; the global Escape guard in ui.js had no such fallback and was always false. closeEditor() also leaves that class on the container, so the landing shown after a close carries it too. Matching the container class instead would treat that landing as a mounted editor. Check for the editor body element, which only exists while the editor is built.
…age fails to load openEditor() mounts the editor shell before it fetches the draft or image. When that fails (draft not found, draft data that cannot be restored, image onerror) it called closeEditor() without force. state.editorOpen is true at that point, so the close was refused: the user got "Close the edit tab first" on top of the real error and was left in an empty editor. The three failure paths now close with force and dispatch gallery-editor-setup-cancelled, the same way a cancelled New canvas does, so the Gallery renders the Edit tab landing again. Forcing the close makes a stale failure dangerous: a slow draft fetch from a session the user already closed could tear down the session opened after it. The failure paths therefore check that the session they belong to is still the open one, like the save pipeline already does, and stay silent otherwise.
closeEditor() reset the Gallery's Edit tab label before it set state.editorOpen to false. _setEditTabLabel(null) writes "Edit" and then re-renders the document tabs, and that renderer only checks state.editorOpen, so it wrote "Edit: <name>" straight back. Every close path left the old name on the tab: the tab x, a cancelled New canvas and the load-failure closes. Reset the label once the editor no longer counts as open. The document tab strip is unchanged while the editor is open; the new spec also checks it with two documents.
With an edit open, closing the Gallery is refused ("Close the edit tab
first"), but two paths still hid the sheet and left it unreachable:
- the sidebar Gallery button: closeGallery() goes through Modals.close(),
which hides and unregisters the node even when closeFn refuses;
- a swipe-down on the sheet header (ui.js), which hides the node and fires
modal-dismissed without asking the gallery.
In both cases _open stayed true, so every later tap went back to the
refused close and the edit was stranded in memory.
closeGallery() now refuses before calling Modals.close(), so the button
leaves the sheet in place and only shows the toast. When the sheet is
hidden while an edit is live, isGalleryOpen() reports false and
openGallery() shows the existing sheet again (re-registering it with the
modal manager if needed) instead of building a new one. The swipe gesture
itself is unchanged.
…nd the dock Phone viewport, real app. With an edit open, the Gallery button must leave the sheet visible, and one tap must bring back the same edit (same layer count) after a CDP touch swipe on the header or a refused dock close. All three fail on dev.
10 of 16 tasks
alteixeira20
approved these changes
Dec 2, 2026
alteixeira20
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed the fixes and verified the integration with the Gallery editor decomposition from #7425.
The original corrections are preserved, all required CI checks and CodeQL pass, and no merge-blocking findings remain.
LGTM! Thanks for identifying and addressing these issues during the decomposition.
touzenesmy
pushed a commit
to touzenesmy/odysseus
that referenced
this pull request
Dec 3, 2026
…on, load-failure close, live-edit close guard ADAPT of upstream e3d13f4 (editor fix odysseus-dev#7429) onto the fork's monolithic galleryEditor.js, preserving fork customizations: - galleryEditor.js: _galleryEditMounted() now keys off the real body element (.ge-editor-body) instead of the stale gallery-editor class; openEditor() tracks the open session token and routes every load-failure path (missing draft, broken project data, image onerror) through _closeEditorAfterLoadFailure(), which force-closes and re-dispatches gallery-editor-setup-cancelled so the Gallery's Edit tab returns to its landing; closeEditor() resets the Edit-tab label after state.editorOpen is false so the document tab strip cannot write the old name back. - gallery.js: _editorMounted() helper; setup-cancel handler, openGallery() re-show, _doCloseGallery()/closeGallery()/isGalleryOpen() all use the DOM-based mount check and a live-edit guard so a refused close cannot strand a hidden sheet. - ui.js: swipe-dismiss path adjusted to the same mount check. - New tests: edit-tab-label, gallery-live-edit-reopen, load-failure-close e2e specs + test_gallery_editor_mounted_checks_browser.py. Gates: browser guard suite 15/15; focused e2e 11 passed, 1 skipped (multi-document tab strip requires upstream 34d61a6, not yet adopted), 1 failed (core-workflow line 28, #ge-layer-tools .ge-true-mask-btn timeout) — reproduced identically on the clean 8c60b1a baseline worktree, i.e. pre-existing, not a regression from this ADAPT.
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
Three close-path fixes for the Gallery image editor, found while working on #7422 and left out of it because it merged first. One commit each, all in
static/jsplus tests. It doesn't depend on the editor decomposition PR opened next to it: both touchstatic/js/galleryEditor.js, but either can merge first and they merge cleanly together.gallery.jssetup-cancel, Gallery Escape,_doCloseGallery;_galleryEditMounted(); the global Escape guard inui.js) looked for a.gallery-editordescendant of#gallery-editor-container._buildEditor()puts that class on the container itself, so all five were always false. They now check#gallery-editor-container > .ge-editor-body, which only exists while the editor is built. The container keeps its class after a close, so matching it instead would count the landing as an open editor.gallery.js:1334is left to fix(gallery): retain the editor after creating a canvas #7156.openEditorcalledcloseEditor()unforced, which is refused while the editor counts as open: "Close the edit tab first" replaced the real error and an empty editor stayed up. These paths now close withforceand firegallery-editor-setup-cancelled, like a cancelled New canvas, so the landing comes back. They first check that their session is still the open one, so a slow failure from a closed session can't close the next one.closeEditor()reset the Edit tab label whilestate.editorOpenwas still true, so the document tab renderer wrote "Edit: " back after every close. The reset now happens once the editor stops counting as open.Target branch
labin the private maintainer-preview repository, ordevin the public repository.mainremains release-curated.Linked Issue
Fixes #7426
Fixes #7427
Fixes #7428
Type of Change
Checklist
labin maintainer-preview;devin the public repository)docker compose uporuvicorn app:app) and verified the change works end-to-end. Type-checks and unit tests are not enough.How to Test
python -m pytest tests/test_gallery_editor_mounted_checks_browser.py -p no:randomly: 15 pass. Each of the five guards runs in Chromium against a mounted editor, the landing after a close, and a fresh landing; ondevthe five "mounted" cases fail.npm run test:photo-editor -- load-failure-close edit-tab-label: 6 pass, all 6 fail ondev. A missing draft, a broken draft and a 404 image each end on the landing with one toast; a stale failure can't close the next session; the tab label resets after the tab x close, and the multi-document tab strip still follows its documents.imgWidth: 0throughPOST /api/editor-drafts), click its card under Saved projects. One "Failed to load draft" toast, the landing, tab readsEdit.Edit, notEdit: 1024×1024.Not verified:
dev, not touched here.Visual / UI changes — REQUIRED if you touched anything that renders
--red,--fg,--bg,--card,--border, etc.) — do not introduce new color values, font sizes, or spacing units.static/index.html) or plain text.Fira Code) for primary UI text. Don't override.Screenshots / clips
No styling change.
Before (
dev): broken saved project clicked, empty editor and "Close the edit tab first"After: same project, one error toast, the landing, tab reads
Edit