Skip to content

feat/image-generation - #1078

Draft
sedanah-m wants to merge 6 commits into
masterfrom
image-generation
Draft

feat/image-generation#1078
sedanah-m wants to merge 6 commits into
masterfrom
image-generation

Conversation

@sedanah-m

@sedanah-m sedanah-m commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Adds an image-generation feature to ai-samples, covering all 4 capabilities from the Firebase AI Logic docs: text-to-image, interleaved text + image, single-turn image editing, and iterative multi-turn editing via chat.

@sedanah-m sedanah-m changed the title Implement Image-Generation feat/image-generation Aug 11, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements an image generation and iterative editing feature using Firebase AI. It introduces a React component (ImageGenerationView) for the UI and a service file (service.ts) to handle chat sessions, image generation, and multi-turn image editing with the Gemini model. The review feedback suggests adding a loading guard to prevent duplicate submissions, resolving an incomplete TODO comment, and improving the robustness of Base64 extraction from file uploads.

Comment thread ai/ai-samples/src/features/image-generation/index.tsx
Comment thread ai/ai-samples/src/features/image-generation/index.tsx Outdated
Comment thread ai/ai-samples/src/features/image-generation/service.ts Outdated

@rafikhan rafikhan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor feedback.

Comment thread ai/ai-samples/src/features/image-generation/service.ts Outdated
prompt: string,
file?: File
): Promise<ImageGenerationResult> {
const messagePayload: (string | Part)[] = [prompt];

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick tip on TypeScript style: you can omit the explicit (string | Part)[] type definition here. Since you're initializing the array inline with [prompt], TypeScript's type inference engine can infer that this is a string[].

As a general rule of thumb, letting the compiler infer types when initializing variables keeps our code cleaner and reduces boilerplate. We only need to explicitly write the type if we plan to push non-string Part objects into this array later in the execution flow.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this comment. Context for follow up question - I kept the explicit (string | Part) [] since I push a non-string object later in the same function. Specifically, messagePayload.push(awaitfileToGenerativePart(file)) a few lines down pushes a Part and not a string. I believe if I omit the annotation, ts would infer the string[] from [prompt] alone and that .push() call would fail to compile. Would your comment still apply? LMK what you think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants