Repository navigation
feat(desktop): 终端同步 Motty 交互:块选择、查找预填、剪贴板图片粘贴、光标形状与粗细设置 - #2000
Merged
Merged
Conversation
同步 Motty 的四项终端交互(d0759bb3、4116260e、fe2570d9/ed6db385、 3f7979e4/8a7476b6),来源记在 termview/NOTICE。 - 块选择:Option(macOS)、Alt(Windows)、Ctrl+Alt(Linux)加拖动选中 矩形列块;term.BlockRange 逐行复制、去掉行尾空白,宽字符被切开时整字保留。 鼠标报告模式下按下仍归程序。 - 查找预填:从关闭状态打开查找时,单行选区(最多 256 字符,去掉末尾空白) 成为查询;每次打开都全选框内文字。 - 图片粘贴:剪贴板没有文字只有图片时,workbench 把 PNG 存到用户缓存目录 (Lithe/terminal-paste,0700),并像拖入文件一样输入路径;WSL 终端输入 /mnt 路径。每次粘贴清理 7 天前的文件,失败和过大给出提示,只用于本地终端。 - 光标:设置“终端”页新增“光标”卡片(形状:方块/竖线/下划线;粗细: 细/正常/粗),存入 settings.json,已打开的终端立即重绘生效;程序请求的 竖线、下划线同样使用所选粗细。DECSCUSR 0 现在恢复用户选的默认形状, 不再固定回到方块。 - i18n:新增 desktop.terminal.pasteImage*、desktop.settings.terminal.cursor* 中英词条并重新生成。 - 功能矩阵 terminal-interaction 补充能力描述、证据、验证命令和备注; Windows 验收待完成。 Motty 的关闭确认(fbd26b86)已由 workbench/process_exit.go 的 BusyProbe 覆盖,未同步。 Closes #1999
xiaoyumuxi
marked this pull request as ready for review
November 15, 2026 19:53
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.
关联 Issue / Linked issue
PR 类型 / Type
改动说明 / What changes
背景 / Why
Viva 桌面端的终端是从 Motty 移植的(基线 8958a472)。PR #1989 同步了第一批改进,本 PR 同步第二批交互改进,解决以下问题:
Motty 的“关闭仍在运行的终端前确认”(fbd26b86)Lithe 已由
workbench/process_exit.go的 BusyProbe 实现,本 PR 不再同步。改动 / Changes
1. 块选择(Motty d0759bb3)
term/selection.go:新增BlockRange(anchor, focus),返回两点之间矩形内的文字:termview/selection.go:block模式,由按下时的修饰键决定,后续拖动和 Shift+点击沿用该模式。span),复制走BlockRange。selectRange(全选等)会清除块模式。2. 查找预填选中文字(Motty 4116260e)
workbench/terminal_find.go:text.Editor。3. 剪贴板图片粘贴为路径(Motty fe2570d9、ed6db385)
termview/view.go、termview/input.go:Config.PasteImage钩子。粘贴时剪贴板没有文字,就先交给宿主处理;宿主不处理时,仍然发送原来的空粘贴,留给自己读剪贴板的程序。workbench/terminal_paste_image.go(新文件):app.ClipboardImagePNG读取图片,写入用户缓存目录下的Lithe/terminal-paste。~/Library/Caches;Windows:%LocalAppData%。paste-<时间>-*.png。/mnt/...路径。pasteImageTooLarge,失败写入operationFailed("terminal_paste_image")日志。workbench/terminals.go:终端新增pastingImage,并接上config.PasteImage。4. 光标形状与粗细设置(Motty 3f7979e4、8a7476b6)
termview/cursor.go(新文件):Cursor{Shape, Thickness}和View.SetCursor。cursorBarWidth和cursorUnderlineHeight常量删除,改由粗细决定。term/csi.go:DECSCUSR 0 恢复用户选的默认形状,不再固定回到方块。这与 Windows Terminal、iTerm2、kitty 一致,也是 vim 和 zsh/fish vi 模式所依赖的行为。settingswindow/terminal_cursor_view.go(新文件):“终端”设置页新增“光标”卡片,包含形状(方块、竖线、下划线)和粗细(细、正常、粗)两个下拉框。workbench/app.go、settings.go、terminal_env.go、editor_view.go:settings.json的terminalCursorShape和terminalCursorThickness,默认值不写入文件。5. 其他
desktop.terminal.pasteImageFailed、desktop.terminal.pasteImageTooLarge和desktop.settings.terminal.cursor*等 10 个中英词条,并重新生成shared.generated.go。termview/NOTICE:记录本次移植的 Motty 提交。terminal-interaction:补充能力描述、两端证据文件、验证命令和 2026-11-16 备注。不在本 PR 范围内 / Out of scope
类型专属:feat
多平台对齐
platform-specific),理由:Viva 桌面端两个平台用同一份代码。Windows 只在 macOS 上做了交叉
go vet,本机没有可用的 Windows 虚拟机,矩阵里 Windows 的验证状态保持pending。范围检查 / Scope checks
功能矩阵 / Feature matrix
shared/platform-feature-matrix/features/<id>.json:两端的实现状态和验证状态、证据路径、owner、验证动作都如实填写;没有运行验证的保持pending./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh;改了平台实现路径的,还运行了./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEAD.artifacts/下生成的矩阵视图插件归属 / Plugin ownership
develop-lithe第三节“插件归属与宿主零依赖”的自查命令,结果为空shared/i18n/;插件的构建步骤、资源路径和补丁没有写进scripts/resources/、docs/ci-builds.md、Agent Note 或 SkillUI 验证 / UI evidence
未附截图:维护者决定这一轮终端同步不补截图。
TestTerminalCursorChoicesApplyWhenChosen检查控件角色、当前值、点击写回,以及打开页面不写入设置。TestChosenCursorShapesAndThicknessesPaint、TestChosenTerminalCursorReachesOpenTerminals、block_selection_test.go断言绘制出的矩形。统一日志系统 / Structured logging
rust/logging/events/<root>.json声明,再用生成的事件类型和 span 记录;没有NSLog、os_log/Logger、直接写 stderr、print或手写事件 IDpath、错误用error类型,动态通道段来自已校验的 IDscripts/logging/)已移除,等价检查恢复前在“验证”一节写明日志门禁未完成,不记为通过:本 PR 没有新增事件图片粘贴失败沿用已声明的
operationFailed事件(operation 字段为terminal_paste_image),保存失败用documentLogError把路径归入path类型;没有新增事件。界面文案 / i18n
shared/i18n/补齐中英词条,运行node scripts/i18n/generate-i18n.mjs并提交生成结果,没有手改生成文件;Viva 代码通过desktop/internal/i18n/的接口读取shared/i18n/:不涉及插件node scripts/i18n/verify-app-language-localization.mjs和node scripts/i18n/generate-i18n.mjs --check,没有放宽脚本或扩大豁免名单逻辑归属 / Logic placement
refactorIssue:终端模拟(
term、termview)只有 Viva 桌面端这一个实现,macOS 和 Windows 共用同一份 Go 代码,没有第二个平台实现需要共享,因此不放进 Core。光标设置的取值归一化(NormalCursorShape和NormalCursorThickness)只是在设置页和工作台之间对齐取值。性能与内存 / Performance and memory
功能、子进程、语言服务器、WebView 首次需要才启动;没有新增空闲轮询;缓存和缓冲有上限;关闭项目、窗口、面板、标签时释放独占资源
主线程没有文件读写、目录遍历、进程启动;跨 C ABI、web view 只传增量或可见窗口
[N/A] 涉及启动、打开项目、输入、滚动、大文件、长输出或搜索的,已附改动前后的性能基线数据;新增运行时或大型依赖的,已写明对启动时间、常驻内存和安装包体积的影响:没有改动输出解析和绘制热路径;块选择只改变选区跨度的计算,查找预填最多 256 个字符
图片保存和清理都在
a.background中执行,30 秒超时。只在粘贴时读剪贴板图片,不预先读取。
图片文件保留 7 天,下一次粘贴时清理。
设置 / Settings
插件契约 / Plugin contract
N/A:不涉及插件契约、能力版本或宿主方法。
发行包与资源 / Bundle and resources
./scripts/desktop/verify/verify-runtime-bundle-immutability.shscripts/resources/worktree-resources.json、scripts/resources/reuse-worktree-resources.mjs的校验路由、对应测试和docs/ci-builds.md“独立工作树的本地编译”一节:粘贴的图片是运行时用户数据,不是构建资源粘贴图片的位置和生命周期写在
terminal_paste_image.go的文件注释里:存于用户缓存目录,由窗口负责,保留 7 天,不影响代码签名或 Sparkle/Viva 增量包。无用代码与重构 / Dead code and refactoring
cursorBarWidth和cursorUnderlineHeight常量refactor标签的 Issue,没有在本 PR 顺手处理:#:没有发现新的;已知的 Shell 集成未接线见 [Feature] 清理或接通终端未接线的 Shell 集成:DirectoryToken、WSLScript、Windows 提示符脚本与 term 提示符/目录回调在生产代码中没有调用方 #1984验证 / Verification
./scripts/desktop/desktop-go.sh test ./... -count=1(desktop/下)./scripts/desktop/desktop-go.sh test ./internal/term/ ./internal/termview/ ./internal/settingswindow/ ./internal/workbench/ ./internal/i18n/ -count=1-race:term、termview、i18n全包;settingswindow的终端页测试;workbench新增的 11 个测试.agents/skills/write-stable-tests/scripts/test-stability-macos.sh(四个包,按新测试过滤,共 81 个)GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go vet ./internal/term/ ./internal/termview/ ./internal/i18n/ ./internal/localshell/./scripts/platform-feature-matrix/verify-platform-feature-matrix.sh./scripts/platform-feature-matrix/verify-platform-feature-matrix-change.sh origin/main HEADnode scripts/i18n/verify-app-language-localization.mjs、node scripts/i18n/generate-i18n.mjs --check./scripts/desktop/verify/verify-runtime-bundle-immutability.shrggofmt -l涉及的包未能执行的检查和原因:
workbench和settingswindow依赖 cgo 的internal/core,无法从 macOS 交叉 vet;Windows 编译和测试依赖标记 ready 后的 Windows CI。提交前确认 / Final checks
main创建;目标分支:feat、fix、docs 为main,release 以发布流程要求为准.build/、target/、dist/、.artifacts/等产物,没有凭据、个人路径和未脱敏的日志或截图