Skip to content

fix: report real log and runtime directories instead of Unix paths - #4

Merged
yujiezhang-ops merged 3 commits into
mainfrom
fix/windows-paths-in-ui
Aug 4, 2026
Merged

fix: report real log and runtime directories instead of Unix paths#4
yujiezhang-ops merged 3 commits into
mainfrom
fix/windows-paths-in-ui

Conversation

@yujiezhang-ops

Copy link
Copy Markdown
Collaborator

问题

两处面向用户的文案把 Unix 路径写死在前端:

  • TaskCenter 的「完整日志:~/.oneagent/logs」
  • RuntimeSection 的「运行时会安装到 ~/.oneagent/runtimes」

两者都是无条件渲染。Windows 上这些目录实际是 C:\Users\<name>\.oneagent\...,所以每个 Windows 用户看到的都是错的路径。

改动

两个目录现在都由后端提供。

运行时目录取自 RuntimeState.installPath —— 它已经是绝对且平台正确的路径,且在 runtime 受支持时就有值(不需要已安装)。新增的 runtimeRoot() 从中截出共同父目录;取不到时退回不含路径的句子,否则会渲染成「运行时会安装到 ,」。

日志目录后端压根没暴露,所以把已有的 CommandLogDir() 加进了 status 的 paths

TaskCenter 通过 prop 接收 logDir 而不是读 WizardContext:那个 hook 没有 provider 会抛错,会让组件无法独立测试(改造过程中确实撞到了这点)。

顺带补上的测试覆盖

PersistRuntimePath 的 Windows 分支此前一行未测,而它会改写用户的 PATH 环境变量。新增测试断言:PATH 只作用于 User 域(绝不碰需要提权的 Machine)、PowerShell 标志完整、pwsh 回退可用、缺少 PowerShell 时报错、无目录时不启动进程。

做了变异测试确认这些测试有效:把作用域改成 Machine 后立刻失败。

验证

  • go vet ./...go test ./... 通过,-race 在改动包上通过
  • Windows 交叉编译通过(amd64 与 arm64,含 Wails 桌面版)
  • GOOS=windows go vet ./... 干净,全部测试包能为 Windows 目标编译
  • 前端 125 个测试通过,tsc --noEmit 与生产构建通过
  • golden fixture 因新增 logs 字段而失败并已更新

未覆盖

静态审查覆盖不到真机运行时行为:icacls 的实际 ACL 效果、PowerShell 执行策略被组策略覆盖的情形、以及 Windows 上真实的终端启动。这些仍需真机或虚拟机验证。

🤖 Generated with Claude Code

yujiezhang-ops and others added 3 commits August 3, 2026 19:51
The Task Center and the runtime install note spelled out "~/.oneagent/logs"
and "~/.oneagent/runtimes". Neither names anything on Windows, where the
directories are C:\Users\<name>\.oneagent\... , so both read as wrong to
every Windows user.

Both directories now come from the backend. The runtime note derives its
parent from RuntimeState.installPath, which is already absolute and
platform-correct, and falls back to a sentence without a directory when no
runtime carries one. The log directory was not exposed at all, so
CommandLogDir joins the status paths map.

TaskCenter takes logDir as a prop rather than reading WizardContext: that
hook throws without a provider, which would have made the component
untestable on its own.

Also covers PersistRuntimePath's Windows branch, which had no tests despite
rewriting the user's PATH. The new tests assert the User scope (never
Machine, which would need elevation), the PowerShell flags, the pwsh
fallback, and that a missing PowerShell surfaces as an error.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Three conflicts, all the same shape: main reworded the copy while this
branch parameterized the paths inside it. Kept main's wording and this
branch's parameter, since the two changes are independent.

The stale "完整日志:~/.oneagent/logs" key is dropped rather than kept
alongside the new one -- nothing references it after the merge, and leaving
a hardcoded Unix path in the table invites its reuse.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@yujiezhang-ops

Copy link
Copy Markdown
Collaborator Author

已解决与 main 的冲突(c9dc860)。三处冲突形状相同:main 改了文案,本分支把文案里的路径参数化了——两者独立,保留 main 的措辞 + 本分支的参数。顺手删掉了失效的 完整日志:~/.oneagent/logs 键,合并后已无引用。

验证:tsc --noEmit 通过,go vet ./... 干净。前端 97 passed(main 是 89),Go 3 个失败与 main 完全一致(已 diff 比对)。

⚠️ 需要单独知晓:main 自身当前是坏的,与本 PR 无关。4d63d75 删了 3 个图标资源却留着 import,导致 pnpm run build 直接失败、7 个前端测试文件无法加载;同时删掉 9 个 guide-only catalog 条目,但 provider_test.go:79cmd/oneagent/main_test.go:20 仍硬编码 openclaw,golden fixture 也没更新。详见 #14 之后我会单独开的 issue。

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.

1 participant