feat(cosh): add clipboard image support and attachment ui to cli#584
feat(cosh): add clipboard image support and attachment ui to cli#584kongld-mq wants to merge 5 commits into
Conversation
…cross-platform support Signed-off-by: konglidong <kld02270359@alibaba-inc.com>
…ies in package-lock.json
There was a problem hiding this comment.
- Blocker: 图片附件提交后可能不会被实际读取
当前实现把图片保存到全局临时目录 ~/.copilot-shell/tmp/clipboard,但提交时又转成相对 workspace 的 @... 引用。现有 @ 文件处理器会校验路径是否在 workspace 内,workspace 外路径会被跳过。结果是 UI 显示附件已添加,但提交后图片可能不会进入模型上下文。
建议修复方式之一:
- 将图片保存到 workspace/project temp 中,并确保该路径可被
@文件读取链路访问; - 或者不要通过
@path文本链路传附件,而是在提交时直接把附件转换成模型可消费的 image/file part; - 补一个端到端或集成测试,覆盖“粘贴图片 -> 提交 -> 图片被实际读入请求”。
- Windows 快捷键与 PR 描述不一致
PR 描述说 Windows/Linux 使用 Ctrl+V 粘贴图片,但 win32 分支当前只绑定了 command/meta + v,没有绑定 ctrl + v。这会导致 Windows 用户按说明操作时无法触发图片粘贴。
建议:
- Windows 分支增加
{ key: 'v', ctrl: true }; - 补充/更新 key matcher 测试覆盖 Windows
Ctrl+V。
- 只贴图片、不输入文字时无法提交
当前提交逻辑只有在 buffer.text.trim() 非空时才会触发。用户只粘贴一张图片然后直接回车时,输入为空,因此不会提交,表现为静默无响应。
建议:
- 提交条件改为类似
buffer.text.trim() || attachments.length > 0; - 当只有附件无文本时,也应生成有效提交内容;
- 补测试覆盖“空文本 + 附件 + 回车提交”。
…g and allow submit with only attachments
感谢详细的 review feedback,三个问题均已修复: 问题 1:图片保存路径 |
Description
Add clipboard image paste support for the CLI prompt, enabling users to paste images directly from clipboard into the input field. The pasted images are saved to a global temporary directory and displayed as attachments above the input prompt, which are automatically converted to file references when submitting.
Key features:
Related Issue
closes #
Type of Change
Scope
cosh(copilot-shell)sec-core(agent-sec-core)skill(os-skills)sight(agentsight)tokenless(tokenless)Checklist
cosh: Lint passes, type check passes, and tests passsec-core(Rust):cargo clippy -- -D warningsandcargo fmt --checkpasssec-core(Python): Ruff format and pytest passskill: Skill directory structure is valid and shell scripts pass syntax checksight:cargo clippy -- -D warningsandcargo fmt --checkpasstokenless:cargo clippy -- -D warningsandcargo fmt --checkpasspackage-lock.json/Cargo.lock)Testing
Unit Tests:
clipboardUtils.test.ts: 9 tests for clipboard image detection and savingInputPrompt.test.tsx: Tests for paste handling, error handling, and attachment UIkeyMatchers.test.tsx: Tests for platform-specific keybinding matchingAll tests pass: 3422 passed | 7 skipped
Manual Testing Steps:
Additional Notes
New Dependency:
@teddyzhu/clipboard: Cross-platform clipboard access library with native bindings for macOS, Linux, and WindowsmacOS Terminal Behavior Notes: