[PR #2034] [MERGED] fix(quartermaster): item images stay with their item (0.1.33) #2085

Closed
opened 2026-11-07 16:39:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Agents/pull/2034
Author: @newfiesledneck
Created: 11/1/2026
Status: ✅ Merged
Merged: 11/1/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/quartermaster-item-images


📝 Commits (6)

  • ead0032 fix(quartermaster): item images stay with their item (0.1.32)
  • 8699dbf Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images
  • 6ed7688 Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images
  • 6a73c4d Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images
  • 1467b0a Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images
  • 35755f0 fix(quartermaster): address review of item image controls (0.1.33)

📊 Changes

19 files changed (+1483 additions, -301 deletions)

View changed files

➕ artifacts/quartermaster-0.1.32.zip (+0 -0)
➕ artifacts/quartermaster-0.1.33.zip (+0 -0)
📝 catalog/catalog.json (+8 -8)
📝 catalog/notes.json (+12 -12)
📝 catalog/v2/catalog.json (+8 -8)
📝 catalog/v2/notes.json (+12 -12)
📝 catalog/v3/catalog.json (+8 -8)
📝 catalog/v3/notes.json (+12 -12)
📝 packages/quartermaster/CHANGELOG.md (+17 -0)
📝 packages/quartermaster/README.md (+49 -4)
📝 packages/quartermaster/client.js (+360 -80)
📝 packages/quartermaster/manifest.json (+5 -5)
📝 packages/quartermaster/server.mjs (+209 -58)
📝 packages/quartermaster/src/00-api.js (+28 -19)
📝 packages/quartermaster/src/05-state.js (+33 -21)
📝 packages/quartermaster/src/10-dock.js (+297 -38)
📝 packages/quartermaster/src/12-image-gen.js (+1 -1)
📝 scripts/build-quartermaster-package.mjs (+1 -1)
📝 tests/quartermaster-modal-lifecycle.regression.mjs (+423 -14)

📄 Description

Linked issue

Closes #1697

#1697 was closed when #1712 (hidden items) merged, but #1712 didn't change item images. This PR is the fix for it.

Why this change

  • #1697: item images periodically go missing. Quartermaster found an item's image only by matching the item's name to a filename. When the item was renamed, by the user or the agent (for example "Sword" → "Rusty Sword"), the name no longer matched the uploaded file and the picture vanished, even though the file was still on disk.
  • While tracing it, two more ways to lose images turned up:
    • Without an Admin Secret saved, any failed image load (a dropped connection, a server restart) hid that item's image until the page was reloaded.
    • A new image for an item named like an existing file replaced that file, so the same-named item in another chat lost its picture.

What changed

Images stay with their item

  • Uploading or generating an image now saves its filename on the item, so renaming the item keeps the picture.
  • Images uploaded before this update are saved to their item the first time it's renamed.
  • Image-pack files (hand-placed in a subfolder) still match by name and are never saved to an item, so renaming onto another pack image's name still switches to it.
  • The saved image travels with the item through outfit snapshots, Revert and Export/Import.

Image details and Unlink

  • Bag cards have an [i] on the image showing the file and where it came from: Uploaded filename, Generated filename, or Matched by name (plus "Saved file missing" if the saved file was removed).
  • The item editor shows the same line under the item's name, with Unlink when the image is saved to the item. Unlink only changes this chat's item: it goes back to matching by name, and the file stays.

Deleting moved to the item editor

  • The × on bag card images is gone. The editor's × offers Delete file (warning that every item using the file, in any chat, loses its image), Unlink, or Cancel. Image-pack files can't be deleted from Quartermaster.

New images never replace another file

  • If apple.png exists, a new image is saved as apple (1).png, apple (2).png and so on.

Bug fixes found along the way

  • Item images always load through Quartermaster's own loader, which tells a real "no image" apart from a connection or server error, so a blip no longer hides images for the session.
  • Fixed the image cache not clearing when an Admin Secret is saved for the first time.
  • The server reports disk errors as errors (500), not as "no image" (404).
  • Item names containing characters a filename can't hold (like "/") now upload correctly, and those characters can no longer affect where the file is written.

Generated outputs: packages/quartermaster/client.js, server.mjs and manifest.json; artifacts/quartermaster-0.1.32.zip and artifacts/quartermaster-0.1.33.zip; and the Quartermaster entries in catalog/. All rebuilt with scripts/build-quartermaster-package.mjs. Both changelogs and the README's Item Images section are updated.

Package and security impact

  • Affected package IDs: quartermaster (0.1.31 → 0.1.33).
  • Engine compatibility impact: none, engine.min stays at 2.4.6.
  • New or changed permissions/entrypoints: no permission changes. The executable code changed in both client.js and server.mjs. Routes, all under the existing /api/quartermaster prefix:
    • New GET …/items/:itemId/image/info: read-only; returns the shown file, its source, the saved filename, and whether it can be deleted.
    • Changed POST …/items/:itemId/image (upload): takes an optional source (generated or uploaded, anything else is uploaded). The filename is built server-side from the item name: characters invalid in filenames, control characters, leading dots and trailing dots/spaces are stripped, Windows reserved names are suffixed, and the name is capped at 120 characters. The file is written with an exclusive-create flag into gallery/quartermaster/items/ only, never a subfolder, and never over an existing file.
    • Changed PATCH …/items/:itemId: the client can't set imageFile (400); it can only send null to unlink.
    • Changed GET …/items/:itemId/image: serves the saved file, then the name match; Cache-Control: no-store; 404 only when there's no image, 500 on other disk errors.
    • Changed DELETE …/items/:itemId/image: deletes only a top-level file (400 for image-pack files) and clears the saved filename.
    • A saved imageFile, from the database or an Import, is only used if it's a plain filename: no / or \, no control characters, no leading dot, an allowed image extension, at most 200 characters. Anything else is ignored (and dropped on Import), so a stored value can't point outside the items folder. Tests cover both safe names and rejected ones.
  • Restart, storage, update, or uninstall impact: new optional fields imageFile and imageSource on items and on outfit/revert snapshots. Data saved by earlier versions loads without them and keeps matching by name. Export/Import carries them. Replacing an item's image leaves the old file on disk (another chat's item may still use it); the editor's × deletes on purpose. The usual update + restart for quartermaster. No migration.

