Skip to content

Fix file drops in new project chats - #14472

Merged
danielhanchen merged 11 commits into
unslothai:mainfrom
Imagineer99:fix/project-new-chat-file-drop
Nov 9, 2026
Merged

danielhanchen merged 11 commits into
unslothai:mainfrom
Imagineer99:fix/project-new-chat-file-drop

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Project landing pages show a new-chat composer but reject desktop file drops with “Dropped files need a single chat. Open one, then drop it there.” This enables those drops and routes the file into the project's draft, while preserving Sources drop priority and Compare rejection.

Keep asynchronous attachment work associated with its originating draft. Late reads and adapter results are discarded when an unsaved runtime is reused; files remain associated with their original chat after it is saved and backgrounded. Cancellation cleanup tracks each operation separately.

Before / after

Project new-chat drop: rejected before, accepted after

Comparison: merge base 37f53745d15141de71711772c8bb301b6467c968 → PR head 1107b7ad447c0867d71da54a4fcc5b5442c47d19. The browser replay uses isolated app instances and controlled HTTP/native bridge fixtures.

Saved-chat registration regression (5 November 2026)

Opening a saved project chat through its thread URL during native file registration could leave the attachment in the project's old queue. Commit 98e9a657fa makes both routes use the same queue. A Chromium replay with delayed native registration lost the file before the fix and displayed it once after the fix. The regression tests also cover registration finishing while another chat is open.

At this head, 14,968 frontend tests passed with one Windows-only skip. All 192 focused tests passed on both WSL and Windows. TypeScript, the production build, and the startup bundle check passed.

Validation after refreshing main (3 November 2026)

Refreshed against main d6ca61ae0c in 92744852c8. Resolved the composer/runtime-provider conflicts while retaining draft ownership and saved-chat attachment handling.

  • Full frontend suite: 14,835 passed, zero failures, one Windows-only skip. The skipped test passed separately on native Windows.
  • Focused attachment/drop tests: 190 passed on WSL and 190 passed on native Windows Node.
  • 22 Chromium browser scenarios passed with controlled HTTP/native bridge fixtures: repeated drops, failure/retry, Sources priority, picker and browser drops, delayed registration/read completion, project changes, Compare, adapter cancellation, first send and saved-chat revisits.
  • TypeScript checks including tests, production build, merge-aware checks and pre-push checks passed.
  • Startup bundle check passes without changing its budget: 3,207.4 KiB raw / 1,065.4 KiB transfer, with 670.7 KiB raw / 176.5 KiB transfer headroom. The earlier reported budget overrun is no longer present after updating main.
  • No PR changes to database schemas, storage formats, dependencies, native commands, or model/hardware paths.

The screenshot above and the original test report describe the earlier 1107b7a head. They remain historical evidence; the refreshed checks are listed separately here.

Remaining validation

This is a draft pending packaged Unsloth Desktop drag/drop and native macOS/Safari smoke checks. Browser evidence does not exercise physical OS drops, packaged webviews, or live model inference. GitHub CI has been requested for 98e9a657fa.

Packaged Desktop drop smoke (macOS 15 and Windows)

Debug Tauri builds of the merge base (91935a13e4) and this head (8501ed8f18) were run on GitHub-hosted macos-15 and windows-latest runners against a real Studio backend installed with install.sh --local --tauri / install.ps1 --local --tauri. A test-only hook does what the runtime does for an OS drop on the main webview: it records the path with NativeIntakeState::note_dropped_paths, then delivers the tauri://drag-enter, drag-over and drag-drop events. The physical OS drag itself is not simulated.

Scenario macOS base macOS head Windows base Windows head
Single chat drop (control) attached attached attached attached
Project new chat drop "Dropped files need a single chat. Open one, then drop it there." attached, no toast same rejection attached, no toast

Packaged Desktop project drop, before and after, macOS and Windows

The macOS network prompt in the screenshots belongs to the test harness's Python process, not to the app.

danielhanchen added a commit that referenced this pull request Oct 21, 2026
## Problem

