feat(mobile): 远程 Windows 项目选择器支持切换盘符
- Dominant language
- TypeScript
- Stars
- 2.7k
- Forks
- 395
- Avg merge
- 21h 48m
- Merged PRs (30d)
- 776
Description
## 用户场景
用户在手机端通过 Device Link 控制 Windows 电脑并新建任务。打开「选择项目」后,远程目录选择器默认从 Windows 用户目录开始浏览;一路返回到 `C:\\` 后,「上级」不可用,也没有切换到 `D:\\`、`E:\\` 等其他磁盘的入口。
因此,当项目位于其他磁盘且没有出现在最近项目中时,用户无法通过手机端选择该目录。
## 当前实现与真实限制
这不是 iOS 沙箱或 Device Link 禁止访问其他磁盘:
- 手机端会把目标路径直接传给被控电脑的 `fs:list-dir`;
- 被控端目录 API 已支持任意绝对路径,`D:\\Projects` 等路径可以正常读取;
- 远程新建任务的安全校验也没有限制 C 盘,只要求目录在被控电脑上真实存在、可访问且确实是文件夹。
当前缺口是目录浏览模型只支持「当前目录 → 子目录 / 上级目录」:
- Windows 每个盘符都是独立根目录;
- 到达 `C:\\` 后,`parent = null`;
- 现有返回结果不包含可用磁盘列表;
- 手机端当前路径仅用于展示,不能输入或切换盘符。
相关实现:
- [Mobile 远程目录加载](https://github.com/makecindy/cindy/blob/main/apps/mobile/app/sessions/new.tsx#L1408-L1459)
- [Mobile 目录选择器 UI](https://github.com/makecindy/cindy/blob/main/apps/mobile/app/sessions/new.tsx#L3161-L3258)
- [Desktop fs:list-dir 实现](https://github.com/makecindy/cindy/blob/main/apps/desktop/src/main/fsBrowse/ipc.ts#L49-L92)
- [远程 workingDir 校验](https://github.com/makecindy/cindy/blob/main/apps/desktop/src/main/device-link/remote-workdir-guard.ts#L111-L126)
## 期望行为
手机端浏览 Windows 电脑目录时,可以发现并切换到当前用户可访问的其他盘符:
1. 在当前路径区域提供盘符切换入口;
2. 展示至少所有可访问的本地固定磁盘,如 `C:\\`、`D:\\`、`E:\\`;
3. 选择盘符后,从对应磁盘根目录继续浏览;
4. 选择项目后,使用完整路径在被控电脑上创建 Claude Code / Codex 任务。
## 实现建议
### 完整方案
扩展现有远程目录浏览结果,可选返回文件系统根目录,例如:
```ts
interface FsListDirResult {
resolvedPath: string;
entries: FsBrowseEntry[];
parent: string | null;
roots?: Array<{
path: string;
label: string;
kind?: 'fixed' | 'removable' | 'network';
}>;
}
```
- Windows 返回可访问盘符;
- macOS / Linux 返回 `/`,只有一个根目录时无需展示切换控件;
- `roots` 使用可选字段,旧控制端可以继续忽略,保持向后兼容;
- 避免对离线网络盘进行无界等待,枚举和访问失败需要有超时与明确错误。
### 兼容兜底
允许点击当前路径后手动输入绝对路径,如 `D:\\Projects` 或 UNC 路径。
该兜底可以直接复用现有 `fs:list-dir`,也能让尚未支持磁盘枚举的旧版 Windows 被控端选择其他盘符。
## 验收标准
- [ ] 手机端连接 Windows 被控电脑时,可以看到可访问的本地固定磁盘;
- [ ] 可以从 `C:\\` 切换至 `D:\\`、`E:\\` 等磁盘并继续浏览;
- [ ] 可以选择其他磁盘中的项目文件夹并成功新建任务;
- [ ] 新任务的 working directory 与用户选择的完整远程路径一致;
- [ ] 旧版被控端不支持磁盘列表时,仍可通过路径输入选择其他盘符,或获得明确的版本提示;
- [ ] 无权限、已断开或读取失败的磁盘不会卡死选择器,并显示清晰错误;
- [ ] 重新打开或刷新选择器后,可以更新可移动磁盘状态;
- [ ] macOS / Linux 现有远程目录选择行为不受影响;
- [ ] 增加 Windows 多盘符、根目录 `parent = null`、旧端兼容和错误状态测试。
Contributor guide
Research direction
Start with apps/mobile/app/sessions/new.tsx lines 1408-1459 and 3161-3258, then trace the fs:list-dir handler in apps/desktop/src/main/fsBrowse/ipc.ts and the working-directory guard. Run the existing directory-selection tests before adding coverage for Windows roots, legacy clients, errors, and macOS/Linux behavior; done means selecting another drive produces the complete remote path and creates the task successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, react-native, typescript
- Domain
- desktop, mobile
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100