[codex] 支持 SSH 终端目录跟随与远程文件区加载反馈#50
Merged
Merged
Conversation
Co-authored-by: Codex <codex@openai.com>
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.
背景
当前 SSH 终端和远程文件面板彼此独立:用户在终端中执行
cd、pushd/popd,或通过 alias/function 改变工作目录后,文件面板不会自动跟随。若直接解析用户输入的cd文本,又无法正确覆盖命令失败、复合命令和脚本内部切目录等情况。本 PR 复用成熟终端工具的设计思路:由远端交互式 shell 上报真实 cwd,main process 提取 cwd 变化,再由 workspace runtime 决定是否驱动远程文件面板。Renderer 只消费 snapshot 和展示开关,不解析终端文本。
主要改动
1. 建立 shell cwd integration
新增
shell-cwd-integration.ts:2. 使用物理目录,修复
/bin/X11循环符号链接问题Debian/Ubuntu 中
/bin/X11常见为指向当前目录的符号链接。连续执行cd X11时,逻辑$PWD会增长为:如果直接上报
$PWD,文件面板会把每次增长都视为新目录,持续触发 SFTP 读取,严重时可能拖慢或断开会话。本 PR 改为使用
pwd -P上报物理路径,因此循环符号链接最终会稳定映射到同一个真实目录。同时增加 4096 字符 OSC cwd payload 防线,拒绝异常长路径。3. 将跟随策略放在 workspace runtime
WorkspaceSessionRuntime负责:4. 拆分核心状态语义
SessionSnapshot新增:shellCwd:终端 shell 当前物理目录。remotePath:远程文件面板当前展示目录。followShellCwd:当前 tab 是否跟随终端目录。remoteFilesLoading:远程文件区域是否正在读取目录。避免继续用单一
remotePath同时承载终端和文件面板语义。5. 增加 renderer 开关和局部加载反馈
main -> preload -> rendererIPC 链路更新。prefers-reduced-motion。架构边界
完整链路为:
保持以下约束:
packages/core。用户影响
cd、pushd/popd后,远程文件面板可以自动切换到真实目录。/bin/X11等循环符号链接不会造成目录路径无限增长和重复读取。暂不包含
cd命令。验证
已完成:
npm run typechecknpm run build -w @termdock/desktoppwd -P物理 cwd 保持稳定git diff --check建议合并前再连接真实 Debian/Ubuntu SSH 主机回归:
cd。pushd/popd。/bin/X11。