Skip to content

fix(desktop): pass file attachments through PromptInput onSubmit#3334

Merged
AviPeltz merged 2 commits intomainfrom
fix-new-workspace-enter
Apr 10, 2026
Merged

fix(desktop): pass file attachments through PromptInput onSubmit#3334
AviPeltz merged 2 commits intomainfrom
fix-new-workspace-enter

Conversation

@AviPeltz
Copy link
Copy Markdown
Collaborator

@AviPeltz AviPeltz commented Apr 10, 2026

Summary

  • handlePromptSubmit was ignoring the message argument from PromptInput's onSubmit, so file attachments were lost when submitting via Enter
  • Now converts message.files (already-available FileUIPart[]) into ConvertedFile[] and passes them directly to handleCreate, bypassing the redundant attachments.takeFiles() path

Test plan

  • Open new workspace modal, attach file(s), press Enter to submit — verify files are included in the workspace creation
  • Open new workspace modal, attach file(s), press Ctrl/Cmd+Enter — verify files still work via the keyboard shortcut path
  • Submit with no attachments — verify no regression

Summary by cubic

Fixes lost attachments when submitting the New Workspace modal with Enter by wiring PromptInput’s onSubmit(message) to pass files into handleCreate. Converts message.files to ConvertedFile[], skipping attachments.takeFiles() when provided; also formats PromptGroup with Biome.

  • Bug Fixes
    • Enter now submits with attached files; Ctrl/Cmd+Enter still works.
    • handleCreate(preConvertedFiles?) accepts pre-converted files to avoid duplicate detaching.

Written for commit bfcb26f. Summary will update on new commits.

Summary by CodeRabbit

  • Refactor
    • Improved workspace prompt submission to better handle attachments: callers can now supply already-prepared files to skip extra conversion steps, while existing submit actions still run the original conversion flow. This makes file uploads more flexible and reduces redundant processing in some submission paths.

…back

handlePromptSubmit was ignoring the message argument from PromptInput,
causing file attachments to be lost when submitting via Enter. Now
converts the already-available FileUIParts and passes them directly to
handleCreate, skipping the redundant takeFiles() path.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 10, 2026

📝 Walkthrough

Walkthrough

The PromptGroup component's file-handling flow was changed so handleCreate optionally accepts pre-converted files; attachment taking and blob→data-url conversion only run when pre-converted files are not supplied. handlePromptSubmit now maps submitted file entries to ConvertedFile objects before invoking handleCreate.

Changes

Cohort / File(s) Summary
File Conversion Refactor
apps/desktop/src/renderer/components/NewWorkspaceModal/components/PromptGroup/PromptGroup.tsx
handleCreate now accepts an optional preConvertedFiles?: ConvertedFile[]; conversion logic initializes convertedFiles from preConvertedFiles ?? [] and skips attachments.takeFiles()/convertBlobUrlToDataUrl when provided. handlePromptSubmit maps incoming files to ConvertedFile objects (using each url as data) and calls handleCreate (passing undefined when no converted files exist). Existing create-call paths (submit button, Enter+mod) still call handleCreate() with no args.

Sequence Diagram(s)

(omitted)

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 I nibble at code and hop with glee,
Passing files pre-warmed or fresh to me,
Conversion skipped when gifts arrive,
PromptGroup hums and keeps things spry,
A cheerful hop — deploy we be! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the loss of file attachments when submitting via the PromptInput onSubmit callback.
Description check ✅ Passed The pull request description covers the main issue, includes a detailed test plan, and provides context about the fix, but is missing the structured template sections.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-new-workspace-enter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 10, 2026

Greptile Summary

This PR fixes a bug in PromptGroup.tsx where handlePromptSubmit — the callback wired to PromptInput's onSubmit — was ignoring its message argument entirely, causing file attachments to be silently dropped on every Enter-key submission. The fix converts message.files (already data-URL-encoded by PromptInput before onSubmit fires) into ConvertedFile[] and passes them directly to handleCreate, bypassing the now-redundant attachments.takeFiles() blob-URL-conversion path.

  • The root cause was a missing parameter — handlePromptSubmit previously called void handleCreate() with no arguments regardless of what was attached.
  • The conversion in PromptInput (blob URL → data URL) happens before onSubmit is called, so message.files[*].url are already data URLs; no double-conversion is needed and none is attempted.
  • The Ctrl/Cmd+Enter keyboard-shortcut path is unchanged and still routes through attachments.takeFiles() + in-handleCreate blob-URL conversion — two functionally correct but divergent code paths now exist for submitting with files.
  • The inline parameter type in handlePromptSubmit re-declares the shape of PromptInputMessage (including filename, which is an informal extra field not in FileUIPart) rather than importing the exported type.

Confidence Score: 5/5

Safe to merge — the fix is correct and the change is isolated to one callback in one file.

