Skip to content

feat(server): place the default workspace under the home folder - #4277

Merged
wbxl2000 merged 1 commit into
mainfrom
qer/default-workspace-home
Oct 19, 2026
Merged

wbxl2000 merged 1 commit into
mainfrom
qer/default-workspace-home

Conversation

@wbxl2000

Copy link
Copy Markdown
Collaborator

Requirement or Bug

默认工作区从 <文稿>/KimiCode/Default 改到 ~/KimiCode/Default,避开 macOS 文稿授权弹窗和文稿云同步。

Bug Reproduction Steps

N/A

Root Cause

N/A

Code Changes

默认工作区(#4224,尚未发版)原来放在系统文稿目录里,有三个问题:

  • macOS 上第一次在默认工作区聊天会弹出“访问文稿文件夹”的系统授权;点了“不允许”后系统不再询问,之后每次建会话都失败,用户得自己去“隐私与安全性”里改。
  • 文稿常被 iCloud“桌面与文稿”或 OneDrive 接管,agent 生成的依赖、虚拟环境都会被同步,开了空间优化还可能只剩占位文件。
  • Windows“受控文件夹访问”默认保护文稿,会拦截写入。

主目录下的普通文件夹不受这三者影响,在 Finder / 资源管理器里也找得到。

 DefaultWorkspaceService.root()
   custom path set → resolveCustomRoot(path)      # unchanged
-  macOS   → ~/Documents/KimiCode/Default
-  Windows → PowerShell GetFolderPath('MyDocuments') / KimiCode/Default
-            lookup failed → documents_unavailable
-  Linux   → XDG_DOCUMENTS_DIR from user-dirs.dirs, else ~/Documents
+  every platform → ~/KimiCode/Default

随之删除:

  • defaultWorkspacePaths.ts 里的 XDG 解析、PowerShell 命令与输出解析、defaultDocumentsDir。
  • 服务对 IHostProcessService 的依赖、文稿路径缓存与失败重试。
  • 错误原因 documents_unavailable(core 类型、server 的 40930 data schema、文档)。
  • 40930 的 data.path 改为必有字符串:去掉 documents_unavailable 后,所有原因都带路径。

文档:server-api.md 和 config-files.md(中英)里的默认位置与原因列表同步更新。

Behavior Changes and Affected Users

Behavior Before After Who relies on the old behavior Escape hatch
未设置 default_workspace.path 时的默认工作区位置 <文稿>/KimiCode/Default(Windows 按系统登记的文稿位置,Linux 按 XDG) ~/KimiCode/Default 无已发版用户:默认工作区 10-19 合入,CLI 2.2.0 与 desktop 1.1.0 均早于它;只有跑过 main 开发版的人本地会留下一个旧文件夹 default_workspace.path 可指回原位置
40930 的 reason 取值 含 documents_unavailable 不再出现 desktop / web 客户端的错误文案(code-app 后续 PR 删除对应词条,未知原因本来就走通用文案) —
40930 的 data.path string | null string 同上;客户端已按可空处理,收窄不影响 —
macOS 首次使用默认工作区 弹出文稿授权 不弹 — —

受影响模块与测试:

  • agent-core-v2/app/defaultWorkspace:defaultWorkspace.test.ts 改为断言主目录位置,保留首次创建与复用、删除后重建、尾部分隔符判断、被文件占用、无权限、自定义位置等用例;删去 XDG 与 Windows 文稿查找的用例。
  • kap-server:sessions.test.ts 的 40930 用例不变并通过;全量 1453 个测试通过。

Checklist

  • I have read the CONTRIBUTING document.
  • I have linked a related issue (external PRs: issue must have a maintainer's /approve).
  • I have added tests that prove my feature works.
  • The behavior-change table above is complete, and every removed behavior or flipped default is named in the changeset and either has an escape hatch or was explicitly approved by a maintainer in this PR.
  • Ran gen-changesets skill, or this PR needs no changeset.(默认工作区尚未发版,feat: add a default workspace for chats without a project #4224 也未写 changeset)
  • Ran gen-docs skill, or this PR needs no doc update.

The default workspace lived in <Documents>/KimiCode/Default. On macOS the
first chat there triggered a Documents privacy prompt, and a denial blocked
every later chat until the user found the setting. Documents is also synced
by iCloud and OneDrive, and covered by Windows Controlled Folder Access.

Use ~/KimiCode/Default on every platform instead. This drops the Windows
PowerShell lookup, the XDG user-dirs parsing, and the documents_unavailable
reason; the error path is now always present.
@changeset-bot

changeset-bot Bot commented Oct 19, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: e38d696

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-19T08:05:59.430457Z e38d696 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@pkg-pr-new

pkg-pr-new Bot commented Oct 19, 2026

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

commit: e38d696

@wbxl2000
wbxl2000 merged commit e5e56bc into main Oct 19, 2026
17 checks passed
@wbxl2000
wbxl2000 deleted the qer/default-workspace-home branch October 19, 2026 08:13
7723qqq pushed a commit to 7723qqq/kimi-code that referenced this pull request Oct 22, 2026
…shotAI#4277)

Ported from MoonshotAI/kimi-code 2.3.0 (e5e56bc).

The default workspace no longer resolves a per-platform Documents folder: it is
`<home>/KimiCode/Default` unless `default_workspace.path` says otherwise, which
drops the XDG / PowerShell documents probes and the code that parsed their
output.

Conflicts resolved:
- defaultWorkspace.test.ts: the two XDG documents cases and the PowerShell
  probe cases are gone upstream, so the conflict block was resolved to upstream
  and the surviving "expands a leading tilde against the user home" case kept
  this file's `it.skipIf(process.platform === 'win32')` guard — `$HOME` is a
  Windows path here, so the POSIX-shaped assertion cannot hold locally.

Verification:
- bun run typecheck: every package and app exits 0
- packages/agent-core-v2: 7883 pass / 1 fail / 0 errors. The failure is the
  fullCompaction pre-shrink case that fails on the parent commit. A second file,
  test/mcpCore/oauth/service-lifecycle.test.ts, kills the Bun process (exit 3,
  native crash, no assertion); it crashes identically on the parent commit, so
  it is environmental, not this port.
- packages/kap-server: 1371 pass / 0 fail / 0 errors
- defaultWorkspace suite: 8 pass, 3 skip, 0 fail
- check:no-comments, no-hardcoded-prose, t-coverage, locale-keys all OK
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