Repository navigation
Conversation
added 5 commits
September 20, 2026 02:05
New files.* keys cover the explorer context menu (open, download, new file, new folder, rename, delete, extract, compress), the inline rename and create inputs, the viewer edit mode, and delete confirmations for en, zh-CN, and zh-TW.
POST /api/files/[...path] gains write, touch, mkdir, rename, delete, extract, and compress actions next to the existing upload flow. Every action is authorized through the same guards the route already uses for reads and uploads: the allowed-roots lexical check plus realpath containment of the resolved parent, so a symlinked ancestor can never move the target outside the workspace. - lib/file-mutations.ts: create/rename/delete/write primitives. Writes are atomic (temp file + rename) and preserve the original mode; binary files are rejected via a NUL-byte sniff; symlinks are never followed for writes. - lib/archive-names.ts + lib/file-archives.ts: extract into an auto-numbered sibling directory and compress into a sibling ZIP via bsdtar (libarchive), whose default extraction handling refuses traversal outside the destination. bsdtar is an optional runtime dependency: without it the two actions return a descriptive 500 and the new tests skip automatically. - Entry names are validated against traversal, separators, and control characters, matching the existing upload name rules.
Adds a context menu for files and folders (open, download, new file, new folder, rename, delete, extract, compress) with inline rename and create inputs, toolbar buttons for creating entries at the workspace root, and an inline error surface for failed mutations. Every mutation refreshes the tree and notifies AppShell through onFileMutated so Git status stays in sync.
Adds an edit mode to TextFileViewer: a monospace textarea drafts the file, Ctrl/Cmd+S saves through the write action, and Tab inserts spaces. The file is loaded in full before editing starts (the read endpoint chunks above 256KB), capped at 2MB to match the write endpoint; server-side binary detection and the existing truncation guard keep media and oversized files out of the editor. Saving refreshes the view and Git state.
vow132
force-pushed
the
pr-file-management
branch
from
September 19, 2026 18:05
de5e0ec to
6de06c2
Compare
Owner
|
Thanks for the work on this — the security model (realpath containment, symlink handling, name validation) is carefully done. We're going to close it, though, for scope reasons rather than code quality: Pi Web is meant to stay a thin web front end for pi, and editing and managing files is the agent's job (or the user's own editor/IDE). A built-in file manager and editor would add a large surface we'd have to keep maintaining (line endings, encodings, concurrent writes with the agent, archive tooling), which is beyond what we want this project to cover. Appreciate the contribution! |
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
agegr#967 / agegr#963 已由上游的 agegr#1009 / agegr#1008 落地,agegr#961 上游原样合并(逐字节相同), agegr#951 已收敛到上游的 agegr#907,agegr#960 上下游都拒绝——这些都与上游一致,按台账规则删行。 agegr#899 上游关闭但本地保留,状态注明为永久分叉。
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
…件批量开关) 唯一冲突是 AGENTS.md 的 lib/ 文件表:在同一个位置,上游插入 file-tree-visibility.ts、我们插入 fold-panes.ts —— 两行都保留(上游那行 紧跟 file-paths.ts,我们的跟在后面,减少以后撞车)。 agegr#1014 对 app/api/files/[...path]/route.ts 的改动(type=list 用 getFileTreeVisibility 过滤)与我们的 agegr#899 文件管理自动合并成功,两段逻辑 互补:上游决定"列不列",我们决定"每个 dirent 怎么判是不是目录"。 验证:tsc/lint 通过;list-route + file-tree-visibility + SkillsConfig.bulk 共 18 个测试 15 通过 3 跳过(上游自己声明 win32 跳过);全量 npm test 仅剩 AGENTS.md 记录的 6 个已知失败;e2e 14 项全绿(含 1280px/390px 文件面板)。
Kano-u
pushed a commit
to Kano-u/pi-web
that referenced
this pull request
Oct 2, 2026
6 处冲突没有一处需要二选一,两个功能都保留:
- app/api/files/[...path]/route.ts(1 处)
并用一个 type 变量分派:allow-link 交给上游的 allowLinkedDirectory,
其余交给我们的 handleFileMutation;上游的 const type 提到 try 顶部,
我们的 mutationType 变量随之去掉
- components/FileExplorer.tsx(5 处)
1) 模块级:我们的 ContextMenuTarget/RenameState/CreateState + mutateFileEntry
与上游的 responseError 并列
2) 上游的 OutsideLinkIcon + 我们的 CreateEntryInput,TreeNode 保持 export
(上游测试直接 import 它)
3) 列表行状态:我们的 isRenaming/isCreatingHere 与上游的
allowedLinkTarget/allowingLink/pendingLinkTarget 并列
4) 名称区:我们的重命名输入框与上游的"链接指向外部"图标并存
5) "空目录"占位:两个排除条件合并为
!loadError && !(creating && creating.parentDir === node.fullPath)
集成修复(不是冲突,是上游测试暴露的真问题):我们的 agegr#899 给 TreeNode
加了 renaming/creating 两个必填 prop,而上游的
FileExplorer.linked-directory.test.mjs 直接渲染 TreeNode 且不传它们,
于是 creating !== null && creating.parentDir 抛 TypeError。改为
creating?.parentDir 并把两个 prop 标为可选——TreeNode 本来就应该能在
"没有重命名/没有新建"时渲染。
验证:tsc/lint 通过;app/api/files/*.test.mjs + FileExplorer*.test.mjs +
linked-directory + file-access + path-security 共 32 个测试全过(含上游新增
的 11 个链接目录测试);全量 npm test 仅剩 AGENTS.md 记录的 6 个已知失败;
e2e 14 项全绿。
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。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The file explorer is currently read-only (browse, upload, preview). This PR turns it into a lightweight file manager while keeping the existing security model untouched:
Ctrl/Cmd+Sto save, save-state indicator, unsaved-changes guardAPI
POST /api/files/[...path]gainswrite,touch,mkdir,rename,delete,extract, andcompressactions next to the existingupload/upload-checkflow.touch/mkdiraddress the destination directory (like upload); the others address the entry itself.Security model
Every action is authorized through the same guards the route already uses for reads and uploads — no new trust decisions:
write/extract/compress(and deleted links are unlinked without following); real files/directories must realpath inside the rootswritereplaces the file atomically (temp file + rename), preserves the original mode, enforces a 2 MB cap, and rejects binary content via a NUL-byte sniffname,name-1, …) so nothing is ever overwrittenisApiRequestAllowedcross-site check that guards uploads covers all new actionsDependency note
extract/compressshell out tobsdtar(libarchive), whose default extraction handling refuses traversal outside the destination. It is an optional runtime dependency: without it the two actions return a descriptive 500 and everything else keeps working, and the new unit tests skip automatically when it is missing.Tests
bsdtaris absentnpm run lint,npx tsc --noEmit,npm test(1135 tests) andnpm run buildall green on this branchDocs