Skip to content

fix(web): open directory links in Files sidebar - #1232

Merged
iruriQ merged 2 commits into
BytePioneer-AI:mainfrom
hhucz:fix/web-directory-link-open
Nov 27, 2026
Merged

iruriQ merged 2 commits into
BytePioneer-AI:mainfrom
hhucz:fix/web-directory-link-open

Conversation

@hhucz

@hhucz hhucz commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Open chat directory links in the existing Files sidebar instead of the regular-file preview, for both direct clicks and Open in CodexHost.
  • Keep regular-file and line-number previews, external opening, and reveal behavior unchanged.
  • Let the Files tab accept a target directory, reset its tree when the root changes, and retire the previous directory watches. Session-targeted opening prevents a delayed stat result from opening in another session.

Validation

  • workspace-links.test.ts and remote-preview.test.ts — 19/19 passed.
  • npm run build --workspace=@codexhost/web-ui — passed.
  • Prettier on the affected files — passed.
  • Isolated Windows smoke test in the real CodexHost Web UI, with synthetic session history and actual temporary workspace files:
    • Direct-click and Open in CodexHost from the directory link's context menu both opened the target in Files.
    • The regular-file link opened the existing preview and highlighted line 7. Files opened from the directory tree still previewed normally.
    • The . link returned Files to the session cwd without a trailing /..
  • Remote Peers were not exercised. Focused tsc reported existing DSH dependency/type diagnostics. The full repository suite was not run locally; CI remains the full-suite gate.

UI evidence

Directory link opened in Files:

Directory link opened in Files

Regular-file preview retained with line 7 highlighted:

Regular-file preview at line 7

Directory link context menu:

Directory link context menu

File-open RPC cost

This change retains the separate workspaceFiles.stat lookup. Extension heuristics misclassify dotted directories and extensionless files; using the preview resource as-is would tie directory navigation to a retrying file watch. A follow-up can make the first metadata result independent of the watch handshake so navigation and preview can share it.

🤖 Generated with Claude Code

Chat file links always opened a file resource, so directories fell through to the regular-file error page. Stat the target and route directories to the existing Files tab, preserving session-targeted opening and closing old watches when the tree root changes.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • 新功能
    • 从文件链接打开目录时,可在对应会话的 Files 侧栏中直接浏览该目录。
    • Files 侧栏支持从指定目录开始浏览工作区。
  • 改进
    • 文件链接使用当前会话的工作区作为路径基准。
    • 切换 Files 侧栏的浏览目录后,目录树会更新至新位置。

Files 侧栏现在可根据导航参数展示指定目录。聊天中的工作区链接会查询路径状态,再打开对应的 Files 目录或文件资源。

Changes: 工作区链接与 Files 目录导航

Layer / File(s) Summary
目录参数与根路径解析
apps/web-ui/packages/client/ui-sidebar-files/src/client/index.ts, apps/web-ui/packages/client/ui-sidebar-files/src/client/root.ts, apps/web-ui/packages/client/ui-sidebar-files/src/client/face.ts, apps/web-ui/packages/client/ui-chat/test/workspace-links.test.ts, tests/vitest.config.js
Files 标签参数新增 directory。filesRoot 根据工作目录、目标目录和远程文件状态解析根路径。启动逻辑处理已中止信号、相同根路径和根目录替换,并仅在节点仍为当前根时更新错误状态。新增测试覆盖根路径解析。
目录树展示与文件地址
apps/web-ui/packages/client/ui-sidebar-files/src/client/FilesBody.tsx
FilesBody 根据导航参数计算目录树根路径,并仅在存储状态根路径匹配时复用状态。打开文件时,地址以当前工作目录为基准构造。
聊天中的工作区链接路由
apps/web-ui/packages/client/ui-chat/src/client/apply.ts, apps/web-ui/packages/client/ui-chat/src/client/open-workspace-link.ts, apps/web-ui/packages/client/ui-chat/test/workspace-links.test.ts
openFile 将普通打开请求交给 openWorkspaceLink。该函数查询路径状态;会话不匹配时不执行导航,目录请求打开 Files 标签,其他请求打开文件资源并传递可选行号。测试覆盖目录、文件、错误结果和会话切换。

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant openFile
  participant openWorkspaceLink
  participant workspaceFiles
  participant sidebarRight
  openFile->>openWorkspaceLink: 传入会话、工作目录、路径和可选行号
  openWorkspaceLink->>workspaceFiles: 查询路径状态
  workspaceFiles-->>openWorkspaceLink: 返回路径状态
  alt 路径是目录且会话仍匹配
    openWorkspaceLink->>sidebarRight: 打开 Files 标签并传入目录路径
  else 路径不是目录且会话仍匹配
    openWorkspaceLink->>sidebarRight: 打开文件资源并传入可选行号
  end
