[PR #7719] [MERGED] fix(gallery): pinned images keep their place and size after a reload, and can be locked #7896

Closed
opened 2026-10-24 04:08:37 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/7719
Author: @SpicyMarinara
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/7688-pinned-gallery-lock


📝 Commits (2)

  • 357694c fix(gallery): pinned images keep their place and size after a reload, and can be locked
  • 53a45e9 fix(gallery): a drag in a small window keeps the pin's saved size

📊 Changes

4 files changed (+354 additions, -111 deletions)

View changed files

➕ e2e/pinned-gallery-layout.e2e.ts (+156 -0)
📝 packages/client/src/components/chat/PinnedImageOverlay.tsx (+160 -107)
📝 packages/client/src/localization/locales/en.json (+4 -0)
📝 packages/client/src/stores/gallery.store.ts (+34 -4)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #7688

Why this change

  • A user arranges images pinned from the gallery around the chat. After a reload they all come back in the middle of the screen at the default size. They asked for a way to lock them so they stay where they were put.
  • Root cause: the pinned list in localStorage saved only which media were pinned, never where they were or how big. Each pin always mounted centred at the default size. Any window resize also reset the pin to the default size, so on a phone the keyboard or address bar could undo a layout without a reload.

What changed

  • gallery.store.ts: each pin can hold a layout (x, y, w, h in viewport pixels, plus locked). setPinnedLayout saves it with the pinned list. A stored layout that is broken is dropped on load and the pin stays.
  • PinnedImageOverlay.tsx: a pin opens at its saved layout and saves it when a drag or resize ends. What you see is that layout fitted to the current window (same shape, kept on screen); the saved layout stays as the user left it, the way floating chat windows work. A window resize no longer resets the size, and a drag in a small window keeps the saved size, so the pin grows back when the window does. An image without stored dimensions no longer resizes itself on load once it has a saved layout.
  • Lock: a lock button next to Dismiss, shown with the other controls (on hover or tap; always on phones). While locked, dragging does nothing, the resize handle is hidden, and the pin's label says it is locked. Dismiss still works. The lock is saved too. The one-shot gallery viewer has no lock and is not saved.
  • Brief's reference: 2D/3D avatars have no placement lock on staging (they move with the sprites' Arrange mode), so this follows the lock on floating chat windows instead (Lock/Unlock icon, aria-pressed, a hint for each state).
  • New English strings: ui.chat.pinnedmediaviewer.lockPinnedMedia, lockHint, unlockHint and pinnedMediaLocked. No existing copy was changed.
  • Regression proof: e2e/pinned-gallery-layout.e2e.ts pins a real gallery image, moves and resizes it, then reloads and checks that its box is the same. Next it narrows the window, drags the shrunk pin and widens the window again, checking that the pin grows back to its size. It then locks the pin, checks that a drag does not move it and that it has no resize handle, reloads and checks again, and finally unlocks it and checks that it moves.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

Agent-run checks:

  • The new e2e fails on unfixed staging (f040d9067, desktop-chromium). After the reload the pin is back in the middle: its x is 474 px from where it was left (expect(...).toBeLessThanOrEqual(1), received 474).
  • The window-resize part also fails on unfixed staging. I ran a scratch copy of the spec without the reload step, with staging's component and store, on desktop-chromium. When the window grew back the pin was 460 px wide, the default size, instead of the 370 px it was given.
  • With the fix, the final spec passed 3/3 on desktop-chromium and 2/2 each on mobile-chromium and mobile-webkit (--workers=1). One run failed on the first page load of a fresh dev server: the pin took more than 10 s to appear, the test deleted the chat, and the image then returned 404. The first visibility check now waits up to 30 s.
  • Local CodeRabbit, first pass: 1 finding. A drag in a narrow window saved the shrunk size, so the pin stayed small once the window grew. It was valid and is fixed in the second commit. Second pass: 0 findings.
  • tsc --noEmit passes for shared, server, client and root (e2e types).
  • ESLint passes on the changed client files. prettier --check passes on all changed files. node scripts/check-locales.mjs, pnpm localization:check and pnpm impeccable:check pass.
  • Not run: the full pnpm check (lint/format/build across the repo), Docker, and the rest of the Playwright suite.

Manual verification notes

  • Manually verify in Roleplay, Conversation and Game: pin an image from the gallery, move and resize it, reload. It should come back in the same place at the same size.
  • Manually verify the lock button: on desktop it appears on hover; on a phone it is next to the X. Locked, the image cannot be dragged or resized, and it stays locked after a reload. Unlocked, it moves again.
  • Manually verify on a phone that opening the keyboard or rotating the screen shrinks a large pin to fit, and that it returns to its saved size when the keyboard closes or the screen turns back.
  • Manually verify a pinned scene video (Game): the lock works the same way, and the video controls still respond.
  • Manually verify that the one-shot gallery viewer (opened, not pinned) has no lock button and still follows the newest image.
  • Manually verify that pins saved before this change load at the default place and size, with no errors.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

No files under docs/ changed.

UI evidence (if applicable)

