Add the optional Immich integration and manual gallery push

Immich connections stay server-side with an encrypted API key, albums can be
imported, and photos are only sent back when an event's push button is pressed:
originals upload once, edited photos re-render, and edits hashes plus checksums
skip anything already in Immich. This also lands the accompanying editor, cloud
and administration work that was still uncommitted.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-25 17:43:05 +00:00
parent e0c76ba965
commit 0b3ab76405
26 changed files with 4323 additions and 144 deletions
+335 -16
View File
@@ -9,6 +9,7 @@ import ExportModal from './components/ExportModal';
import CompareView from './components/CompareView';
import FilterBar from './components/FilterBar';
import ImportModal from './components/ImportModal';
import ImmichPanel from './components/ImmichPanel';
import LibraryGrid from './components/LibraryGrid';
import MergeModal from './components/MergeModal';
import PasteSettingsModal from './components/PasteSettingsModal';
@@ -22,18 +23,23 @@ import {
currentUser,
deleteEventRemote,
deletePhotoRemote,
createImmichEventAlbum,
getHealth,
getImmichStatus,
getQuota,
immichEventQueue,
login as apiLogin,
logout as apiLogout,
pullAll,
pullProofs,
pushEvent,
publishImmichOriginal,
pushImmichPhoto,
pushPhoto,
register as apiRegister,
uploadOriginal,
} from './lib/api';
import type { Health, ProofSummary, QuotaState, SessionUser } from './lib/api';
import type { Health, ImmichStatus, ProofSummary, QuotaState, SessionUser } from './lib/api';
import {
deleteEventRecord,
deletePhotoRecord,
@@ -136,6 +142,41 @@ export default function App() {
const [cloudUser, setCloudUser] = useState<SessionUser | null>(null);
const [cloudOpen, setCloudOpen] = useState(false);
const [adminOpen, setAdminOpen] = useState(false);
const [immichOpen, setImmichOpen] = useState(false);
const [immichStatus, setImmichStatus] = useState<ImmichStatus | null>(null);
const [immichProgress, setImmichProgress] = useState<{
done: number;
total: number;
current: string;
} | null>(null);
const immichStatusRef = useRef<ImmichStatus | null>(null);
immichStatusRef.current = immichStatus;
const immichBusyRef = useRef(false);
// The Immich entry points only appear when this account has opted in.
useEffect(() => {
if (!cloudUser) {
setImmichStatus(null);
return;
}
let alive = true;
getImmichStatus()
.then((status) => {
if (alive) setImmichStatus(status);
})
.catch(() => {
if (alive) setImmichStatus(null);
});
return () => {
alive = false;
};
}, [cloudUser]);
useEffect(
() => () => {
},
[],
);
const [cloudBusy, setCloudBusy] = useState(false);
const [cloudError, setCloudError] = useState<string | null>(null);
const [cloudNote, setCloudNote] = useState<string | null>(null);
@@ -337,6 +378,16 @@ export default function App() {
[queueSave],
);
const immichEventIds = useMemo(
() => new Set(events.filter((event) => event.immich).map((event) => event.id)),
[events],
);
const canSendToImmich = useCallback(
(photo: PhotoRecord) =>
Boolean(immichStatus?.enabled && (photo.immich || immichEventIds.has(photo.eventId))),
[immichStatus?.enabled, immichEventIds],
);
const livePhotos = useMemo(() => photos.filter((p) => !p.deletedAt), [photos]);
const trashCount = photos.length - livePhotos.length;
const proofCounts = useMemo(() => {
@@ -475,19 +526,56 @@ export default function App() {
[activeId],
);
const createEvent = useCallback(async (name: string) => {
const event: EventRecord = {
id: uid(),
name: name.trim() || `Event ${new Date().toLocaleDateString()}`,
createdAt: Date.now(),
date: Date.now(),
order: eventsRef.current.length,
workspace: userRef.current?.id,
};
await putEvent(event);
if (userRef.current) pushEvent(event).catch(() => undefined);
setEvents((prev) => [...prev, event].sort(byOrder));
return event;
const createEvent = useCallback(
async (name: string, options: { immichGallery?: boolean } = {}) => {
const event: EventRecord = {
id: uid(),
name: name.trim() || `Event ${new Date().toLocaleDateString()}`,
createdAt: Date.now(),
date: Date.now(),
order: eventsRef.current.length,
workspace: userRef.current?.id,
};
await putEvent(event);
// The gallery endpoint looks the event up server-side, so let this land first.
if (userRef.current) await pushEvent(event).catch(() => undefined);
let created = event;
if (options.immichGallery && userRef.current && immichStatusRef.current?.enabled) {
try {
const result = await createImmichEventAlbum(event.id, event.name);
created = result.event;
await putEvent(created);
setToast(`Immich gallery created for ${created.name}`);
} catch (err) {
setToast(
`Event created, but the Immich gallery failed: ${
err instanceof Error ? err.message : 'unknown error'
}`,
);
}
}
const nextEvents = [...eventsRef.current.filter((e) => e.id !== created.id), created].sort(byOrder);
// ImportModal creates an event and immediately asks for its Immich gallery.
// Update the ref now so that follow-up call can find the new event.
eventsRef.current = nextEvents;
setEvents(nextEvents);
return created;
},
[],
);
const createImmichGalleryForEvent = useCallback(async (id: string) => {
const event = eventsRef.current.find((item) => item.id === id);
if (!event) throw new Error('No such event');
const result = await createImmichEventAlbum(id, event.name);
await putEvent(result.event);
const nextEvents = eventsRef.current
.map((item) => (item.id === id ? result.event : item))
.sort(byOrder);
eventsRef.current = nextEvents;
setEvents(nextEvents);
setToast(`Immich gallery created for ${event.name}`);
return result.event;
}, []);
const renameEvent = useCallback(async (id: string, name: string) => {
@@ -1236,6 +1324,169 @@ export default function App() {
}
}, [activePhoto, bridgeEvent]);
/**
* Renders each edit and uploads the queue one at a time. Checksums make a
* repeat send of an unchanged edit a no-op on the server.
*/
const pushImmichQueue = useCallback(async (targets: PhotoRecord[]) => {
if (immichBusyRef.current) return;
const queue = targets.filter(
(photo) => photo.immich || immichEventIds.has(photo.eventId),
);
const localCount = targets.length - queue.length;
if (!queue.length) {
setToast('None of the selected photos can go to Immich yet');
return;
}
immichBusyRef.current = true;
let sent = 0;
let skipped = 0;
let failed = 0;
let trashed = 0;
let warning = '';
setImmichProgress({ done: 0, total: queue.length, current: queue[0].name });
try {
for (let i = 0; i < queue.length; i += 1) {
const photo = queue[i];
setImmichProgress({ done: i, total: queue.length, current: photo.name });
try {
const blob = await renderPhotoBlob(photo, {
...DEFAULT_EXPORT,
format: 'jpeg',
quality: 92,
resize: 'none',
});
const result = await pushImmichPhoto(photo.id, await blobToBase64(blob));
if (result.alreadyPushed) skipped += 1;
else sent += 1;
if (result.trashed) trashed += 1;
if (result.warning && !warning) warning = result.warning;
} catch (err) {
failed += 1;
if (!warning) warning = err instanceof Error ? err.message : 'A photo could not be sent';
}
setImmichProgress({ done: i + 1, total: queue.length, current: photo.name });
// Let the progress paint before the next full-resolution render.
await new Promise((resolve) => setTimeout(resolve, 0));
}
} finally {
immichBusyRef.current = false;
setImmichProgress(null);
}
const parts = [];
if (sent) parts.push(`Sent ${sent} edit${sent === 1 ? '' : 's'}`);
if (skipped) parts.push(`${skipped} already in Immich`);
if (localCount) parts.push(`${localCount} not from Immich`);
if (trashed) parts.push(`${trashed} original${trashed === 1 ? '' : 's'} in trash`);
if (failed) parts.push(`${failed} failed`);
let message = parts.length ? parts.join(' · ') : 'Nothing to send';
if (warning) message += ` · ${warning}`;
setToast(message);
}, [immichEventIds]);
/**
* Manual push for one event. Photos Immich has never seen upload their
* original from the server; photos edited since the last push are rendered
* here so the gallery receives the current look. Nothing runs on its own -
* this only happens when the button is pressed, and each finished upload is
* recorded so a repeat press skips everything that is already up to date.
*/
const syncEventGallery = useCallback(async (targetEventId: string) => {
if (immichBusyRef.current) {
setToast('An Immich upload is already running');
return;
}
if (!immichStatusRef.current?.enabled) {
setToast('Turn on Immich in the Immich sync panel first');
return;
}
let plan: { photoId: string; mode: 'original' | 'edit' }[];
try {
plan = (await immichEventQueue(targetEventId)).queue;
} catch (err) {
setToast(err instanceof Error ? err.message : 'Could not read the Immich queue');
return;
}
const byId = new Map(
photosRef.current.filter((photo) => !photo.deletedAt).map((photo) => [photo.id, photo]),
);
const queue: { entry: { photoId: string; mode: 'original' | 'edit' }; photo: PhotoRecord }[] = [];
for (const entry of plan) {
const photo = byId.get(entry.photoId);
if (!photo) continue;
// A photo Immich already has only needs a new upload once it is edited.
if (entry.mode === 'edit' && !isEdited(photo.edits)) continue;
queue.push({ entry, photo });
}
if (!queue.length) {
setToast('Everything in this event is already in Immich');
return;
}
immichBusyRef.current = true;
let sent = 0;
let skipped = 0;
let failed = 0;
let warning = '';
setImmichProgress({ done: 0, total: queue.length, current: queue[0].photo.name });
try {
for (let i = 0; i < queue.length; i += 1) {
const { entry, photo } = queue[i];
setImmichProgress({ done: i, total: queue.length, current: photo.name });
try {
const result = entry.mode === 'edit'
? await pushImmichPhoto(
photo.id,
await blobToBase64(
await renderPhotoBlob(photo, {
...DEFAULT_EXPORT,
format: 'jpeg',
quality: 92,
resize: 'none',
}),
),
)
: await publishImmichOriginal(photo.id);
if (result.alreadyPushed || result.skipped) skipped += 1;
else sent += 1;
if (result.warning && !warning) warning = result.warning;
} catch (err) {
failed += 1;
if (!warning) {
warning = `${photo.name}: ${
err instanceof Error ? err.message : 'could not be sent'
}`;
}
}
setImmichProgress({ done: i + 1, total: queue.length, current: photo.name });
// Let the progress paint before the next render or upload.
await new Promise((resolve) => setTimeout(resolve, 0));
}
} finally {
immichBusyRef.current = false;
setImmichProgress(null);
}
const parts = [];
if (sent) parts.push(`Sent ${sent} photo${sent === 1 ? '' : 's'}`);
if (skipped) parts.push(`${skipped} already in Immich`);
if (failed) parts.push(`${failed} failed`);
let message = parts.length ? parts.join(' · ') : 'Nothing to send';
if (warning) message += ` · ${warning}`;
setToast(message);
}, []);
const openImmichAsset = useCallback((photo: PhotoRecord) => {
const status = immichStatusRef.current;
if (!status?.url || !photo.immich) return;
window.open(
`${status.url.replace(/\/+$/, '')}/photos/${encodeURIComponent(photo.immich.assetId)}`,
'_blank',
'noopener,noreferrer',
);
}, []);
const handleCloudLogin = useCallback(
async (email: string, password: string) => {
setCloudBusy(true);
@@ -1754,9 +2005,11 @@ export default function App() {
setTrashOpen(false);
setEventId(id);
}}
onCreate={async (name) => {
await createEvent(name);
immichEnabled={Boolean(immichStatus?.enabled)}
onCreate={async (name, immichGallery) => {
await createEvent(name, { immichGallery });
}}
onSyncGallery={syncEventGallery}
onRename={renameEvent}
onDelete={removeEvent}
onReorderEvents={reorderEvents}
@@ -1855,6 +2108,15 @@ export default function App() {
onBulkRate={(rating) => bulkUpdate(selected, { rating })}
onBulkFlag={(flag) => bulkUpdate(selected, { flag })}
onBulkColor={(color) => bulkUpdate(selected, { color })}
onSendToImmich={
selected.some((id) => {
const photo = photos.find((item) => item.id === id);
return photo ? canSendToImmich(photo) : false;
})
? () => void pushImmichQueue(photos.filter((photo) => selected.includes(photo.id)))
: undefined
}
immichBusy={Boolean(immichProgress)}
onDelete={() => (trashOpen ? void removePhotos(selected) : trashPhotos(selected))}
onExport={openExport}
onCompare={() => setCompareOpen(true)}
@@ -1899,6 +2161,11 @@ export default function App() {
onLocalClipboard={setLocalClipboard}
onExport={openExport}
onPrint={() => setPrintOpen(true)}
canPushImmich={canSendToImmich(activePhoto)}
onPushImmich={() => void pushImmichQueue([activePhoto])}
onOpenImmich={
activePhoto.immich ? () => openImmichAsset(activePhoto) : undefined
}
presets={[...PRESETS, ...customPresets]}
onSavePreset={savePreset}
onDelete={() => trashPhotos([activePhoto.id])}
@@ -1949,6 +2216,8 @@ export default function App() {
setToast(`Imported ${imported.length} photo${imported.length === 1 ? '' : 's'}`);
}}
onCreateEvent={createEvent}
immichEnabled={Boolean(immichStatus?.enabled)}
onCreateImmichGallery={createImmichGalleryForEvent}
/>
)}
@@ -2061,6 +2330,10 @@ export default function App() {
setCloudOpen(false);
setAdminOpen(true);
}}
onImmich={() => {
setCloudOpen(false);
setImmichOpen(true);
}}
onClose={() => setCloudOpen(false)}
/>
)}
@@ -2071,11 +2344,23 @@ export default function App() {
onClose={() => setAdminOpen(false)}
onChanged={() => {
void getHealth().then((health) => setCloudHealth(health));
void getImmichStatus().then(setImmichStatus).catch(() => undefined);
}}
onRestored={() => void refreshCatalogFromServer()}
/>
)}
{immichOpen && cloudUser && (
<ImmichPanel
onClose={() => setImmichOpen(false)}
onChanged={() => {
void getImmichStatus().then(setImmichStatus).catch(() => undefined);
void refreshCatalogFromServer();
}}
onToast={setToast}
/>
)}
{menu &&
(() => {
const targets = photos.filter((p) => menu.ids.includes(p.id));
@@ -2133,6 +2418,21 @@ export default function App() {
disabled: menu.ids.length < 2,
onSelect: () => setMergeOpen(true),
},
...(targets.some(canSendToImmich)
? ([
{
label:
targets.filter(canSendToImmich).length === 1
? 'Send edit to Immich'
: `Send ${targets.filter(canSendToImmich).length} edits to Immich`,
disabled: Boolean(immichProgress),
onSelect: () => void pushImmichQueue(targets),
},
...(lead.immich
? [{ label: 'Open in Immich', onSelect: () => openImmichAsset(lead) }]
: []),
] as MenuEntry[])
: []),
{ label: 'Export…', onSelect: openExport },
{ label: 'Print…', onSelect: () => setPrintOpen(true) },
{
@@ -2168,6 +2468,25 @@ export default function App() {
/>
)}
{immichProgress && (
<div className="toast immich-progress" role="status" aria-live="polite">
<div className="immich-progress-head">
<strong>Sending to Immich</strong>
<span>
{immichProgress.done} / {immichProgress.total}
</span>
</div>
<div className="quota-meter">
<span
style={{
width: `${immichProgress.total ? Math.round((immichProgress.done / immichProgress.total) * 100) : 0}%`,
}}
/>
</div>
<span className="muted small">{immichProgress.current}</span>
</div>
)}
{toast && (
<div className="toast">
<span>{toast}</span>
+159 -1
View File
@@ -15,14 +15,17 @@ import {
adminCreateUser,
adminDeleteEvent,
adminDeleteUser,
adminDisconnectImmich,
adminRestoreCatalog,
adminRevokeInvite,
adminOverview,
adminRenameEvent,
adminSaveImmich,
adminSaveMail,
adminSchedulePrune,
adminSetQuota,
adminSetStorage,
adminTestImmich,
adminTestMail,
adminUpdateUser,
adminWarnUser,
@@ -68,7 +71,7 @@ const planSummary = (quota: AdminQuota) => {
return parts.length ? parts.join(', ') : 'nothing';
};
type Tab = 'users' | 'invites' | 'content' | 'storage' | 'quotas' | 'backup';
type Tab = 'users' | 'invites' | 'content' | 'storage' | 'quotas' | 'immich' | 'backup';
const inviteUrl = (token: string) => `${window.location.origin}/join/${token}`;
@@ -112,6 +115,8 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
const [quotaDrafts, setQuotaDrafts] = useState<Record<string, string>>({});
const [mailDraft, setMailDraft] = useState({ user: '', appPassword: '', from: '' });
const [mail, setMail] = useState<MailStatus | null>(null);
const [immichDraft, setImmichDraft] = useState({ url: '', apiKey: '', enabled: true });
const restoreCatalog = async (file: File | undefined) => {
if (!file || busy) return;
@@ -161,6 +166,11 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
user: current.user || next.mail.user,
from: current.from || next.mail.from,
}));
setImmichDraft((current) => ({
url: next.immich.hasKey ? current.url || next.immich.url : next.immich.url,
apiKey: '',
enabled: next.immich.hasKey ? (current.url ? current.enabled : next.immich.enabled) : true,
}));
setRootInput((current) => (current ? current : next.storage.root));
onChanged();
}, [onChanged]);
@@ -174,6 +184,13 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
setOverview(next);
setMail(next.mail);
setMailDraft({ user: next.mail.user, appPassword: '', from: next.mail.from });
// A connection being set up for the first time defaults to on; the box
// would otherwise be unchecked and silently save publishing as off.
setImmichDraft({
url: next.immich.url,
apiKey: '',
enabled: next.immich.hasKey ? next.immich.enabled : true,
});
setRootInput(next.storage.root);
setQuotaDrafts(
Object.fromEntries(
@@ -345,6 +362,42 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
setNote(`Test email sent to ${user.email}`);
});
const saveImmich = () =>
run(async () => {
const next = await adminSaveImmich({
url: immichDraft.url.trim(),
apiKey: immichDraft.apiKey,
enabled: immichDraft.enabled,
});
setImmichDraft({ url: next.url, apiKey: '', enabled: next.enabled });
setNote(
next.enabled
? 'Immich connection saved for every account'
: 'Immich connection saved; automatic publishing is off',
);
});
const testImmich = () =>
run(async () => {
const result = await adminTestImmich();
setNote(
`Connected to Immich ${result.version} · ${result.albumCount} album${
result.albumCount === 1 ? '' : 's'
}`,
);
});
const disconnectImmichConnection = () => {
if (!window.confirm('Remove the server-wide Immich connection? Existing albums and photos stay in Immich.')) {
return;
}
void run(async () => {
const next = await adminDisconnectImmich();
setImmichDraft({ url: next.url, apiKey: '', enabled: next.enabled });
setNote('Immich connection removed');
});
};
const renameEvent = () => {
if (!editEvent) return;
const name = editEvent.name.trim();
@@ -404,6 +457,9 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
<button className={`tab ${tab === 'quotas' ? 'on' : ''}`} onClick={() => setTab('quotas')}>
Quotas
</button>
<button className={`tab ${tab === 'immich' ? 'on' : ''}`} onClick={() => setTab('immich')}>
Immich
</button>
<button className={`tab ${tab === 'backup' ? 'on' : ''}`} onClick={() => setTab('backup')}>
Backup
</button>
@@ -926,6 +982,108 @@ export default function AdminPanel({ user, onClose, onChanged, onRestored }: Pro
</p>
</div>
</section>
) : tab === 'immich' ? (
<section className="admin-section">
<h3>Immich connection</h3>
<p className="muted small">
One connection is shared by every account. When it is enabled, importing into a
Luminary event creates a matching Immich album, publishes the originals there, and
saves edited versions to the same album.
</p>
<label className="field">
<span>Immich server address</span>
<input
value={immichDraft.url}
spellCheck={false}
placeholder="http://192.168.1.10:2283"
onChange={(e) =>
setImmichDraft((current) => ({ ...current, url: e.target.value }))
}
onKeyDown={(e) => e.key === 'Enter' && saveImmich()}
/>
</label>
<label className="field">
<span>API key</span>
<input
type="password"
autoComplete="off"
value={immichDraft.apiKey}
placeholder={overview.immich.hasKey ? 'Saved — type to replace' : 'Immich API key'}
onChange={(e) =>
setImmichDraft((current) => ({ ...current, apiKey: e.target.value }))
}
onKeyDown={(e) => e.key === 'Enter' && saveImmich()}
/>
</label>
<label className="check-row">
<input
type="checkbox"
checked={immichDraft.enabled}
disabled={busy}
onChange={(e) =>
setImmichDraft((current) => ({ ...current, enabled: e.target.checked }))
}
/>
Automatically publish event photos and edits
</label>
<div className="btn-row">
<button
className="btn primary"
onClick={saveImmich}
disabled={
busy ||
!immichDraft.url.trim() ||
(!immichDraft.apiKey && !overview.immich.hasKey)
}
>
Save connection
</button>
<button
className="btn ghost"
onClick={testImmich}
disabled={busy || !overview.immich.hasKey}
>
Test connection
</button>
{overview.immich.hasKey && (
<button
className="btn ghost"
onClick={disconnectImmichConnection}
disabled={busy}
>
Disconnect
</button>
)}
</div>
{overview.immich.configured ? (
<div className={`banner ${overview.immich.enabled ? 'ok' : 'info'}`}>
{overview.immich.enabled
? 'Connected and automatic publishing is on.'
: 'Connection saved; automatic publishing is off.'}{' '}
{overview.immich.version ? `Immich ${overview.immich.version}.` : 'Test it to verify access.'}
</div>
) : (
<div className="banner info">
Add the server address and API key to enable Immich publishing.
</div>
)}
<div className="admin-note">
<p>
The key needs <code>album.read</code>, <code>album.create</code>,{' '}
<code>albumAsset.create</code>, <code>asset.read</code>,{' '}
<code>asset.download</code>, <code>asset.upload</code> and{' '}
<code>asset.update</code>. Add <code>asset.delete</code> only if originals should
move to the Immich trash after an edited version is uploaded.
</p>
<p className="muted small">
The key is encrypted on the server and never sent back to a browser. Existing
albums already in Immich stay untouched if the connection is removed.
</p>
</div>
</section>
) : tab === 'backup' ? (
<section className="admin-section">
<h3>Catalog backup</h3>
+10
View File
@@ -12,6 +12,7 @@ interface Props {
onLogout: () => void;
onSync: () => void;
onAdmin: () => void;
onImmich: () => void;
onClose: () => void;
}
@@ -32,6 +33,7 @@ export default function CloudPanel({
onLogout,
onSync,
onAdmin,
onImmich,
onClose,
}: Props) {
const [mode, setMode] = useState<'signin' | 'signup'>('signin');
@@ -121,6 +123,14 @@ export default function CloudPanel({
Administration
</button>
)}
<button
className="btn ghost"
onClick={onImmich}
disabled={busy}
title="Optional: sync albums with your own Immich server"
>
Immich sync
</button>
</div>
{note && <div className="banner ok">{note}</div>}
</div>
+18
View File
@@ -128,6 +128,9 @@ interface Props {
onLocalClipboard: (layer: LocalLayer | null) => void;
onExport: () => void;
onPrint: () => void;
canPushImmich?: boolean;
onPushImmich?: () => void;
onOpenImmich?: () => void;
presets: Preset[];
onSavePreset: (name: string, edits: Edits) => void;
onDelete: () => void;
@@ -155,6 +158,9 @@ export default function Develop({
onLocalClipboard,
onExport,
onPrint,
canPushImmich = false,
onPushImmich,
onOpenImmich,
presets,
onSavePreset,
onDelete,
@@ -1453,6 +1459,12 @@ export default function Develop({
{ label: 'Paste settings', shortcut: '⌘V', onSelect: onPaste, disabled: !clipboard },
{ label: 'Reset settings', onSelect: resetAll },
'separator',
...(canPushImmich && onPushImmich
? ([{ label: 'Send edit to Immich', onSelect: onPushImmich }] as MenuEntry[])
: []),
...(onOpenImmich
? ([{ label: 'Open in Immich', onSelect: onOpenImmich }] as MenuEntry[])
: []),
{ label: 'Export…', onSelect: onExport },
{ label: 'Delete photo…', danger: true, onSelect: onDelete },
];
@@ -1462,6 +1474,12 @@ export default function Develop({
{ label: 'Paste settings', onSelect: onPaste, disabled: !clipboard },
{ label: 'Reset settings', onSelect: resetAll },
'separator',
...(canPushImmich && onPushImmich
? ([{ label: 'Send edit to Immich', onSelect: onPushImmich }] as MenuEntry[])
: []),
...(onOpenImmich
? ([{ label: 'Open in Immich', onSelect: onOpenImmich }] as MenuEntry[])
: []),
{ label: 'Export…', onSelect: onExport },
{ label: 'Delete photo…', danger: true, onSelect: onDelete },
];
+27 -2
View File
@@ -17,9 +17,11 @@ interface Props {
photos: PhotoRecord[];
eventId: string;
onSelectEvent: (id: string) => void;
onCreate: (name: string) => Promise<void> | void;
immichEnabled?: boolean;
onCreate: (name: string, immichGallery?: boolean) => Promise<void> | void;
onRename: (id: string, name: string) => void;
onDelete: (id: string) => void;
onSyncGallery?: (id: string) => void;
onReorderEvents: (dragId: string, targetId: string) => void;
onDropPhotos: (ids: string[], eventId: string) => void;
trashOpen: boolean;
@@ -39,9 +41,11 @@ export default function EventSidebar({
photos,
eventId,
onSelectEvent,
immichEnabled = false,
onCreate,
onRename,
onDelete,
onSyncGallery,
onReorderEvents,
onDropPhotos,
trashOpen,
@@ -55,6 +59,7 @@ export default function EventSidebar({
}: Props) {
const [adding, setAdding] = useState(false);
const [name, setName] = useState('');
const [createGallery, setCreateGallery] = useState(false);
const [dropTarget, setDropTarget] = useState<string | null>(null);
const counts = new Map<string, number>();
@@ -72,8 +77,9 @@ export default function EventSidebar({
setAdding(false);
return;
}
await onCreate(name);
await onCreate(name, createGallery);
setName('');
setCreateGallery(false);
setAdding(false);
};
@@ -189,6 +195,16 @@ export default function EventSidebar({
<button className="btn primary small" onClick={() => void submit()}>
Add
</button>
{immichEnabled && (
<label className="check-row small new-event-gallery">
<input
type="checkbox"
checked={createGallery}
onChange={(e) => setCreateGallery(e.target.checked)}
/>
Create Immich gallery
</label>
)}
</div>
)}
@@ -234,6 +250,15 @@ export default function EventSidebar({
<span className="event-count">{counts.get(event.id) ?? 0}</span>
</button>
<div className="event-tools">
{immichEnabled && event.immich && onSyncGallery && (
<button
className="icon-btn"
title="Push edits and originals to this event's Immich gallery"
onClick={() => onSyncGallery(event.id)}
>
☁
</button>
)}
<button
className="icon-btn"
title="Rename event"
+431
View File
@@ -0,0 +1,431 @@
import { useCallback, useEffect, useState } from 'react';
import type { ImmichAlbum, ImmichImportJob, ImmichStatus } from '../lib/api';
import {
disconnectImmich,
getImmichJob,
getImmichStatus,
immichAlbums,
immichImportAlbum,
saveImmichSettings,
testImmich,
} from '../lib/api';
interface Props {
onClose: () => void;
onChanged: () => void;
onToast: (message: string) => void;
}
const fmtDate = (ms: number | null) =>
ms
? new Date(ms).toLocaleString(undefined, {
month: 'short',
day: 'numeric',
hour: 'numeric',
minute: '2-digit',
})
: 'never';
/**
* Optional, per-account Immich setup. Nothing here is shown anywhere else in
* the app until the user saves a connection and turns the integration on.
*/
export default function ImmichPanel({ onClose, onChanged, onToast }: Props) {
const [status, setStatus] = useState<ImmichStatus | null>(null);
const [loading, setLoading] = useState(true);
const [saving, setSaving] = useState(false);
const [error, setError] = useState<string | null>(null);
const [draft, setDraft] = useState({ url: '', apiKey: '' });
const [albums, setAlbums] = useState<ImmichAlbum[] | null>(null);
const [albumsLoading, setAlbumsLoading] = useState(false);
const [job, setJob] = useState<ImmichImportJob | null>(null);
const load = useCallback(async () => {
try {
const next = await getImmichStatus();
setStatus(next);
setDraft((current) => ({ url: current.url || next.url, apiKey: '' }));
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not read the Immich settings');
} finally {
setLoading(false);
}
}, []);
useEffect(() => {
void load();
}, [load]);
useEffect(() => {
const onKey = (event: KeyboardEvent) => {
if (event.key !== 'Escape') return;
event.preventDefault();
event.stopImmediatePropagation();
if (!saving) onClose();
};
window.addEventListener('keydown', onKey, true);
return () => window.removeEventListener('keydown', onKey, true);
}, [saving, onClose]);
useEffect(() => {
if (!job || job.state !== 'running') return;
let alive = true;
const timer = setInterval(() => {
void getImmichJob(job.id)
.then((next) => {
if (!alive) return;
setJob(next);
if (next.state === 'running') return;
onToast(next.message || 'Immich import finished');
setAlbums(null);
void load();
onChanged();
})
.catch((err) => {
if (!alive) return;
setError(err instanceof Error ? err.message : 'Could not check the import');
setJob({ ...job, state: 'error' });
});
}, 1500);
return () => {
alive = false;
clearInterval(timer);
};
}, [job, load, onChanged, onToast]);
const save = async (patch: Record<string, unknown> = {}) => {
if (saving) return null;
setSaving(true);
setError(null);
try {
const next = await saveImmichSettings({
url: draft.url.trim(),
apiKey: draft.apiKey,
...patch,
});
setStatus(next);
setDraft({ url: next.url, apiKey: '' });
onChanged();
return next;
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not save the Immich connection');
return null;
} finally {
setSaving(false);
}
};
const test = async () => {
if (saving) return;
setSaving(true);
setError(null);
try {
const result = await testImmich();
onToast(
`Connected to Immich ${result.version} · ${result.albumCount} album${result.albumCount === 1 ? '' : 's'}`,
);
await load();
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not reach Immich');
} finally {
setSaving(false);
}
};
const loadAlbums = async () => {
if (albumsLoading) return;
setAlbumsLoading(true);
setError(null);
try {
setAlbums(await immichAlbums());
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not load Immich albums');
} finally {
setAlbumsLoading(false);
}
};
const startImport = async (album: ImmichAlbum) => {
if (job?.state === 'running') return;
if (
album.eventId &&
!window.confirm(
`“${album.name}” is already linked to a Luminary event. Importing again adds new photos and skips ones already here.`,
)
) {
return;
}
setError(null);
try {
setJob(await immichImportAlbum(album.id));
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not start the import');
}
};
const disconnect = async () => {
if (!window.confirm('Disconnect Immich? Imported events and photos stay in the library.')) return;
setSaving(true);
setError(null);
try {
const next = await disconnectImmich();
setStatus(next);
setDraft({ url: next.url, apiKey: '' });
setAlbums(null);
setJob(null);
onChanged();
onToast('Immich disconnected');
} catch (err) {
setError(err instanceof Error ? err.message : 'Could not disconnect');
} finally {
setSaving(false);
}
};
const configured = Boolean(status?.configured);
const enabled = Boolean(status?.enabled);
const managed = Boolean(status?.managed);
const running = job?.state === 'running';
return (
<div className="modal-backdrop" onPointerDown={(e) => e.target === e.currentTarget && onClose()}>
<div className="modal immich-modal">
<header className="modal-head">
<h2>Immich sync</h2>
<button className="icon-btn" onClick={onClose} title="Close (Esc)">
✕
</button>
</header>
<div className="modal-body">
<p className="muted small immich-intro">
{managed
? 'This server uses an Immich connection managed by an administrator. You can import albums, but the server address and API key are managed centrally.'
: 'Optional and private to your account. Your API key is stored encrypted on the server and is never sent to the browser. Nothing changes in the library until you turn this on.'}
</p>
{managed && status?.url && (
<div className="banner info">
Shared Immich server: <code>{status.url}</code>
</div>
)}
{loading && !status ? (
<p className="muted small">Checking…</p>
) : (
<>
<label className="field">
<span>Immich server</span>
<input
value={draft.url}
spellCheck={false}
placeholder="http://192.168.1.10:2283"
disabled={saving || managed}
onChange={(e) => setDraft((current) => ({ ...current, url: e.target.value }))}
onKeyDown={(e) => e.key === 'Enter' && void save()}
/>
</label>
<label className="field">
<span>API key</span>
<input
type="password"
value={draft.apiKey}
disabled={saving || managed}
placeholder={
managed
? 'Managed by an administrator'
: status?.hasKey
? 'Saved — type to replace'
: 'Immich API key'
}
onChange={(e) => setDraft((current) => ({ ...current, apiKey: e.target.value }))}
onKeyDown={(e) => e.key === 'Enter' && void save()}
/>
</label>
<div className="btn-row">
<button
className="btn primary"
onClick={() => void save()}
disabled={
saving || managed || !draft.url.trim() || (!draft.apiKey && !status?.hasKey)
}
>
{saving ? 'Saving…' : configured ? 'Save connection' : 'Connect'}
</button>
<button className="btn ghost" onClick={() => void test()} disabled={saving || !status?.hasKey}>
Test connection
</button>
{configured && !managed && (
<button className="btn ghost" onClick={() => void disconnect()} disabled={saving}>
Disconnect
</button>
)}
</div>
<p className="muted small">
Create a key in Immich under Account Settings → API Keys. It needs{' '}
<code>album.read</code>, <code>album.create</code>, <code>albumAsset.create</code>,{' '}
<code>asset.read</code>,
<code>asset.download</code>, <code>asset.upload</code> and <code>asset.update</code>;
add <code>tag.read</code>, <code>tag.create</code> and <code>tag.asset</code> for
keyword sync, and <code>asset.delete</code> only if you want originals moved to the
Immich trash after an upload.
</p>
{configured && (
<>
<div className="subhead">
<span>Integration</span>
<span className="muted small">
{status?.version ? `Immich ${status.version}` : 'Not tested yet'}
</span>
</div>
<label className="check-row">
<input
type="checkbox"
checked={enabled}
disabled={saving || managed}
onChange={(e) => void save({ enabled: e.target.checked })}
/>
Show Immich tools in my account (import albums, send edits back)
</label>
<p className="muted small">
Nothing is uploaded while you edit. Press the ☁ button on an event to push
its edited photos and any originals Immich has not seen yet.
</p>
<label className="check-row">
<input
type="checkbox"
checked={Boolean(status?.trashOriginal)}
disabled={saving || !enabled || managed}
onChange={(e) => void save({ trashOriginal: e.target.checked })}
/>
After uploading an edit, move the original to the Immich trash
</label>
<p className="muted small">
Recoverable in Immich. Luminary never permanently deletes the Immich original.
</p>
{enabled && (
<>
<div className="subhead">
<span>Albums</span>
<span className="muted small">Only linked albums sync automatically</span>
</div>
<div className="admin-table">
<div className="admin-row admin-row-head content-row">
<span>Album</span>
<span>Photos</span>
<span>Last sync</span>
<span>Actions</span>
</div>
{albums === null ? (
<p className="muted small">
{albumsLoading
? 'Loading albums…'
: 'Choose Refresh to list albums from this Immich account.'}
</p>
) : albums.length === 0 ? (
<p className="muted small">This Immich account has no albums.</p>
) : (
albums.map((album) => (
<div className="admin-row content-row" key={album.id}>
<div className="admin-event-name">
<strong>{album.name}</strong>
<div className="muted small">
{album.updatedAt
? `Updated ${fmtDate(album.updatedAt)}`
: 'Immich album'}
</div>
</div>
<span className="admin-num">{album.assetCount}</span>
<span className="admin-num">
{album.lastSyncAt ? fmtDate(album.lastSyncAt) : '—'}
</span>
<div className="admin-actions">
{album.kind === 'gallery' ? (
<span className="muted small">Gallery</span>
) : (
<button
className="btn small"
disabled={running}
onClick={() => void startImport(album)}
>
{album.eventId ? 'Sync again' : 'Import'}
</button>
)}
</div>
</div>
))
)}
</div>
<div className="btn-row">
<button
className="btn ghost"
onClick={() => void loadAlbums()}
disabled={albumsLoading}
>
{albumsLoading ? 'Loading…' : 'Refresh albums'}
</button>
</div>
</>
)}
{job && (
<div className="admin-note">
<p>
<strong>{job.albumName || 'Album'}</strong> ·{' '}
{job.state === 'running'
? job.scheduled
? 'Syncing in the background…'
: 'Importing…'
: job.state === 'done'
? 'Complete'
: 'Stopped'}
</p>
<div className="quota-meter" aria-label="Import progress">
<span
className={job.state === 'error' ? 'warn' : ''}
style={{
width: `${job.total ? Math.round(((job.done + job.skipped + job.failed) / job.total) * 100) : 0}%`,
}}
/>
</div>
<p className="muted small">
{job.done} imported · {job.skipped} already present
{job.failed ? ` · ${job.failed} failed` : ''}
</p>
{job.message && <p className="muted small">{job.message}</p>}
{job.errors.length > 0 && (
<ul className="muted small">
{job.errors.map((message) => (
<li key={message}>{message}</li>
))}
</ul>
)}
</div>
)}
</>
)}
</>
)}
{error && <div className="banner error">{error}</div>}
</div>
<footer className="modal-foot">
<span className="muted small">
Nothing uploads automatically. Use ☁ on an event to push its edits and originals.
</span>
<button className="btn" onClick={onClose}>
Done
</button>
</footer>
</div>
</div>
);
}
+116 -2
View File
@@ -1,4 +1,5 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { publishImmichOriginal } from '../lib/api';
import type { CloudImport, ImportProgress } from '../lib/import';
import { importFiles, isSupportedFile } from '../lib/import';
import { isRawFile, RAW_ACCEPT } from '../lib/raw';
@@ -13,6 +14,9 @@ interface Props {
onClose: () => void;
onImported: (photos: PhotoRecord[], eventId: string) => void;
onCreateEvent: (name: string) => Promise<EventRecord>;
/** Turns on the optional Immich gallery for the created/target event. */
immichEnabled?: boolean;
onCreateImmichGallery?: (eventId: string) => Promise<EventRecord>;
cloud?: CloudImport | null;
onNeedServer: () => void;
}
@@ -25,6 +29,8 @@ export default function ImportModal({
onClose,
onImported,
onCreateEvent,
immichEnabled = false,
onCreateImmichGallery,
cloud,
onNeedServer,
}: Props) {
@@ -37,11 +43,16 @@ export default function ImportModal({
const [progress, setProgress] = useState<ImportProgress | null>(null);
const [failures, setFailures] = useState<string[]>([]);
const [allowDuplicates, setAllowDuplicates] = useState(false);
const [createGallery, setCreateGallery] = useState(immichEnabled);
const [galleryCreated, setGalleryCreated] = useState(false);
const [galleryError, setGalleryError] = useState<string | null>(null);
const [summary, setSummary] = useState<{
imported: number;
failed: number;
skipped: number;
cancelled: boolean;
published: number;
publishFailed: number;
} | null>(null);
const inputRef = useRef<HTMLInputElement>(null);
const abortRef = useRef<AbortController | null>(null);
@@ -56,6 +67,12 @@ export default function ImportModal({
);
const readyFiles = allowDuplicates ? files : files.filter((file) => !duplicateFiles.includes(file));
useEffect(() => {
setGalleryCreated(false);
setGalleryError(null);
setCreateGallery(immichEnabled);
}, [eventId, immichEnabled]);
useEffect(() => {
// Capture phase: Escape closes this dialog even while a photo is open behind it.
const onKey = (e: KeyboardEvent) => {
@@ -91,16 +108,67 @@ export default function ImportModal({
const created = await onCreateEvent(newName || `Event ${new Date().toLocaleDateString()}`);
targetId = created.id;
}
let hasGallery = Boolean(events.find((event) => event.id === targetId)?.immich);
if (
createGallery &&
!galleryCreated &&
onCreateImmichGallery &&
!hasGallery
) {
try {
await onCreateImmichGallery(targetId);
hasGallery = true;
setGalleryCreated(true);
} catch (err) {
setGalleryError(
err instanceof Error ? err.message : 'The Immich gallery could not be created',
);
}
}
const result = await importFiles(readyFiles, targetId, [], setProgress, cloud ?? null, controller.signal);
if (result.photos.length) onImported(result.photos, targetId);
let published = 0;
let publishFailed = 0;
const publishFailures: string[] = [];
if (hasGallery && immichEnabled && cloud && result.photos.length) {
const total = result.photos.length;
for (let index = 0; index < total; index++) {
if (controller.signal.aborted) break;
const photo = result.photos[index];
setProgress({
done: index,
total,
current: `Adding ${photo.name} to the Immich gallery…`,
});
try {
const pushed = await publishImmichOriginal(photo.id);
if (!pushed.skipped) published += 1;
} catch (err) {
publishFailed += 1;
publishFailures.push(
`${photo.name} — Immich: ${err instanceof Error ? err.message : 'upload failed'}`,
);
}
}
setProgress({ done: total, total, current: '' });
}
const skipped = allowDuplicates ? 0 : duplicateFiles.length;
setSummary({
imported: result.photos.length,
failed: result.failed.length,
skipped,
cancelled: Boolean(result.cancelled),
published,
publishFailed,
});
if (result.failed.length) setFailures(result.failed.map((f) => `${f.name} — ${f.reason}`));
if (result.failed.length || publishFailures.length) {
setFailures([
...result.failed.map((f) => `${f.name} — ${f.reason}`),
...publishFailures,
]);
}
} catch (err) {
setFailures([err instanceof Error ? err.message : 'Import failed']);
} finally {
@@ -152,6 +220,45 @@ export default function ImportModal({
</label>
)}
{immichEnabled &&
!galleryCreated &&
!events.find((event) => event.id === eventId)?.immich && (
<>
<label className="check-row">
<input
type="checkbox"
checked={createGallery}
onChange={(e) => setCreateGallery(e.target.checked)}
disabled={busy}
/>
Create an Immich album and publish originals
</label>
<p className="muted small">
Luminary creates a matching album in Immich, uploads each original into it, and
saves edited versions to the same album as you work.
</p>
</>
)}
{galleryCreated && (
<p className="muted small">
Immich album linked. Imported originals will upload automatically, and edits will be
saved there as new versions.
</p>
)}
{!galleryCreated &&
immichEnabled &&
Boolean(events.find((event) => event.id === eventId)?.immich) && (
<p className="muted small">
Imported originals will be added to this event&apos;s Immich album automatically.
Edits will be saved there too.
</p>
)}
{galleryError && (
<div className="banner warn">
<strong>Immich gallery not created.</strong> {galleryError}
</div>
)}
<div
className={`dropzone ${dragOver ? 'over' : ''}`}
onDragOver={(e) => {
@@ -260,18 +367,25 @@ export default function ImportModal({
{summary.imported} imported
{summary.skipped ? ` · ${summary.skipped} duplicate${summary.skipped === 1 ? '' : 's'} skipped` : ''}
{summary.failed ? ` · ${summary.failed} failed` : ''}
{summary.published ? ` · ${summary.published} added to Immich` : ''}
{summary.publishFailed
? ` · ${summary.publishFailed} Immich upload${summary.publishFailed === 1 ? '' : 's'} failed`
: ''}
</span>
<p className="muted small">
{summary.cancelled
? 'Files already in progress were allowed to finish. The imported photos are in the catalog.'
: 'New photos are selected in the library and ready to review.'}
{summary.published
? ' The imported photos were added to the event\'s Immich gallery.'
: ''}
</p>
</div>
)}
{failures.length > 0 && (
<div className="failures">
<strong>Some files could not be imported</strong>
<strong>Some files had problems</strong>
<ul>
{failures.map((f) => (
<li key={f}>{f}</li>
+14
View File
@@ -15,6 +15,8 @@ interface Props {
onBulkRate: (rating: number) => void;
onBulkFlag: (flag: Flag) => void;
onBulkColor: (color: ColorLabel) => void;
onSendToImmich?: () => void;
immichBusy?: boolean;
onDelete: () => void;
onExport: () => void;
onCompare: () => void;
@@ -51,6 +53,8 @@ export default function LibraryGrid({
onBulkRate,
onBulkFlag,
onBulkColor,
onSendToImmich,
immichBusy = false,
onDelete,
onExport,
onCompare,
@@ -277,6 +281,16 @@ export default function LibraryGrid({
<button className="btn ghost small" onClick={onMerge} disabled={selected.length < 2}>
Merge
</button>
{onSendToImmich && (
<button
className="btn ghost small"
onClick={onSendToImmich}
disabled={immichBusy}
title="Send rendered edits for this selection to Immich"
>
Send to Immich
</button>
)}
<button className="btn ghost small" onClick={onExport}>
Export
</button>
+33 -7
View File
@@ -131,6 +131,27 @@ function drawBrush(ctx: CanvasRenderingContext2D, layer: LocalLayer, w: number,
ctx.globalCompositeOperation = 'source-over';
}
/**
* Softens a mask rim without thinning what was painted. A plain blur pulls the
* stroke edge inward and drops thin strokes below full coverage, which reads as
* a weaker, uneven adjustment. Blurring a copy and keeping the original on top
* (lighten = max) softens only the outside of the edge: the painted core stays
* at 100% and the falloff grows past the brush outline.
*/
function featherMask(canvas: HTMLCanvasElement, radius: number) {
const out = makeCanvas(canvas.width, canvas.height);
const ctx = out.getContext('2d');
if (!ctx) return canvas;
// A sub-pixel blur keeps a feather of 0 from aliasing along the brush edge.
ctx.filter = `blur(${Math.max(0.4, radius)}px)`;
ctx.drawImage(canvas, 0, 0);
ctx.filter = 'none';
ctx.globalCompositeOperation = 'lighten';
ctx.drawImage(canvas, 0, 0);
ctx.globalCompositeOperation = 'source-over';
return out;
}
export function buildLocalMasks(layers: LocalLayer[], srcW: number, srcH: number): PackedMasks {
const w = 800;
const h = Math.max(120, Math.min(1400, Math.round((w * Math.max(1, srcH)) / Math.max(1, srcW))));
@@ -151,14 +172,19 @@ export function buildLocalMasks(layers: LocalLayer[], srcW: number, srcH: number
else drawBrush(ctx, layer, w, h);
let source = canvas;
if ((layer.kind === 'brush' || layer.kind === 'raster') && layer.feather > 0) {
const blur = makeCanvas(w, h);
const bctx = blur.getContext('2d');
if (bctx) {
bctx.filter = `blur(${Math.max(0.1, ((layer.feather / 100) * w) / 16)}px)`;
bctx.drawImage(canvas, 0, 0);
source = blur;
if (layer.kind === 'brush') {
// Feather follows the brush, not the frame: 100% softens the edge by
// roughly three quarters of the stroke's half width, so a small dab and a
// wide sweep both feel the same under the slider.
let widest = 0;
for (const stroke of layer.brush.strokes) {
widest = Math.max(widest, stroke.size * 2 * w);
}
source = featherMask(canvas, (layer.feather / 100) * widest * 0.75);
} else if (layer.kind === 'raster') {
// Generated masks are low-resolution coverage, so their feather is tied
// to the frame width and only ever loosens the outside edge.
source = featherMask(canvas, ((layer.feather / 100) * w) / 16);
}
const pixels = source.getContext('2d')?.getImageData(0, 0, w, h).data;
+9 -1
View File
@@ -427,7 +427,15 @@ void main(){
float ll = clamp(luma(local), 0.0, 1.0);
local += (adj2.z / 100.0) * 0.45 * pow(1.0 - ll, 3.0);
local += (adj2.y / 100.0) * 0.50 * pow(ll, 2.0);
local = mix(vec3(luma(local)), local, clamp(1.0 + adj2.x / 100.0, 0.0, 3.0));
// Desaturate in linear light. Mixing towards a gamma-space luma drags a
// saturated colour towards a much darker grey (a pure red collapses to
// near black), so pulling saturation down made the masked area look muddy
// instead of simply calmer. Scaling chroma around the linear luminance
// keeps the brightness of the patch where it was.
vec3 localLin = toLinear(clamp(local, 0.0, 1.0));
float localLuma = luma(localLin);
localLin = mix(vec3(localLuma), localLin, clamp(1.0 + adj2.x / 100.0, 0.0, 2.0));
local = clamp(toSRGB(max(localLin, vec3(0.0))), 0.0, 1.0);
srgb = mix(srgb, clamp(local, 0.0, 1.0), m);
}
}
+183 -1
View File
@@ -1,4 +1,4 @@
import type { EventRecord, PhotoRecord, Preset } from '../types';
import type { EventRecord, Flag, PhotoRecord, Preset } from '../types';
export interface Health {
ok: boolean;
@@ -418,6 +418,75 @@ export interface MailStatus {
gmail: boolean;
}
export interface ImmichStatus {
configured: boolean;
enabled: boolean;
/** The connection is configured server-wide by an administrator. */
managed?: boolean;
url: string;
hasKey: boolean;
autoSync: boolean;
syncMinutes: number;
trashOriginal: boolean;
syncMetadata: boolean;
lastSyncAt: number | null;
lastError: string | null;
version: string | null;
albumCount: number;
}
export interface ImmichAlbum {
id: string;
name: string;
assetCount: number;
/** A gallery created from a Luminary event is an upload destination, not an import source. */
kind?: 'import' | 'gallery';
updatedAt: number | null;
startDate: number | null;
endDate: number | null;
thumbnailAssetId: string | null;
/** Set when this account already imported the album. */
eventId?: string | null;
lastSyncAt?: number | null;
}
export interface ImmichImportJob {
id: string;
albumId: string;
albumName: string;
eventId: string | null;
state: 'running' | 'done' | 'error';
scheduled?: boolean;
total: number;
done: number;
skipped: number;
failed: number;
bytes: number;
message: string;
errors: string[];
startedAt: number;
finishedAt: number | null;
}
export interface ImmichTestResult {
ok: boolean;
url: string;
version: string;
major: number;
albumCount: number;
}
export interface ImmichPushResult {
ok: boolean;
assetId: string;
alreadyPushed: boolean;
/** True when the photo already existed in Immich and no upload was made. */
skipped?: boolean;
trashed: boolean;
associations: Partial<Record<'albums' | 'stack' | 'favorite' | 'sidecar', boolean>>;
warning: string;
}
export interface AdminOverview {
users: AdminUser[];
events: AdminEvent[];
@@ -426,6 +495,7 @@ export interface AdminOverview {
storage: { root: string; defaultRoot: string; custom: boolean; diskBytes?: number };
quotas: AdminQuota[];
mail: MailStatus;
immich: ImmichStatus;
}
export interface StorageChange {
@@ -576,6 +646,118 @@ export function adminSetStorage(root: string): Promise<StorageChange> {
});
}
export function adminSaveImmich(input: {
url: string;
apiKey?: string;
enabled?: boolean;
}): Promise<ImmichStatus> {
return request<{ immich: ImmichStatus }>('/api/admin/immich', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(input),
}).then((res) => res.immich);
}
export function adminTestImmich(): Promise<ImmichTestResult> {
return request<ImmichTestResult>('/api/admin/immich/test', { method: 'POST' });
}
export function adminDisconnectImmich(): Promise<ImmichStatus> {
return request<{ immich: ImmichStatus }>('/api/admin/immich', { method: 'DELETE' }).then(
(res) => res.immich,
);
}
export function getImmichStatus(): Promise<ImmichStatus> {
return request<{ immich: ImmichStatus }>('/api/immich').then((res) => res.immich);
}
export function saveImmichSettings(input: {
url: string;
apiKey?: string;
enabled?: boolean;
autoSync?: boolean;
syncMinutes?: number;
trashOriginal?: boolean;
syncMetadata?: boolean;
}): Promise<ImmichStatus> {
return request<{ immich: ImmichStatus }>('/api/immich', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(input),
}).then((res) => res.immich);
}
export function disconnectImmich(): Promise<ImmichStatus> {
return request<{ immich: ImmichStatus }>('/api/immich', { method: 'DELETE' }).then(
(res) => res.immich,
);
}
export function testImmich(): Promise<ImmichTestResult> {
return request<ImmichTestResult>('/api/immich/test', { method: 'POST' });
}
export function pushImmichPhoto(photoId: string, jpegBase64: string): Promise<ImmichPushResult> {
return request<ImmichPushResult>(
`/api/immich/photos/${encodeURIComponent(photoId)}/push`,
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ jpeg: jpegBase64 }),
},
);
}
export interface ImmichQueueEntry {
photoId: string;
name: string;
/** Upload the untouched original, or the current rendered edit. */
mode: 'original' | 'edit';
}
/** The manual push plan for an event: originals and edits changed since last push. */
export function immichEventQueue(
eventId: string,
): Promise<{ queue: ImmichQueueEntry[]; total: number }> {
return request(`/api/immich/events/${encodeURIComponent(eventId)}/queue`);
}
export function publishImmichOriginal(photoId: string): Promise<ImmichPushResult> {
return request(
`/api/immich/photos/${encodeURIComponent(photoId)}/publish`,
{ method: 'POST' },
);
}
export function createImmichEventAlbum(
eventId: string,
name: string,
): Promise<{ album: ImmichAlbum; event: EventRecord }> {
return request('/api/immich/albums', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ eventId, name }),
});
}
export function immichAlbums(): Promise<ImmichAlbum[]> {
return request<{ albums: ImmichAlbum[] }>('/api/immich/albums').then((res) => res.albums ?? []);
}
export function immichImportAlbum(albumId: string): Promise<ImmichImportJob> {
return request<{ job: ImmichImportJob }>(
`/api/immich/albums/${encodeURIComponent(albumId)}/import`,
{ method: 'POST' },
).then((res) => res.job);
}
export function getImmichJob(jobId: string): Promise<ImmichImportJob> {
return request<{ job: ImmichImportJob }>(
`/api/immich/jobs/${encodeURIComponent(jobId)}`,
).then((res) => res.job);
}
export function pushPresets(presets: Preset[]): Promise<void> {
return request('/api/presets', {
method: 'PUT',
+46 -29
View File
@@ -106,6 +106,14 @@ const PRINT: [number, number][] = [
[1, 0.98],
];
/** Ektar's steeper negative curve: dense blacks without a slide's clipped highlights. */
const EKTAR: [number, number][] = [
[0, 0.015],
[0.25, 0.23],
[0.75, 0.79],
[1, 0.985],
];
/** Lifted blacks of instant film. */
const INSTANT: [number, number][] = [
[0, 0.09],
@@ -164,15 +172,24 @@ const FILM_PACK: FilmSpec[] = [
id: 'film-ektar-100',
name: 'Kodak Ektar 100',
group: 'Kodak',
contrast: 18,
blacks: -10,
vibrance: 26,
saturation: 8,
clarity: 6,
curve: SLIDE,
hsl: { red: { sat: 12 }, green: { sat: 6, hue: -4 }, blue: { sat: 14, lum: -4 }, aqua: { sat: 8 } },
grade: { shadows: [214, 6], highlights: [45, 4] },
grain: [6, 22],
temp: -2,
contrast: 10,
highlights: -4,
shadows: 3,
blacks: -6,
vibrance: 14,
saturation: 2,
clarity: 3,
curve: EKTAR,
hsl: {
red: { sat: 8 },
orange: { sat: 4, lum: 2 },
green: { sat: 3, hue: -2 },
blue: { sat: 9, lum: -2 },
aqua: { sat: 4 },
},
grade: { shadows: [214, 4], highlights: [45, 3] },
grain: [5, 20],
},
{
id: 'film-gold-200',
@@ -463,11 +480,11 @@ const FILM_PACK: FilmSpec[] = [
name: 'Fujifilm Velvia 50',
group: 'Fujifilm',
temp: -8,
contrast: 26,
blacks: -14,
clarity: 8,
vibrance: 34,
saturation: 18,
contrast: 20,
blacks: -10,
clarity: 6,
vibrance: 26,
saturation: 12,
curve: SLIDE,
hsl: {
red: { sat: 18 },
@@ -484,11 +501,11 @@ const FILM_PACK: FilmSpec[] = [
name: 'Fujifilm Velvia 100',
group: 'Fujifilm',
temp: -7,
contrast: 24,
blacks: -12,
clarity: 6,
vibrance: 30,
saturation: 14,
contrast: 18,
blacks: -8,
clarity: 5,
vibrance: 22,
saturation: 8,
curve: SLIDE,
hsl: {
red: { sat: 16 },
@@ -532,10 +549,10 @@ const FILM_PACK: FilmSpec[] = [
name: 'Fujifilm Fortia SP',
group: 'Fujifilm',
temp: -4,
contrast: 20,
blacks: -10,
vibrance: 30,
saturation: 24,
contrast: 16,
blacks: -8,
vibrance: 22,
saturation: 16,
curve: SLIDE,
hsl: { green: { sat: 18 }, red: { sat: 20 }, blue: { sat: 16 }, magenta: { sat: 12 } },
grain: [6, 22],
@@ -687,9 +704,9 @@ const FILM_PACK: FilmSpec[] = [
name: 'Agfa Ultra 100',
group: 'Agfa',
temp: 4,
contrast: 14,
vibrance: 20,
saturation: 26,
contrast: 10,
vibrance: 14,
saturation: 16,
curve: SLIDE,
hsl: { red: { sat: 18 }, blue: { sat: 12 }, green: { sat: 8 } },
grain: [8, 24],
@@ -765,9 +782,9 @@ const FILM_PACK: FilmSpec[] = [
name: 'Lomography Color Negative 100',
group: 'Lomography',
temp: 6,
contrast: 18,
vibrance: 20,
saturation: 14,
contrast: 14,
vibrance: 14,
saturation: 8,
curve: SLIDE,
hsl: { green: { sat: 14 }, blue: { sat: 10 }, red: { sat: 8 } },
grade: { shadows: [220, 10], highlights: [45, 6] },
+12
View File
@@ -2381,6 +2381,18 @@ figcaption {
.field-row .field.narrow { flex: 0 0 96px; }
.cloud-modal { width: 520px; }
.immich-modal { width: 640px; }
.immich-intro { margin: 0 0 14px; max-width: 60ch; }
.immich-progress {
bottom: 64px;
min-width: min(320px, calc(100vw - 32px));
display: flex;
flex-direction: column;
align-items: stretch;
gap: 6px;
}
.immich-progress-head { display: flex; justify-content: space-between; gap: 18px; }
.new-event-gallery { flex: 1 0 100%; margin-top: 4px; }
.cloud-offline strong { display: block; margin-bottom: 6px; }
.code-block {
background: #16161a;
+9
View File
@@ -268,6 +268,8 @@ export interface PhotoRecord {
previewUrl?: string;
/** server URL for the grid thumbnail */
thumbUrl?: string;
/** set when this photo was imported from an Immich album */
immich?: { albumId: string; assetId: string; checksum: string };
/** timestamp of the last rendered client proof published to the server */
proofAt?: number;
/** Account this cached record belongs to (server workspaces). */
@@ -289,6 +291,13 @@ export interface EventRecord {
order?: number;
/** Account this cached record belongs to (server workspaces). */
workspace?: string;
/** Set when this event mirrors an Immich album. */
immich?: {
albumId: string;
albumName: string;
serverUrl: string;
lastSyncAt: number;
};
/** Set when this event is a temporary import from the dashboard bridge. */
bridge?: {
sessionId: string;