Loading

Suggested reviewers: bytepioneer-ai

Merge Risk: Minimal · up to 9d898

Chat links to directories now open in the Files sidebar, while regular-file and line-number previews keep their existing behavior. No concrete defect was found in the root-change handling or the session-targeted opening path. The change looks ready to merge once CI passes.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“fix(web): open directory links in Files sidebar”概括了主要变更:目录链接在 Files 侧边栏中打开,而不是进入普通文件预览。变更摘要中的 openWorkspaceLink、filesRoot 和 FilesBody 等修改均支持这一点。标题与变更集相关,且具体。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed PR 描述与变更集高度相关。描述说明了目录链接改为在 Files 侧边栏打开、普通文件预览与行号、外部打开及 reveal 行为保持不变、Files 标签页接受目标目录并在根目录变化时重置、会话定向打开防止延迟的 stat 结果在其他会话中打开。这些内容与 apply.ts、FilesBody.tsx、face.ts、open-workspace-link.ts、root.ts 及测试文件的变更一…
Full details: Description check

Explanation

PR 描述与变更集高度相关。描述说明了目录链接改为在 Files 侧边栏打开、普通文件预览与行号、外部打开及 reveal 行为保持不变、Files 标签页接受目标目录并在根目录变化时重置、会话定向打开防止延迟的 stat 结果在其他会话中打开。这些内容与 apply.ts、FilesBody.tsx、face.ts、open-workspace-link.ts、root.ts 及测试文件的变更一致。描述还包含验证步骤、截图及 workspaceFiles.stat 额外 RPC 的说明。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
Fix failing CI checks

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@iruriQ iruriQ added the awaiting-author Waiting for the author to respond or update the PR. label Nov 26, 2026
@iruriQ

iruriQ commented Nov 26, 2026

Copy link
Copy Markdown
Collaborator

感谢修复聊天中目录链接误走普通文件预览报错的问题!合入前麻烦补充几项:

  1. UI 演示截图与回归单测:本 PR 涉及可见 Web UI 行为,按 AGENTS.md 需在 PR 描述中附带脱敏演示截图/录屏,并补充目录链接与普通文件链接的回归测试。
  2. "." 路径归一化:FilesBody.tsx 中 resolveWorkspacePath(cwd, params.directory) 在目录为 "." 时会拼出 cwd/. 而非 cwd,建议规范化。
  3. 普通文件打开往返开销:目前每次点击普通文件都会多一次前置 workspaceFiles.stat RPC(弱网/远端 Peer 下会增加延迟),可评估是否仅对明显无扩展名/尾斜杠目录或按需探测,减少常规文件打开延迟。

先标 awaiting-author,补齐后我们安排 Web 隔离实测。

@hhucz

hhucz commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@iruriQ 已按复审补齐:新增目录/普通文件回归(与 remote-preview 合计 19/19)、目录 "." 归一化,以及三张脱敏 UI 截图,均已写入 PR 正文。普通文件前置 stat 暂保留,扩展名误判与 watch 耦合的原因、后续共享首个元数据结果的方案已写在 “File-open RPC cost”。当前 head:9d898b5ae.

@iruriQ
iruriQ merged commit 5eb84e6 into BytePioneer-AI:main Nov 27, 2026
5 of 8 checks passed
@iruriQ iruriQ removed the awaiting-author Waiting for the author to respond or update the PR. label Nov 27, 2026
@iruriQ

iruriQ commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

感谢跟进补齐截图、回归测试与 . 路径归一化!已完成隔离 Web 实测(src/nested、.、src/nested/ 均精准打开右侧 Files 目录树无报错,普通文件 #L5 预览与行号定位无回归,0 console/page/http 错误),已合入 main。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants