Skip to content

fix: handle windows session workdir separators - #486

Merged
liruifengv merged 3 commits into
MoonshotAI:mainfrom
qkunio:fix/windows-session-workdir
Jun 8, 2026
Merged

fix: handle windows session workdir separators#486
liruifengv merged 3 commits into
MoonshotAI:mainfrom
qkunio:fix/windows-session-workdir

Conversation

@qkunio

@qkunio qkunio commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Related Issue

Resolve #477

Problem

Windows 下恢复 session 时,使用kimi -r 误报:

Sessionxxxxxx was created under a different directory.

原因是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.ts
  • apps/kimi-code/src/tui/kimi-tui.ts

修复地很简单直接把原始路径里的'\'都换成'/'就可以了,目前测试下来没有问题,当然欢迎更好的方法。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, or this PR needs no doc update.

@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8d98695

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new

pkg-pr-new Bot commented Jun 5, 2026

Copy link
Copy Markdown
pnpm dlx https://pkg.pr.new/@moonshot-ai/kimi-code@8d98695
npx https://pkg.pr.new/@moonshot-ai/kimi-code@8d98695

commit: 8d98695

@liruifengv

Copy link
Copy Markdown
Collaborator

@codex

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread apps/kimi-code/src/cli/run-prompt.ts Outdated
@qkunio
qkunio force-pushed the fix/windows-session-workdir branch from a9d53c3 to 9427739 Compare June 5, 2026 11:00
@qkunio

qkunio commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

刚完成了修改,现在按照session的地址存入函数来比对,应该没啥问题了

@liruifengv

Copy link
Copy Markdown
Collaborator

代码没问题,但应该补一个单元测试 @qkunio

@qkunio

qkunio commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@liruifengv 我补了两个单元测试。

这个pr修改的思路是:恢复 session 时先用 pathe.resolve 统一当前目录和 session 记录目录的路径格式,避免 Windows 下 \ 与 / 不一致被误判为不同目录。

所以模拟了Windows下查(C:\Users\kimi\project)和存(C:/Users/kimi/project)的一致性判断,最终判断成功。

测试已通过,麻烦帮忙审阅一下,万分感谢🥹🥹有任何需要修改的,我马上改

@liruifengv liruifengv left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you!

@liruifengv
liruifengv merged commit 0fe1317 into MoonshotAI:main Jun 8, 2026
8 checks passed
@liruifengv

Copy link
Copy Markdown
Collaborator

@qkunio 忘了加 changeset 了,可以再提一个 PR 来补一下,运行 gen-changesets skill

@liruifengv liruifengv mentioned this pull request Jun 8, 2026
2 tasks
liruifengv added a commit that referenced this pull request Jun 8, 2026
@qkunio

qkunio commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

@liruifengv 实在不好意思,刚刚没看到消息,下次我尝试做贡献的时候会注意测试和changeset!感谢补全

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.

恢复session失败

2 participants