Studio: make the paste-to-attachment threshold a chat setting by shimmyshimmer · Pull Request #8963 · unslothai/unsloth · GitHub
Skip to content

Studio: make the paste-to-attachment threshold a chat setting - #8963

Merged
shimmyshimmer merged 1 commit into
mainfrom
feat/pasted-text-threshold-setting
Aug 16, 2026
Merged

Studio: make the paste-to-attachment threshold a chat setting#8963
shimmyshimmer merged 1 commit into
mainfrom
feat/pasted-text-threshold-setting

Conversation

@shimmyshimmer

Copy link
Copy Markdown
Member

Problem

A long paste in Chat becomes a .txt attachment instead of filling the message box. Two things decided that, and neither was adjustable:

  • 2,000 characters, which is low enough that ordinary prompts got condensed.
  • 40 lines, regardless of length. A 45 line paste of short lines was condensed even though it would have sat fine inline.

The preview dialog was also narrower than the text needed, so lines wrapped that did not have to.

Changes

Threshold. Default raised to 4,000 characters. The line rule is gone, so length alone decides.

Setting. Settings > Chat gets a dropdown: Off, 2,000, 4,000, 8,000, 16,000. Off keeps every paste inline no matter how long. The value is stored in the existing unsloth_chat_preferences localStorage entry.

A stored value outside those choices falls back to the default. Without that, a stale or hand-edited entry leaves the dropdown blank with no way to fix it from the UI.

Preview dialog. Widened from 46rem to 68rem and from 80dvh to 88dvh, with the body pre growing from 64dvh to 72dvh so the extra height is usable rather than padding.

shouldAttachPastedText and pasteLongTextAsFile take the threshold as an optional argument defaulting to 4,000, so the one production caller passes the preference and the rest of the call sites are unchanged.

Verification

Dialog geometry measured on a vite entry with no backend, at a 1280x720 viewport, to confirm the arbitrary Tailwind values resolve rather than assuming they compile:

before after
width 736px 1088px
max height 576px 633.6px

tests/pasted-text-attachment.test.ts covers the new behaviour: the configurable threshold at 2,000, 4,000 and 16,000 against the same input, Off refusing a 5MB paste, a negative value not re-enabling it, a 200 line short paste now staying inline, and the default being one of the offered choices.

Full frontend suite passes at 2705. tsc -b clean. npm run i18n:check:strict passes, with the three new keys added to all 12 locales. No new biome findings on the touched files.

Note on CI

Frontend build + bundle sanity fails on tests/llama-extra-args-diagnostics.test.ts for a missing parallelSlotsClamped on LlamaFlagCatalog, and Backend CI fails on AttributeError: '_Backend' object has no attribute 'context_length'. Both reproduce on a clean main checkout and are unrelated to this branch, which changes no Python.

This touches studio/frontend/src/components/assistant-ui/thread.tsx, which #8849 also touches. Whichever merges second needs a small conflict resolution; the two changes are in different parts of the composer.

Long pastes became a .txt attachment at 2,000 characters, or at 40 lines
regardless of length, and neither was adjustable. A 45 line paste of
short lines was condensed even though it would have sat fine inline.

Raise the default to 4,000 characters, drop the line rule so length
alone decides, and add a Settings > Chat dropdown offering Off, 2,000,
4,000, 8,000 and 16,000. Off keeps every paste inline. A stored value
outside those choices falls back to the default, so a stale one cannot
leave the dropdown blank.

Widen the paste preview dialog from 46rem to 68rem and 80dvh to 88dvh,
with the body growing to match, since the old width wrapped lines that
did not need wrapping.
@shimmyshimmer

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

@shimmyshimmer
shimmyshimmer merged commit aa3f3c2 into main Aug 16, 2026
38 of 46 checks passed
@shimmyshimmer
shimmyshimmer deleted the feat/pasted-text-threshold-setting branch August 16, 2026 08:49
rhsCZ pushed a commit to rhsCZ/unsloth that referenced this pull request Aug 16, 2026
Resolves the conflict in studio/frontend/src/components/assistant-ui/thread.tsx.
Main's paste-to-attachment threshold (unslothai#8963) added pastedTextMinChars at the same
spot this branch declares justSentRef, so both declarations are kept.

Also tightens the two longest comments the branch adds, in the draft-restore
suppression and the deliberate-write retire effect. Comment-only: the file
transpiles byte-identical with comments stripped.
danielhanchen added a commit that referenced this pull request Aug 16, 2026
…load it (#8981)

Frontend build + bundle sanity is red on main. tests/delete-chat-files-preference.test.ts
fails with ERR_MODULE_NOT_FOUND for
studio/frontend/src/features/chat/utils/pasted-text, and the file is there.

The frontend suite runs under `node --experimental-strip-types --test`, and
Node's ESM resolver does not add extensions. #8963 added

    } from "../utils/pasted-text";

to chat-preferences-store.ts, which the test imports for its value, so the
resolver is asked for a file called pasted-text and there is not one. The two
sibling modules that import the same file, use-chat-search-index.ts and
prompt-storage-dialog.tsx, both write ../utils/pasted-text.ts, which is the
convention this restores.

Reproduced the mechanism on its own: a.ts importing "./b" fails with
ERR_MODULE_NOT_FOUND under --experimental-strip-types, and "./b.ts" resolves.

Scope. 47 other relative imports without an extension sit in modules the tests
name, but all except two are erased before resolution, being `import type` or a
braced clause of nothing but types. The two real ones,
chat-settings-api.ts -> ../utils/settings-retry and
per-model-config.ts -> ./model-identity, are not reached at runtime: the tests
that mention those files pass them to readFile as source text, or import only
their types. They are latent rather than broken, so they are left alone here
and worth a separate look.
danielhanchen added a commit that referenced this pull request Aug 16, 2026
One conflict, in the composer's hook block: main added the
pastedTextMinChars preference read (#8963) and this branch added the
Cmd/Ctrl+Enter ref and its handler at the same spot. Both are kept.

Nothing else in thread.tsx conflicted, and the paste threshold does not
change what the queue sees: a long paste still arrives as an attachment
that isPastedTextFile recognises, which is what canQueuePastedTextPrompt
gates on.
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