Skip to content

Studio: show attachments when editing a message - #11054

Merged
danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:fix-edit-composer-attachments
Sep 29, 2026
Merged

danielhanchen merged 4 commits into
unslothai:mainfrom
NilayYadav:fix-edit-composer-attachments

Conversation

@NilayYadav

@NilayYadav NilayYadav commented Sep 15, 2026 •

Copy link
Copy Markdown
Collaborator

When you edited a message that had a file, a long paste or an image, the edit box only showed the text. The attachments were hidden but still sent again on Update, and there was no way to remove them. A message that was only a long paste opened as an empty box.

The edit box now shows the attachments with the same remove button as the main message box. Removing one counts as a change, so Update sends the message without it. Leaving them alone works like before.

On main, editing a message with a file, a long paste or an image showed no attachments and Update sent them again. With this change they show up, removing one really drops it and the model no longer sees it, and Cancel keeps them. Added tests.

Before / after

Merge base 7617fc3 vs head fb02900, same Studio build steps, a scripted provider on both sides. A message was sent with a 7.4 KB paste, then edited.

Edit box. Before: only the text. After: the paste shows as a card with a remove button.

Edit box before and after

Thread after sending the edit. Before: the hidden paste went out again (8033 byte request). After: the card was removed, so the resent message has no attachment (444 byte request, last user message is just Summarise this).

Thread after sending the edit, before and after

Attachments in edit box Remove buttons Paste resent
Before 0 0 yes
After 1 1 no, after removing it

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-15T20:11:09.864331Z 2ae031c PR opened
ℹ️ 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.

@danielhanchen

Copy link
Copy Markdown
Member

Confirmed the edit composer in studio/frontend/src/components/assistant-ui/thread.tsx only renders the input today, so attachments stay hidden and get resent on Update; will get this reviewed.