The fix correctly addresses the root cause: PromptInput already converts blob URLs to data URLs before calling onSubmit, so mapping message.files directly is the right approach. No data-loss or regression risk was found. The remaining P2 comments (inline type duplication, two divergent submit paths) are non-blocking cleanup items.

No files require special attention beyond the reviewed PromptGroup.tsx.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/components/NewWorkspaceModal/components/PromptGroup/PromptGroup.tsx Adds handlePromptSubmit that properly reads message.files from PromptInput.onSubmit and converts them to ConvertedFile[] before passing to handleCreate; the fix is correct since PromptInput already converts blob URLs to data URLs before calling onSubmit.

Sequence Diagram

sequenceDiagram
    participant User
    participant PromptInput
    participant handlePromptSubmit
    participant handleCreate
    participant Agent as AgentLaunchRequest

    Note over User,Agent: Enter key path (FIXED)
    User->>PromptInput: Press Enter (with files attached)
    PromptInput->>PromptInput: Convert blob URLs to data URLs
    PromptInput->>handlePromptSubmit: onSubmit({ text, files: FileUIPart[] })
    handlePromptSubmit->>handlePromptSubmit: Map files to ConvertedFile[]
    handlePromptSubmit->>handleCreate: handleCreate(convertedFiles)
    handleCreate->>Agent: buildLaunchRequest(prompt, convertedFiles)

    Note over User,Agent: Ctrl/Cmd+Enter path (unchanged)
    User->>handleCreate: keydown handler calls handleCreate()
    handleCreate->>handleCreate: attachments.takeFiles() returns blob URLs
    handleCreate->>handleCreate: convertBlobUrlToDataUrl() per file
    handleCreate->>Agent: buildLaunchRequest(prompt, convertedFiles)
Loading

Comments Outside Diff (1)

  1. apps/desktop/src/renderer/components/NewWorkspaceModal/components/PromptGroup/PromptGroup.tsx, line 1065-1075 (link)

    P2 Ctrl/Cmd+Enter path still bypasses PromptInput form submission — files go through a different code path

    The keyboard-shortcut handler calls handleCreate() with no arguments, which falls back to attachments.takeFiles() + blob-URL-to-data-URL conversion inside handleCreate. This is the old path and it still works correctly, but it is now divergent from the Enter-key path introduced in this PR (which uses pre-converted data URLs from message.files).

    Specifically, there is an asymmetry:

    • Enter keyPromptInput converts blob URLs → onSubmit(message)handlePromptSubmithandleCreate(preConverted)
    • Ctrl/Cmd+EnterhandleCreate()attachments.takeFiles() (blob URLs) → convertBlobUrlToDataUrl() inside handleCreate

    Both paths produce the correct result today, but the two code routes for "submit with files" are easy to let diverge in future refactors. Consider routing the keyboard shortcut through handlePromptSubmit or through a shared helper, or at least leave a comment noting the intentional split.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "fix(desktop): pass file attachments thro..." | Re-trigger Greptile

Comment on lines +1051 to +1063
const handlePromptSubmit = useCallback(
(message: { files: Array<{ url: string; mediaType: string; filename?: string }> }) => {
const converted: ConvertedFile[] = message.files
.filter((f) => f.url)
.map((f) => ({
data: f.url,
mediaType: f.mediaType,
filename: f.filename,
}));
void handleCreate(converted.length > 0 ? converted : undefined);
},
[handleCreate],
);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Use exported PromptInputMessage type instead of inline structural type

The callback's inline parameter type { files: Array<{ url: string; mediaType: string; filename?: string }> } duplicates the structure of the already-exported PromptInputMessage type from @superset/ui/ai-elements/prompt-input. The existing import list at the top of the file imports several members from that module — adding PromptInputMessage here would be more type-safe and consistent.

Note that filename on FileUIPart is not part of the official SDK type; it's an extra field added at object-creation time in prompt-input.tsx. Referencing it through the informal inline type works at runtime (the field is present via the spread in the blob-URL conversion), but using the authoritative imported type makes the dependency explicit.

Or simply add PromptInputMessage to the existing import from @superset/ui/ai-elements/prompt-input.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@AviPeltz AviPeltz merged commit d7eed78 into main Apr 10, 2026
7 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

MocA-Love pushed a commit to MocA-Love/superset that referenced this pull request Apr 11, 2026
…erset-sh#3334)

* fix(desktop): pass file attachments through PromptInput onSubmit callback

handlePromptSubmit was ignoring the message argument from PromptInput,
causing file attachments to be lost when submitting via Enter. Now
converts the already-available FileUIParts and passes them directly to
handleCreate, skipping the redundant takeFiles() path.

* style(desktop): format PromptGroup with biome
@Kitenite Kitenite deleted the fix-new-workspace-enter branch April 13, 2026 16:35
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