fix(journey): keep photo deletes out of the assistant and never let the capture reader block an upload

delete_journey_photos removes uploaded files for good and has no undo; its
generic approval card could only list ids, so the assistant is not offered it.
External MCP clients keep the tool.

A HEIC upload no longer fails when the lazily loaded capture reader cannot be
loaded: the photo goes up without its capture, as before. The upload schema's
doc comment is back on the schema it describes.
This commit is contained in:
Maurice
2026-11-30 14:46:20 +01:00
parent e59cd23e60
commit 535503b73d
5 changed files with 42 additions and 12 deletions
+10 -1
View File
@@ -1,4 +1,4 @@
// FE-W4HEIC-001 to FE-W4HEIC-010
// FE-W4HEIC-001 to FE-W4HEIC-011
import { describe, it, expect, vi, beforeEach } from 'vitest'
const isHeic = vi.fn(async (_f: File) => true)
@@ -117,4 +117,13 @@ describe('normalizeJourneyPhotos', () => {
expect(readHeicCapture).not.toHaveBeenCalled()
expect(captureFields(out)).toEqual([])
})
it('FE-W4HEIC-011: a reader that fails costs the capture, never the upload', async () => {
readHeicCapture.mockRejectedValue(new Error('chunk failed to load'))
const [out] = await normalizeJourneyPhotos([new File(['x'], 'c.heic')])
expect(out.name).toBe('c.jpg')
expect((out as CapturedFile).capture).toBeUndefined()
})
})
+16 -2
View File
@@ -1,3 +1,4 @@
import type { PhotoCapture } from './heicCapture'
import type { CapturedFile } from './photoCapture'
function looksLikeHeic(file: File): boolean {
@@ -23,6 +24,20 @@ export async function normalizeImageFile(file: File): Promise<File> {
return (await convertHeic(file)) ?? file
}
/**
* The HEIC's capture time and place, or null. The reader is a chunk of its own:
* when it cannot be loaded the photo still goes up, only without them.
*/
async function readCapture(file: File): Promise<PhotoCapture | null> {
try {
const { readHeicCapture } = await import('./heicCapture')
return await readHeicCapture(file)
} catch {
// A chunk that failed to load costs the capture, never the upload.
return null
}
}
/**
* A journey photo made ready to upload. A HEIC is converted like any other image,
* but its capture time and place are read first and travel on the converted file
@@ -32,8 +47,7 @@ export async function normalizeImageFile(file: File): Promise<File> {
*/
async function normalizeJourneyPhoto(file: File): Promise<CapturedFile> {
if (!looksLikeHeic(file)) return file
const { readHeicCapture } = await import('./heicCapture')
const capture = await readHeicCapture(file)
const capture = await readCapture(file)
const converted: CapturedFile | null = await convertHeic(file)
if (!converted) return file
if (capture) converted.capture = capture