feat: 大段纯文本粘贴自动转为 paste_text.txt 附件 (v0.1.23) - #1
Open
athenafirst wants to merge 2 commits into
Open
Conversation
….23) Rebased onto upstream main (e683182, v0.1.22). Version bumped to 0.1.23 because upstream independently released v0.1.22 (DSH 0.1.5-alpha.1 support). - capture-phase paste interception before the composer's own listener (Lexical contenteditable + textarea-era guards) - threshold (chars) or 50+ lines => File([text]) through the existing add() pipeline: paste_text.txt naming, uniqueLabel (2)/(3) de-dup, per-send directory, DSH_PASTE_INPUT_V1 block, bubble folding - settings panel: threshold select (off/1000/2000/5000, default 2000) - first-paste notice mentions the text conversion
athenafirst
force-pushed
the
feat/big-text-paste
branch
from
September 9, 2026 02:57
add959b to
bd339d7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
粘贴大段日志/执行输出时,整段文本直接插入输入框,消息气泡里一大坨,模型上下文也浪费在原始粘贴上。本 PR 让超过阈值的纯文本粘贴自动走既有粘贴文件管道,变成可折叠的
paste_text.txt芯片——与 DeepSeek 网页版的大段粘贴体验对齐。改动(全部在
lib/client.js,host 侧零改动)onBigTextPaste,document 层,先于 composer 自身监听):text/plain粘贴,字符数 > 阈值或行数 > 20时触发preventDefault + stopPropagation:文本不再进入草稿(capture 阶段拦截,Lexical 的PASTE_COMMAND挂在 editor root 上,事件到不了)new File([text], 'paste_text.txt', {type:'text/plain'}),走既有add()管道isContentEditableroot)与 textarea 代(value === draft,同onBeforeInput守卫)都覆盖;只拦落在 composer 上的粘贴,队列编辑器/设置搜索框等不受影响uniqueLabel——paste_text.txt、paste_text(2).txt…(与paste_image/paste_file同族;跨发送同名无冲突,批次目录本就带committedAt-hash8)localStorage持久化)全链路复用(无新基建)
芯片插入 → dock 显示(× 可删)→ 发送时复制进
<workspace>/.dsh/tmp/attachments/<session>/<send>/→DSH_PASTE_INPUT_V1协议块 → 气泡自动折叠为 📎 芯片 → 设置面板按会话/工作区清理。全部与粘贴图片同一管道。验证
node --check通过读取 paste_text.txt成功add()在 composer 忙碌(phase !== 'plain')时拒绝,与粘贴图片同一失败模式(toast 报错,文本不插入)兼容性
纯客户端改动;
dsh.client声明、槽位、服务注入均不变;对 0.1.2-alpha.x ~ 0.1.3-alpha.x 的兼容面与 v0.1.21 相同。textarea 代 composer 的识别分支未实机验证(本机为 Lexical),逻辑与 v0.1.4 时代onBeforeInput的 composer 识别一致。