Skip to content

Add directory creation to the folder picker - #981

Merged
agegr merged 4 commits into
agegr:mainfrom
Ingress007:feat/directory-picker-create-folder
Sep 30, 2026
Merged

agegr merged 4 commits into
agegr:mainfrom
Ingress007:feat/directory-picker-create-folder

Conversation

@Ingress007

Copy link
Copy Markdown

Summary

  • add a left-aligned New directory action to the directory picker footer
  • add a compact picker-styled dialog with Create and select, Create, and Cancel actions
  • start browsing from the currently selected project directory
  • create only a direct child of the current directory, with path traversal and filesystem error handling
  • protect the mutating endpoint with the existing API request-origin and JSON content-type checks
  • add English, Simplified Chinese, and Traditional Chinese translations
  • update the existing directory-browser and project-identity regression tests

Tests

  • node_modules/.bin/tsc --noEmit ✅
  • npm run lint ✅
  • related existing tests: 11 passed ✅
  • full suite on this branch: 1298 passed, 9 failed, 2 skipped
  • full suite on current upstream main: 1296 passed, the same 9 failed, 2 skipped

The remaining failures are the existing Windows baseline; this change adds two passing tests and no new failures.

ingress and others added 3 commits September 27, 2026 21:51
…g it

- Creating a folder now opens it in the picker, so "Select this folder" stays
  the only commit point and nested folders work the same way. This drops the
  separate "Create and select" action.
- "New directory" uses the secondary button style; the accent is reserved for
  selecting.
- Keep the picker starting from the last validated custom path. Starting from
  the selected project was an unrelated behavior change that bypassed it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@agegr

agegr commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Thanks @Ingress007! A "new folder" action in the picker is a small, useful addition. On a phone or a remote host it's otherwise hard to start a project in a fresh directory. The server side looks good: it goes through isApiRequestAllowed + JSON content-type, rejects . / .. / separators / NUL, and creates exactly one direct child with a non-recursive mkdir, so EEXIST surfaces as a 409.

I pushed a few changes to keep it minimal:

  • Create opens the new folder instead of selecting it. The nested dialog had three actions (Create and select / Create / Cancel). Now Create (or Enter) makes the folder and navigates into it, and Select this folder stays the picker's single commit point. Nested folders work the same way.
  • "New directory" uses the secondary button style. Two accent buttons in the footer competed with "Select this folder".
  • Reverted the start-directory change. initialPath={selectedCwd || …} bypassed the remembered last custom path whenever a project is selected, which is almost always. It's also unrelated to creating folders, so the picker keeps starting from customPathValue as before.
  • Merged main and resolved the AGENTS.md conflict with the open-in-explorer route line.
  • The zh-CN / zh-TW button label now reads 创建 / 建立 instead of 确认 / 確認.

Checked in the browser: create → lands in the new empty folder, a duplicate name shows the 409 message inline, and the outer picker stays open. tsc --noEmit, eslint, and the full unit suite pass (the one failure, worktree.test.mjs force removal, also fails on main in my macOS temp dir). LGTM 👍


Generated by Claude Code

@Ingress007

Copy link
Copy Markdown
Author

Thanks for the thoughtful review and refinements! I've synced the latest changes and tested them locally. The updated flow works well: creating a folder opens it in the picker, and selecting remains a separate explicit action. The styling, duplicate-name error handling, and remembered custom path all behave as expected. I have no issues with the changes—thanks again!

@agegr
agegr merged commit 680db65 into agegr:main Sep 30, 2026
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
6 处冲突都是"两边各加了不同东西"的纯追加,没有取舍:

- components/DirectoryPicker.tsx
  import:我们加的 useMemo + 上游加的 type CSSProperties
  状态:sortKey/sortDirection + createOpen/directoryName/createError/creating
- lib/directory-browser.ts
  取上游新增的 isValidDirectoryName()/createDirectory()(同一插入点),
  listDirectories 保留我们的返回类型 BrowsableDirectoryEntry[](多了 mtimeMs 供排序)
- lib/i18n/messages/{en,zh-CN,zh-TW}.ts
  同一插入点:我们的 4 个 sort* 键 + 上游的 6 个 newDirectory* 键,两个并集
  (上游的键放在前,我们的附在后面,减少以后上游再动这块时的冲突)

两块 UI 不互相遮挡:排序行在路径栏下方,上游的「新建目录」按钮在底部 footer
左侧(accent 仍只留给「选择此文件夹」)。route 的 POST 与请求校验自动合并。

验证:tsc/lint 通过;lib/directory-browser.test.mjs 6/6(含上游新增的
creates one direct child directory / new directory names cannot escape the
current directory);全量 npm test 仅剩 AGENTS.md 记录的 6 个已知失败。
Kano-u pushed a commit to Kano-u/pi-web that referenced this pull request Oct 2, 2026
解开 agegr#981 的 DirectoryPicker 冲突后,这一段(390e70f..f52fd84)实测 0 冲突:

- agegr#992 移动端输入框停在键盘上方并给打字更多空间
- agegr#997 限制每客户端 SSE 积压
- agegr#1001 可配置发送键(Enter / Ctrl+Enter)
- agegr#1006 从 pi 的 provider catalog 解析 discovery endpoint
- agegr#1017 空闲关闭被禁用时回收 Stop 无法解除的运行
- agegr#1016 Stop 结束输出被幸存进程持住的命令
- agegr#1015 保留用户消息里输入的换行
- agegr#1019 在 Safari / iOS 16.2 上可加载(新增 browserslist,无新依赖)
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 6, 2026
* Add directory creation to the folder picker

* refactor(directory-picker): open a created folder instead of selecting it

- Creating a folder now opens it in the picker, so "Select this folder" stays
  the only commit point and nested folders work the same way. This drops the
  separate "Create and select" action.
- "New directory" uses the secondary button style; the accent is reserved for
  selecting.
- Keep the picker starting from the last validated custom path. Starting from
  the selected project was an unrelated behavior change that bypassed it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: ingress <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
windli2018 pushed a commit to aiti-ai/aiti-ai that referenced this pull request Nov 8, 2026
* Add directory creation to the folder picker

* refactor(directory-picker): open a created folder instead of selecting it

- Creating a folder now opens it in the picker, so "Select this folder" stays
  the only commit point and nested folders work the same way. This drops the
  separate "Create and select" action.
- "New directory" uses the secondary button style; the accent is reserved for
  selecting.
- Keep the picker starting from the last validated custom path. Starting from
  the selected project was an unrelated behavior change that bypassed it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: ingress <[email protected]>
Co-authored-by: Alex Yang <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
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