Browse Source

docs(21): mark Gemini image-to-image issue as resolved

- Remove Task 1 (part ordering fix) - no longer needed
- Phase now focused on unifying MD5 hashing for deduplication
- 1 task remaining

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
handoff-20260429-1057
shrimbly 6 months ago
parent
commit
e73dce47cd
  1. 4
      .planning/ROADMAP.md
  2. 78
      .planning/phases/21-fix-image-input-deduplication/21-01-PLAN.md

4
.planning/ROADMAP.md

@ -271,12 +271,12 @@ Plans:
**Plans**: 1 plan **Plans**: 1 plan
**Issues:** **Issues:**
1. nano-banana-pro model generates without considering image inputs (image data sent but not used) 1. ~~nano-banana-pro model generates without considering image inputs~~ - RESOLVED (no longer an issue)
2. Input and generated images have duplicate files despite different hashes - need consistent hashing approach matching video saving 2. Input and generated images have duplicate files despite different hashes - need consistent hashing approach matching video saving
3. Generated images should be prepended with prompt details like generated videos 3. Generated images should be prepended with prompt details like generated videos
Plans: Plans:
- [ ] 21-01: Fix Gemini image-to-image part ordering and unify MD5 hashing - [ ] 21-01: Unify MD5 hashing for image deduplication
#### Phase 22: Generate Node Dynamic Input Tests #### Phase 22: Generate Node Dynamic Input Tests

78
.planning/phases/21-fix-image-input-deduplication/21-01-PLAN.md

