Skip to content

Desktop: drop documents into a chat instead of rejecting them as non-GGUF (#7661) - #7668

Merged
wasimysaid merged 7 commits into
unslothai:mainfrom
LeoBorcherding:fix-7661-desktop-drop-attachments
Jul 31, 2026
Merged

wasimysaid merged 7 commits into
unslothai:mainfrom
LeoBorcherding:fix-7661-desktop-drop-attachments

Conversation

@LeoBorcherding

Copy link
Copy Markdown
Collaborator

Fixes #7661.

On desktop, one window-level Tauri drag handler owned every drop and only accepted a lone .gguf, so dragging a pdf at the composer got "GGUF models only". The dom attachment dropzones were switched off under isTauri waiting on "Phase 1d token bridging". This adds that bridging, so document drops attach the way they do in the web ui.

The enums were already there (NativePathKind::Attachment, NativePathOperation::Attach), nothing minted or spent them.

rust

  • classify_native_attachment_path accepts the RAG upload types and grants Attach + Reveal only, so an attachment grant can never be spent as a model load.
  • register_native_attachment_path command, NativePathValidationPolicy::Attachment so the path is re-classified and re-fingerprinted at sign time like model paths are.

backend

  • _save_native_path_upload verifies the grant (operation attach, kind attachment, file, extension in UPLOAD_EXTS), then copies into the uploads root under the same size cap as a multipart upload. The webview never names a path; it forwards what Rust signed.
  • the three document routes take file OR nativePathLease through _resolve_document_upload.

frontend

  • classifyDropPaths decides model / docs / unsupported once, used by both the hover overlay and the drop.
  • dropped docs are registered as attachments, queued on the native-intent store, drained by the thread bar (which owns the upload and can materialize a thread id).
  • leases are minted per upload, not at drop time, since they expire in 2 minutes.
  • overlay copy now says what is actually accepted instead of "GGUF models only".

tests

  • rust: attachment classification allows attach, refuses .exe, refuses model ops
  • backend: signed drop is copied, forged signature rejected, model grant rejected as an attachment, unsupported extension, empty file, replay of a spent nonce, resolver needs one of file/lease
  • frontend: drop classification for lone gguf, doc batches, mixed and unsupported payloads

Local runs on this branch: cargo test 98 passed, backend pytest 21 passed (new file plus the neighbouring upload tests), npm test 74 passed, npm run build clean, eslint on the touched features matches main's baseline exactly.

Behavior notes: a mixed gguf+doc drop is still refused (ambiguous), and native drops dedup by filename since the webview has no size/mtime for them.

Not included: the Projects source dropzone still silently eats drops on desktop (project-source-dropzone.tsx has no isTauri guard). Called out in the issue, separate fix.

…GGUF (unslothai#7661)

One window-level Tauri drag handler owned every drop and only took a lone .gguf, so
dragging a pdf at the composer got "GGUF models only" while the dom attachment dropzones
sat disabled under isTauri, waiting on the token bridging this adds.

Rust classifies a dropped document as NativePathKind::Attachment and signs an Attach
grant for it; the RAG document routes take that grant in place of a multipart file,
re-verify it and copy from the signed path under the usual size cap, so the webview
never names a path itself. The drop handler registers the paths and queues them for the
thread bar, which owns the upload and can materialize a thread id. Leases are minted per
upload since they expire in two minutes.

A mixed model+document drop is still refused, and native drops dedup by filename because
the webview has no size or mtime for them.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c5be7a3c0f

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread studio/src-tauri/src/native_intents.rs Resolved
…ped doc visible

Two things surfaced testing the drop in the desktop shell.

The overlay sat at top-4 of a container whose top belongs to the chat header, so the
card rendered under it and got clipped. Offset it by the header vars the header fade
already uses.

A drop with the RAG pill off uploaded and indexed fine, but the thread bar returns null
when retrieval is off, so nothing appeared: the file landed in a bar that renders
nothing. Dropping a document is the intent, so turn retrieval on and let the chips show.
A KB-scoped chat uploads through the KB dialog instead, so refuse that case with a toast
rather than indexing into something this bar never displays.
@LeoBorcherding

LeoBorcherding commented Jul 31, 2026 •

Copy link
Copy Markdown
Collaborator Author

Testing this in the desktop shell turned up two things, both fixed in 44955b287.

The overlay was clipped. It sat at top-4 of a container whose top belongs to the chat header, so the card rendered under the header. Now offset by the same --studio-content-top-inset / --studio-chat-header-height vars the header fade already uses.

A drop with the RAG pill off looked like nothing happened. The upload, lease, copy and indexing all succeeded (POST /api/rag/threads/.../documents 200, ingestion job ran), but thread-documents-bar.tsx returns null when retrieval is off, so the file landed in a bar that renders nothing. Dropping a document is the intent, so the drop now turns retrieval on and the chips show. A KB-scoped chat uploads through the KB dialog instead, so that case is refused with a toast rather than indexing into something the bar never displays.

Worth a second opinion on the auto-enable: it is the only place in the app that flips ragEnabled without an explicit click. The alternative is refusing the drop and telling the user to turn the pill on, which is safer but makes the drop feel dead.

image

…on a real fingerprint

Review follow-ups on the native document drop.

register_native_attachment_path signed whatever path the renderer named, so a script in
the webview could have registered any readable document and spent it through the RAG
upload. Rust now records the paths the OS reports on WindowEvent::DragDrop and refuses to
register anything else, with a two minute expiry so a stale drop can't be spent later.

NativePathRef carries the size and mtime Rust already stat'd, so a native drop dedups on
name|size|mtime like a browser File does. Two different README.md files were previously
collapsed into one by the name-only signature.

Document drops also wait for native_path_leases_supported. A lease is the only way they
reach the ingest, so offering the drop before the backend can verify one just fails after
release.
@LeoBorcherding

Copy link
Copy Markdown
Collaborator Author

Thanks, all four addressed. Codex reviewed c5be7a3c0, so one of them was already fixed by the time it landed.

P1, require a real drop before signing attachment paths. Fixed in 114370cec. Rust now records the paths the OS reports on WindowEvent::DragDrop and register_attachment_path refuses any canonical path that isn't in that set, with a two minute expiry so a stale drop can't be spent later. A script in the webview naming an arbitrary readable document gets "Attachments must come from a file dropped on the window." Covered by two tests, including that dropping one file doesn't unlock a sibling in the same folder.

Worth noting the same shape exists on main for register_native_model_path, which also trusts a renderer-supplied path. I left it alone to keep this PR scoped, happy to follow up separately if you want the guard extended to model drops too.

P2, name-only dedup. Fixed. NativePathRef now carries the size and mtime Rust already stat'd, so a native drop dedups on name|size|mtime, the same shape as a browser File. Two different README.md files are no longer collapsed. If either value is missing the signature falls back to the unique path token, so the drop is never blocked client-side and the backend's content hash stays authoritative.

P2, wait for lease support. Fixed. canAttachDocs requires nativePathLeasesSupported, so before the backend can verify a lease the overlay shows the reject state and the drop explains why instead of failing after release.

P2, gate on the active RAG thread source. Already fixed in 44955b287, which took the "switch the RAG state explicitly" option: a document drop turns retrieval on so the chips are visible and the file is actually used, and a KB-scoped chat refuses the drop with a toast pointing at the KB dialog rather than indexing thread docs nothing displays.

Test status on 114370cec: cargo test 100 passed (2 new), npm test 74 passed, npm run build clean, backend pytest unchanged from the last run. The drop-ordering assumption behind the P1 fix (Rust sees the OS event before the webview does) is reasoned plus unit tested, but I have not yet re-confirmed it with an end-to-end drag from the file manager since the change; doing that next.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 114370cec7

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a448f456fc

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: e8be7ba18e

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid
wasimysaid merged commit 21074d3 into unslothai:main Jul 31, 2026
42 of 48 checks passed
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.

[Bug] Desktop: every file drop is claimed by the GGUF model overlay, so chat attachments can't be dragged in

2 participants