makecindy / makecindy/cindy

device-link 远程草稿:引用目录与文件附件需要走对端文件系统(#957 暂时关闭了这两个入口)

Open
#1,012 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
2.7k
Forks
395
Avg merge
21h 48m
Merged PRs (30d)
776

Description

## 背景

PR #957(Issue #807,device-link 先选设备再选工作区)把「设备」提成创建页的一级维度后,两个依赖**控制端**文件系统的入口在远程草稿下不再成立。它们在该 PR 里被**关掉/拒绝**(宁可明确不可用,也不要显示一个不描述真实结果的控件),能力本身留到这里恢复。

原始 review:
- 附件:https://github.com/makecindy/cindy/pull/957#discussion_r3677563123 附近的 thread
- 引用目录:同一轮的第二条 thread

## 现状(#957 之后)

1. **文件附件**:远程草稿下拖入 / 粘贴非图片文件会被拒绝并 toast 说明。原因是 `attachment-path-passthrough` 之后非图片附件只把 **path** 透传给模型(agent 自己 `Read`),而那是控制端的绝对路径 —— 发到对端要么读不到,要么读到同路径下一个毫不相关的文件。图片不受影响(走 `xdt-image://` 缓存,由 `rehomeDraftAttachments` 搬运)。
2. **引用目录(extraDirs)**:远程草稿下不渲染引用目录段(`onExtraDirsChange` 不下传)。原因是 `ExtraDirsButton` 开的是控制端原生目录对话框,选出来的本机路径发到对端后会被 `validateExtraDirs` 静默丢掉、或撞上对端同名的无关目录 —— 界面上的 chip 并不描述真实授予的上下文。

## 要做什么

**引用目录(较简单,建议先做)**:把 picker 路由到所选设备。设备域的远程浏览器已经存在(`AddRemoteProjectDialog` 经 `fs:list-dir` 浏览对端 FS),复用它选目录即可,选出的就是对端真实路径,`validateExtraDirs` 也能正常通过。

**文件附件(需要设计)**:要把文件真正送到对端,需要一个能在对端写字节的通道。当前 device-link 的 invoke allowlist 里没有写通道,**加一个属于权限边界变更**,必须先过 `docs/dev-rules/plugin-security-and-authoring.md` / device-link 的边界评审,不能顺手加。可能的方向:
- 复用媒体缓存链路,在对端 session 目录下落盘后把**对端路径**回传给草稿;
- 或者干脆维持「远程草稿只支持图片附件」,把它写成明确的产品约束。

后者也是一个合法结论 —— 需要产品侧拍板,不是纯工程判断。

## 相关

- `apps/desktop/src/renderer/features/cc-agent/NewMakerDraftRoute.tsx`(`guardedAttachmentState` / `onExtraDirsChange` 两处 gate)
- `apps/desktop/src/renderer/components/new-chat/ExtraDirsButton.tsx`
- `apps/desktop/src/renderer/components/new-chat/AddRemoteProjectDialog.tsx`(可复用的远程目录浏览)
- PR #957

Contributor guide

Open the contributing guide

Research direction

Start with NewMakerDraftRoute.tsx, ExtraDirsButton.tsx, and AddRemoteProjectDialog.tsx, then read PR #957 and docs/dev-rules/plugin-security-and-authoring.md. Trace the existing remote directory browsing and attachment gates first. Done requires a reviewed decision and implementation plan for remote extra directories and the unresolved attachment behavior, including its security and product constraints.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
desktop, frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.