@ -5,16 +5,15 @@ type: execute
--- ---
<objective> <objective>
Fix Gemini nano-banana-pro model ignoring image inputs and resolve duplicate image saving across input/generated images. Resolve duplicate image saving across input/generated images by unifying the hashing approach.
Purpose: Ensure image-to-image generation works correctly with Gemini and that the deduplication system consistently prevents duplicate files in the generations folder. Purpose: Ensure the deduplication system consistently prevents duplicate files in the generations folder by using the same hashing algorithm everywhere.
Output: Working image-to-image generation with Gemini Pro, consistent hashing across all image saving operations. Output: Consistent MD5 hashing across all image saving operations.
</objective> </objective>
<execution_context> <execution_context>
~/.claude/get-shit-done/workflows/execute-phase.md ~/.claude/get-shit-done/workflows/execute-phase.md
~/.claude/get-shit-done/templates/summary.md ~/.claude/get-shit-done/templates/summary.md
~/.claude/get-shit-done/references/checkpoints.md
</execution_context> </execution_context>
<context> <context>
@ -23,65 +22,28 @@ Output: Working image-to-image generation with Gemini Pro, consistent hashing ac
@.planning/STATE.md @.planning/STATE.md
# Key source files: # Key source files:
@src/app/api/generate/route.ts
@src/app/api/save-generation/route.ts @src/app/api/save-generation/route.ts
@src/utils/imageStorage.ts @src/utils/imageStorage.ts
# Prior phase with related hashing decision: # Prior phase with related hashing decision:
@.planning/phases/13-fix-duplicate-generations/13-01-SUMMARY.md @.planning/phases/13-fix-duplicate-generations/13-01-SUMMARY.md
**Tech stack available:** Next.js 16, Zustand, @google/genai SDK **Tech stack available:** Next.js 16, Zustand
**Established patterns:** MD5 content hashing for deduplication (Phase 13) **Established patterns:** MD5 content hashing for deduplication (Phase 13)
**Issues being addressed:** **Issues being addressed:**
1. nano-banana-pro model generates without considering image inputs (image data sent but not used) 1. ~~nano-banana-pro model generates without considering image inputs~~ - RESOLVED (no longer an issue)
2. Input and generated images have duplicate files despite different hashes - need consistent hashing approach 2. Input and generated images have duplicate files despite different hashes - need consistent hashing approach
3. Generated images should be prepended with prompt details like generated videos
**Research findings:** **Root cause:**
- Gemini SDK docs show that for image editing, the order matters: image should come BEFORE text in the parts array
- Current implementation sends [text, ...images] but should send [...images, text] for image-to-image
- imageStorage.ts uses position-based sampling hash while save-generation uses MD5 - these are incompatible - imageStorage.ts uses position-based sampling hash while save-generation uses MD5 - these are incompatible
- Same image saved via different code paths gets different hashes
</context> </context>
<tasks> <tasks>
<task type="auto"> <task type="auto">
<name>Task 1: Fix Gemini image-to-image part ordering</name> <name>Task 1: Unify image hashing to MD5 across all save operations</name>
<files>src/app/api/generate/route.ts</files>
<action>
In generateWithGemini(), change the requestParts array construction to place images BEFORE text prompt. The Gemini SDK documentation shows image editing works with [inlineData, text] order, not [text, inlineData].
Current code (around line 59):
```
const requestParts = [
{ text: prompt }, // Text first - WRONG for image-to-image
...imageData.map(...) // Images second
];
```
Change to:
```
const requestParts = [
...imageData.map(...) // Images first - correct for image editing
{ text: prompt }, // Text second
];
```
WHY: Gemini's image generation models treat the first content type as primary input. For text-to-image, text should be first. For image-to-image (editing), images should be first so the model knows it's modifying existing images.
IMPORTANT: Only reorder when images are present. If no images, text should still be the only part.
</action>
<verify>
Build succeeds with `npm run build`. Manual test: Create workflow with ImageInput → GenerateImage (nano-banana-pro) → Output, connect an image, add prompt like "make it blue", run workflow. Output should visually reference the input image.
</verify>
<done>
When images are connected to a Gemini GenerateImage node, the generated output incorporates/transforms the input image based on the prompt.
</done>
</task>
<task type="auto">
<name>Task 2: Unify image hashing to MD5 across all save operations</name>
<files>src/utils/imageStorage.ts</files> <files>src/utils/imageStorage.ts</files>
<action> <action>
Replace the position-based sampling hash in imageStorage.ts with MD5 content hashing (matching save-generation/route.ts pattern). Replace the position-based sampling hash in imageStorage.ts with MD5 content hashing (matching save-generation/route.ts pattern).
@ -111,41 +73,19 @@ imageStorage.ts uses MD5 hashing, consistent with save-generation API. Same imag
</done> </done>
</task> </task>
<task type="checkpoint:human-verify" gate="blocking">
<what-built>
Fixed Gemini image-to-image generation (part ordering) and unified MD5 hashing for deduplication.
</what-built>
<how-to-verify>
1. Run: `npm run dev`
2. Create a new workflow with:
- ImageInput node (load any test image)
- GenerateImage node (select nano-banana-pro model)
- Prompt node with text like "add a sunset background" or "make it black and white"
- Output node
3. Connect: ImageInput → GenerateImage (image handle), Prompt → GenerateImage (text handle)
4. Run the workflow
5. Verify: The generated image should visually show the transformation applied to the input image (not a completely new unrelated image)
6. Check generations folder: No duplicate files for the same generated content
</how-to-verify>
<resume-signal>Type "approved" if image-to-image works correctly, or describe issues</resume-signal>
</task>
</tasks> </tasks>
<verification> <verification>
Before declaring phase complete: Before declaring phase complete:
- [ ] `npm run build` succeeds without errors - [ ] `npm run build` succeeds without errors
- [ ] `npm test` passes all existing tests - [ ] `npm test` passes all existing tests
- [ ] Gemini image-to-image generation produces output that transforms the input image
- [ ] No TypeScript errors in modified files - [ ] No TypeScript errors in modified files
</verification> </verification>
<success_criteria> <success_criteria>
- All tasks completed - Task completed
- All verification checks pass - All verification checks pass
- Image-to-image generation with nano-banana-pro produces visually related output
- Deduplication uses consistent MD5 hashing across all image save paths - Deduplication uses consistent MD5 hashing across all image save paths
- No regression in text-to-image generation (still works when no image connected)
</success_criteria> </success_criteria>
<output> <output>

Loading…
Cancel
Save