Skip to content

fix(file): use file-upload subblock#3862

Merged
icecrasher321 merged 4 commits intostagingfrom
fix/file-block-append
Mar 31, 2026
Merged

fix(file): use file-upload subblock#3862
icecrasher321 merged 4 commits intostagingfrom
fix/file-block-append

Conversation

@icecrasher321
Copy link
Copy Markdown
Collaborator

@icecrasher321 icecrasher321 commented Mar 31, 2026

Summary

Replace append tool file dropdown with file upload subblock

Type of Change

  • Code Improvement

Testing

Tested manually

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
Copy Markdown

vercel bot commented Mar 31, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Mar 31, 2026 4:28am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Mar 31, 2026

PR Summary

Medium Risk
Moderate risk because it changes the file_append block input contract (new appendFileInput handling) and could affect existing workflows or UI interactions when selecting/refreshing workspace files.

Overview
Updates workflow notification log links to use logs?executionId=... (instead of search=...) across email previews and background notification delivery.

Refactors the editor FileUpload sub-block to source workspace files via the shared useWorkspaceFiles React Query hook, removing its bespoke fetch/effect and using refetch on dropdown open and after uploads.

Changes FileV3Block’s append operation to use a new basic file-upload sub-block (plus an advanced filename input) backed by a canonical appendFileInput, and updates tool param mapping to derive the target filename from either a selected file object or a string.

Written by Cursor Bugbot for commit af4eb8b. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 31, 2026

Greptile Summary

This PR replaces the file_append operation's custom dropdown (with an inline fetchOptions fetch) with a file-upload subblock, bringing it into line with the pattern already used by the read operation. Simultaneously, the FileUpload component's manual loadWorkspaceFiles state + fetch logic is migrated to the shared useWorkspaceFiles React Query hook, enabling caching and consistent invalidation across the app.

Key changes:

  • file.ts: appendFileName (dropdown) → appendFile (file-upload, basic) + appendFileName (short-input, advanced), both mapped to canonicalParamId: 'appendFileInput'. The params() handler now correctly resolves fileName from either a plain string (advanced mode) or a file object (basic mode) via normalizeFileInput.
  • file-upload.tsx: Removes the ad-hoc useState/useEffect/fetch pattern and replaces it with useWorkspaceFiles, useQueryClient, and workspaceFilesKeys.lists() invalidation on upload — consistent with the rest of the codebase's query layer.
  • One behavioural regression: the old loadWorkspaceFiles guard if (!workspaceId || isPreview) return is no longer applied. The useWorkspaceFiles hook fires on mount and refetchWorkspaceFiles() is called unconditionally in onOpenChange even when isPreview === true, generating unnecessary network requests in preview mode.

Confidence Score: 5/5

Safe to merge; the one flagged regression is a spurious extra read-only fetch in preview mode, not a data or functional correctness issue.

All findings are P2 (minor behavioural regression). The core logic change — extracting fileName from the file object for the append tool — is correct, and the React Query migration follows the established project pattern. No data integrity, security, or primary-path breakage was found.

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx — missing isPreview guard on the query enabled condition and refetch calls.

Important Files Changed

Filename Overview
apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/file-upload/file-upload.tsx Replaces manual state + fetch pattern with useWorkspaceFiles React Query hook; the isPreview guard that previously prevented workspace file fetching in preview mode is no longer applied to the hook's enabled condition or the refetchWorkspaceFiles calls.
apps/sim/blocks/blocks/file.ts Replaces the append operation's dropdown subblock (with fetchOptions) with a file-upload subblock (basic) + short-input (advanced) sharing canonicalParamId 'appendFileInput'; params handler correctly handles both string and object inputs to extract fileName.

Sequence Diagram

sequenceDiagram
    participant User
    participant FileUpload as FileUpload Component
    participant RQ as React Query (useWorkspaceFiles)
    participant API as /api/workspaces/:id/files
    participant Block as FileV3Block params()
    participant AppendTool as file_append tool

    User->>FileUpload: Opens append dropdown
    FileUpload->>RQ: refetchWorkspaceFiles()
    RQ->>API: GET /api/workspaces/{workspaceId}/files
    API-->>RQ: WorkspaceFileRecord[]
    RQ-->>FileUpload: workspaceFiles updated

    alt User selects existing file
        User->>FileUpload: Picks file from combobox
        FileUpload->>FileUpload: handleSelectWorkspaceFile(fileId)
        FileUpload->>FileUpload: setStoreValue({ name, path, key, size, type })
    else User uploads new file
        User->>FileUpload: Clicks Upload New File
        FileUpload->>API: POST /api/files/upload
        API-->>FileUpload: { file: { url, key } }
        FileUpload->>RQ: invalidateQueries(workspaceFilesKeys.lists())
        FileUpload->>FileUpload: setStoreValue({ name, path, key, size, type })
    end

    User->>Block: Runs workflow (file_append operation)
    Block->>Block: appendInput = params.appendFileInput

    alt appendInput is string (advanced mode)
        Block->>Block: fileName = appendInput.trim()
    else appendInput is object (file-upload mode)
        Block->>Block: normalizeFileInput(appendInput, single true)
        Block->>Block: fileName = file?.name
    end

    Block->>AppendTool: { fileName, content, workspaceId }
    AppendTool->>API: POST /api/tools/file/manage { operation: append, fileName }
    API-->>AppendTool: { success, data }
    AppendTool-->>Block: ToolResponse
Loading

Reviews (1): Last reviewed commit: "fix(file): use file-upload subblock" | Re-trigger Greptile

@icecrasher321
Copy link
Copy Markdown
Collaborator Author

bugbot run

Copy link
Copy Markdown

@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 90f5927 into staging Mar 31, 2026
6 checks passed
@waleedlatif1 waleedlatif1 deleted the fix/file-block-append branch March 31, 2026 04:29
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.

1 participant