diff --git a/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx b/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
index f62aba2c73668..aee00d9630704 100644
--- a/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
+++ b/apps/mobile/src/features/settings/SettingsFollowUpRouteScreen.tsx
@@ -1,6 +1,11 @@
import { msg, T, useGT, useMessages, Var } from "gt-react-native";
import { ScreenScrollView as ScrollView } from "../../components/ui/ScreenScrollView";
import { useAtomSet, useAtomValue } from "@effect/atom-react";
+import {
+ DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD,
+ type PastedTextAttachmentThreshold,
+} from "@t3tools/contracts";
+import { pastedTextThresholdLabel } from "@t3tools/client-runtime/text-paste";
import { AsyncResult } from "effect/reactivity";
import { Platform } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -29,6 +34,23 @@ const FOLLOW_UP_OPTIONS: ReadonlyArray<{
},
];
+const THRESHOLD_OPTIONS: ReadonlyArray<{
+ readonly threshold: PastedTextAttachmentThreshold;
+ readonly description: string;
+}> = [
+ {
+ threshold: 1_000,
+ description: msg("Most logs, stack traces, and code snippets become files."),
+ },
+ {
+ threshold: 5_000,
+ description: msg("Long logs and documents become files; snippets stay as text."),
+ },
+ { threshold: 32_768, description: msg("Default. Only very large pastes become files.") },
+];
+
+const PASTE_AS_TEXT_SHORTCUT = Platform.OS === "ios" ? "Command + Shift + V" : "Ctrl + Shift + V";
+
export function SettingsFollowUpRouteScreen() {
const gt = useGT();
const m = useMessages();
@@ -39,6 +61,10 @@ export function SettingsFollowUpRouteScreen() {
const selectedBehavior = AsyncResult.isSuccess(preferencesResult)
? (preferencesResult.value.followUpBehavior ?? DEFAULT_FOLLOW_UP_BEHAVIOR)
: null;
+ const selectedThreshold = AsyncResult.isSuccess(preferencesResult)
+ ? (preferencesResult.value.pastedTextAttachmentThreshold ??
+ DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD)
+ : null;
const content = (
{Platform.OS === "android" ? "Ctrl" : "Command"} while sending.
+
+ {THRESHOLD_OPTIONS.map(({ threshold, description }, index) => (
+ 0}
+ disabled={!preferencesReady}
+ onPress={() => savePreferences({ pastedTextAttachmentThreshold: threshold })}
+ />
+ ))}
+
+
+
+ Shorter pastes go into the message as text when they fit. Non-Latin text and emoji use
+ more bytes per character, so they reach the limit sooner. With a hardware keyboard, press{" "}
+ {PASTE_AS_TEXT_SHORTCUT} to paste a long block as text instead.
+
+
);
diff --git a/apps/mobile/src/features/settings/settings-search.ts b/apps/mobile/src/features/settings/settings-search.ts
index 9b8334641290d..147036f533003 100644
--- a/apps/mobile/src/features/settings/settings-search.ts
+++ b/apps/mobile/src/features/settings/settings-search.ts
@@ -119,6 +119,9 @@ const SETTINGS_SEARCH_TERMS = {
msg("queue", { $context: "settings search keyword" }),
msg("steer", { $context: "settings search keyword" }),
msg("while the agent is running", { $context: "settings search keyword" }),
+ msg("large pastes", { $context: "settings search keyword" }),
+ msg("attachment", { $context: "settings search keyword" }),
+ msg("text file", { $context: "settings search keyword" }),
],
SettingsArchive: [
msg("archive", { $context: "settings search keyword" }),
diff --git a/apps/mobile/src/features/threads/ThreadComposer.tsx b/apps/mobile/src/features/threads/ThreadComposer.tsx
index 1d4f06c4f5c4b..f30462e3be8d5 100644
--- a/apps/mobile/src/features/threads/ThreadComposer.tsx
+++ b/apps/mobile/src/features/threads/ThreadComposer.tsx
@@ -39,6 +39,7 @@ import {
} from "../../state/composer-attachment-uploads";
import Animated, { FadeIn, FadeOut, ReduceMotion } from "react-native-reanimated";
import { useUniwindTheme } from "../../lib/useUniwindTheme";
+import { usePastedTextAttachmentThreshold } from "../../lib/usePastedTextAttachmentThreshold";
import { themeColorWithAlpha } from "../../lib/mobileTheme";
import { armAgentAwarenessLiveActivityForLocalWork } from "../agent-awareness/remoteRegistration";
import { scopedThreadKey } from "../../lib/scopedEntities";
@@ -262,6 +263,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
const navigation = useNavigation();
const foregroundColor = useUniwindTheme()["--color-foreground"];
const bodyText = useComposerTextRole();
+ const pastedTextAttachmentThreshold = usePastedTextAttachmentThreshold();
const fallbackInputRef = useRef(null);
const inputRef = props.editorRef ?? fallbackInputRef;
const [isFocused, setIsFocused] = useState(false);
@@ -910,6 +912,7 @@ export const ThreadComposer = function ThreadComposer(props: ThreadComposerProps
text: paste.text,
wouldExceedInputLimit,
canAttach: true,
+ thresholdBytes: pastedTextAttachmentThreshold,
}) === "attachment"
) {
if (canAttach) {
diff --git a/apps/mobile/src/i18n/translations/de.json b/apps/mobile/src/i18n/translations/de.json
index c9d43d96b3eb8..8c358a726a4fe 100644
--- a/apps/mobile/src/i18n/translations/de.json
+++ b/apps/mobile/src/i18n/translations/de.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Versucht, {started} Review-Leitfaden zu starten, {failed} fehlgeschlagen} other {Versucht, {started} Review-Leitfäden zu starten, {failed} fehlgeschlagen}}",
"672850007e49cfb6": "{started, plural, one {{started} Review-Leitfaden gestartet} other {{started} Review-Leitfäden gestartet}}",
"5dce4a54eaffeccf": "{started, plural, one {Versucht, {started} Review-Leitfaden zu starten} other {Versucht, {started} Review-Leitfäden zu starten}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB (~{characters, number} Zeichen)",
+ "c62d732adb53f0ab": "{kilobytes} KB (~{characters, number} Zeichen)",
"420bea546d5f8802": "Thread kopiert",
"2efb2dd3bf170f67": "Thread konnte nicht kopiert werden",
"6c03545936b55e0b": "PR-Link kopiert",
@@ -3221,7 +3223,11 @@
"00b1b3b0bf010b1d": "Deine Nachricht wartet und wird nach der aktuellen Runde ausgeführt.",
"79e87310525279f8": "Umlenken",
"a1e23f7b109d5925": "Deine Nachricht erreicht den Agenten sofort und ändert, woran er arbeitet.",
+ "12fbffef5c5d01d6": "Die meisten Logs, Stacktraces und Code-Schnipsel werden zu Dateien.",
+ "6f73933b65186db1": "Lange Logs und Dokumente werden zu Dateien; Schnipsel bleiben Text.",
+ "ac160279d6fd62ea": "Standard. Nur sehr große Einfügungen werden zu Dateien.",
"683838755eb7fe37": "Während der Agent läuft",
+ "e0b70d25f7b2238d": "Eingefügten Text als Datei anhängen ab",
"afda415d2d75a5d3": "Chat",
"85163bc64c8c56a1": [
"Drücke lange auf die Senden-Schaltfläche, um für eine einzelne Nachricht die andere Option zu verwenden. Mit einer Hardware-Tastatur halte beim Senden ",
@@ -3232,6 +3238,15 @@
},
" gedrückt."
],
+ "ac88b5819c86bc5b": [
+ "Kürzerer eingefügter Text landet als Text in der Nachricht, sofern er hineinpasst. Nicht-lateinische Schrift und Emoji belegen mehr Bytes pro Zeichen und erreichen die Grenze daher früher. Mit einer Hardware-Tastatur drückst du ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ ", um einen langen Block stattdessen als Text einzufügen."
+ ],
"95ee62a0d6968b89": "Nachricht senden",
"1ad8b2750f0d2b17": "{returnKey} sendet die Nachricht. {shiftReturn} fügt eine neue Zeile ein.",
"92390c8eef972ca0": "Neue Zeile einfügen",
@@ -3807,6 +3822,9 @@
"4c2495d10dfbf72f": "warteschlange",
"4ebe2aa17b91e168": "umlenken",
"48f04bb3132077ef": "während der agent läuft",
+ "1481b12232710e91": "große einfügungen",
+ "715a3f6de78e8e6d": "anhang",
+ "f4da8226929a4a4c": "textdatei",
"ffb1ded95eb81974": "archivieren",
"3d5aeb06f2128b12": "archiviert",
"2a34f68d985e9fde": "wiederherstellen",
diff --git a/apps/mobile/src/i18n/translations/en.json b/apps/mobile/src/i18n/translations/en.json
index 7a89a1cf37c22..0d27924f218e3 100644
--- a/apps/mobile/src/i18n/translations/en.json
+++ b/apps/mobile/src/i18n/translations/en.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Tried to start {started} review guide, {failed} failed} other {Tried to start {started} review guides, {failed} failed}}",
"672850007e49cfb6": "{started, plural, one {Started {started} review guide} other {Started {started} review guides}}",
"5dce4a54eaffeccf": "{started, plural, one {Tried to start {started} review guide} other {Tried to start {started} review guides}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB (~{characters, number} chars)",
+ "c62d732adb53f0ab": "{kilobytes} KB (~{characters, number} chars)",
"420bea546d5f8802": "Thread copied",
"2efb2dd3bf170f67": "Failed to copy thread",
"6c03545936b55e0b": "PR link copied",
@@ -3222,7 +3224,11 @@
"00b1b3b0bf010b1d": "Your message waits and runs after the current turn finishes.",
"79e87310525279f8": "Steer",
"a1e23f7b109d5925": "Your message reaches the agent right away, changing what it is working on.",
+ "12fbffef5c5d01d6": "Most logs, stack traces, and code snippets become files.",
+ "6f73933b65186db1": "Long logs and documents become files; snippets stay as text.",
+ "ac160279d6fd62ea": "Default. Only very large pastes become files.",
"683838755eb7fe37": "While the agent is running",
+ "e0b70d25f7b2238d": "Attach pastes as files from",
"afda415d2d75a5d3": "Chat",
"85163bc64c8c56a1": [
"Long-press the send button to use the other option for a single message. With a hardware keyboard, hold ",
@@ -3233,6 +3239,16 @@
},
" while sending."
],
+ "ac88b5819c86bc5b": [
+ "Shorter pastes go into the message as text when they fit. Non-Latin text and emoji use more bytes per character, so they reach the limit sooner. With a hardware keyboard, press",
+ " ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " to paste a long block as text instead."
+ ],
"95ee62a0d6968b89": "Send message",
"1ad8b2750f0d2b17": "{returnKey} sends the message. {shiftReturn} inserts a new line.",
"92390c8eef972ca0": "Insert new line",
@@ -3808,6 +3824,9 @@
"4c2495d10dfbf72f": "queue",
"4ebe2aa17b91e168": "steer",
"48f04bb3132077ef": "while the agent is running",
+ "1481b12232710e91": "large pastes",
+ "715a3f6de78e8e6d": "attachment",
+ "f4da8226929a4a4c": "text file",
"ffb1ded95eb81974": "archive",
"3d5aeb06f2128b12": "archived",
"2a34f68d985e9fde": "restore",
diff --git a/apps/mobile/src/i18n/translations/es.json b/apps/mobile/src/i18n/translations/es.json
index 288dbfc7da2cf..bef3b43c83503 100644
--- a/apps/mobile/src/i18n/translations/es.json
+++ b/apps/mobile/src/i18n/translations/es.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Intentó iniciar {started} guía de revisión, {failed} con errores} other {Intentó iniciar {started} guías de revisión, {failed} con errores}}",
"672850007e49cfb6": "{started, plural, one {Inició {started} guía de revisión} other {Inició {started} guías de revisión}}",
"5dce4a54eaffeccf": "{started, plural, one {Intentó iniciar {started} guía de revisión} other {Intentó iniciar {started} guías de revisión}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB (~{characters, number} caracteres)",
+ "c62d732adb53f0ab": "{kilobytes} KB (~{characters, number} caracteres)",
"420bea546d5f8802": "Hilo copiado",
"2efb2dd3bf170f67": "No se pudo copiar el hilo",
"6c03545936b55e0b": "Enlace de la PR copiado",
@@ -3216,7 +3218,11 @@
"00b1b3b0bf010b1d": "Tu mensaje espera y se ejecuta cuando termina el turno actual.",
"79e87310525279f8": "Redirigir",
"a1e23f7b109d5925": "Tu mensaje llega al agente al instante y cambia aquello en lo que está trabajando.",
+ "12fbffef5c5d01d6": "La mayoría de los registros, trazas de pila y fragmentos de código se convierten en archivos.",
+ "6f73933b65186db1": "Los registros y documentos largos se convierten en archivos; los fragmentos siguen como texto.",
+ "ac160279d6fd62ea": "Predeterminado. Solo los pegados muy grandes se convierten en archivos.",
"683838755eb7fe37": "Mientras el agente trabaja",
+ "e0b70d25f7b2238d": "Adjuntar el texto pegado como archivo a partir de",
"afda415d2d75a5d3": "Chat",
"85163bc64c8c56a1": [
"Mantén pulsado el botón de enviar para usar la otra opción con un solo mensaje. Con un teclado físico, mantén ",
@@ -3227,6 +3233,15 @@
},
" al enviar."
],
+ "ac88b5819c86bc5b": [
+ "Los pegados más cortos entran en el mensaje como texto si caben. El texto no latino y los emojis ocupan más bytes por carácter, así que alcanzan el límite antes. Con un teclado físico, pulsa ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " para pegar un bloque largo como texto."
+ ],
"95ee62a0d6968b89": "Enviar mensaje",
"1ad8b2750f0d2b17": "{returnKey} envía el mensaje. {shiftReturn} inserta una línea nueva.",
"92390c8eef972ca0": "Insertar línea nueva",
@@ -3802,6 +3817,9 @@
"4c2495d10dfbf72f": "cola",
"4ebe2aa17b91e168": "redirigir",
"48f04bb3132077ef": "mientras el agente trabaja",
+ "1481b12232710e91": "pegados grandes",
+ "715a3f6de78e8e6d": "adjunto",
+ "f4da8226929a4a4c": "archivo de texto",
"ffb1ded95eb81974": "archivar",
"3d5aeb06f2128b12": "archivados",
"2a34f68d985e9fde": "restaurar",
diff --git a/apps/mobile/src/i18n/translations/fr.json b/apps/mobile/src/i18n/translations/fr.json
index 28ec2284fca74..a4d111e43262c 100644
--- a/apps/mobile/src/i18n/translations/fr.json
+++ b/apps/mobile/src/i18n/translations/fr.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Tentative de lancer {started} guide de revue, {failed} en échec} other {Tentative de lancer {started} guides de revue, {failed} en échec}}",
"672850007e49cfb6": "{started, plural, one {{started} guide de revue lancé} other {{started} guides de revue lancés}}",
"5dce4a54eaffeccf": "{started, plural, one {Tentative de lancer {started} guide de revue} other {Tentative de lancer {started} guides de revue}}",
+ "de2c541d89da7d2d": "{kibibytes} Kio (~{characters, number} caractères)",
+ "c62d732adb53f0ab": "{kilobytes} Ko (~{characters, number} caractères)",
"420bea546d5f8802": "Fil copié",
"2efb2dd3bf170f67": "Échec de la copie du fil",
"6c03545936b55e0b": "Lien de la PR copié",
@@ -3216,7 +3218,11 @@
"00b1b3b0bf010b1d": "Votre message attend et s’exécute une fois le tour actuel terminé.",
"79e87310525279f8": "Réorienter",
"a1e23f7b109d5925": "Votre message parvient immédiatement à l’agent et modifie ce sur quoi il travaille.",
+ "12fbffef5c5d01d6": "La plupart des journaux, traces de pile et extraits de code deviennent des fichiers.",
+ "6f73933b65186db1": "Les longs journaux et documents deviennent des fichiers ; les extraits restent du texte.",
+ "ac160279d6fd62ea": "Par défaut. Seuls les très longs collages deviennent des fichiers.",
"683838755eb7fe37": "Pendant que l’agent travaille",
+ "e0b70d25f7b2238d": "Joindre les collages en fichier à partir de",
"afda415d2d75a5d3": "Discussion",
"85163bc64c8c56a1": [
"Appuyez longuement sur le bouton d’envoi pour utiliser l’autre option pour un seul message. Avec un clavier physique, maintenez ",
@@ -3227,6 +3233,15 @@
},
" pendant l’envoi."
],
+ "ac88b5819c86bc5b": [
+ "Les collages plus courts sont insérés dans le message sous forme de texte s’ils y tiennent. Les textes non latins et les émojis occupent plus d’octets par caractère et atteignent donc la limite plus tôt. Avec un clavier physique, appuyez sur ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " pour coller un long bloc en tant que texte."
+ ],
"95ee62a0d6968b89": "Envoyer le message",
"1ad8b2750f0d2b17": "{returnKey} envoie le message. {shiftReturn} insère une nouvelle ligne.",
"92390c8eef972ca0": "Insérer une nouvelle ligne",
@@ -3802,6 +3817,9 @@
"4c2495d10dfbf72f": "file d’attente",
"4ebe2aa17b91e168": "réorienter",
"48f04bb3132077ef": "pendant que l’agent travaille",
+ "1481b12232710e91": "longs collages",
+ "715a3f6de78e8e6d": "pièce jointe",
+ "f4da8226929a4a4c": "fichier texte",
"ffb1ded95eb81974": "archiver",
"3d5aeb06f2128b12": "archivés",
"2a34f68d985e9fde": "restaurer",
diff --git a/apps/mobile/src/i18n/translations/ja.json b/apps/mobile/src/i18n/translations/ja.json
index f6741fdb8b775..1e16862f49463 100644
--- a/apps/mobile/src/i18n/translations/ja.json
+++ b/apps/mobile/src/i18n/translations/ja.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, other {{started} 件のレビューガイドを開始しようとしました。{failed} 件失敗しました}}",
"672850007e49cfb6": "{started, plural, other {{started} 件のレビューガイドを開始しました}}",
"5dce4a54eaffeccf": "{started, plural, other {{started} 件のレビューガイドを開始しようとしました}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB(約 {characters, number} 文字)",
+ "c62d732adb53f0ab": "{kilobytes} KB(約 {characters, number} 文字)",
"420bea546d5f8802": "スレッドをコピーしました",
"2efb2dd3bf170f67": "スレッドをコピーできませんでした",
"6c03545936b55e0b": "PR のリンクをコピーしました",
@@ -3213,7 +3215,11 @@
"00b1b3b0bf010b1d": "メッセージは待機し、現在のターンが終わった後に実行されます。",
"79e87310525279f8": "軌道修正",
"a1e23f7b109d5925": "メッセージはすぐにエージェントに届き、作業内容を変更します。",
+ "12fbffef5c5d01d6": "ほとんどのログ、スタックトレース、コードスニペットがファイルになります。",
+ "6f73933b65186db1": "長いログやドキュメントはファイルになり、スニペットはテキストのままです。",
+ "ac160279d6fd62ea": "デフォルト。非常に大きな貼り付けだけがファイルになります。",
"683838755eb7fe37": "エージェントの実行中",
+ "e0b70d25f7b2238d": "貼り付けをファイルとして添付するサイズ",
"afda415d2d75a5d3": "チャット",
"85163bc64c8c56a1": [
"1 つのメッセージだけもう一方のオプションを使うには、送信ボタンを長押しします。ハードウェアキーボードでは、",
@@ -3224,6 +3230,15 @@
},
" を押しながら送信します。"
],
+ "ac88b5819c86bc5b": [
+ "これより短い貼り付けは、メッセージに収まる場合はテキストとして入ります。ラテン文字以外の文字や絵文字は 1 文字あたりのバイト数が多いため、より少ない文字数で上限に達します。ハードウェアキーボードでは、",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " を押すと長いブロックをテキストのまま貼り付けられます。"
+ ],
"95ee62a0d6968b89": "メッセージを送信",
"1ad8b2750f0d2b17": "{returnKey} でメッセージを送信し、{shiftReturn} で改行します。",
"92390c8eef972ca0": "改行を挿入",
@@ -3799,6 +3814,9 @@
"4c2495d10dfbf72f": "キュー",
"4ebe2aa17b91e168": "軌道修正",
"48f04bb3132077ef": "エージェントの実行中",
+ "1481b12232710e91": "大きな貼り付け",
+ "715a3f6de78e8e6d": "添付",
+ "f4da8226929a4a4c": "テキストファイル",
"ffb1ded95eb81974": "アーカイブ",
"3d5aeb06f2128b12": "アーカイブ済み",
"2a34f68d985e9fde": "復元",
diff --git a/apps/mobile/src/i18n/translations/ko.json b/apps/mobile/src/i18n/translations/ko.json
index b1ef20ba0f347..81ee724e3a879 100644
--- a/apps/mobile/src/i18n/translations/ko.json
+++ b/apps/mobile/src/i18n/translations/ko.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, other {검토 가이드 {started}개 시작 시도함, {failed}개 실패}}",
"672850007e49cfb6": "{started, plural, other {검토 가이드 {started}개 시작함}}",
"5dce4a54eaffeccf": "{started, plural, other {검토 가이드 {started}개 시작 시도함}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB(약 {characters, number}자)",
+ "c62d732adb53f0ab": "{kilobytes} KB(약 {characters, number}자)",
"420bea546d5f8802": "스레드 복사됨",
"2efb2dd3bf170f67": "스레드를 복사하지 못했습니다",
"6c03545936b55e0b": "PR 링크 복사됨",
@@ -3217,7 +3219,11 @@
"00b1b3b0bf010b1d": "메시지가 대기했다가 현재 턴이 끝난 뒤 실행됩니다.",
"79e87310525279f8": "방향 조정",
"a1e23f7b109d5925": "메시지가 즉시 에이전트에 전달되어 진행 중인 작업을 바꿉니다.",
+ "12fbffef5c5d01d6": "대부분의 로그, 스택 트레이스, 코드 조각이 파일이 됩니다.",
+ "6f73933b65186db1": "긴 로그와 문서는 파일이 되고, 코드 조각은 텍스트로 남습니다.",
+ "ac160279d6fd62ea": "기본값. 아주 큰 붙여넣기만 파일이 됩니다.",
"683838755eb7fe37": "에이전트가 실행 중일 때",
+ "e0b70d25f7b2238d": "붙여넣기를 파일로 첨부하는 크기",
"afda415d2d75a5d3": "채팅",
"85163bc64c8c56a1": [
"보내기 버튼을 길게 누르면 메시지 하나에 대해 다른 옵션을 사용합니다. 하드웨어 키보드에서는 ",
@@ -3228,6 +3234,15 @@
},
"를 누른 채 보내세요."
],
+ "ac88b5819c86bc5b": [
+ "이보다 짧은 붙여넣기는 메시지에 들어갈 수 있으면 텍스트로 들어갑니다. 라틴 문자가 아닌 글자와 이모지는 글자당 바이트 수가 많아 더 적은 글자 수로 한도에 도달합니다. 하드웨어 키보드에서는 ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ "를 누르면 긴 블록을 텍스트로 붙여 넣습니다."
+ ],
"95ee62a0d6968b89": "메시지 보내기",
"1ad8b2750f0d2b17": "{returnKey}는 메시지를 보냅니다. {shiftReturn}은 새 줄을 넣습니다.",
"92390c8eef972ca0": "새 줄 넣기",
@@ -3803,6 +3818,9 @@
"4c2495d10dfbf72f": "대기열",
"4ebe2aa17b91e168": "방향 조정",
"48f04bb3132077ef": "에이전트 실행 중",
+ "1481b12232710e91": "큰 붙여넣기",
+ "715a3f6de78e8e6d": "첨부",
+ "f4da8226929a4a4c": "텍스트 파일",
"ffb1ded95eb81974": "보관",
"3d5aeb06f2128b12": "보관됨",
"2a34f68d985e9fde": "복원",
diff --git a/apps/mobile/src/i18n/translations/pt-BR.json b/apps/mobile/src/i18n/translations/pt-BR.json
index b40494fca3885..e7770790b1a46 100644
--- a/apps/mobile/src/i18n/translations/pt-BR.json
+++ b/apps/mobile/src/i18n/translations/pt-BR.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Tentou iniciar {started} guia de revisão, {failed} com falha} other {Tentou iniciar {started} guias de revisão, {failed} com falha}}",
"672850007e49cfb6": "{started, plural, one {Iniciou {started} guia de revisão} other {Iniciou {started} guias de revisão}}",
"5dce4a54eaffeccf": "{started, plural, one {Tentou iniciar {started} guia de revisão} other {Tentou iniciar {started} guias de revisão}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB (~{characters, number} caracteres)",
+ "c62d732adb53f0ab": "{kilobytes} KB (~{characters, number} caracteres)",
"420bea546d5f8802": "Thread copiada",
"2efb2dd3bf170f67": "Falha ao copiar a thread",
"6c03545936b55e0b": "Link do PR copiado",
@@ -3216,7 +3218,11 @@
"00b1b3b0bf010b1d": "Sua mensagem aguarda e é executada depois que o turno atual termina.",
"79e87310525279f8": "Direcionar",
"a1e23f7b109d5925": "Sua mensagem chega ao agente imediatamente, mudando o que ele está fazendo.",
+ "12fbffef5c5d01d6": "A maioria dos logs, stack traces e trechos de código vira arquivo.",
+ "6f73933b65186db1": "Logs e documentos longos viram arquivos; trechos continuam como texto.",
+ "ac160279d6fd62ea": "Padrão. Só colagens muito grandes viram arquivos.",
"683838755eb7fe37": "Enquanto o agente está em execução",
+ "e0b70d25f7b2238d": "Anexar colagens como arquivo a partir de",
"afda415d2d75a5d3": "Chat",
"85163bc64c8c56a1": [
"Mantenha pressionado o botão de enviar para usar a outra opção em uma única mensagem. Com um teclado físico, segure ",
@@ -3227,6 +3233,15 @@
},
" ao enviar."
],
+ "ac88b5819c86bc5b": [
+ "Colagens mais curtas entram na mensagem como texto se couberem. Texto não latino e emojis usam mais bytes por caractere, então chegam ao limite antes. Com um teclado físico, pressione ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " para colar um bloco longo como texto."
+ ],
"95ee62a0d6968b89": "Enviar mensagem",
"1ad8b2750f0d2b17": "{returnKey} envia a mensagem. {shiftReturn} insere uma nova linha.",
"92390c8eef972ca0": "Inserir nova linha",
@@ -3802,6 +3817,9 @@
"4c2495d10dfbf72f": "fila",
"4ebe2aa17b91e168": "direcionar",
"48f04bb3132077ef": "enquanto o agente está em execução",
+ "1481b12232710e91": "colagens grandes",
+ "715a3f6de78e8e6d": "anexo",
+ "f4da8226929a4a4c": "arquivo de texto",
"ffb1ded95eb81974": "arquivar",
"3d5aeb06f2128b12": "arquivadas",
"2a34f68d985e9fde": "restaurar",
diff --git a/apps/mobile/src/i18n/translations/ru.json b/apps/mobile/src/i18n/translations/ru.json
index cadf07e57eda9..08fbbc780903e 100644
--- a/apps/mobile/src/i18n/translations/ru.json
+++ b/apps/mobile/src/i18n/translations/ru.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Попытка начать {started} руководство по ревью, ошибок: {failed}} few {Попытка начать {started} руководства по ревью, ошибок: {failed}} many {Попытка начать {started} руководств по ревью, ошибок: {failed}} other {Попытка начать {started} руководства по ревью, ошибок: {failed}}}",
"672850007e49cfb6": "{started, plural, one {Начато {started} руководство по ревью} few {Начато {started} руководства по ревью} many {Начато {started} руководств по ревью} other {Начато {started} руководства по ревью}}",
"5dce4a54eaffeccf": "{started, plural, one {Попытка начать {started} руководство по ревью} few {Попытка начать {started} руководства по ревью} many {Попытка начать {started} руководств по ревью} other {Попытка начать {started} руководства по ревью}}",
+ "de2c541d89da7d2d": "{kibibytes} КиБ (~{characters, number} симв.)",
+ "c62d732adb53f0ab": "{kilobytes} КБ (~{characters, number} симв.)",
"420bea546d5f8802": "Тред скопирован",
"2efb2dd3bf170f67": "Не удалось скопировать тред",
"6c03545936b55e0b": "Ссылка на PR скопирована",
@@ -3270,7 +3272,11 @@
"00b1b3b0bf010b1d": "Ваше сообщение ждёт и выполняется после окончания текущего хода.",
"79e87310525279f8": "Скорректировать",
"a1e23f7b109d5925": "Ваше сообщение сразу доходит до агента и меняет то, над чем он работает.",
+ "12fbffef5c5d01d6": "Большинство логов, трассировок стека и фрагментов кода становятся файлами.",
+ "6f73933b65186db1": "Длинные логи и документы становятся файлами; фрагменты остаются текстом.",
+ "ac160279d6fd62ea": "По умолчанию. Файлами становятся только очень большие вставки.",
"683838755eb7fe37": "Пока агент работает",
+ "e0b70d25f7b2238d": "Прикреплять вставки файлом начиная с",
"afda415d2d75a5d3": "Чат",
"85163bc64c8c56a1": [
"Нажмите и удерживайте кнопку отправки, чтобы использовать другой вариант для одного сообщения. С аппаратной клавиатурой удерживайте ",
@@ -3281,6 +3287,15 @@
},
" при отправке."
],
+ "ac88b5819c86bc5b": [
+ "Более короткие вставки попадают в сообщение как текст, если помещаются. Нелатинский текст и эмодзи занимают больше байтов на символ, поэтому достигают лимита раньше. С аппаратной клавиатурой нажмите ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ ", чтобы вставить длинный блок как текст."
+ ],
"95ee62a0d6968b89": "Отправить сообщение",
"1ad8b2750f0d2b17": "{returnKey} отправляет сообщение. {shiftReturn} вставляет новую строку.",
"92390c8eef972ca0": "Вставить новую строку",
@@ -3856,6 +3871,9 @@
"4c2495d10dfbf72f": "очередь",
"4ebe2aa17b91e168": "корректировка",
"48f04bb3132077ef": "пока агент работает",
+ "1481b12232710e91": "большие вставки",
+ "715a3f6de78e8e6d": "вложение",
+ "f4da8226929a4a4c": "текстовый файл",
"ffb1ded95eb81974": "архивировать",
"3d5aeb06f2128b12": "в архиве",
"2a34f68d985e9fde": "восстановить",
diff --git a/apps/mobile/src/i18n/translations/sv.json b/apps/mobile/src/i18n/translations/sv.json
index 3a0273aef36fd..1b5ea667c7692 100644
--- a/apps/mobile/src/i18n/translations/sv.json
+++ b/apps/mobile/src/i18n/translations/sv.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, one {Försökte starta {started} granskningsguide, {failed} misslyckades} other {Försökte starta {started} granskningsguider, {failed} misslyckades}}",
"672850007e49cfb6": "{started, plural, one {Startade {started} granskningsguide} other {Startade {started} granskningsguider}}",
"5dce4a54eaffeccf": "{started, plural, one {Försökte starta {started} granskningsguide} other {Försökte starta {started} granskningsguider}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB (~{characters, number} tecken)",
+ "c62d732adb53f0ab": "{kilobytes} kB (~{characters, number} tecken)",
"420bea546d5f8802": "Tråden kopierades",
"2efb2dd3bf170f67": "Det gick inte att kopiera tråden",
"6c03545936b55e0b": "PR-länken kopierades",
@@ -3222,7 +3224,11 @@
"00b1b3b0bf010b1d": "Ditt meddelande väntar och körs när den aktuella omgången är klar.",
"79e87310525279f8": "Styr om",
"a1e23f7b109d5925": "Ditt meddelande når agenten direkt och ändrar det den arbetar med.",
+ "12fbffef5c5d01d6": "De flesta loggar, stackspårningar och kodsnuttar blir filer.",
+ "6f73933b65186db1": "Långa loggar och dokument blir filer; kodsnuttar förblir text.",
+ "ac160279d6fd62ea": "Standard. Bara mycket stora inklistringar blir filer.",
"683838755eb7fe37": "Medan agenten körs",
+ "e0b70d25f7b2238d": "Bifoga inklistringar som filer från",
"afda415d2d75a5d3": "Chatt",
"85163bc64c8c56a1": [
"Tryck länge på skicka-knappen för att använda det andra alternativet för ett enskilt meddelande. Med ett fysiskt tangentbord håller du ned ",
@@ -3233,6 +3239,15 @@
},
" när du skickar."
],
+ "ac88b5819c86bc5b": [
+ "Kortare inklistringar hamnar som text i meddelandet om de får plats. Icke-latinsk text och emojier tar fler byte per tecken och når gränsen därför tidigare. Med ett fysiskt tangentbord trycker du på ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " för att klistra in ett långt block som text i stället."
+ ],
"95ee62a0d6968b89": "Skicka meddelande",
"1ad8b2750f0d2b17": "{returnKey} skickar meddelandet. {shiftReturn} infogar en ny rad.",
"92390c8eef972ca0": "Infoga ny rad",
@@ -3808,6 +3823,9 @@
"4c2495d10dfbf72f": "köa",
"4ebe2aa17b91e168": "styr om",
"48f04bb3132077ef": "medan agenten körs",
+ "1481b12232710e91": "stora inklistringar",
+ "715a3f6de78e8e6d": "bilaga",
+ "f4da8226929a4a4c": "textfil",
"ffb1ded95eb81974": "arkivera",
"3d5aeb06f2128b12": "arkiverade",
"2a34f68d985e9fde": "återställ",
diff --git a/apps/mobile/src/i18n/translations/zh.json b/apps/mobile/src/i18n/translations/zh.json
index f1c394c60c606..b7d0eedb84ba3 100644
--- a/apps/mobile/src/i18n/translations/zh.json
+++ b/apps/mobile/src/i18n/translations/zh.json
@@ -306,6 +306,8 @@
"1b659e38a50d9bc5": "{started, plural, other {尝试开始 {started} 份审查导览,{failed} 份失败}}",
"672850007e49cfb6": "{started, plural, other {已开始 {started} 份审查导览}}",
"5dce4a54eaffeccf": "{started, plural, other {尝试开始 {started} 份审查导览}}",
+ "de2c541d89da7d2d": "{kibibytes} KiB(约 {characters, number} 个字符)",
+ "c62d732adb53f0ab": "{kilobytes} KB(约 {characters, number} 个字符)",
"420bea546d5f8802": "已复制会话",
"2efb2dd3bf170f67": "无法复制会话",
"6c03545936b55e0b": "已复制 PR 链接",
@@ -3218,7 +3220,11 @@
"00b1b3b0bf010b1d": "你的消息会等待,并在当前轮次结束后运行。",
"79e87310525279f8": "引导当前执行",
"a1e23f7b109d5925": "你的消息会立即传达给智能体,改变它正在进行的工作。",
+ "12fbffef5c5d01d6": "大多数日志、堆栈跟踪和代码片段会变成文件。",
+ "6f73933b65186db1": "长日志和文档会变成文件;代码片段保持为文字。",
+ "ac160279d6fd62ea": "默认。只有非常大的粘贴内容会变成文件。",
"683838755eb7fe37": "智能体运行时",
+ "e0b70d25f7b2238d": "粘贴内容达到此大小时作为文件附加",
"afda415d2d75a5d3": "聊天",
"85163bc64c8c56a1": [
"长按发送按钮可对单条消息使用另一选项。使用硬件键盘时,发送时按住 ",
@@ -3229,6 +3235,15 @@
},
"。"
],
+ "ac88b5819c86bc5b": [
+ "较短的粘贴内容在消息容纳得下时会作为文字进入消息。非拉丁文字和表情符号每个字符占用更多字节,因此会更早达到上限。使用硬件键盘时,按 ",
+ {
+ "i": 1,
+ "k": "_gt_value_1",
+ "v": "v"
+ },
+ " 可将长文本块作为文字粘贴。"
+ ],
"95ee62a0d6968b89": "发送消息",
"1ad8b2750f0d2b17": "{returnKey} 发送消息。{shiftReturn} 插入新行。",
"92390c8eef972ca0": "插入新行",
@@ -3804,6 +3819,9 @@
"4c2495d10dfbf72f": "加入队列",
"4ebe2aa17b91e168": "引导当前执行",
"48f04bb3132077ef": "智能体运行时",
+ "1481b12232710e91": "大段粘贴",
+ "715a3f6de78e8e6d": "附件",
+ "f4da8226929a4a4c": "文本文件",
"ffb1ded95eb81974": "归档",
"3d5aeb06f2128b12": "已归档",
"2a34f68d985e9fde": "恢复",
diff --git a/apps/mobile/src/lib/usePastedTextAttachmentThreshold.ts b/apps/mobile/src/lib/usePastedTextAttachmentThreshold.ts
new file mode 100644
index 0000000000000..a798ea756b301
--- /dev/null
+++ b/apps/mobile/src/lib/usePastedTextAttachmentThreshold.ts
@@ -0,0 +1,19 @@
+import { useAtomValue } from "@effect/atom-react";
+import { DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD } from "@t3tools/contracts";
+import { AsyncResult } from "effect/reactivity";
+
+import { mobilePreferencesAtom } from "../state/preferences";
+
+/**
+ * Paste size at which the composer folds clipboard text into a text-file
+ * attachment. Selects only the threshold so unrelated preference writes do not
+ * re-render the composer editors.
+ */
+export function usePastedTextAttachmentThreshold() {
+ return useAtomValue(mobilePreferencesAtom, (preferences) =>
+ AsyncResult.isSuccess(preferences)
+ ? (preferences.value.pastedTextAttachmentThreshold ??
+ DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD)
+ : DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD,
+ );
+}
diff --git a/apps/mobile/src/native/T3ComposerEditor.ios.tsx b/apps/mobile/src/native/T3ComposerEditor.ios.tsx
index e8f0a1253e374..aab1994cd2f72 100644
--- a/apps/mobile/src/native/T3ComposerEditor.ios.tsx
+++ b/apps/mobile/src/native/T3ComposerEditor.ios.tsx
@@ -1,4 +1,3 @@
-import { PASTED_TEXT_ATTACHMENT_THRESHOLD_BYTES } from "@t3tools/client-runtime/text-paste";
import { PROVIDER_SEND_TURN_MAX_INPUT_CHARS } from "@t3tools/contracts";
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
import { composerContextEditorTokens, composerSkillLabels } from "../lib/composerContext";
@@ -28,6 +27,7 @@ import { contextChipIconUri, modelChipIcon, modelChipIconUri } from "../lib/cont
import { useUniwindTheme } from "../lib/useUniwindTheme";
import { createNativeComposerTheme } from "../lib/nativeComposerTheme";
import { FONT_FAMILIES } from "../lib/fontFamilies";
+import { usePastedTextAttachmentThreshold } from "../lib/usePastedTextAttachmentThreshold";
import { useComposerTextRole } from "../features/settings/appearance/useScaledTextRole";
import {
acknowledgeComposerNativeEvent,
@@ -181,6 +181,7 @@ export function ComposerEditor({
const bodyText = useComposerTextRole();
const theme = useUniwindTheme();
const fontFamily = FONT_FAMILIES.regular;
+ const pastedTextAttachmentThreshold = usePastedTextAttachmentThreshold();
const skillLabels = useMemo(() => composerSkillLabels(skills), [skills]);
const { modelsBySource, modelTokens } = useComposerModelTokens(props.value, models);
@@ -374,7 +375,7 @@ export function ComposerEditor({
autoFocus={props.autoFocus ?? false}
autoCorrect={props.autoCorrect ?? true}
spellCheck={props.spellCheck ?? true}
- textPasteThresholdBytes={onPasteText ? PASTED_TEXT_ATTACHMENT_THRESHOLD_BYTES : 0}
+ textPasteThresholdBytes={onPasteText ? pastedTextAttachmentThreshold : 0}
maxInputChars={PROVIDER_SEND_TURN_MAX_INPUT_CHARS}
style={style as StyleProp}
onComposerChange={(event) => applyNativeChange(event.nativeEvent)}
diff --git a/apps/mobile/src/native/T3ComposerEditor.native.tsx b/apps/mobile/src/native/T3ComposerEditor.native.tsx
index 5aabd8e0d6071..b957a4d1e054c 100644
--- a/apps/mobile/src/native/T3ComposerEditor.native.tsx
+++ b/apps/mobile/src/native/T3ComposerEditor.native.tsx
@@ -1,4 +1,3 @@
-import { PASTED_TEXT_ATTACHMENT_THRESHOLD_BYTES } from "@t3tools/client-runtime/text-paste";
import { PROVIDER_SEND_TURN_MAX_INPUT_CHARS } from "@t3tools/contracts";
import { collectComposerInlineTokens } from "@t3tools/shared/composerInlineTokens";
import { composerContextEditorTokens, composerSkillLabels } from "../lib/composerContext";
@@ -29,6 +28,7 @@ import { contextChipIconUri, modelChipIcon, modelChipIconUri } from "../lib/cont
import { MOBILE_TYPOGRAPHY } from "../lib/typography";
import { useNativePaste } from "../lib/useNativePaste";
import { FONT_FAMILIES } from "../lib/fontFamilies";
+import { usePastedTextAttachmentThreshold } from "../lib/usePastedTextAttachmentThreshold";
import { useAppearancePreferences } from "../features/settings/appearance/AppearancePreferencesProvider";
import { useUniwindTheme } from "../lib/useUniwindTheme";
import { createNativeComposerTheme } from "../lib/nativeComposerTheme";
@@ -313,6 +313,7 @@ export function ComposerEditor({
});
const resolvedTextStyle = StyleSheet.flatten(textStyle) ?? {};
const regularFontFamily = FONT_FAMILIES.regular;
+ const pastedTextAttachmentThreshold = usePastedTextAttachmentThreshold();
return (
{
diff --git a/apps/mobile/src/persistence/mobile-preferences.ts b/apps/mobile/src/persistence/mobile-preferences.ts
index 71d095b0b4fb5..f2664f05ae2f1 100644
--- a/apps/mobile/src/persistence/mobile-preferences.ts
+++ b/apps/mobile/src/persistence/mobile-preferences.ts
@@ -14,6 +14,7 @@ import {
PullRequestInvolvement,
PullRequestListFilters,
PullRequestListState,
+ PastedTextAttachmentThreshold,
type ProviderInstanceId,
PullRequestMergeMethod,
type SidebarProjectGroupingMode,
@@ -31,6 +32,7 @@ import { MobileStorageDecodeError, MobileStorageEncodeError } from "./mobile-sto
const PREFERENCES_KEY = "t3code.preferences";
const PREFERENCES_FALLBACK_KEY = "t3code.preferences.fallback";
const encodeJson = Schema.encodeUnknownEffect(Schema.fromJsonString(Schema.Unknown));
+const isPastedTextAttachmentThreshold = Schema.is(PastedTextAttachmentThreshold);
export const PullRequestListControls = Schema.Struct({
state: PullRequestListState,
@@ -162,6 +164,7 @@ export interface Preferences {
/** Hardware-keyboard Return behavior in the composer. */
readonly composerEnterBehavior?: ComposerEnterBehavior;
readonly followUpBehavior?: FollowUpBehavior;
+ readonly pastedTextAttachmentThreshold?: PastedTextAttachmentThreshold;
/** The client `language` setting: a locale code or "system". Unset means English. */
readonly language?: string;
readonly microphones?: ReadonlyArray;
@@ -253,6 +256,7 @@ function sanitizePreferences(parsed: Preferences): Preferences {
dismissedDatabaseStorageNotices?: readonly string[];
composerEnterBehavior?: ComposerEnterBehavior;
followUpBehavior?: FollowUpBehavior;
+ pastedTextAttachmentThreshold?: PastedTextAttachmentThreshold;
language?: string;
microphones?: ReadonlyArray;
projectGroupingEnabled?: boolean;
@@ -368,6 +372,9 @@ function sanitizePreferences(parsed: Preferences): Preferences {
if (parsed.followUpBehavior === "queue" || parsed.followUpBehavior === "steer") {
preferences.followUpBehavior = parsed.followUpBehavior;
}
+ if (isPastedTextAttachmentThreshold(parsed.pastedTextAttachmentThreshold)) {
+ preferences.pastedTextAttachmentThreshold = parsed.pastedTextAttachmentThreshold;
+ }
if (typeof parsed.language === "string") preferences.language = parsed.language;
if (Array.isArray(parsed.microphones)) {
preferences.microphones = parsed.microphones.flatMap((entry): MicrophoneEntry[] => {
diff --git a/apps/web/src/components/chat/ChatComposer.tsx b/apps/web/src/components/chat/ChatComposer.tsx
index fb4ed5eb0f626..b1208a6f8cad7 100644
--- a/apps/web/src/components/chat/ChatComposer.tsx
+++ b/apps/web/src/components/chat/ChatComposer.tsx
@@ -2724,6 +2724,7 @@ export const ChatComposer = memo(function ChatComposer(props: ChatComposerProps)
questionAttachmentTarget,
attachmentTargetKey,
fileStagingLimit,
+ pastedTextAttachmentThreshold: settings.pastedTextAttachmentThreshold,
promptRef,
composerImagesRef,
composerFilesRef,
diff --git a/apps/web/src/components/chat/useComposerAttachmentIntake.browser.test.tsx b/apps/web/src/components/chat/useComposerAttachmentIntake.browser.test.tsx
index 9060af0d9fac7..c4ee753eebffd 100644
--- a/apps/web/src/components/chat/useComposerAttachmentIntake.browser.test.tsx
+++ b/apps/web/src/components/chat/useComposerAttachmentIntake.browser.test.tsx
@@ -1,5 +1,6 @@
import { useEffect } from "react";
import { EnvironmentId, ProjectId, ThreadId } from "@t3tools/contracts";
+import { DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD } from "@t3tools/contracts/settings";
import { scopeProjectRef, scopeThreadRef } from "@t3tools/client-runtime/environment";
import { expect, it, vi } from "vite-plus/test";
import { AsyncResult } from "effect/reactivity";
@@ -86,6 +87,7 @@ it("prepares a repeated paste without a tile, and still keeps a different image"
questionAttachmentTarget: null,
attachmentTargetKey: target,
fileStagingLimit: null,
+ pastedTextAttachmentThreshold: DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD,
promptRef: { current: "" },
composerImagesRef,
composerFilesRef: { current: [] },
@@ -171,6 +173,7 @@ it.each(["thread", "session"] as const)(
questionAttachmentTarget: null,
attachmentTargetKey: targetKey,
fileStagingLimit: null,
+ pastedTextAttachmentThreshold: DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD,
promptRef: { current: "half-written prompt" },
composerImagesRef: { current: [] },
composerFilesRef: { current: [] },
@@ -217,3 +220,53 @@ it.each(["thread", "session"] as const)(
expect(restored?.images).toEqual([]);
},
);
+
+it.each([
+ { thresholdBytes: 1_000, folds: true },
+ { thresholdBytes: DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD, folds: false },
+])(
+ "a 4,600-byte paste at a $thresholdBytes-byte threshold folds: $folds",
+ async ({ thresholdBytes, folds }) => {
+ const attachedNames: string[] = [];
+ const input = {
+ activeThreadId: ThreadId.make("thread"),
+ activePendingProgress: null,
+ activePendingIsResponding: false,
+ pendingUserInputs: [],
+ supportsQuestionAttachments: false,
+ isLiteralPendingAnswer: false,
+ projectSelectionRequired: false,
+ questionAttachmentTarget: null,
+ attachmentTargetKey: DraftId.make("intake-paste-threshold"),
+ fileStagingLimit: 1_000_000,
+ pastedTextAttachmentThreshold: thresholdBytes,
+ promptRef: { current: "" },
+ composerImagesRef: { current: [] },
+ composerFilesRef: { current: [] },
+ composerEditorRef: { current: null },
+ isRevertingCheckpointRef: { current: false },
+ setThreadError: () => {},
+ countReservedAttachments: () => 0,
+ addComposerImage: () => [],
+ addComposerImagesToDraft: () => [],
+ addComposerFilesToDraft: (files) => {
+ attachedNames.push(...files.map((file) => file.name));
+ return [];
+ },
+ removeComposerImageFromDraft: () => {},
+ insertAttachmentReferences: () => false,
+ } satisfies IntakeInput;
+ let intake!: Intake;
+ await using _screen = await render(
+ {
+ intake = value;
+ }}
+ />,
+ );
+
+ expect(intake.foldPastedText("x".repeat(4_600), false)).toBe(folds);
+ expect(attachedNames).toEqual(folds ? ["pasted-text.txt"] : []);
+ },
+);
diff --git a/apps/web/src/components/chat/useComposerAttachmentIntake.ts b/apps/web/src/components/chat/useComposerAttachmentIntake.ts
index d6f981bc9440a..a6a0585020751 100644
--- a/apps/web/src/components/chat/useComposerAttachmentIntake.ts
+++ b/apps/web/src/components/chat/useComposerAttachmentIntake.ts
@@ -75,6 +75,7 @@ export function useComposerAttachmentIntake(input: {
readonly questionAttachmentTarget: DraftId | null;
readonly attachmentTargetKey: string;
readonly fileStagingLimit: number | null;
+ readonly pastedTextAttachmentThreshold: number;
readonly promptRef: ChatComposerProps["promptRef"];
readonly composerImagesRef: ChatComposerProps["composerImagesRef"];
readonly composerFilesRef: ChatComposerProps["composerFilesRef"];
@@ -103,6 +104,7 @@ export function useComposerAttachmentIntake(input: {
questionAttachmentTarget,
attachmentTargetKey,
fileStagingLimit,
+ pastedTextAttachmentThreshold,
promptRef,
composerImagesRef,
composerFilesRef,
@@ -435,6 +437,7 @@ export function useComposerAttachmentIntake(input: {
bypassAutoAttachment,
wouldExceedInputLimit,
canAttach: true,
+ thresholdBytes: pastedTextAttachmentThreshold,
}) === "attachment";
if (!shouldFold) {
return false;
diff --git a/apps/web/src/components/settings/SettingsPanels.tsx b/apps/web/src/components/settings/SettingsPanels.tsx
index e0a12417848fa..e66b997ab0627 100644
--- a/apps/web/src/components/settings/SettingsPanels.tsx
+++ b/apps/web/src/components/settings/SettingsPanels.tsx
@@ -16,11 +16,13 @@ import {
type ProviderInstanceId,
type SidebarProjectGroupingMode,
} from "@t3tools/contracts";
+import { pastedTextThresholdLabel } from "@t3tools/client-runtime/text-paste";
import {
DEFAULT_UNIFIED_SETTINGS,
type DiffLayout,
MAX_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
MIN_SIDEBAR_AUTO_SETTLE_AFTER_DAYS,
+ PASTED_TEXT_ATTACHMENT_THRESHOLDS,
type ResponseStreamingMode,
type QuitConfirmationMode,
SidebarProjectSortOrder,
@@ -576,6 +578,10 @@ export function useSettingsRestore(onRestored?: () => void) {
...(settings.sendShortcut !== DEFAULT_UNIFIED_SETTINGS.sendShortcut
? [gt("Send shortcut")]
: []),
+ ...(settings.pastedTextAttachmentThreshold !==
+ DEFAULT_UNIFIED_SETTINGS.pastedTextAttachmentThreshold
+ ? [gt("Large paste threshold")]
+ : []),
...(settings.followUpBehavior !== DEFAULT_UNIFIED_SETTINGS.followUpBehavior
? [gt("Follow-up behavior")]
: []),
@@ -709,6 +715,7 @@ export function useSettingsRestore(onRestored?: () => void) {
showSkillsInSlashMenu: DEFAULT_UNIFIED_SETTINGS.showSkillsInSlashMenu,
composerRichTextEnabled: DEFAULT_UNIFIED_SETTINGS.composerRichTextEnabled,
sendShortcut: DEFAULT_UNIFIED_SETTINGS.sendShortcut,
+ pastedTextAttachmentThreshold: DEFAULT_UNIFIED_SETTINGS.pastedTextAttachmentThreshold,
followUpBehavior: DEFAULT_UNIFIED_SETTINGS.followUpBehavior,
toolCallVisibility: DEFAULT_UNIFIED_SETTINGS.toolCallVisibility,
screenReaderAnnouncements: DEFAULT_UNIFIED_SETTINGS.screenReaderAnnouncements,
@@ -1213,6 +1220,7 @@ export function GeneralSettingsPanel() {
export function ChatSettingsPanel() {
const setting = useSearchableSetting();
const gt = useGT();
+ const m = useMessages();
const modifierLabel = isMacPlatform(navigator.platform) ? "⌘" : "Ctrl";
const sendShortcutOptions = [
{ value: "enter", label: "Enter" },
@@ -1300,6 +1308,60 @@ export function ChatSettingsPanel() {
}
/>
+
+ updateSettings({
+ pastedTextAttachmentThreshold:
+ DEFAULT_UNIFIED_SETTINGS.pastedTextAttachmentThreshold,
+ })
+ }
+ />
+ ) : null
+ }
+ control={
+
+ }
+ />
{
it("accepts the V key on non-Latin layouts but follows the letter on Latin ones", () => {
@@ -10,3 +11,32 @@ describe("isPasteAsTextShortcut", () => {
expect(isPasteAsTextShortcut({ ...chord, key: "V", code: "Period" }, false)).toBe(true);
});
});
+
+describe("pastedTextDisposition", () => {
+ it("folds at each selectable threshold", () => {
+ for (const thresholdBytes of PASTED_TEXT_ATTACHMENT_THRESHOLDS) {
+ expect(
+ pastedTextDisposition({
+ text: "x".repeat(thresholdBytes - 1),
+ canAttach: true,
+ thresholdBytes,
+ }),
+ ).toBe("inline");
+ expect(
+ pastedTextDisposition({
+ text: "x".repeat(thresholdBytes),
+ canAttach: true,
+ thresholdBytes,
+ }),
+ ).toBe("attachment");
+ }
+ });
+
+ it("counts UTF-8 bytes, so non-Latin text folds with fewer characters", () => {
+ const text = "日本語".repeat(120);
+ expect(text.length).toBeLessThan(1_000);
+ expect(pastedTextDisposition({ text, canAttach: true, thresholdBytes: 1_000 })).toBe(
+ "attachment",
+ );
+ });
+});
diff --git a/packages/client-runtime/src/textPaste.ts b/packages/client-runtime/src/textPaste.ts
index 59a6182034572..065a51ecad396 100644
--- a/packages/client-runtime/src/textPaste.ts
+++ b/packages/client-runtime/src/textPaste.ts
@@ -1,4 +1,5 @@
-export const PASTED_TEXT_ATTACHMENT_THRESHOLD_BYTES = 32 * 1024;
+import { mFallback, msg } from "gt-i18n";
+import type { MFunctionType } from "gt-i18n/types";
const textEncoder = new TextEncoder();
@@ -25,12 +26,14 @@ export function isPasteAsTextShortcut(
}
/**
- * The threshold is byte-based: character counts substantially understate the
- * context cost of some Unicode-heavy clipboard contents.
+ * `thresholdBytes` is the `pastedTextAttachmentThreshold` setting. It is compared
+ * with both the length and the UTF-8 byte count: character counts substantially
+ * understate the context cost of some Unicode-heavy clipboard contents.
*/
export function pastedTextDisposition(input: {
readonly text: string;
readonly canAttach: boolean;
+ readonly thresholdBytes: number;
readonly bypassAutoAttachment?: boolean;
readonly wouldExceedInputLimit?: boolean;
}): PastedTextDisposition {
@@ -38,12 +41,34 @@ export function pastedTextDisposition(input: {
return "inline";
}
return input.wouldExceedInputLimit ||
- input.text.length >= PASTED_TEXT_ATTACHMENT_THRESHOLD_BYTES ||
- textEncoder.encode(input.text).byteLength >= PASTED_TEXT_ATTACHMENT_THRESHOLD_BYTES
+ input.text.length >= input.thresholdBytes ||
+ textEncoder.encode(input.text).byteLength >= input.thresholdBytes
? "attachment"
: "inline";
}
+/**
+ * Settings label for a `pastedTextAttachmentThreshold` preset, such as
+ * "5 KB (~5,000 chars)". Sizes come first because the threshold also counts
+ * UTF-8 bytes, so non-Latin text and emoji fold with fewer characters.
+ */
+export function pastedTextThresholdLabel(
+ thresholdBytes: number,
+ resolve: MFunctionType = mFallback,
+) {
+ return resolve(
+ thresholdBytes % 1024 === 0
+ ? msg("{kibibytes} KiB (~{characters, number} chars)", {
+ kibibytes: thresholdBytes / 1024,
+ characters: thresholdBytes,
+ })
+ : msg("{kilobytes} KB (~{characters, number} chars)", {
+ kilobytes: Math.floor(thresholdBytes / 1000),
+ characters: thresholdBytes,
+ }),
+ );
+}
+
export function nextPastedTextFileName(existingNames: ReadonlyArray): string {
const names = new Set(existingNames.map((name) => name.toLowerCase()));
if (!names.has("pasted-text.txt")) {
diff --git a/packages/contracts/src/settings.test.ts b/packages/contracts/src/settings.test.ts
index 9dc56d7a6a02d..71dcfe761f1d8 100644
--- a/packages/contracts/src/settings.test.ts
+++ b/packages/contracts/src/settings.test.ts
@@ -323,6 +323,17 @@ describe("resolveIdleCompaction", () => {
});
});
+describe("ClientSettings large paste threshold", () => {
+ it("falls back to the default for a stored preset this build no longer offers", () => {
+ const settings = decodeClientSettings({
+ pastedTextAttachmentThreshold: 4_000,
+ sendShortcut: "mod-enter",
+ });
+ expect(settings.pastedTextAttachmentThreshold).toBe(32_768);
+ expect(settings.sendShortcut).toBe("mod-enter");
+ });
+});
+
describe("ClientSettings notifications", () => {
it("requires opt-in when existing settings omit notification preferences", () => {
expect(decodeClientSettings({}).notificationMode).toBe("off");
diff --git a/packages/contracts/src/settings.ts b/packages/contracts/src/settings.ts
index 678f58294c66a..dfd096b0cb202 100644
--- a/packages/contracts/src/settings.ts
+++ b/packages/contracts/src/settings.ts
@@ -342,6 +342,16 @@ export const LoadBalancingWeights = Schema.Record(
export const DiffColorScheme = Schema.Literals(["red-green", "blue-orange"]);
+/**
+ * Paste sizes at which the composer folds clipboard text into a text-file
+ * attachment. A paste folds when either its length or its UTF-8 byte count
+ * reaches the threshold.
+ */
+export const PASTED_TEXT_ATTACHMENT_THRESHOLDS = [1_000, 5_000, 32_768] as const;
+export const PastedTextAttachmentThreshold = Schema.Literals(PASTED_TEXT_ATTACHMENT_THRESHOLDS);
+export type PastedTextAttachmentThreshold = typeof PastedTextAttachmentThreshold.Type;
+export const DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD: PastedTextAttachmentThreshold = 32_768;
+
export const ChatWidth = Schema.Literals(["comfortable", "wide", "full"]);
export type ChatWidth = typeof ChatWidth.Type;
@@ -519,6 +529,12 @@ export const ClientSettingsSchema = Schema.Struct({
pullRequestLinksOpenInApp: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
composerRichTextEnabled: Schema.Boolean.pipe(Schema.withDecodingDefault(Effect.succeed(true))),
+ // A stored preset this build no longer offers falls back to the default
+ // instead of failing the whole settings decode.
+ pastedTextAttachmentThreshold: PastedTextAttachmentThreshold.pipe(
+ Schema.catchDecoding(() => Effect.succeedSome(DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD)),
+ Schema.withDecodingDefault(Effect.succeed(DEFAULT_PASTED_TEXT_ATTACHMENT_THRESHOLD)),
+ ),
sendShortcut: Schema.Literals(["enter", "mod-enter-multiline", "mod-enter"]).pipe(
Schema.withDecodingDefault(Effect.succeed("enter")),
),
@@ -2096,6 +2112,7 @@ export const ClientSettingsPatch = Schema.Struct({
),
pullRequestLinksOpenInApp: Schema.optionalKey(Schema.Boolean),
composerRichTextEnabled: Schema.optionalKey(Schema.Boolean),
+ pastedTextAttachmentThreshold: Schema.optionalKey(PastedTextAttachmentThreshold),
sendShortcut: Schema.optionalKey(Schema.Literals(["enter", "mod-enter-multiline", "mod-enter"])),
followUpBehavior: Schema.optionalKey(Schema.Literals(["queue", "steer"])),
proactivePanelsEnabled: Schema.optionalKey(Schema.Boolean),