Skip to content

[Bug] 连接容器根目录时工作区标题退化为孤立的 "/"(窗口标题变为 "ZCode / /") #821

Description

@nightwares

问题类别 · Category: UI / 界面体验 · UI / UX
Agent 框架 · Framework: ZCode Agent(自研)
严重程度 · Severity: 影响体验 · Major(功能可用但体验受损)
复现频率 · Reproducibility: 必现 · Always

问题描述 · Description

把工作区连接到 Docker devcontainer 的文件系统根目录(/)时,所有工作区标题都退化为孤立的 /,无法分辨是哪个环境:

  • Header 工作区标题显示 /(远程场景显示 / @ docker:容器名)
  • 桌面窗口标题显示 ZCode / /
  • 空态工作区切换菜单中,根目录工作区同样只显示 /

我在公开源码(v3.14.3)中定位到了根因:packages/ui/src/App.tsx 用 getPathLeaf(workspaceAbsPath) 派生项目名,而 getPathLeaf("/")(packages/ui/src/lib/path.ts)对根目录没有路径叶子可取,?? path 兜底直接把原始路径 "/" 透传给了所有标题面。devcontainer 场景下工作区恰好常常就是容器根目录。

When a workspace connects to a container root, every workspace title degrades to a bare / (header, desktop window title ZCode / /, workspace switcher). Root cause in the public source: getPathLeaf("/") has no leaf to return, and its ?? path fallback passes the raw "/" through to every title surface.

复现步骤 · Steps to reproduce

  1. 打开 ZCode 桌面端 / Open the ZCode desktop app
  2. 新建 Docker 远程连接,工作区路径填 /(devcontainer 默认 workdir 常为根目录)/ Create a Docker remote connection with workspace path /
  3. 连接成功后查看 Header 工作区标题与窗口标题 / Connect and observe the header title and window title

期望表现 · Expected behavior

根目录工作区应显示可读的名称——远程场景下最自然的身份是主机标识(如 docker:my-devcontainer),本地根目录显示本地化文案(如「根目录」/ "Root directory")。

Root workspaces should show a readable name — for remote, the host identity (e.g. docker:my-devcontainer); for local, a localized label.

实际表现 · Actual behavior

标题显示为孤立的 /(窗口标题为 ZCode / /),远程场景显示 / @ docker:容器名。

A bare / is displayed (window title ZCode / /); remote shows / @ docker:<container>.

版本与环境 · Version & environment

  • ZCode v3.14.3(当前公开源码版本 / current public source)
  • Linux 桌面端,连接 Docker devcontainer / Linux desktop app connected to a Docker devcontainer

附:修复方案 · Proposed fix

我已基于公开源码准备了一个小补丁并愿意提交 PR(如果仓库接受):新增统一的 getWorkspaceDisplayName 出口——根目录 + 远端回落到主机标识(复用 formatRemoteWorkspaceHeaderHostLabel),根目录 + 本地回落到 i18n 文案(workspace.rootDirectory:根目录 / Root directory),其余路径行为不变。已接入 Header、窗口标题、空态工作区菜单三个标题面,附单元测试,pnpm typecheck / pnpm lint / pnpm architecture:check --changed 全部通过。如需要可提供补丁文件或 fork 分支。

Activity

  1. github-actions commented on Sep 26, 2026

    @github-actions

    👋 感谢你的反馈,我们已经收到。

    • 维护者看到后会尽快回复你。
    • 状态保持为 status: 待评估,你可以随时补充信息。
    • 信息不全时我们会打上 needs: 更多信息 标签并 @ 你。

    👋 Thanks — we've received your issue.

    • A maintainer will get back to you as soon as we can.
    • Status stays at status: 待评估 (Triage); feel free to add context.
    • If we need more details, we'll add needs: 更多信息 and ping you.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions