Land camera-native raw profiles, real ICC soft proofing and 16-bit proxies.

Camera profiles, proofing tables and the half-float sidecar all have to agree
with the pixels the editor actually grades, so they land together with the
preset filter menu that was unusable while thumbnails streamed in.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 03:59:55 +00:00
parent 6dfddffc14
commit 0c113e7a91
53 changed files with 9217 additions and 476 deletions
+361 -2
View File
@@ -15,6 +15,12 @@ import MergeModal from './components/MergeModal';
import PasteSettingsModal from './components/PasteSettingsModal';
import PrintModal from './components/PrintModal';
import ShareModal from './components/ShareModal';
import RawReprocessModal, {
type RawReprocessFailure,
type RawReprocessJob,
} from './components/RawReprocessModal';
import CullAssistModal from './components/CullAssistModal';
import TetherPanel from './components/TetherPanel';
import Shortcuts from './components/Shortcuts';
import Stars, { ColorSwatches, FlagButtons } from './components/Stars';
import TopBar from './components/TopBar';
@@ -37,6 +43,7 @@ import {
pushImmichPhoto,
pushPhoto,
register as apiRegister,
reprocessRawPhoto,
uploadOriginal,
} from './lib/api';
import type { Health, ImmichStatus, ProofSummary, QuotaState, SessionUser } from './lib/api';
@@ -58,8 +65,9 @@ import { COLOR_LABELS, defaultEdits, isEdited, normalizePhoto } from './lib/edit
import { applyEditSections, type EditSectionId } from './lib/editSections';
import type { MergeResult } from './lib/merge';
import { evictBitmap } from './lib/images';
import { uid } from './lib/import';
import { importFiles, uid } from './lib/import';
import { PRESETS } from './lib/presets';
import { downloadXmp, readXmpFile, xmpToEdits } from './lib/xmp';
import type {
Edits,
EventRecord,
@@ -185,6 +193,12 @@ export default function App() {
const [exportOptions, setExportOptions] = useState<ExportOptions>(DEFAULT_EXPORT);
const [exportRecipes, setExportRecipes] = useState<ExportRecipe[]>([]);
const [mergeOpen, setMergeOpen] = useState(false);
const [rawJob, setRawJob] = useState<RawReprocessJob | null>(null);
const [cullOpen, setCullOpen] = useState(false);
const [tetherEventId, setTetherEventId] = useState<string | null>(null);
const rawBusyRef = useRef(false);
const rawCancelRef = useRef(false);
const rawBusy = Boolean(rawJob?.running);
const [printOpen, setPrintOpen] = useState(false);
const saveTimers = useRef(new Map<string, ReturnType<typeof setTimeout>>());
@@ -363,6 +377,151 @@ export default function App() {
[queueSave],
);
/**
* Re-decode selected RAW files on the server, then refresh the cached proxy so
* the grid and Develop pick up the new pixels without a reload. Existing edits
* are kept; only width, height and the decode engine change on the record.
*/
const reprocessRawPhotos = useCallback(
async (ids: string[], options: { eventName?: string } = {}) => {
if (rawBusyRef.current) {
setToast('A RAW reprocess is already running');
return;
}
const targets = photosRef.current.filter(
(photo) => ids.includes(photo.id) && photo.raw && !photo.deletedAt,
);
if (!targets.length) {
setToast('Select RAW photos to reprocess');
return;
}
if (!userRef.current) {
setToast('Sign in to the server to reprocess RAW files');
return;
}
rawBusyRef.current = true;
rawCancelRef.current = false;
const failures: RawReprocessFailure[] = [];
let attempts = 0;
setRawJob({
running: true,
done: 0,
total: targets.length,
current: targets[0].name,
eventName: options.eventName,
failures: [],
});
try {
for (let index = 0; index < targets.length; index += 1) {
if (rawCancelRef.current) break;
const photo = targets[index];
setRawJob((prev) =>
prev ? { ...prev, done: index, current: photo.name, failures: failures.slice() } : prev,
);
try {
const result = await reprocessRawPhoto(photo.id);
const res = await fetch(
`/api/photos/${encodeURIComponent(photo.id)}/preview?v=${Date.now()}`,
{ credentials: 'same-origin' },
);
if (!res.ok) throw new Error('The new preview could not be read');
const blob = await res.blob();
// Replace the cached proxy, then drop the decoded bitmap so the next
// render fetches the new pixels instead of the old ones.
await putAsset(photo.id, blob);
evictBitmap(photo.id);
const version = result.previewVersion ?? Date.now();
updatePhoto(photo.id, {
width: result.width || photo.width,
height: result.height || photo.height,
decode: result.engine ?? photo.decode,
previewVersion: version,
// The stored files keep their names; the query is only a cache buster.
previewUrl:
result.previewUrl ??
`/api/photos/${encodeURIComponent(photo.id)}/preview?v=${version}`,
thumbUrl:
result.thumbUrl ??
`/api/photos/${encodeURIComponent(photo.id)}/thumb?v=${version}`,
});
attempts += 1;
} catch (err) {
failures.push({
name: photo.name,
error: err instanceof Error ? err.message : 'could not be reprocessed',
});
}
setRawJob((prev) =>
prev
? { ...prev, done: index + 1, failures: failures.slice() }
: prev,
);
}
} finally {
rawBusyRef.current = false;
setRawJob((prev) =>
prev
? {
...prev,
running: false,
done: attempts,
failures: failures.slice(),
cancelled: rawCancelRef.current,
}
: prev,
);
}
const succeeded = attempts - failures.length;
const parts = [
`Reprocessed ${succeeded} of ${targets.length} RAW${targets.length === 1 ? '' : 's'}`,
];
if (failures.length) parts.push(`${failures.length} failed`);
if (rawCancelRef.current) parts.push('cancelled');
setToast(parts.join(' · '));
},
[updatePhoto],
);
/** Reprocess every RAW file in one event, with a confirmation that names it. */
const reprocessEventRaws = useCallback(
(id: string) => {
const event = eventsRef.current.find((item) => item.id === id);
if (!event) return;
const raws = photosRef.current.filter(
(photo) => photo.eventId === id && photo.raw && !photo.deletedAt,
);
if (!raws.length) {
setToast('This event has no RAW photos');
return;
}
if (!userRef.current) {
setToast('Sign in to the server to reprocess RAW files');
return;
}
if (rawBusyRef.current) {
setToast('A RAW reprocess is already running');
return;
}
const ok = window.confirm(
`Re-decode ${raws.length} RAW file${raws.length === 1 ? '' : 's'} in “${event.name}”? ` +
'Existing edits and crops are kept.',
);
if (!ok) return;
void reprocessRawPhotos(raws.map((photo) => photo.id), { eventName: event.name });
},
[reprocessRawPhotos],
);
/** Auto-sync in Develop: merge the same patch into every selected photo. */
const updatePhotoEdits = useCallback(
(ids: string[], patch: Partial<Edits>, historyLabel?: string) => {
for (const id of ids) {
updatePhoto(id, (p) => ({ edits: { ...p.edits, ...patch } }), historyLabel);
}
},
[updatePhoto],
);
const bulkUpdate = useCallback(
(ids: string[], patch: Partial<PhotoRecord>) => {
if (!ids.length) return;
@@ -868,7 +1027,9 @@ export default function App() {
const savePreset = useCallback(
(name: string, edits: Edits) => {
const { crop: _crop, ...withoutCrop } = edits;
// Crop and the camera profile are properties of this photo, not a look:
// copying either onto another body would be wrong.
const { crop: _crop, cameraProfile: _cameraProfile, ...withoutCrop } = edits;
const preset: Preset = {
id: uid(),
name,
@@ -887,6 +1048,19 @@ export default function App() {
[customPresets],
);
const deletePreset = useCallback(
(id: string) => {
const next = customPresets.filter((preset) => preset.id !== id);
setCustomPresets(next);
setKV('customPresets', next).catch((err) => console.error(err));
if (userRef.current) {
import('./lib/api').then(({ pushPresets }) => pushPresets(next).catch(() => undefined));
}
setToast('Preset deleted');
},
[customPresets],
);
/* ------------------------------------------------------------- reordering */
const reorderPhotos = useCallback(
@@ -1477,6 +1651,40 @@ export default function App() {
setToast(message);
}, []);
/**
* Manual publish for an event that has no Immich gallery yet: create the
* album, link it to the event, then push originals and current edits.
*/
const publishEventToImmich = useCallback(
async (targetEventId: string) => {
const event = eventsRef.current.find((item) => item.id === targetEventId);
if (!event) return;
if (!immichStatusRef.current?.enabled) {
setToast('Turn on Immich in the Immich sync panel first');
return;
}
if (event.immich) {
await syncEventGallery(targetEventId);
return;
}
try {
await createImmichGalleryForEvent(targetEventId);
} catch (err) {
setToast(err instanceof Error ? err.message : 'Could not create the Immich gallery');
return;
}
const count = photosRef.current.filter(
(photo) => photo.eventId === targetEventId && !photo.deletedAt,
).length;
if (!count) {
setToast(`Immich gallery created for ${event.name} — import photos to fill it`);
return;
}
await syncEventGallery(targetEventId);
},
[createImmichGalleryForEvent, syncEventGallery],
);
const openImmichAsset = useCallback((photo: PhotoRecord) => {
const status = immichStatusRef.current;
if (!status?.url || !photo.immich) return;
@@ -1854,7 +2062,94 @@ export default function App() {
? 'Unsorted'
: events.find((e) => e.id === eventId)?.name ?? 'All photos';
const tetherImport = useCallback(
async (files: File[]) => {
if (!tetherEventId) return 0;
const result = await importFiles(
files,
tetherEventId,
[],
undefined,
cloudUser ? { uploadOriginal, push: pushPhoto } : null,
);
if (result.photos.length) {
const tagged = result.photos.map((photo) =>
cloudUser ? { ...photo, workspace: cloudUser.id } : photo,
);
setPhotos((prev) => [...tagged, ...prev]);
}
return result.photos.length;
},
[cloudUser, tetherEventId],
);
const importSidecar = useCallback(async () => {
if (selected.length !== 1) {
setToast('Select exactly one photo to import a sidecar into');
return;
}
const target = photos.find((photo) => photo.id === selected[0]);
if (!target) return;
try {
const xml = await readXmpFile();
if (!xml) return;
const result = xmpToEdits(xml, target.edits);
updatePhoto(target.id, { edits: result.edits }, 'Import XMP sidecar');
setToast(
result.source === 'luminary'
? 'Imported Luminary settings from the sidecar'
: `Imported ${result.applied.length} Lightroom setting${result.applied.length === 1 ? '' : 's'}`,
);
} catch (err) {
setToast(err instanceof Error ? err.message : 'Could not import the sidecar');
}
}, [photos, selected, updatePhoto]);
const paletteActions = [
{
id: 'xmp-export',
label: 'Export XMP sidecar for the selection',
hint: 'Sidecar',
run: () => {
const chosen = photos.filter((photo) => selected.includes(photo.id));
if (!chosen.length) {
setToast('Select photos to export sidecars for');
return;
}
for (const photo of chosen) downloadXmp(photo);
setToast(`Exported ${chosen.length} sidecar${chosen.length === 1 ? '' : 's'}`);
},
},
{
id: 'xmp-import',
label: 'Import XMP sidecar into the selected photo',
hint: 'Sidecar',
run: () => void importSidecar(),
},
{
id: 'tether',
label: 'Tether this event from a watch folder',
hint: 'Capture',
run: () => {
if (eventId === 'all' || eventId === 'unsorted') {
setToast('Open an event to tether into it');
return;
}
setTetherEventId(eventId);
},
},
{
id: 'cull-assist',
label: 'Cull assist for the selection',
hint: 'Focus',
run: () => {
if (!selected.length) {
setToast('Select photos to cull');
return;
}
setCullOpen(true);
},
},
{
id: 'import',
label: 'Import photos',
@@ -1889,6 +2184,29 @@ export default function App() {
run: () => setFilters(EMPTY_FILTERS),
},
{ id: 'shortcuts', label: 'Show keyboard shortcuts', hint: '?', run: () => setHelpOpen(true) },
...(cloudUser &&
eventId !== 'all' &&
eventId !== 'unsorted' &&
photos.some((photo) => photo.eventId === eventId && photo.raw && !photo.deletedAt)
? [
{
id: 'reprocess-event-raws',
label: 'Reprocess all RAW photos in this event',
hint: 'RAW',
run: () => reprocessEventRaws(eventId),
},
]
: []),
...(cloudUser && immichStatus?.enabled && eventId !== 'all' && eventId !== 'unsorted'
? [
{
id: 'immich-publish',
label: 'Publish this event to Immich',
hint: 'Immich',
run: () => void publishEventToImmich(eventId),
},
]
: []),
...(cloudUser && eventId !== 'all' && eventId !== 'unsorted'
? [{ id: 'share', label: 'Open client proofing', hint: 'Share', run: () => setShareEventId(eventId) }]
: []),
@@ -2010,6 +2328,9 @@ export default function App() {
await createEvent(name, { immichGallery });
}}
onSyncGallery={syncEventGallery}
onPublishGallery={publishEventToImmich}
canReprocessRaw={Boolean(cloudUser)}
onReprocessEvent={reprocessEventRaws}
onRename={renameEvent}
onDelete={removeEvent}
onReorderEvents={reorderEvents}
@@ -2117,6 +2438,12 @@ export default function App() {
: undefined
}
immichBusy={Boolean(immichProgress)}
onReprocessRaw={
cloudUser && selected.some((id) => photos.find((photo) => photo.id === id)?.raw)
? () => void reprocessRawPhotos(selected)
: undefined
}
reprocessBusy={rawBusy}
onDelete={() => (trashOpen ? void removePhotos(selected) : trashPhotos(selected))}
onExport={openExport}
onCompare={() => setCompareOpen(true)}
@@ -2154,6 +2481,7 @@ export default function App() {
onSelect={setActiveId}
onExit={() => setView('grid')}
onUpdate={updatePhoto}
onUpdateEdits={updatePhotoEdits}
clipboard={clipboard}
onCopy={copySettings}
onCopyOf={copySettingsOf}
@@ -2170,6 +2498,7 @@ export default function App() {
}
presets={[...PRESETS, ...customPresets]}
onSavePreset={savePreset}
onDeletePreset={deletePreset}
onDelete={() => trashPhotos([activePhoto.id])}
onVirtualCopy={() => void createVirtualCopy(activePhoto.id, true)}
metadataPresets={metadataPresets}
@@ -2489,6 +2818,36 @@ export default function App() {
</div>
)}
{tetherEventId && (
<TetherPanel
event={{
id: tetherEventId,
name: events.find((e) => e.id === tetherEventId)?.name ?? 'this event',
}}
onImport={tetherImport}
onClose={() => setTetherEventId(null)}
/>
)}
{cullOpen && (
<CullAssistModal
photos={photos.filter((photo) => selected.includes(photo.id))}
onReject={(ids) => bulkUpdate(ids, { flag: 'reject' })}
onClose={() => setCullOpen(false)}
/>
)}
{rawJob && (
<RawReprocessModal
job={rawJob}
onCancel={() => {
rawCancelRef.current = true;
setRawJob((prev) => (prev ? { ...prev, cancelled: true } : prev));
}}
onClose={() => setRawJob(null)}
/>
)}
{toast && (
<div className="toast">
<span>{toast}</span>