feat(editor): finish the quick/advanced editor handoff
CI / build (push) Has been cancelled

Reopen advanced edits from their saved recipe, seed or take over the quick
editor from them, refresh thumbnails after a save, and add an edited-only
download. Also fixes the Lumenroom library collapsing to slivers on large
shoots and documents deploying both containers on a new host.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-21 06:35:24 +00:00
parent ab4a07a40f
commit ebe0c77f7e
35 changed files with 1844 additions and 150 deletions
+36 -7
View File
@@ -9,7 +9,7 @@
import crypto from 'node:crypto';
import { BRIDGE_SECRET, BRIDGE_TTL_HOURS, GLENLOCH_URL } from './config.mjs';
import { db, removeEvent, removePhoto, saveEvent, savePhoto } from './db.mjs';
import { db, getPhoto, removeEvent, removePhoto, saveEvent, savePhoto } from './db.mjs';
import { removeAsset } from './storage.mjs';
const VERSION = 'g1';
@@ -173,11 +173,17 @@ function photoRecordFrom(photo, eventId, sessionId, index) {
meta: {},
thumb: '',
thumbUrl: `/api/photos/${id}/thumb`,
// Thumbnail of the saved edit; the timestamp keeps the browser from reusing
// a thumbnail rendered before the edit was saved.
thumbVersion: photo.editedAt ? Date.parse(photo.editedAt) || undefined : undefined,
rating: 0,
flag: 'none',
color: '',
keywords: [],
edits: {},
// The dashboard sends back the recipe saved for this photo, so reopening
// the advanced editor starts from the sliders the user left it with.
edits:
photo.edits && typeof photo.edits === 'object' ? photo.edits : {},
history: [],
raw,
previewUrl: raw ? `/api/photos/${id}/preview` : undefined,
@@ -189,7 +195,7 @@ function photoRecordFrom(photo, eventId, sessionId, index) {
* Mirrors one event into the local catalog. The photo bytes stay on the
* dashboard; only metadata, previews and thumbnails are temporary here.
*/
export async function importBridgeEvent({ serviceToken, sessionId }) {
export async function importBridgeEvent({ serviceToken, sessionId, returnUrl }) {
const expiresAt =
Date.now() + Math.max(1, BRIDGE_TTL_HOURS) * 60 * 60 * 1000;
@@ -198,12 +204,35 @@ export async function importBridgeEvent({ serviceToken, sessionId }) {
serviceToken,
);
const eventId = bridgeEventId(listing.event.id);
// Preserve anything still unsaved locally before the import replaces rows, so
// reopening the editor never discards work in progress.
const localEdits = new Map();
for (const row of photosForEvent.all(eventId)) {
const record = getPhoto(row.id);
if (record?.edits && Object.keys(record.edits).length > 0) {
localEdits.set(row.id, record);
}
}
dropBridgeEvent(eventId);
const returnUrl = listing.editor?.returnUrl ?? null;
saveEvent(eventRecordFrom(listing, eventId, sessionId, returnUrl, expiresAt), 0);
// The exchange hands back the dashboard address the browser actually used;
// the listing's value is a fallback derived from server configuration and may
// point at localhost in a LAN deployment.
const dashboardReturn =
typeof returnUrl === 'string' && /^https?:\/\//i.test(returnUrl)
? returnUrl
: listing.editor?.returnUrl ?? null;
saveEvent(eventRecordFrom(listing, eventId, sessionId, dashboardReturn, expiresAt), 0);
listing.photos.forEach((photo, index) => {
savePhoto(photoRecordFrom(photo, eventId, sessionId, index));
const record = photoRecordFrom(photo, eventId, sessionId, index);
const local = localEdits.get(record.id);
if (local) {
record.edits = local.edits;
if (Array.isArray(local.history) && local.history.length > 0) {
record.history = local.history;
}
}
savePhoto(record);
});
bridgeInsert.run(
eventId,
@@ -211,7 +240,7 @@ export async function importBridgeEvent({ serviceToken, sessionId }) {
serviceToken,
GLENLOCH_URL,
listing.event.id,
returnUrl,
dashboardReturn,
expiresAt,
Date.now(),
);