fix: handle windows session workdir separators#486
Conversation
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a9d53c31d7
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| throw new Error(`Session "${opts.session}" not found.`); | ||
| } | ||
| if (target.workDir !== workDir) { | ||
| if (target.workDir.replaceAll('\\', '/') !== workDir.replaceAll('\\', '/')) { |
There was a problem hiding this comment.
Preserve POSIX backslashes when comparing workdirs
Because this normalization runs on POSIX as well as Windows, a session created under a literal directory like /tmp/a\b is now treated as if it belongs to /tmp/a/b, so an explicit -r can bypass the “different directory” guard and resume a session against the wrong cwd. This guard matters because listSessions({ workDir, sessionId }) falls back to the global session index when the session is not in the current workDir bucket, so please only apply separator normalization for Windows paths (the same pattern appears in the TUI resume path).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
确实有一定可能,我将改为和保存session一样的地址转录逻辑。
a9d53c3 to
9427739
Compare
|
刚完成了修改,现在按照session的地址存入函数来比对,应该没啥问题了 |
Related Issue
Resolve #477
Problem
Windows 下恢复 session 时,使用
kimi -r误报:原因是Windows下对于路径的判断逻辑有点问题,保存的时候是normalized,统一两种路径分隔符(比如“C:/a/b”),比对的时候取当前目录却用原始路径(比如"C:\a\b"),同一个目录在比较的时候可能同时出现 “/” 和 ”\“ 两种路径分隔符,直接字符串比较会被判断为不同目录。统一这个下划线格式就好了。
What changed
恢复 session 前比较工作目录时,先统一路径分隔符。
影响位置
(两个判断,一个是在kimi -r session_1exxxxxxxxx,一个是在kimi -p "hello"-r session_1exxxxxxxxxxxx):
apps/kimi-code/src/cli/run-prompt.tsapps/kimi-code/src/tui/kimi-tui.ts修复地很简单直接把原始路径里的'\'都换成'/'就可以了,目前测试下来没有问题,当然欢迎更好的方法。
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.