Skip to content

Conversation

@pixelsama
Copy link
Contributor

Important

  1. Read CONTRIBUTING.md
  2. Ensure issue exists and you're assigned
  3. Link correctly: Fixes #<issue number>

What & Why

What: Add core business logic and React hook for content image uploads

Why: Building on PR #278's storage infrastructure, this PR implements the service layer that handles image validation, upload, deletion, and state management. This provides reusable and type-safe APIs for the image upload dialog (PR #3) and content editor integration (PR #4).

Related to #250

Pre-PR Checklist

Run these:

  • pnpm type-check
  • pnpm format:check
  • pnpm lint
  • pnpm build
  • pnpm i18n:check (if applicable - N/A)

Type

  • 🐛 Bug fix
  • ✨ Feature
  • 💥 Breaking change
  • 📚 Docs
  • ♻️ Refactor
  • ⚡ Performance

Screenshots (if UI changes)

N/A - This PR adds backend service layer only (no UI changes)

Add core business logic for content image uploads:

Service Layer (lib/services/content-image-upload-service.ts):
- validateImageFile(): Validate file type (JPEG, PNG, WebP, GIF) and size (10MB max)
- generateContentImagePath(): Generate unique file paths (user-{userId}/{timestamp}-{uuid}.ext)
- uploadContentImage(): Upload images to content-images bucket
- deleteContentImage(): Delete images from storage
- listUserContentImages(): List user's uploaded images
- extractFilePathFromUrl(): Extract file path from Supabase URLs

Hook Layer (lib/hooks/use-content-image-upload.ts):
- useContentImageUpload(): React hook for state management
- State management: loading, error, progress tracking
- Operations: uploadImage, deleteImage, validateFile, resetState
- Type-safe interfaces for state and results

Technical Details:
- Bucket: content-images (created in PR ifLabX#278)
- Max file size: 10MB
- Supported formats: JPEG, JPG, PNG, WebP, GIF
- Path structure: user-{userId}/{timestamp}-{uuid}.{ext}
- Cache control: 3600s
- Follows existing pattern from use-avatar-upload.ts

Related to ifLabX#250

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Sep 30, 2025

@pixelsama is attempting to deploy a commit to the zhang's projects Team on Vercel.

A member of the Team first needs to authorize it.

@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Sep 30, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @pixelsama, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request establishes the foundational service layer and a corresponding React hook for managing content image uploads. It builds upon existing storage infrastructure to provide robust image validation, seamless uploading, deletion, and state management. This new functionality offers reusable and type-safe APIs, paving the way for future UI integrations such as image upload dialogs and content editor enhancements.

Highlights

  • New React Hook for Image Uploads: Introduced useContentImageUpload hook for managing the state and operations related to content image uploads and deletions, including progress tracking, error handling, and status updates.
  • Dedicated Image Upload Service: Added content-image-upload-service which encapsulates core business logic for image management, including file type and size validation, unique path generation, and direct interaction with Supabase Storage for uploading, deleting, and listing images.
  • Image Validation: Implemented client-side validation for image files, checking against allowed MIME types (JPEG, JPG, PNG, WebP, GIF) and a maximum file size of 10MB before upload.
  • Supabase Storage Integration: The service layer provides functions to interact with Supabase Storage for secure and efficient handling of content images, including generating unique file paths and retrieving public URLs.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@dosubot dosubot bot added area:api API integration, request/response handling, SSE. type:feature Request for a brand-new capability. labels Sep 30, 2025
Copy link
Contributor

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

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 introduces a service and a hook for handling content image uploads, which is a great addition. The code is well-structured and covers validation, upload, and deletion. I've identified a few areas for improvement to enhance robustness and maintainability. My main suggestions are to make file extension generation more reliable by using MIME types, remove redundant validation logic from the hook, and simplify the hook's state management to prevent potential inconsistencies. Overall, this is a solid implementation.

…eration

- Remove redundant validation in useContentImageUpload hook (service layer handles it)
- Add MIME type to file extension mapping for reliable extension extraction
- Update generateContentImagePath to accept MIME type parameter
- Keep validateFile export for UI-level validation needs

Addresses code review feedback from PR ifLabX#283
@lyzno1 lyzno1 merged commit c3004b6 into ifLabX:main Oct 2, 2025
13 of 14 checks passed
@dosubot dosubot bot added the lgtm Looks good to me; approved by a reviewer. label Oct 2, 2025
pixelsama added a commit to pixelsama/AgentifUI that referenced this pull request Oct 2, 2025
- Create ImageUploadDialog with file picker and drag-drop support
- Add upload progress indicator and image preview
- Integrate use-content-image-upload hook from PR ifLabX#283
- Add i18n translations for upload UI (en-US)

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

Labels

area:api API integration, request/response handling, SSE. lgtm Looks good to me; approved by a reviewer. size:L This PR changes 100-499 lines, ignoring generated files. type:feature Request for a brand-new capability.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants