feat: 文件面板虚拟滚动重构与终端 CWD 无缝同步机制#51
Merged
Merged
Conversation
本次提交包含两个核心维度的性能与体验升级: 1. 终端与文件面板的 CWD 同步重构 - 废弃了对用户 `PS1` 环境变量的暴力修改注入,改为采用单行自适应脚本(兼容 Bash/Zsh/Fish 等主流 Shell)。 - 在主进程引入了回显消除机制(Echo Suppression),拦截并剔除了注入脚本在终端的输出,实现了“无感接管”。 - 保证用户在终端使用 `cd` 等命令切换目录时,右侧文件面板能够平滑感知并自动刷新。 2. 远程与本地文件列表的极致性能优化 - 引入了业界最佳实践 `@tanstack/react-virtual@3` 实现了真正的虚拟滚动列表。 - 彻底舍弃了原始的 DOM 全量渲染,对于像 `/usr/bin` 等含有数千个文件的大型目录,主线程渲染耗时从数百毫秒降低至不足 1 毫秒,彻底消灭了界面卡死和长达 1 秒的高斯模糊“僵尸期”。 - 优化了列表布局架构:将滚动条剥离外层 `.pane` 容器,精准下放至 `.file-table-shell`。 - 实现了顶部路径栏固定和表格标题行(Thead)的 CSS Sticky 吸顶效果,极大提升了在海量文件中的浏览体验。 - 在虚拟列表架构下,完整保留并兼容了原本的拖拽上传、右键菜单和 Shift 连选等所有的交互功能。
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.
🚀 核心改进点
本次 PR 包含了 TermDock 往商业级产品进化的两项核心体验优化:
1. 终端 CWD (当前工作目录) 的无缝同步接管
背景:原先对用户
PS1进行正则表达式替换的做法不仅暴力,且经常在复杂的自定义 Shell 主题中失效。改进:
PS1的暴力修改。onData,剔除了注入脚本和同步命令的脏数据回显,实现了真正无感知的远端路径同步。cd、使用alias等),侧边栏的远程文件面板都会立刻感知并平滑拉取新目录。2. 本地与远程文件面板的极致性能飞跃(虚拟列表)
背景:当用户切入拥有上千个文件的系统目录(如
/usr/bin)时,原版 React 组件会因为一次性暴力渲染数千个 DOM 节点导致主线程被死锁长达数百毫秒至 1 秒,不仅界面卡死,原本的“加载转圈”动画也被挤掉,变成了丑陋的“一秒钟高斯模糊黑屏僵尸期”。改进:
@tanstack/react-virtual@3实现了真实的 Table 行级虚拟滚动。.pane) 的滚动条抽离,精准挂载到.file-table-shell上,让虚拟列表准确测算可视区域的高度。