You are already running inside the megaplan harness for this step. Do the requested planning/review/execution work directly. Do NOT invoke the megaplan CLI, do NOT read or activate the megaplan skill, do NOT start nested megaplan plans, and do NOT recurse into another planning harness. Treat mentions of megaplan in the repository or environment as implementation context only.
WRITE ACCESS CONTRACT: You are running with auto-approved writes inside a writable workspace. Treat the working directory as fully writable. Do NOT preemptively skip or block tasks on permission, sandbox, or read-only grounds. Attempt every required edit; only report failure AFTER a real OS-level rejection from a specific shell command. Do not infer 'read-only' from absence of activity; absence is not denial. If a single shell command unexpectedly fails, retry with a different invocation before concluding the environment is restricted.
You are creating an implementation plan for the following idea.
code
Idea:
Wire timeline drop to use the existing local-file-handle flow
Read CLAUDE.md at the repo root first — it has cross-cutting rules and points to relevant sub-docs.
Problem
When a user drops a large file onto the timeline, it always uploads to Supabase Storage. It should instead use the existing local-file-handle flow (storage_mode='local' + local_handle_id, served via useLocalMediaUrl() with LocalMediaPermissionOverlay as the recovery UX) — the same way the gallery's useDropToGeneration already works for large files.
What already exists (do NOT rebuild)
Local-handle write path: src/shared/lib/media/createGenerationFromFile.ts — createGenerationForLocalFile() writes storage_mode='local' + local_handle_id and persists the handle via saveHandle() from src/shared/lib/media/localHandleStore.ts.
Threshold + browser-capability gate: src/features/gallery/hooks/useDropToGeneration.ts checks file size against IMAGE_INLINE_UPLOAD_LIMIT_BYTES from src/shared/lib/media/dropToGenerationConfig.ts AND that DataTransferItem.getAsFileSystemHandle() is available. Use the same gate.
Resolver + permission UX: useLocalMediaUrl() in src/shared/media/localMediaResolver.ts and LocalMediaPermissionOverlay.tsx already handle rendering + recovery — no changes needed there.
Assistant
I've drafted a 6-step plan. Highlights:
Step 1: synchronous handle capture in useUnifiedDrop.handleDrop (kicks off getAsFileSystemHandle() promises before any await).
Step 2: extends FileDropHandler and the local onFileDrop types with an optional 3rd handles arg (no breakage for non-timeline callers — Plus button, trailing-frame, file input).
Step 3: useDropActions.handleTimelineImageDrop re-aligns handles to processed files via reference equality after cropImagesToShotAspectRatio, then forwards via ExternalImageDropVariables.handles.
Step 4: processDroppedImages re-aligns again after cropFilesIfNeeded, and processSingleDroppedImage branches on size ≥ IMAGE_INLINE_UPLOAD_LIMIT_BYTES && handle != null → createGenerationForLocalFile, else upload as today.
Step 5: tests for both branches in plus a case for crop-replaced-file → handle nulled.
User
What's broken
The timeline drop pipeline is a separate, older path that never got updated:
Drop handler chain ends at useDropActions.handleTimelineImageDrop → calls processDroppedImages in src/shared/hooks/shots/externalImageDrop.ts.
processDroppedImages only receives File[]. It calls processSingleDroppedImage, which unconditionally calls createGenerationForUploadedImage. No size check, no getAsFileSystemHandle() probe, no local branch.
There is also an intermediate chain of timeline drop hooks (in the travel-between-images tool) that strips/discards DataTransferItem info before it reaches useDropActions. Those hooks must be updated to capture and forward handles.
The fix
Capture the FileSystemFileHandle synchronously at the timeline drop event boundary. The DataTransferItem.getAsFileSystemHandle() call MUST happen synchronously inside the drop handler (or its returned promises captured before any await), because DataTransferItem is invalidated after the event resolves. Look at how useDropToGeneration does this and replicate the pattern.
Thread an optional FileSystemFileHandle | null array through the timeline drop hooks → useDropActions.handleTimelineImageDrop → ExternalImageDropVariables → processDroppedImages → processSingleDroppedImage. The new array is parallel to imageFiles. Make it optional so non-timeline callers aren't broken.
Branch in processSingleDroppedImage using the same gate as useDropToGeneration — file size ≥ IMAGE_INLINE_UPLOAD_LIMIT_BYTES AND a handle is present. When the gate passes, call createGenerationForLocalFile. Otherwise keep current behavior (createGenerationForUploadedImage).
Crop interaction (important): cropFilesIfNeeded may return a newFile for a given input. If it did, the captured handle no longer corresponds to the bytes you're storing — fall back to upload in that case. Use reference equality (processedFile === originalFile) to detect this.
Don't break callers. The new param is optional. Other callers of processDroppedImages (batch drop, app-level drop, shot-creation flows) keep current behavior unchanged because they don't supply handles.
Constraints
Don't refactor unrelated code. Don't add new abstractions. Don't add comments explaining the change.
Reuse existing helpers from useDropToGeneration if possible (e.g. the supportsLocalFileHandles() probe pattern). Keep the gate condition identical to what the gallery uses so behavior stays consistent.
The local_handle_id is a UUID generated client-side and is the link between the DB row and the IndexedDB-persisted handle. Mirror exactly how the gallery flow generates and stores it.
Tests
Mirror the patterns in src/features/gallery/hooks/useDropToGeneration.test.tsx and the existing src/shared/hooks/shots/externalImageDrop.test.ts (if present).
Add at least two cases on the externalImageDrop side: (a) large file + handle → local-handle path is taken, (b) small file or no handle → upload path is taken.
Verification
Run npx tsc --noEmit -p tsconfig.app.json. Note: the codebase has pre-existing type errors. Your changes must not introduce new errors beyond the pre-existing pattern that already affects useDropToGeneration.ts (FileSystemFileHandle missing queryPermission/requestPermission lib types).
Run vitest on the affected directories: src/shared/hooks/shots, src/features/gallery/hooks, and any timeline-drop hook directory you modify.
Deliverables
All changed files with the wiring in place.
New/updated tests covering both branches.
A short note in your final summary listing every caller of processDroppedImages and confirming each one still works.
code
Project directory:
/Users/user_c042661f/Documents/reigh-workspace/.megaplan-worktrees/timeline-local-handle-20260505/all-claude
No prior clarification artifact exists. Identify ambiguities, ask clarifying questions, and state your assumptions inside the plan output.
Requirements:
- If the engineering brief suggests an approach, use it as your starting hypothesis — but before committing, consider if there's a simpler or more fundamental fix. The brief is well-researched input, not a final answer.
- If the brief is absent, incomplete, or says "skip", inspect the repository yourself before planning.
- Stay focused on the requested idea. If repo exploration surfaces unrelated issues or docs, ignore them and return to the task.
- Prefer source code, tests, and directly relevant config files. Avoid `.megaplan/`, prior plan artifacts, and unrelated `docs/` or ops/deployment material unless the task explicitly depends on them.
- Stop exploring once you have enough evidence to name the concrete touch points and validation path. Do not keep browsing after you can write the plan.
- Produce a concrete implementation plan in markdown.
- Define observable success criteria as objects with `criterion` (string) and `priority` (`must`, `should`, or `info`):
- `must` — hard gate. The reviewer will block on failure. Use for correctness, functional requirements, and verifiable outcomes (e.g., "all existing tests pass", "API returns 200 for valid input"). Every `must` criterion must have a clear yes/no answer.
- `should` — quality target. The reviewer flags but does not block. Use for subjective goals, numeric guidelines, and best-effort improvements (e.g., "file under ~300 lines", "no deeply nested conditionals", "each function has a single responsibility").
- `info` — documented for humans, reviewer skips. Use for criteria that cannot be verified in this pipeline (e.g., "13 manual smoke tests pass", "stakeholder sign-off obtained").
- Each success criterion should include a `requires` field listing the capabilities needed for verification. Valid capability strings: `run_shell`, `read_files`, `run_tests`, `parse_diff`, `read_build_output`, `run_linter` (container), `drive_browser`, `inspect_runtime_ui`, `observe_runtime_logs`, `subjective_judgment`, `verify_physical_device` (human). `must` criteria MUST have non-empty `requires`. Example: `{"criterion": "All tests pass", "priority": "must", "requires": ["run_tests"]}`.
- Use the `questions` field for ambiguities that would materially change implementation.
- Use the `assumptions` field for defaults you are making so planning can proceed now.
- Prefer cheap validation steps early.
- Keep the plan proportional to the task. A 1-line fix needs a 2-step plan (apply fix + run tests), not a 5-step investigation.
- If user notes answer earlier questions, incorporate them into the draft plan instead of re-asking them.
- Fix the problem fully. Do not limit scope just to avoid breaking existing tests — update the tests too if needed.
- Prefer the simplest, most direct fix. No fallbacks, type conversions, or defensive wrappers without concrete evidence they are needed.
- If the task or issue hints suggest a specific approach, follow it. Only deviate with concrete counter-evidence.
Plan template — simple format (adapt to the actual repo and scope):
md
# Implementation Plan: [Title]
## Overview
Summarize the goal, current repository shape, and the constraints that matter.
## Main Phase
### Step 1: Audit the current behavior (`megaplan/prompts.py`)
**Scope:** Small
1. **Inspect** the current implementation and call out the exact insertion points (`megaplan/prompts.py:29`).
### Step 2: Add the first change (`megaplan/evaluation.py`)
**Scope:** Medium
1. **Implement** the smallest viable change with exact file references (`megaplan/evaluation.py:1`).
2. **Capture** any tricky behavior with a short example.
```python
issues = validate_plan_structure(plan_text)
```
### Step 3: Wire downstream behavior (`megaplan/handlers.py`, `megaplan/workers.py`)
**Scope:** Medium
1. **Update** the runtime flow in the touched files (`megaplan/handlers.py:400`, `megaplan/workers.py:199`).
### Step 4: Prove the change (`tests/test_evaluation.py`, `tests/test_megaplan.py`)
**Scope:** Small
1. **Run** the cheapest targeted checks first (`tests/test_evaluation.py:1`).
2. **Finish** with broader verification once the wiring is in place (`tests/test_megaplan.py:1`).
## Execution Order
1. Update prompts and mocks before enforcing stricter validation.
2. Land higher-risk wiring after the validator and tests are ready.
## Validation Order
1. Start with focused unit tests.
2. Run the broader suite after the flow changes are in place.
For complex plans, use multiple phases:
md
## Phase 1: Foundation — Dependencies, DB, Types
### Step 1: Install dependencies (`package.json`)
...
### Step 2: Create database migration (`supabase/migrations/`)
...
## Phase 2: Core Integration
### Step 3: Port the main component (`src/components/`)
...
Template guidance:
Simple plans: use ## Main Phase with ### Step N: sections underneath.
Complex plans: use multiple ## Phase N: sections, each containing ### Step N: steps. Step numbers are global (not per-phase).
The flat ## Step N: format (without phases) also works for backwards compatibility.
Key invariants: one H1 title, one ## Overview, numbered step sections (### Step N: or ## Step N:), and at least one ordering section.
externalImageDrop.test.ts
useDropActions.test.ts
Step 6: targeted vitest first, then directory sweep, then tsc --noEmit.
Caller audit confirms App.tsx, ShotListView.tsx, useModalImageHandlers.ts, and shot-creation paths don't supply handles and remain on the upload path. Three clarifying questions called out (images-only scope, silent fallback on crop, Plus-button uploads regardless of size).
You are already running inside the megaplan harness for this step. Do the requested planning/review/execution work directly. Do NOT invoke the megaplan CLI, do NOT read or activate the megaplan skill, do NOT start nested megaplan plans, and do NOT recurse into another planning harness. Treat mentions of megaplan in the repository or environment as implementation context only.
WRITE ACCESS CONTRACT: You are running with auto-approved writes inside a writable workspace. Treat the working directory as fully writable. Do NOT preemptively skip or block tasks on permission, sandbox, or read-only grounds. Attempt every required edit; only report failure AFTER a real OS-level rejection from a specific shell command. Do not infer 'read-only' from absence of activity; absence is not denial. If a single shell command unexpectedly fails, retry with a different invocation before concluding the environment is restricted.
You are revising an implementation plan after critique and gate feedback.
Wire timeline drop to use the existing local-file-handle flow
Read CLAUDE.md at the repo root first — it has cross-cutting rules and points to relevant sub-docs.
Problem
When a user drops a large file onto the timeline, it always uploads to Supabase Storage. It should instead use the existing local-file-handle flow (storage_mode='local' + local_handle_id, served via useLocalMediaUrl() with LocalMediaPermissionOverlay as the recovery UX) — the same way the gallery's useDropToGeneration already works for large files.
What already exists (do NOT rebuild)
Local-handle write path: src/shared/lib/media/createGenerationFromFile.ts — createGenerationForLocalFile() writes storage_mode='local' + local_handle_id and persists the handle via saveHandle() from src/shared/lib/media/localHandleStore.ts.
Threshold + browser-capability gate: src/features/gallery/hooks/useDropToGeneration.ts checks file size against IMAGE_INLINE_UPLOAD_LIMIT_BYTES from src/shared/lib/media/dropToGenerationConfig.ts AND that DataTransferItem.getAsFileSystemHandle() is available. Use the same gate.
Resolver + permission UX: useLocalMediaUrl() in src/shared/media/localMediaResolver.ts and LocalMediaPermissionOverlay.tsx already handle rendering + recovery — no changes needed there.
What's broken
The timeline drop pipeline is a separate, older path that never got updated:
Drop handler chain ends at useDropActions.handleTimelineImageDrop → calls processDroppedImages in src/shared/hooks/shots/externalImageDrop.ts.
processDroppedImages only receives File[]. It calls processSingleDroppedImage, which unconditionally calls createGenerationForUploadedImage. No size check, no getAsFileSystemHandle() probe, no local branch.
There is also an intermediate chain of timeline drop hooks (in the travel-between-images tool) that strips/discards DataTransferItem info before it reaches useDropActions. Those hooks must be updated to capture and forward handles.
The fix
Capture the FileSystemFileHandle synchronously at the timeline drop event boundary. The DataTransferItem.getAsFileSystemHandle() call MUST happen synchronously inside the drop handler (or its returned promises captured before any await), because DataTransferItem is invalidated after the event resolves. Look at how useDropToGeneration does this and replicate the pattern.
Thread an optional FileSystemFileHandle | null array through the timeline drop hooks → useDropActions.handleTimelineImageDrop → ExternalImageDropVariables → processDroppedImages → processSingleDroppedImage. The new array is parallel to imageFiles. Make it optional so non-timeline callers aren't broken.
Branch in processSingleDroppedImage using the same gate as useDropToGeneration — file size ≥ IMAGE_INLINE_UPLOAD_LIMIT_BYTES AND a handle is present. When the gate passes, call createGenerationForLocalFile. Otherwise keep current behavior (createGenerationForUploadedImage).
Crop interaction (important): cropFilesIfNeeded may return a newFile for a given input. If it did, the captured handle no longer corresponds to the bytes you're storing — fall back to upload in that case. Use reference equality (processedFile === originalFile) to detect this.
Don't break callers. The new param is optional. Other callers of processDroppedImages (batch drop, app-level drop, shot-creation flows) keep current behavior unchanged because they don't supply handles.
Constraints
Don't refactor unrelated code. Don't add new abstractions. Don't add comments explaining the change.
Reuse existing helpers from useDropToGeneration if possible (e.g. the supportsLocalFileHandles() probe pattern). Keep the gate condition identical to what the gallery uses so behavior stays consistent.
The local_handle_id is a UUID generated client-side and is the link between the DB row and the IndexedDB-persisted handle. Mirror exactly how the gallery flow generates and stores it.
Tests
Mirror the patterns in src/features/gallery/hooks/useDropToGeneration.test.tsx and the existing src/shared/hooks/shots/externalImageDrop.test.ts (if present).
Add at least two cases on the externalImageDrop side: (a) large file + handle → local-handle path is taken, (b) small file or no handle → upload path is taken.
Verification
Run npx tsc --noEmit -p tsconfig.app.json. Note: the codebase has pre-existing type errors. Your changes must not introduce new errors beyond the pre-existing pattern that already affects useDropToGeneration.ts (FileSystemFileHandle missing queryPermission/requestPermission lib types).
Run vitest on the affected directories: src/shared/hooks/shots, src/features/gallery/hooks, and any timeline-drop hook directory you modify.
Deliverables
All changed files with the wiring in place.
New/updated tests covering both branches.
A short note in your final summary listing every caller of processDroppedImages and confirming each one still works.
code
Current plan (markdown):
Implementation Plan: Wire Timeline Drop to the Local-File-Handle Flow
Overview
The timeline drop path (useUnifiedDrop → useDropActions.handleTimelineImageDrop → useHandleExternalImageDrop mutation → processDroppedImages → processSingleDroppedImage → createGenerationForUploadedImage) unconditionally uploads to Supabase Storage and never captures FileSystemFileHandles. The gallery drop path (useDropToGeneration) already implements the local-handle flow against the same IMAGE_INLINE_UPLOAD_LIMIT_BYTES gate, calling createGenerationForLocalFile for large images.
We will: (1) capture handles synchronously at the timeline drop event, (2) thread an optional Array<FileSystemFileHandle | null> parallel to imageFiles through the timeline pipeline into processDroppedImages/processSingleDroppedImage, and (3) reuse the useDropToGeneration gate (size ≥ IMAGE_INLINE_UPLOAD_LIMIT_BYTES AND a usable handle) to branch into createGenerationForLocalFile. All non-timeline callers of processDroppedImages (ShotListView, App.tsx, useModalImageHandlers, shot-creation flows) keep working because the new param is optional and defaults to absent → upload path.
The crop steps complicate things: useDropActions.handleTimelineImageDrop calls cropImagesToShotAspectRatiobefore invoking the mutation, and processDroppedImages then calls cropFilesIfNeeded again. Both can return newFiles. We use reference equality (processedFile === originalFile) at each crop boundary and null out the handle if the bytes diverged.
Constraints
New param everywhere is optional. No behavior change for callers that don't supply it.
Keep the gate logic identical to useDropToGeneration: file.size >= IMAGE_INLINE_UPLOAD_LIMIT_BYTES AND getAsFileSystemHandle() resolves to a kind-file handle with getFile.
Don't refactor unrelated code; don't add comments justifying the change.
Pre-existing tsc error in useDropToGeneration.ts (FileSystemFileHandle missing queryPermission/requestPermission lib types) is acceptable to mirror.
Main Phase
Step 1: Capture handles at the drop boundary (src/tools/travel-between-images/components/Timeline/hooks/drag/useUnifiedDrop.ts)
Scope: Small
ExtendUseUnifiedDropProps.onFileDrop to accept an optional 3rd argument: handles?: Array<FileSystemFileHandle | null> (useUnifiedDrop.ts:18).
In handleDrop, in the file-drop branch, synchronously snapshot e.dataTransfer.items filtered by kind === 'file' BEFORE any await, and immediately invoke getAsFileSystemHandle() on each (storing the returned promise). This matches the useDropToGeneration pattern (useDropToGeneration.ts:60-77) but kicks off the promises during the synchronous portion of the event handler:
Filter the parallel arrays together with filterValidTimelineImageFiles. Replace the existing validFiles = filterValidTimelineImageFiles(files) with a paired filter that retains handle promises only at indices whose file passed validation.
Resolve the handle promises (await Promise.all), guard with the same isReadableFileHandle check from the gallery hook (kind === 'file' && getFile present), and pass the resolved Array<FileSystemFileHandle | null> as the third arg to onFileDrop.
Add a small private helper supportsLocalFileHandles() mirroring useDropToGeneration.ts:41-44. If false, skip the getAsFileSystemHandle calls and pass undefined.
Step 2: Update FileDropHandler and propagate the optional handles arg through plumbing (src/shared/types/imageHandlers.ts, src/tools/travel-between-images/components/Timeline/TimelineContainer/components/{TimelineBottomControls,TimelineTrackPrelude,TimelineTrackContent,TimelineControls}.tsx, src/tools/travel-between-images/components/Timeline/TimelineContainer/TimelineContainer.tsx, src/tools/travel-between-images/components/Timeline/hooks/segment/useTrailingEndpoint.ts, src/tools/travel-between-images/components/Timeline/hooks/drag/useEmptyStateDrop.ts, src/tools/travel-between-images/components/ShotEditor/sections/TimelineSection.tsx, src/tools/travel-between-images/components/VideoGenerationModalSections.tsx, src/tools/travel-between-images/components/ShotEditor/hooks/editor-state/useShotSettingsValue.ts)
Mirror the same expanded signature on every locally-typed onFileDrop?: (files, targetFrame?) => Promise<void> declaration: useEmptyStateDrop.ts:13, useUnifiedDrop.ts:18, useTrailingEndpoint.ts:17, TimelineBottomControls.tsx:14, TimelineTrackPrelude.tsx:52. Existing callers that pass only (files) or (files, frame) keep compiling.
At intermediate forwarding points that already invoke onFileDrop(files, frame) (e.g. useTrailingEndpoint.ts:141, TimelineBottomControls.tsx:106 Plus button), leave call sites unchanged — the handles arg is optional so synthetic File sources (canvas blob, file input) correctly fall through to upload path.
In useShotSettingsValue.ts:210-212, update the onFileDrop wrapper to accept and forward the third arg:
Step 3: Wire through useDropActions.handleTimelineImageDrop and re-align handles after the local crop step (src/tools/travel-between-images/components/ShotEditor/hooks/actions/useDropActions.ts)
PassalignedHandles into the mutation payload (useDropActions.ts:266-273) as a new handles? field on ExternalImageDropVariables.
Mirror the same signature on useGenerationActions.ts:61-79 (the wrapper that returns handleTimelineImageDrop) so the type flows up to useShotSettingsValue's GenerationActionsReturn interface (useShotSettingsValue.ts:33). Update that interface as well.
Step 4: Add the local-handle branch to processDroppedImages / processSingleDroppedImage (src/shared/hooks/shots/externalImageDrop.ts)
Scope: Medium
ExtendExternalImageDropVariables with handles?: Array<FileSystemFileHandle | null> (externalImageDrop.ts:9-17). Optional → batch/app/modal/shot-list callers need no change.
Re-align handles to processed files after cropFilesIfNeeded:
Pass the per-index handle into processSingleDroppedImage (externalImageDrop.ts:336-346) as a new optional handle arg.
Branch in processSingleDroppedImage (externalImageDrop.ts:248-310): if imageFile.size >= IMAGE_INLINE_UPLOAD_LIMIT_BYTES AND handle != null, call createGenerationForLocalFile({ file: imageFile, projectId, handle, mediaType: 'image' }) to produce the generation row. Otherwise keep the existing createGeneration(...) upload path. Pass the resulting generation into attachGenerationToShot unchanged. Note that the local path produces location: null and a real thumbnail_url — attachGenerationToShot already tolerates generation.location || undefined.
ImportcreateGenerationForLocalFile and IMAGE_INLINE_UPLOAD_LIMIT_BYTES in externalImageDrop.ts.
In externalImageDrop.test.ts add two cases mirroring the existing setup:
Large file + handle → local-handle path: mock createGenerationForLocalFile (mocked module @/shared/lib/media/createGenerationFromFile), pass a 26 MB file (Object.defineProperty(file, 'size', { value: 26*1024*1024 })) and a stub FileSystemFileHandle-shaped object with kind: 'file'. Assert createGenerationForLocalFile was called once and uploadImageWithThumbnail / createGenerationForUploadedImage was NOT.
Small file or no handle → upload path: assert the existing upload mocks still fire and createGenerationForLocalFile was NOT called. Cover both sub-cases (small-file-with-handle, large-file-without-handle).
In useDropActions.test.ts add a case verifying that handleTimelineImageDrop(files, frame, handles) forwards the handles array into handleExternalImageDropMutateAsyncMock and that, when cropImagesToShotAspectRatio returns a differentFile reference, the corresponding handle is nulled out before forwarding.
Step 6: Verify (terminal)
Scope: Small
Run the targeted suites first:
npx vitest run src/shared/hooks/shots/externalImageDrop.test.ts
npx vitest run src/tools/travel-between-images/components/ShotEditor/hooks/actions/__tests__/useDropActions.test.ts
npx vitest run src/features/gallery/hooks/useDropToGeneration.test.tsx
Run broader vitest on the touched directories:
npx vitest run src/shared/hooks/shots src/features/gallery/hooks src/tools/travel-between-images/components/Timeline
Runnpx tsc --noEmit -p tsconfig.app.json and confirm no NEW errors beyond the pre-existing FileSystemFileHandle.queryPermission/requestPermission pattern.
Execution Order
Add the optional handles plumbing types and the synchronous capture in useUnifiedDrop first — these are invisible until consumed.
Wire through useDropActions → ExternalImageDropVariables → processSingleDroppedImage next.
Add tests last so they exercise the full branch.
Validation Order
externalImageDrop.test.ts (cheapest unit-level check of the branch).
src/tools/travel-between-images/components/hooks/useModalImageHandlers.ts:33 — modal flow. No handles → upload path (unchanged).
Tests in src/shared/hooks/__tests__/useShotCreation.test.ts, src/shared/hooks/shots/__tests__/useShotCreation.test.ts, src/tools/travel-between-images/pages/ShotListView.test.tsx mock the mutation directly; no payload-shape change needed for them.
code
Current plan metadata:
{
"version": 1,
"timestamp": "2026-05-05T00:36:32Z",
"hash": "sha256:41141dfbef38ef81a28a4533a2c93d19d22049cbd8bcd4a20e5da7d98518791b",
"questions": [
"Should the local-handle branch be applied to videos in this iteration, or images only? The brief talks exclusively about images and IMAGE_INLINE_UPLOAD_LIMIT_BYTES, and the timeline pipeline currently filters for images via filterValidTimelineImageFiles (only JPEG/PNG/WebP), so videos won't reach processSingleDroppedImage. Assuming images-only.",
"When cropImagesToShotAspectRatio (or cropFilesIfNeeded) replaces a file, should we silently null the handle (chosen here, falls back to upload) or surface an info toast like the gallery does for browser-fallback cases? The brief says fall back to upload, no mention of UX message \u2014 assuming silent fallback.",
"The Plus-button file-input path in TimelineBottomControls.tsx cannot produce FileSystemFileHandles. OK that the Plus button continues to upload regardless of size (no behavioral regression, just no new optimization)? Assuming yes."
],
"success_criteria": [
{
"criterion": "Dropping an image \u2265 25 MB onto the timeline (with a browser that supports getAsFileSystemHandle) creates a generation row with storage_mode='local' and local_handle_id set, and does NOT upload the original file to Supabase Storage. Verified via the new externalImageDrop.test.ts case that createGenerationForLocalFile is called and upload mocks are not.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "Dropping a small image (or any image when no handle is captured) onto the timeline still goes through the existing upload path \u2014 (or its inner upload helpers) is invoked, is not.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "When or returns a new instance for a given input, the corresponding handle is nulled before reaching , so cropped files always go through the upload path. Verified by reference-equality test in and (optionally) .",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": "All existing tests still pass \u2014 , the existing cases in , the existing cases in , and the touched directory vitest sweep.",
"priority": "must",
"requires": [
"run_tests"
]
},
{
"criterion": " produces no NEW type errors beyond the pre-existing pattern already present in .",
"priority": "must",
"requires": [
"run_shell",
"read_build_output"
]
},
{
"criterion": "Non-timeline callers of ( app drop, , ) compile and behave identically \u2014 none supply , all keep using the upload path.",
"priority": "must",
"requires": [
"run_tests",
"read_files"
]
},
{
"criterion": "The calls are initiated synchronously inside (before any ), so handles survive past the event boundary.",
"priority": "must",
"requires": [
"read_files",
"parse_diff"
]
},
{
"criterion": "No new abstractions, helper modules, or comments justifying the change beyond what the brief requests; existing patterns (, , -style probe) are reused.",
"priority": "should",
"requires": [
"parse_diff",
"subjective_judgment"
]
},
{
"criterion": "Manual smoke: drop a >25 MB PNG on the timeline, confirm in the DB that + is populated and the gallery resolver renders it via .",
"priority": "info",
"requires": [
"inspect_runtime_ui"
]
}
],
"assumptions": [
"Images-only scope: timeline drop currently filters to JPEG/PNG/WebP via , so videos never reach ; no video branch is required.",
"When a crop step replaces the file, fall back silently to upload (no toast).",
"Plus-button file-input path () cannot capture handles and continues to use the upload path even for large files \u2014 no regression concern.",
"'s callers that pass synthetic Files (e.g. 's extracted frame) intentionally don't pass handles \u2192 upload path, which is correct.",
"The field on is parallel to after the timeline-side crop. Tests will use to simulate large files."
],
"structure_warnings": []
}
md
# Implementation Plan: [Title]
## Overview
Summarize the goal, current repository shape, and the constraints that matter.
## Main Phase
### Step 1: Audit the current behavior (`megaplan/prompts.py`)
**Scope:** Small
1. **Inspect** the current implementation and call out the exact insertion points (`megaplan/prompts.py:29`).
### Step 2: Add the first change (`megaplan/evaluation.py`)
**Scope:** Medium
1. **Implement** the smallest viable change with exact file references (`megaplan/evaluation.py:1`).
2. **Capture** any tricky behavior with a short example.
```python
issues = validate_plan_structure(plan_text)
```
### Step 3: Wire downstream behavior (`megaplan/handlers.py`, `megaplan/workers.py`)
**Scope:** Medium
1. **Update** the runtime flow in the touched files (`megaplan/handlers.py:400`, `megaplan/workers.py:199`).
### Step 4: Prove the change (`tests/test_evaluation.py`, `tests/test_megaplan.py`)
**Scope:** Small
1. **Run** the cheapest targeted checks first (`tests/test_evaluation.py:1`).
2. **Finish** with broader verification once the wiring is in place (`tests/test_megaplan.py:1`).
## Execution Order
1. Update prompts and mocks before enforcing stricter validation.
2. Land higher-risk wiring after the validator and tests are ready.
## Validation Order
1. Start with focused unit tests.
2. Run the broader suite after the flow changes are in place.
For complex plans, use multiple phases:
md
## Phase 1: Foundation — Dependencies, DB, Types
### Step 1: Install dependencies (`package.json`)
...
### Step 2: Create database migration (`supabase/migrations/`)
...
## Phase 2: Core Integration
### Step 3: Port the main component (`src/components/`)
...
Template guidance:
Simple plans: use ## Main Phase with ### Step N: sections underneath.
Complex plans: use multiple ## Phase N: sections, each containing ### Step N: steps. Step numbers are global (not per-phase).
The flat ## Step N: format (without phases) also works for backwards compatibility.
Key invariants: one H1 title, one ## Overview, numbered step sections (### Step N: or ## Step N:), and at least one ordering section.
"recommendation": "ITERATE",
"rationale": "Light robustness: single revision pass to incorporate critique feedback.",
"signals_assessment": "",
"warnings": [],
"settled_decisions": []
}
code
Open significant flags:
[]
Requirements:
- Before addressing individual flags, check: does any flag suggest the plan is targeting the wrong code or the wrong root cause? If so, consider whether the plan needs a new approach rather than adjustments. Explain your reasoning.
- Update the plan to address the significant issues.
- Keep the plan readable and executable.
- Return flags_addressed with the exact flag IDs you addressed.
- Include `changes_summary` as a short plain-English summary of what changed in the revision. If there were no concrete flags, say that explicitly (for example: `No critique flags were raised; refined wording and kept the plan aligned for execution.`).
- Preserve or improve success criteria quality. Each criterion must have a `priority` of `must`, `should`, or `info`. Promote or demote priorities if critique feedback reveals a criterion was over- or under-weighted.
- Each success criterion should include a `requires` field listing the capabilities needed for verification. Valid capability strings: `run_shell`, `read_files`, `run_tests`, `parse_diff`, `read_build_output`, `run_linter` (container), `drive_browser`, `inspect_runtime_ui`, `observe_runtime_logs`, `subjective_judgment`, `verify_physical_device` (human). `must` criteria MUST have non-empty `requires`. Example: `{"criterion": "All tests pass", "priority": "must", "requires": ["run_tests"]}`.
- Verify that the plan remains aligned with the user's original intent, not just internal plan quality.
- Remove unjustified scope growth. If critique raised scope creep, narrow the plan back to the original idea unless the broader work is strictly required.
- Maintain the structural template: H1 title, ## Overview, phase sections with numbered step sections, ## Execution Order or ## Validation Order.
- CRITICAL: Your entire revised plan markdown (all sections) must be output as the `plan` field in the structured output. The prose response must not contain the plan text.
- CRITICAL: Return only the structured JSON object for the schema fields `plan`, `changes_summary`, `flags_addressed`, `assumptions`, `success_criteria`, and `questions`. Do not add commentary before or after the JSON object.
Plan template — simple format (adapt to the actual repo and scope):