Skip to content

feat: let users customize the Use default directory path - #892

Closed
lucheng-hugh wants to merge 1 commit into
agegr:mainfrom
lucheng-hugh:feat/custom-default-directory
Closed

lucheng-hugh wants to merge 1 commit into
agegr:mainfrom
lucheng-hugh:feat/custom-default-directory

Conversation

@lucheng-hugh

@lucheng-hugh lucheng-hugh commented Sep 19, 2026 •

Copy link
Copy Markdown

Summary

  • Add a General settings field for the directory used by the sidebar “Use default directory” action, persisted in ~/.pi/agent/pi-web.json.
  • Keep the current dated ~/pi-cwd-YYYYMMDD folder when the setting is empty, and expand ~ plus {date} in custom paths.
  • Create the configured directory on use, allow it for file browsing, and surface errors if the action fails.

Test plan

  • Open Settings → General and confirm Default directory shows ~/pi-cwd-{date} as the placeholder and a resolved “Opens …” path.
  • Save an absolute or ~/… path, then choose Use default directory in the project picker and confirm the sidebar cwd matches it (the folder is created if missing).
  • Save a path with {date} and confirm it expands to today’s YYYYMMDD.
  • Click reset, then Use default directory again and confirm it returns to ~/pi-cwd-YYYYMMDD.
  • Confirm a relative path is rejected and does not overwrite the previous setting.

Made with Cursor

Persist a user-chosen path in ~/.pi/agent/pi-web.json so the sidebar action can open a stable folder instead of always creating ~/pi-cwd-YYYYMMDD.

Co-authored-by: Cursor <[email protected]>
@agegr

agegr commented Sep 29, 2026

Copy link
Copy Markdown
Owner

Thanks @lucheng-hugh for the PR. The implementation and tests are thorough.

The dated folder name is intentional, though, so I won't merge this:

It keeps users out of folders that already hold their data. A first-time user will likely just click "Use default directory". A dated name almost never collides with an existing folder, so the agent won't run inside the user's own data. A configurable path gives up that guarantee.
A stable path isn't needed. Once a default folder has a session, it shows up in the cwd picker and can be reopened from there.
It doubles as a scratch space. A fresh folder each day works well as a per-day temporary cwd.

Your PR did point at a real annoyance: the dated folders clutter the home directory. agegr/pi-web#996 · feat(default-cwd): create dated… moves them to ~/pi-cwd/YYYYMMDD. It also switches to the local date (it was UTC, so in UTC+8 you got yesterday's date before 08:00) and selects the default directory through /api/cwd/validate like any other directory.

Closing this in favor of agegr/pi-web#996 · feat(default-cwd): create dated…. Thanks again!

@agegr agegr closed this Sep 29, 2026
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
…w project its own path setting

Upstream closed agegr#892 in favour of agegr#996, so the configurable default cwd is gone:
lib/default-cwd.ts, app/api/default-cwd/route.ts, lib/file-access.ts and
lib/default-cwd.test.mjs are byte-identical to upstream/main again, and the
DirectoryPicker Escape tweak that came with agegr#892 is reverted. "Use default
directory" therefore keeps upstream's dated ~/pi-cwd/<YYYYMMDD> behaviour.

The New project action that grew out of it keeps working through its own layer:

- lib/default-project.ts stores defaultProjectPath in ~/.pi/agent/pi-web.json,
  empty meaning the built-in ~/pi-cwd (upstream's dated-folder parent).
- GET/PUT /api/default-project own that setting; POST { name } creates or reuses
  <project directory>/<name>, and the sidebar selects the result through
  /api/cwd/validate like any other directory.
- The Settings panel's General section now offers "Default project directory"
  instead of "Default directory" (settings.defaultProjectPath*).
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
上游已合并的 agegr#884/agegr#871/agegr#996 我们已同步(代码与上游一致),agegr#892 已回退,
四行都不再是取舍信息,删掉;保留的都是上游仍未合并(我们领先)或被我们
拒绝的 PR。顺带修掉 agegr#907 的理由措辞:状态列里出现「已摘取」会让
scripts/prs.sh 把它误判成已摘取。
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
上游以 agegr#996 的 ~/pi-cwd/YYYYMMDD 关闭了 agegr#892,我们保留的却是另一层东西
(lib/default-project.ts + /api/default-project + defaultProjectPath),
不与 agegr#996 冲突,也不在还活着的 PR 上,所以之前只写在 AGENTS.md 里。
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
新增「Fork-only additions (not in upstream)」一节,把散落在文件表和设计章节里的
自有内容收成一处清单:agegr#899 文件管理、新建项目目录设置(agegr#892)、目录选择器排序、
固定卡片折叠、以及 fork 文档与 .gitattributes。

顺带补上文件表里漏掉的自有文件:lib/file-mutations.ts、lib/file-archives.ts、
lib/archive-names.ts、components/PinnedCard.tsx、components/ThinkingCard.tsx、
components/NewProjectDialog.tsx。
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