makecindy / makecindy/cindy

bug(macOS): 文件预览模式下文件树无法隐藏

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

Description

## Project state

- Status: 待评估
- Owner: 待认领
- Proposer: zhaotianyi-source
- Priority: P2
- Next: 确认“隐藏文件树但保留文件预览”的交互方案,并补 macOS / Windows 回归验证

## 问题描述

在 macOS 的文件预览模式中,文件正文旁边的文件树列表无法隐藏。用户只能看到文件树顶部的搜索、收起目录和刷新按钮,无法把整个文件树面板收起来;这会持续占用预览空间。

当前最新主干 `main@7e7c577a` 的实现表明,这不是文件内容渲染问题,而是文件浏览器内部没有提供“折叠文件树”能力。macOS 上如果右侧工具面板又被换位到聊天区左侧,外层面板的收起按钮还会固定在窗口最右上角,进一步让用户误以为红框中的文件列表无法关闭。

## 复现步骤

1. 在 macOS Cindy 中打开一个本地项目会话。
2. 打开右侧文件预览 / File Browser,并选择任意项目文件。
3. 观察文件正文旁边的项目文件树。
4. 点击文件树顶部的“收起所有目录”按钮,或拖动正文与文件树之间的分隔线。
5. 观察文件树仍然存在,且不能收起到 0 宽度。

## 源码定位

- `FileBrowserBody` 始终按“正文 + 分割线 + 文件树”渲染,树 pane 没有 collapsed 状态:
[FileBrowserBody.tsx#L546-L611](https://github.com/makecindy/cindy/blob/7e7c577a/apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx#L546-L611)
- 文件树宽度最小值是 `140px`,拖拽不能把它缩到 0:
[useSessionScopedTreeWidth.ts#L36-L39](https://github.com/makecindy/cindy/blob/7e7c577a/apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts#L36-L39)
[useSessionScopedTreeWidth.ts#L109-L115](https://github.com/makecindy/cindy/blob/7e7c577a/apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/useSessionScopedTreeWidth.ts#L109-L115)
- 文件树顶部只有搜索、收起所有目录、刷新;“收起所有目录”只改变目录展开状态,不隐藏 pane:
[FileBrowserBody.tsx#L697-L760](https://github.com/makecindy/cindy/blob/7e7c577a/apps/desktop/src/renderer/features/right-sidebar/plugins/file-browser/FileBrowserBody.tsx#L697-L760)
- macOS 外层工具面板的折叠按钮固定在窗口右上角:
[MainLayout.tsx#L1343-L1382](https://github.com/makecindy/cindy/blob/7e7c577a/apps/desktop/src/renderer/components/layout/MainLayout.tsx#L1343-L1382)
- Windows 的外层工具面板关闭按钮在面板自身 TabBar 内,macOS 不同:
[TabBar.tsx#L257-L263](https://github.com/makecindy/cindy/blob/7e7c577a/apps/desktop/src/renderer/features/right-sidebar/TabBar.tsx#L257-L263)

## 期望行为

- 文件预览模式应支持单独隐藏 / 展开文件树,隐藏后文件正文继续保留并占用释放出来的宽度。
- 隐藏文件树后应提供清晰、可发现的恢复入口。
- 隐藏状态和最近一次树宽度应按会话或合理的布局偏好持久化,恢复时不应丢失用户之前设置的宽度。
- 隐藏整个右侧工具面板与隐藏文件树应是两个独立动作,按钮文案和位置不能混淆。
- macOS 面板位于聊天区左侧时,外层面板的收起 / 展开入口也应保持可发现。

## 实际行为

- 文件树没有独立折叠状态。
- 拖拽宽度最小只能到 `140px`,无法隐藏。
- “收起所有目录”容易被误认为“隐藏文件列表”,但实际只收起目录节点。
- macOS 上外层面板按钮位于窗口最右上角;当面板被换位到聊天左侧时,入口与文件树距离很远。

## 平台边界

- 文件树内部“无法隐藏”的实现目前没有 macOS / Windows 分支,因此能力缺失本身是跨平台的。
- macOS 的问题更明显:外层折叠按钮固定在窗口右上角;Windows 外层关闭按钮位于工具面板 TabBar 内。
- 相关但独立的面板换位问题见 [#1081](https://github.com/makecindy/cindy/issues/1081)。

## 验收标准

- [ ] macOS 文件预览模式可以隐藏文件树,同时保留文件正文预览。
- [ ] 有明确的展开 / 恢复入口,键盘和辅助功能标签可用。
- [ ] 恢复后使用隐藏前的树宽度,不出现布局跳变。
- [ ] 文件树隐藏与整个右侧工具面板折叠是两个独立状态。
- [ ] Windows 与 macOS 均通过文件树折叠、恢复、切换文件和切换会话回归测试。
- [ ] “收起所有目录”仍只负责目录节点状态,不与 pane 折叠语义混淆。

## 环境

- Cindy 当前源码基线:`main@7e7c577a`
- 用户版本:0.1.23
- 平台:macOS,具体 macOS 版本待补充
- 安装方式:待补充

Contributor guide

Open the contributing guide

Research direction

Start with FileBrowserBody.tsx and useSessionScopedTreeWidth.ts to trace the file-tree pane state and width constraints, then inspect MainLayout.tsx and TabBar.tsx for the platform-specific panel controls. Confirm the interaction design before implementation and identify the existing file-browser regression test entry points. Done means independent tree hide/restore on macOS and Windows, preserved width, accessible controls, and separate outer-panel behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
desktop, frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.