danielhanchen added a commit that referenced this pull request Sep 16, 2026
…tree (#11063)

`Repo tests (CPU, studio)` failed on #11054, which touches three frontend files and cannot reach an installer test:

```
shutil.Error: [('.../studio/backend/requirements/.extras-filtered-_30x7ggm.txt',
  ..., "[Errno 2] No such file or directory")]
FAILED tests/studio/install/test_studio_deps_cli.py::test_malformed_core_metadata_is_a_foreign_conflict
```

`install_python_stack._filter_requirements` writes its filtered copy beside the source on purpose, so relative -r and -c includes resolve, and its source is the real requirements tree this fixture copies into every fake venv. Under xdist that is two workers on one directory: the name was there when copytree listed the tree and gone when it read it.

The fixture skips `.*-filtered-*.txt`. Ignored names are never scheduled for copying, so there is no window to lose, and a tree meant to mirror the shipped requirements no longer picks up another process's scratch either.

Two tests, both failing without the ignore: the generated file is not copied, and the file vanishing between the listing and the read no longer fails the copy. The second was vacuous as first written, since copytree binds copy2 as a default argument and patching shutil.copy2 does not reach it; it passes copy_function explicitly now.

No product file changes.
shaojun pushed a commit to shaojun/unsloth that referenced this pull request Sep 29, 2026
…tree (unslothai#11063)

`Repo tests (CPU, studio)` failed on unslothai#11054, which touches three frontend files and cannot reach an installer test:

```
shutil.Error: [('.../studio/backend/requirements/.extras-filtered-_30x7ggm.txt',
  ..., "[Errno 2] No such file or directory")]
FAILED tests/studio/install/test_studio_deps_cli.py::test_malformed_core_metadata_is_a_foreign_conflict
```

`install_python_stack._filter_requirements` writes its filtered copy beside the source on purpose, so relative -r and -c includes resolve, and its source is the real requirements tree this fixture copies into every fake venv. Under xdist that is two workers on one directory: the name was there when copytree listed the tree and gone when it read it.

The fixture skips `.*-filtered-*.txt`. Ignored names are never scheduled for copying, so there is no window to lose, and a tree meant to mirror the shipped requirements no longer picks up another process's scratch either.

Two tests, both failing without the ignore: the generated file is not copied, and the file vanishing between the listing and the read no longer fails the copy. The second was vacuous as first written, since copytree binds copy2 as a default argument and patching shutil.copy2 does not reach it; it passes copy_function explicitly now.

No product file changes.
@danielhanchen danielhanchen self-assigned this Sep 29, 2026
Main now always resends from the edit composer (unslothai#11407) and diffs attachments
itself, so the original-attachments comparison is dropped; the edit composer
still renders the attachments and a paste without its File previews instead
of inlining.
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 29, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Sep 29, 2026
@danielhanchen

Copy link
Copy Markdown
Member

Review record for #11054, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#220.

Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found.

Round 1: reviewed mirror 24b239e72 (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] on studio/frontend/src/components/assistant-ui/thread.tsx (on the mirror)

@@ -8652,6 +8652,7 @@ const EditComposer: FC = () => {
           submitEdit();
         }}
       >
+        <ComposerAttachments className="mb-0 px-3 pt-3 [&_.aui-pasted-text-chip:not(:hover)]:bg-background" />

P2 Badge Handle removing the sole content of an edited message

When a message consists only of an attachment—particularly the paste-only case described by this change—removing that attachment leaves the edit composer with empty text and no attachments. submitEdit() then calls send({ startRun: true }), but assistant-ui's BaseComposerRuntimeCore.send() returns immediately whenever isEmpty, before considering startRun; therefore the enabled Send button silently does nothing and the editor remains open. The last removal needs an explicit empty-message/delete behavior or must not leave the composer in an unsaveable state.

Useful? React with 👍 / 👎.

Accepted on the mirror

Reply from shimmyshimmer:

Fixed in 3ab7f0a: Send in the edit box is now disabled while the composer is empty (composer.isEmpty), matching the main composer. Reproduced on the previous head with a paste-only message: removing the chip left Send enabled and clicking it sent nothing; on the new head Send is disabled.

Round 2: reviewed mirror cdbf3ede1 (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] on studio/frontend/src/components/assistant-ui/thread.tsx (on the mirror)

@@ -8670,7 +8673,7 @@ const EditComposer: FC = () => {
               Cancel
             </Button>
           </ComposerPrimitive.Cancel>
-          <Button type="submit" size="sm" disabled={researchActive}>
+          <Button type="submit" size="sm" disabled={researchActive || editEmpty}>

P2 Badge Guard the form submission when the edit is empty

When the sole attachment is removed and the configured send shortcut is pressed in the input, ComposerPrimitive.Input still calls form.requestSubmit(), so this disabled button does not prevent the form's onSubmit from invoking submitEdit(). BaseComposerRuntimeCore.send() then returns immediately for the empty composer, leaving the editor open with no feedback. Fresh evidence beyond the resolved click path is this keyboard submission route; guard submitEdit/onSubmit with editEmpty as well as disabling the button.

Useful? React with 👍 / 👎.

Rejected on the mirror

Reply from danielhanchen:

Not reachable as harm: ComposerInput only calls requestSubmit while a run is active when thread capabilities.queue is true, and every assistant-ui runtime Studio uses hard-codes queue: false, so Enter cannot cancel a streaming reply here (reproduced: reply ran to completion). With nothing running, send() already returns on an empty composer, so a guard in submitEdit would change nothing observable.

Round 3: reviewed mirror cdbf3ede1 (no equivalent commit found on this PR)

chatgpt-codex-connector[bot] (on the mirror)

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

Reviewed commit: cdbf3ede19

No triage reaction was recorded on the mirror

Verdict

The round converged at mirror cdbf3ede1 (no equivalent commit found on this PR).

This is the review as it stood at that commit. Anything pushed to this PR afterwards was not part of it.

@danielhanchen
danielhanchen merged commit 990e50b into unslothai:main Sep 29, 2026
36 of 39 checks passed
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