Five checks fail on main, so the `Repo tests (CPU, studio)`, `Repo tests
(CPU, rest)` and `workflow-trigger lint` shards are red on every open PR
(for example #14472, #14482, #14488, #14490 and #14494). All five
reproduce on main `4d7ebf5cea`.

| Test | Introduced by | Fault |
|---|---|---|
|
`tests/security/test_lint_risky_loaders.py::test_the_tree_matches_the_baseline`
| #14437 | Baseline. Two new dynamic-import sites: `import_module` in
`studio/backend/core/rag/embeddings.py`, and a third
`import_from_string` in `unsloth/models/sentence_transformer.py`
(`_require_word_tokenizer`). Both are safe, see below. |
|
`tests/studio/test_tauri_branding_contract.py::test_desktop_surfaces_do_not_restore_studio_branding`
| #14473 | Product. "Studio" became "Unsloth Studio" in the Markdown
import errors and the Tauri webview reject message. The desktop contract
allows "Unsloth" there, never "Unsloth Studio". "Unsloth" meets both
#14473's rule (no bare "Studio") and this one. |
|
`tests/studio/test_usage_examples_model_source_contract.py::test_auto_switch_section_sits_above_the_usage_examples`
| #14455 | Test. The redesign moved the usage examples above the monitor
link on purpose, and its own `api-settings-tab.test.ts` pins that. |
|
`tests/studio/test_usage_examples_model_source_contract.py::test_monitor_can_unload_the_loaded_model`
| #14455 | Test. Unloading moved from a standalone button on the page
into the model picker's eject (`ApiModelLoadControls`). The `/unload`
path itself is unchanged. |
|
`tests/studio/test_settings_compact_overflow_contract.py::test_api_monitor_entries_and_expanded_text_can_shrink`
| #14455 | Test. Entry rows are now rounded cards (no `border-b`), and
the prompt/reply box's `rounded-lg` became conditional, so the class
literals the test matched are gone. The overflow guards themselves are
still in the source. |

## Fix

- **Risky loaders:** two baseline entries with reasons.
- `embeddings.py` imports only the three `sentence_transformers.models`
paths written out in a literal tuple, to wrap their `import_from_string`
with the trust gate.
- `_require_word_tokenizer` imports only after its caller has refused
any `tokenizer_class` outside `sentence_transformers.*`, and only dotted
identifiers.
- **Branding:** "Unsloth Studio" to "Unsloth" in those seven Markdown
import errors and the Rust reject message.
`conversation-markdown-import.test.ts` now matches `/Unsloth Markdown/`.
- **#14455 contracts:** rewritten to guard what the redesign keeps:
- the auto-switch section still follows the monitor link, and the usage
examples come before both;
- the page passes `unloadActiveModel` to the load controls as
`onUnloadActive`, and eject is withheld while `busy` (`modelLoading ||
unloading`, #11223's rule);
  - the `/unload` call still reads the internal id from status;
  - entry rows keep `w-full min-w-0`;
  - the prompt/reply box keeps `max-h-72 overflow-auto break-words`;
  - the model id keeps `min-w-0 break-all`.

## Verification

- The four Python files: 78 passed (5 failed on main).
- `studio/frontend/tests/conversation-markdown-import.test.ts`: 20
passed.
- Sabotage, each run against the rewritten tests, each failing exactly
one test:
- removing `min-w-0` from the entry row, or `break-words` from the text
box: the overflow test fails;
- dropping `unloading` from `busy`, or passing `onEject` while busy: the
unload test fails;
- putting the auto-switch section above the monitor link: the order test
fails.
@danielhanchen

Copy link
Copy Markdown
Member

Frontend build + bundle sanity fails on the startup bundle budget:

eager startup JS: 6704.4 KB raw, 2018.9 KB transfer, 97 chunks
over the startup budget: transfer 2018.9 KB > 2018.4 KB, raw 6704.4 KB > 6702.8 KB

That run merged into e08466e825. The overrun (about 1.6 KB raw, 0.5 KB transfer) is this PR's own addition to the eager chunks. Current main is within its budget with only about 0.2 KB to spare, so merging main will not clear it. Either keep the new file-drop code out of the startup chunks with a lazy import, or raise BUDGET in studio/frontend/scripts/check-bundle-budget.ts in this PR, set to the merged build's measurement plus the same 160 B raw / 189 B transfer margin, with a comment entry like the others.

@Imagineer99

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-09T14:28:35.193559Z
We couldn’t complete this review. Comment @codex review to try again.
8501ed8 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: be92eb4bb9

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Imagineer99

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

Reviewed commit: 98e9a657fa

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danielhanchen danielhanchen self-assigned this Nov 7, 2026
A cancelled add under an unchanged owner and target key requeued into the
same queue and re-drained immediately, so a destination that keeps refusing
(a tombstoned chat still mounted) spun forever re-reading the file. Retry
once, then drop it and cancel any parked send.
The draft-scoped adapter resolves a cancelled add instead of throwing, so the
Library handoff counted the file as attached and dropped it. Treat the
cancellation as a refusal so attachLibraryChatFiles holds it.
- Cancel when a delegate generator returns without another yield after a
  draft switch, so native drains requeue instead of losing the file.
- Hold native drains until the runtime reaches the route's thread, so a
  saved project chat's queue cannot drain into the previous chat.
- Re-drain images only for the owning composer, matching the other kinds.
- Skip removing the pasted selection when the attachment add was cancelled.
@Imagineer99

Copy link
Copy Markdown
Member Author

@codex review

1 similar comment
@Imagineer99

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 8501ed8f18

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 9, 2026
@danielhanchen
danielhanchen marked this pull request as ready for review November 9, 2026 14:28
@danielhanchen
danielhanchen self-requested a review as a code owner November 9, 2026 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants