Skip to content

Make shared composer drafts opt-in - #16548

Merged
danielhanchen merged 24 commits into
unslothai:mainfrom
Imagineer99:fix/chat-draft-isolation
Nov 9, 2026
Merged

danielhanchen merged 24 commits into
unslothai:mainfrom
Imagineer99:fix/chat-draft-isolation

Conversation

@Imagineer99

@Imagineer99 Imagineer99 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Typing an unfinished prompt in one chat currently carries it into other chats and New chat. Keep drafts separate by default, and expose the existing shared-draft behavior under Settings → Chat → Chat defaults → Share drafts across chats (off by default).

This follows up on the intentional behavior change in #13722 and preserves #15782's cross-window isolation. Opting in shares a draft across chats and Compare within the same tab; it does not restore live synchronization between windows. Opening as a draft for agreement on the default behavior.

  • Saved chats, fresh New chat navigation, and Compare pairs have separate draft scopes, including long pasted text.
  • Flush pending text on navigation without removing the typing debounce; clear sent drafts and discard paste restores that finish after switching chats.
  • Preserve the stored shared draft and per-chat copies when changing the preference. Include translations in every locale.

Validation:

  • 74 focused draft, composer-preference, and send-guard tests pass, including upstream tab-isolation coverage.
  • npm run typecheck and npm run i18n:check:strict pass.
  • Local React lifecycle probe passes quick navigation, New chat, sends, late paste restores, Compare isolation, preference toggles, and temporary-chat isolation.
  • Playwright/Chromium drove the repository's real SettingsDialog preview: navigated to Chat, verified the toggle defaults off, enabled it, and verified persistence after reload.

The native Unsloth Desktop shell and model-backed sends were not exercised.

Before / after: composer drafts

Two isolated Studio installs, no model loaded. Two saved chats are seeded; the draft "unfinished question typed in chat A" is typed in chat A, then the sidebar opens chat B, then New chat. Draft pairs: merge base 6c486bd0c vs head a55e89f10.

Chat B after leaving chat A: before, chat A's draft follows into chat B; after, chat B starts empty.
Chat B composer, before vs after

New chat after leaving chat A: before, the draft follows into New chat; after, New chat starts empty. Returning to chat A afterwards shows its own draft again. Unsent New chat text is kept in one New chat slot, so stored drafts are only chat-draft:__new__ and one per saved chat.
New chat composer, before vs after

Settings > Chat > Chat defaults gains "Share drafts across chats", off by default (merge base 6c486bd0c vs head fe81dbae8, current main layout). With it switched on, the same chat A, New chat, chat B, chat A sequence shows the same composer text at every step on both builds.
Settings Chat defaults, before vs after

@Imagineer99
Imagineer99 marked this pull request as ready for review November 4, 2026 13:07
@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-09T17:49:10.843954Z 6d0eadc Manual request
ℹ️ 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[bot]

This comment was marked as resolved.

@Imagineer99 Imagineer99 changed the title Unsloth: make shared composer drafts opt-in Make shared composer drafts opt-in Nov 5, 2026
@danielhanchen danielhanchen self-assigned this Nov 7, 2026
…g it

A per-chat copy left behind after adoption came back once sharing was
turned off, restoring a prompt already sent from the shared slot.

[skip ci]
The draft key changes before the runtime swaps threads, so the save and
navigation flush paired the previous chat's text with the new key: a saved
chat's draft was copied into New chat, and returning to a chat from a New
chat erased its draft. Skip saving while the composer still shows the text
from before the restore.

[skip ci]
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 7, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 7, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 7, 2026
Resolve composer-settings against unslothai#16888, which moved Plain text, Rich
text paste and Context window usage to Display; Share drafts across chats
stays in Chat defaults, and the pinned Chat defaults row list includes it.
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 8, 2026
Imagineer99 and others added 3 commits November 9, 2026 12:34
New chat ids and fresh Compare pair ids are minted per navigation, so a
per-id draft slot was never read or removed once the user left it, and
large pastes could fill localStorage. Every unsent New chat now drafts in
the pre-sharing chat-draft:__new__ slot, and a Compare pair with no stored
threads drafts in one new-pair slot until its first send.

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

Opening Settings hides the chat view, so the composer that held the draft
was not mounted when the preference flipped and Compare never adopted its
draft. Adopt in the preference setter from the per-chat slot this tab last
typed into, prefer this tab's cached copy over another window's later
write, and keep text typed in Compare while its history loads when the
pair moves to the new-pair slot.

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
Same behaviour (the reset only fires on a pair change, which never takes
the early return), but keeps the gate and the listed-pair assignment
together as project-chat-run-keepalive pins them.

[skip ci]
chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
@unslothai unslothai deleted a comment from danielhanchen Nov 9, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 6d0eadc1aa

ℹ️ 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".

@unslothai unslothai deleted a comment from chatgpt-codex-connector Bot Nov 9, 2026
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Nov 9, 2026
@danielhanchen
danielhanchen merged commit aec9952 into unslothai:main Nov 9, 2026
danielhanchen added a commit that referenced this pull request Nov 10, 2026
…ount (#17399)

## Summary

`(Python 3.13, a-f)` is red on `main`:

```
studio/backend/tests/test_device_sync_settings.py::test_every_synced_store_field_is_saved
E   AssertionError: ('ChatPrefsPayload', {'shareComposerDraft'})
```

This is a merge race between two correct PRs. #16548 (merged yesterday)
added the opt-in `shareComposerDraft` preference to the chat preferences
store. #17240 (merged today) added a guard that every synced chat
preferences field is accepted by the server: the sync hook sends the
whole store, and `ChatPrefsPayload` ignores unknown keys, so a field the
model does not list is silently dropped and never follows the account.
`shareComposerDraft` is not in `LOCAL_CHAT_PREFS` (which is only for
browser-bound state such as notification permission and panel layout),
so it is meant to sync like the other composer preferences, and today it
does not.

## Changes

- `studio/backend/routes/settings.py`: `ChatPrefsPayload` accepts
`shareComposerDraft: Optional[bool]`, next to the other composer
preferences. The setting now follows the account like
`plainTextComposer` does; nothing else changes and older clients that do
not send it are unaffected.

## Testing

- `studio/backend/tests/test_device_sync_settings.py`: 19 passed; on
`main` the guard fails as above (1 failed, 18 passed).
danielhanchen added a commit to debojyoti-dev/unsloth that referenced this pull request Nov 13, 2026
…dd strings for the newer locales

Main made shared composer drafts opt-in (unslothai#16548), so the handoff now writes the
New chat slot the composer restores from and resets the runtime like New chat.
The history is also capped by total characters so a full localStorage cannot
throw out of addEntry after a translation succeeded. The 11 locales added since
the PR opened get the Translate strings, so i18n:check:strict passes again.
The bundle budget raise is dropped: main's budget has room.

[skip ci]
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