The e2e attaches locked-pin.png (a locked pin on a phone: lock button highlighted next to the X, no resize handle) to its test results.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/7719 **Author:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/7688-pinned-gallery-lock` --- ### 📝 Commits (2) - [`357694c`](https://github.com/Pasta-Devs/Marinara-Engine/commit/357694cf8b0c7f1952cfc71afb928a08660a9809) fix(gallery): pinned images keep their place and size after a reload, and can be locked - [`53a45e9`](https://github.com/Pasta-Devs/Marinara-Engine/commit/53a45e986792a65bd145b6ad2c909995b6479ddb) fix(gallery): a drag in a small window keeps the pin's saved size ### 📊 Changes **4 files changed** (+354 additions, -111 deletions) <details> <summary>View changed files</summary> ➕ `e2e/pinned-gallery-layout.e2e.ts` (+156 -0) 📝 `packages/client/src/components/chat/PinnedImageOverlay.tsx` (+160 -107) 📝 `packages/client/src/localization/locales/en.json` (+4 -0) 📝 `packages/client/src/stores/gallery.store.ts` (+34 -4) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #7688 ## Why this change - A user arranges images pinned from the gallery around the chat. After a reload they all come back in the middle of the screen at the default size. They asked for a way to lock them so they stay where they were put. - Root cause: the pinned list in localStorage saved only *which* media were pinned, never where they were or how big. Each pin always mounted centred at the default size. Any window `resize` also reset the pin to the default size, so on a phone the keyboard or address bar could undo a layout without a reload. ## What changed - `gallery.store.ts`: each pin can hold a `layout` (`x`, `y`, `w`, `h` in viewport pixels, plus `locked`). `setPinnedLayout` saves it with the pinned list. A stored layout that is broken is dropped on load and the pin stays. - `PinnedImageOverlay.tsx`: a pin opens at its saved layout and saves it when a drag or resize ends. What you see is that layout fitted to the current window (same shape, kept on screen); the saved layout stays as the user left it, the way floating chat windows work. A window resize no longer resets the size, and a drag in a small window keeps the saved size, so the pin grows back when the window does. An image without stored dimensions no longer resizes itself on load once it has a saved layout. - Lock: a lock button next to Dismiss, shown with the other controls (on hover or tap; always on phones). While locked, dragging does nothing, the resize handle is hidden, and the pin's label says it is locked. Dismiss still works. The lock is saved too. The one-shot gallery viewer has no lock and is not saved. - Brief's reference: 2D/3D avatars have no placement lock on staging (they move with the sprites' Arrange mode), so this follows the lock on floating chat windows instead (`Lock`/`Unlock` icon, `aria-pressed`, a hint for each state). - New English strings: `ui.chat.pinnedmediaviewer.lockPinnedMedia`, `lockHint`, `unlockHint` and `pinnedMediaLocked`. No existing copy was changed. - Regression proof: `e2e/pinned-gallery-layout.e2e.ts` pins a real gallery image, moves and resizes it, then reloads and checks that its box is the same. Next it narrows the window, drags the shrunk pin and widens the window again, checking that the pin grows back to its size. It then locks the pin, checks that a drag does not move it and that it has no resize handle, reloads and checks again, and finally unlocks it and checks that it moves. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` Agent-run checks: - The new e2e **fails on unfixed staging** (`f040d9067`, desktop-chromium). After the reload the pin is back in the middle: its x is 474 px from where it was left (`expect(...).toBeLessThanOrEqual(1)`, received 474). - The window-resize part also **fails on unfixed staging**. I ran a scratch copy of the spec without the reload step, with staging's component and store, on desktop-chromium. When the window grew back the pin was 460 px wide, the default size, instead of the 370 px it was given. - With the fix, the final spec passed 3/3 on desktop-chromium and 2/2 each on mobile-chromium and mobile-webkit (`--workers=1`). One run failed on the first page load of a fresh dev server: the pin took more than 10 s to appear, the test deleted the chat, and the image then returned 404. The first visibility check now waits up to 30 s. - Local CodeRabbit, first pass: 1 finding. A drag in a narrow window saved the shrunk size, so the pin stayed small once the window grew. It was valid and is fixed in the second commit. Second pass: 0 findings. - `tsc --noEmit` passes for shared, server, client and root (e2e types). - ESLint passes on the changed client files. `prettier --check` passes on all changed files. `node scripts/check-locales.mjs`, `pnpm localization:check` and `pnpm impeccable:check` pass. - Not run: the full `pnpm check` (lint/format/build across the repo), Docker, and the rest of the Playwright suite. ### Manual verification notes - Manually verify in Roleplay, Conversation and Game: pin an image from the gallery, move and resize it, reload. It should come back in the same place at the same size. - Manually verify the lock button: on desktop it appears on hover; on a phone it is next to the X. Locked, the image cannot be dragged or resized, and it stays locked after a reload. Unlocked, it moves again. - Manually verify on a phone that opening the keyboard or rotating the screen shrinks a large pin to fit, and that it returns to its saved size when the keyboard closes or the screen turns back. - Manually verify a pinned scene video (Game): the lock works the same way, and the video controls still respond. - Manually verify that the one-shot gallery viewer (opened, not pinned) has no lock button and still follows the newest image. - Manually verify that pins saved before this change load at the default place and size, with no errors. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) No files under `docs/` changed. ## UI evidence (if applicable) The e2e attaches `locked-pin.png` (a locked pin on a phone: lock button highlighted next to the X, no resize handle) to its test results. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-24 04:08:37 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#7896
No description provided.