Skip to content

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Supabase storage upload updates. Remove dead workspaces route.

Type of Change

  • Bug fix

Testing

Tested with @Sg312

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Jan 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
docs Skipped Skipped Jan 25, 2026 9:22pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 25, 2026

Greptile Overview

Greptile Summary

This PR refactors the Supabase storage upload functionality to support both basic and advanced modes. The main changes include:

  • New API endpoint: Created /api/tools/supabase/storage-upload to handle file uploads server-side with intelligent base64 detection and support for both UserFile objects (basic mode) and string content (advanced mode)
  • Basic/Advanced mode toggle: Added canonicalParamId linking between file (file-upload, basic mode) and fileContent (code input, advanced mode) fields in the Supabase block configuration
  • Parameter rename: Changed fileContent to fileData in the tool definition to support both file objects and string content
  • Canonical mode fix: Updated collaborativeSetBlockCanonicalMode to apply state changes immediately before queuing, preventing UI desync issues
  • Operation queue improvement: Added automatic operation processing trigger when emit functions are registered with a workflowId
  • React.memo optimization: Fixed canonicalToggle comparison to properly handle undefined values
  • Cleanup: Removed unused /api/organizations/[id]/workspaces route

The implementation follows established patterns for file handling and includes comprehensive logging throughout the upload flow.

Confidence Score: 4/5

  • This PR is safe to merge with minor style improvements recommended
  • The changes are well-structured and address the stated goals. The new API endpoint has proper authentication, validation, and error handling. The canonical mode fix prevents UI desync issues. One minor style suggestion was made regarding base64 size calculation accuracy, but this doesn't affect functionality.
  • No files require special attention - all changes follow established patterns and include proper error handling

Important Files Changed

Filename Overview
apps/sim/app/api/tools/supabase/storage-upload/route.ts New API endpoint for Supabase storage uploads with base64 detection and file handling
apps/sim/tools/supabase/storage_upload.ts Updated tool config to route through internal API and renamed fileContent to fileData
apps/sim/blocks/blocks/supabase.ts Added basic/advanced mode toggle for file upload with separate fields for file-upload and code input
apps/sim/hooks/use-collaborative-workflow.ts Fixed canonical mode updates to apply immediately and queue operation, preventing desync issues

Sequence Diagram

sequenceDiagram
    participant User
    participant UI as Supabase Block UI
    participant Tool as storage_upload.ts
    participant API as /api/tools/supabase/storage-upload
    participant FileUtils as File Utils
    participant Supabase as Supabase Storage

    User->>UI: Select mode (basic/advanced)
    
    alt Basic Mode
        User->>UI: Upload file via file-upload field
        UI->>Tool: fileData = UserFile object
    else Advanced Mode
        User->>UI: Enter content in code field
        UI->>Tool: fileData = string (base64/text)
    end

    Tool->>API: POST /api/tools/supabase/storage-upload
    API->>API: checkInternalAuth()
    API->>API: validate with SupabaseStorageUploadSchema
    
    alt fileData is string
        API->>API: Check for data URL pattern
        API->>API: Detect if base64 or plain text
        API->>API: Convert to Buffer
    else fileData is object (UserFile)
        API->>FileUtils: processSingleFileToUserFile()
        FileUtils-->>API: userFile
        API->>FileUtils: downloadFileFromStorage()
        FileUtils-->>API: Buffer
    end

    API->>API: Construct fullPath with folder
    API->>Supabase: POST /storage/v1/object/{bucket}/{path}
    Supabase-->>API: Upload response
    API->>API: Generate publicUrl
    API-->>Tool: {success, output: {message, results}}
    Tool-->>UI: Display results
    UI-->>User: Show upload success
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321
Copy link
Collaborator Author

@cursor review

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@icecrasher321 icecrasher321 merged commit d83c418 into staging Jan 25, 2026
11 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/hackathon-fixes branch January 26, 2026 21:15
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