Validation

  • node scripts/validate-catalog.mjs passes locally
  • git diff --check passes locally
  • Rebuilt every affected manifest, payload, artifact, and catalog entry
  • Installed or updated the affected package through Marinara Engine
  • Checked supported modes, restart behavior, and uninstall cleanup
  • Read and followed CONTRIBUTING.md

Manual verification notes

Automated checks. These passed locally after merging current staging:

  • npm run check
  • node scripts/test-catalog-lanes.mjs
  • node scripts/validate-package-locales.mjs
  • node scripts/validate-catalog.mjs
  • node scripts/tests/catalog-release-notes.regression.mjs
  • node scripts/tests/vendored-engine.regression.mjs
  • node tests/quartermaster-modal-lifecycle.regression.mjs (38 tests)
  • git diff --check

New regression tests. They cover:

  • a saved image surviving a rename, and Unlink affecting only its own chat (an Apple renamed to Orange in one chat, while another chat's Apple keeps its picture)
  • the client being unable to set imageFile, and a saved file that's gone reporting as missing
  • older uploads saved to the item on rename, while image-pack matches keep following the name
  • image-pack files refusing deletion
  • safe and numbered filenames (/, .., Windows reserved names, empty names, apple (1).png)
  • the saved image travelling through outfit rebuilds, Revert and Export/Import, and Import rejecting unsafe filenames
  • images loading through the cache with or without an Admin Secret, and a secret saved later clearing the cache
  • a failed or deleted image being re-checked instead of hidden for the session
  • generated images being saved as "generated"
  • the detail labels, Unlink only for a saved file, an older slow answer never replacing a newer one, the × choices, and [i] on bag cards vs × in the editor

18 deliberate breakages of the new logic were each caught by these tests. One gap: the 500 on disk errors has no automated test, because the error can't be produced reliably on Windows.

Manual testing in Marinara Engine. Quartermaster 0.1.32 was installed and tested across several chats:

  • The [i] on bag cards opens the image details as intended.
  • Renaming items, including ones whose images were uploaded before this update, in various ways across chats: every item kept its picture, and older uploads then showed "Uploaded filename".
  • New uploads and generations, and items with no saved image, show Uploaded / Generated / Matched by name correctly in the editor line.
  • Unlink and Delete: after renaming Apple → Orange, unlinking or deleting falls back to matching by name (an orange image if one exists, otherwise the default icon).
  • The editor's × wording for all three choices. Delete file shows the warning "Delete apple.png? This deletes the file. Every item using it, in any chat, loses its image. To remove it from just this item and keep the file, use Unlink." and really removes the image file.
  • The same item name in two chats: unlinking in one doesn't change the other. After deleting the file in one chat, the other chat's item shows "Saved file missing: apple.png" and "Matched by name: orange.png".

Documentation impact

  • No documentation changes needed
  • Updated this README catalog and package guidance
  • Updated linked Marinara Engine documentation

Quartermaster README: Item Images section rewritten, and 0.1.32 and 0.1.33 changelog entries.

UI evidence (if applicable)


🔄 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-Agents/pull/2034 **Author:** [@newfiesledneck](https://github.com/newfiesledneck) **Created:** 11/1/2026 **Status:** ✅ Merged **Merged:** 11/1/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/quartermaster-item-images` --- ### 📝 Commits (6) - [`ead0032`](https://github.com/Pasta-Devs/Marinara-Agents/commit/ead00325114902763ee7f6d9a7b49378c636ce25) fix(quartermaster): item images stay with their item (0.1.32) - [`8699dbf`](https://github.com/Pasta-Devs/Marinara-Agents/commit/8699dbf13ff968b294f55ca5ab6a01b8b94444cb) Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images - [`6ed7688`](https://github.com/Pasta-Devs/Marinara-Agents/commit/6ed768881e4af318905c6491091ea816eafc68cd) Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images - [`6a73c4d`](https://github.com/Pasta-Devs/Marinara-Agents/commit/6a73c4d4e2eb8a21a5e3d3d517d9ec7c17a83920) Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images - [`1467b0a`](https://github.com/Pasta-Devs/Marinara-Agents/commit/1467b0acd26b55020497d328103e59a334f810a6) Merge remote-tracking branch 'upstream/staging' into fix/quartermaster-item-images - [`35755f0`](https://github.com/Pasta-Devs/Marinara-Agents/commit/35755f055ac0e2a59a7c2d9c38ade9853fd40dd9) fix(quartermaster): address review of item image controls (0.1.33) ### 📊 Changes **19 files changed** (+1483 additions, -301 deletions) <details> <summary>View changed files</summary> ➕ `artifacts/quartermaster-0.1.32.zip` (+0 -0) ➕ `artifacts/quartermaster-0.1.33.zip` (+0 -0) 📝 `catalog/catalog.json` (+8 -8) 📝 `catalog/notes.json` (+12 -12) 📝 `catalog/v2/catalog.json` (+8 -8) 📝 `catalog/v2/notes.json` (+12 -12) 📝 `catalog/v3/catalog.json` (+8 -8) 📝 `catalog/v3/notes.json` (+12 -12) 📝 `packages/quartermaster/CHANGELOG.md` (+17 -0) 📝 `packages/quartermaster/README.md` (+49 -4) 📝 `packages/quartermaster/client.js` (+360 -80) 📝 `packages/quartermaster/manifest.json` (+5 -5) 📝 `packages/quartermaster/server.mjs` (+209 -58) 📝 `packages/quartermaster/src/00-api.js` (+28 -19) 📝 `packages/quartermaster/src/05-state.js` (+33 -21) 📝 `packages/quartermaster/src/10-dock.js` (+297 -38) 📝 `packages/quartermaster/src/12-image-gen.js` (+1 -1) 📝 `scripts/build-quartermaster-package.mjs` (+1 -1) 📝 `tests/quartermaster-modal-lifecycle.regression.mjs` (+423 -14) </details> ### 📄 Description ## Linked issue Closes #1697 #1697 was closed when #1712 (hidden items) merged, but #1712 didn't change item images. This PR is the fix for it. ## Why this change - #1697: item images periodically go missing. Quartermaster found an item's image only by matching the item's name to a filename. When the item was renamed, by the user or the agent (for example "Sword" → "Rusty Sword"), the name no longer matched the uploaded file and the picture vanished, even though the file was still on disk. - While tracing it, two more ways to lose images turned up: - Without an Admin Secret saved, any failed image load (a dropped connection, a server restart) hid that item's image until the page was reloaded. - A new image for an item named like an existing file replaced that file, so the same-named item in another chat lost its picture. ## What changed **Images stay with their item** - Uploading or generating an image now saves its filename on the item, so renaming the item keeps the picture. - Images uploaded before this update are saved to their item the first time it's renamed. - Image-pack files (hand-placed in a subfolder) still match by name and are never saved to an item, so renaming onto another pack image's name still switches to it. - The saved image travels with the item through outfit snapshots, Revert and Export/Import. **Image details and Unlink** - Bag cards have an **[i]** on the image showing the file and where it came from: Uploaded filename, Generated filename, or Matched by name (plus "Saved file missing" if the saved file was removed). - The item editor shows the same line under the item's name, with **Unlink** when the image is saved to the item. Unlink only changes this chat's item: it goes back to matching by name, and the file stays. **Deleting moved to the item editor** - The × on bag card images is gone. The editor's × offers **Delete file** (warning that every item using the file, in any chat, loses its image), **Unlink**, or Cancel. Image-pack files can't be deleted from Quartermaster. **New images never replace another file** - If `apple.png` exists, a new image is saved as `apple (1).png`, `apple (2).png` and so on. **Bug fixes found along the way** - Item images always load through Quartermaster's own loader, which tells a real "no image" apart from a connection or server error, so a blip no longer hides images for the session. - Fixed the image cache not clearing when an Admin Secret is saved for the first time. - The server reports disk errors as errors (500), not as "no image" (404). - Item names containing characters a filename can't hold (like "/") now upload correctly, and those characters can no longer affect where the file is written. **Generated outputs:** `packages/quartermaster/client.js`, `server.mjs` and `manifest.json`; `artifacts/quartermaster-0.1.32.zip` and `artifacts/quartermaster-0.1.33.zip`; and the Quartermaster entries in `catalog/`. All rebuilt with `scripts/build-quartermaster-package.mjs`. Both changelogs and the README's Item Images section are updated. ## Package and security impact - **Affected package IDs:** `quartermaster` (0.1.31 → 0.1.33). - **Engine compatibility impact:** none, `engine.min` stays at 2.4.6. - **New or changed permissions/entrypoints:** no permission changes. The executable code changed in both `client.js` and `server.mjs`. Routes, all under the existing `/api/quartermaster` prefix: - **New** `GET …/items/:itemId/image/info`: read-only; returns the shown file, its source, the saved filename, and whether it can be deleted. - **Changed** `POST …/items/:itemId/image` (upload): takes an optional `source` (`generated` or `uploaded`, anything else is `uploaded`). The filename is built server-side from the item name: characters invalid in filenames, control characters, leading dots and trailing dots/spaces are stripped, Windows reserved names are suffixed, and the name is capped at 120 characters. The file is written with an exclusive-create flag into `gallery/quartermaster/items/` only, never a subfolder, and never over an existing file. - **Changed** `PATCH …/items/:itemId`: the client can't set `imageFile` (400); it can only send `null` to unlink. - **Changed** `GET …/items/:itemId/image`: serves the saved file, then the name match; `Cache-Control: no-store`; 404 only when there's no image, 500 on other disk errors. - **Changed** `DELETE …/items/:itemId/image`: deletes only a top-level file (400 for image-pack files) and clears the saved filename. - A saved `imageFile`, from the database or an Import, is only used if it's a plain filename: no `/` or `\`, no control characters, no leading dot, an allowed image extension, at most 200 characters. Anything else is ignored (and dropped on Import), so a stored value can't point outside the items folder. Tests cover both safe names and rejected ones. - **Restart, storage, update, or uninstall impact:** new optional fields `imageFile` and `imageSource` on items and on outfit/revert snapshots. Data saved by earlier versions loads without them and keeps matching by name. Export/Import carries them. Replacing an item's image leaves the old file on disk (another chat's item may still use it); the editor's × deletes on purpose. The usual update + restart for quartermaster. No migration. ## Validation - [x] `node scripts/validate-catalog.mjs` passes locally - [x] `git diff --check` passes locally - [x] Rebuilt every affected manifest, payload, artifact, and catalog entry - [x] Installed or updated the affected package through Marinara Engine - [x] Checked supported modes, restart behavior, and uninstall cleanup - [x] Read and followed `CONTRIBUTING.md` ### Manual verification notes **Automated checks.** These passed locally after merging current `staging`: - `npm run check` - `node scripts/test-catalog-lanes.mjs` - `node scripts/validate-package-locales.mjs` - `node scripts/validate-catalog.mjs` - `node scripts/tests/catalog-release-notes.regression.mjs` - `node scripts/tests/vendored-engine.regression.mjs` - `node tests/quartermaster-modal-lifecycle.regression.mjs` (38 tests) - `git diff --check` **New regression tests.** They cover: - a saved image surviving a rename, and Unlink affecting only its own chat (an Apple renamed to Orange in one chat, while another chat's Apple keeps its picture) - the client being unable to set `imageFile`, and a saved file that's gone reporting as missing - older uploads saved to the item on rename, while image-pack matches keep following the name - image-pack files refusing deletion - safe and numbered filenames (`/`, `..`, Windows reserved names, empty names, `apple (1).png`) - the saved image travelling through outfit rebuilds, Revert and Export/Import, and Import rejecting unsafe filenames - images loading through the cache with or without an Admin Secret, and a secret saved later clearing the cache - a failed or deleted image being re-checked instead of hidden for the session - generated images being saved as "generated" - the detail labels, Unlink only for a saved file, an older slow answer never replacing a newer one, the × choices, and [i] on bag cards vs × in the editor 18 deliberate breakages of the new logic were each caught by these tests. One gap: the 500 on disk errors has no automated test, because the error can't be produced reliably on Windows. **Manual testing in Marinara Engine.** Quartermaster 0.1.32 was installed and tested across several chats: - The [i] on bag cards opens the image details as intended. - Renaming items, including ones whose images were uploaded before this update, in various ways across chats: every item kept its picture, and older uploads then showed "Uploaded filename". - New uploads and generations, and items with no saved image, show Uploaded / Generated / Matched by name correctly in the editor line. - Unlink and Delete: after renaming Apple → Orange, unlinking or deleting falls back to matching by name (an orange image if one exists, otherwise the default icon). - The editor's × wording for all three choices. Delete file shows the warning "Delete apple.png? This deletes the file. Every item using it, in any chat, loses its image. To remove it from just this item and keep the file, use Unlink." and really removes the image file. - The same item name in two chats: unlinking in one doesn't change the other. After deleting the file in one chat, the other chat's item shows "Saved file missing: apple.png" and "Matched by name: orange.png". ## Documentation impact - [ ] No documentation changes needed - [x] Updated this README catalog and package guidance - [ ] Updated linked Marinara Engine documentation Quartermaster README: Item Images section rewritten, and 0.1.32 and 0.1.33 changelog entries. ## UI evidence (if applicable) <!-- Screenshots to add: the [i] popover on a bag card; the image line with Unlink in the item editor; the × choice (Delete file / Unlink / Cancel). --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 16:39:22 +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-Agents#2085
No description provided.