Skip to content

feat(web-shell): add file creation and confirmed folder deletion - #14169

Merged
ytahdn merged 7 commits into
QwenLM:mainfrom
ytahdn:codex/file-tree-create
Oct 16, 2026
Merged

ytahdn merged 7 commits into
QwenLM:mainfrom
ytahdn:codex/file-tree-create

Conversation

@ytahdn

@ytahdn ytahdn commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

What this PR does

Adds New file and New folder to the Files toolbar and folder menus. Toolbar actions create at the selected workspace root; folder menus create inside that folder. The name dialog shows the destination, prevents accidental replacement, and keeps failures available for correction or retry.

Adds Delete to folder menus with a second confirmation that names the folder and warns that it and all its contents will be permanently deleted. Cancel is initially focused. Successful deletion removes the subtree and its active descendant preview while preserving unrelated expansion and filtering. Regular-file deletion remains in #14158.

Uses sticky-note-plus for New file and rotate-cw for Refresh, and horizontally centers the initial Files loading label. Creation and folder deletion are authenticated and limited to the selected trusted local workspace, with no primary-workspace fallback.

The review follow-up also keeps workspace mutations out of the read-only transcript bundle without raising its size ceiling, restores visible focus after deletion, revalidates new folders on first expansion, discards stale state after same-path folder recreation, and aligns directory error/audit metadata and protocol documentation.

Why it's needed

Files already supports browsing, previews and uploads, but creating empty files and folders and removing an unwanted folder currently requires another tool. These actions keep routine workspace file management in the tree and make destructive operations explicit.

Reviewer Test Plan

How to verify

  1. Open Files in a trusted local workspace. Use the toolbar to create an empty file and folder; both should appear at the workspace root even when another entry is selected. The icons should match the choices above.
  2. Hover a folder and open its trailing menu, or right-click it. New file and New folder should show that folder as the destination and create there. Invalid names and existing entries must not overwrite data. Cancel must send no mutation; failures should remain retryable.
  3. Choose Delete on a nonempty folder. Expect the relative path, a warning covering all contents and irreversible deletion, and initial focus on Cancel. Cancel or Escape must leave the directory intact. Confirming should remove the entire subtree and close its active descendant preview while preserving other expanded folders. Pending actions must prevent cancellation and duplicate submissions; failures must remain visible for retry. While a file-tree upload is active, deletion confirmation must wait for it to finish. New drops must be rejected while deletion is pending.
  4. Verify creation and folder deletion in a secondary workspace preserve same-named primary entries. Roots, escaping paths and final symlinks must be rejected; links within a deleted subtree must not remove their outside targets. SSH workspaces and missing capabilities must not expose unsupported actions.
  5. On a cold first opening, the loading label should be horizontally centered. Refresh should still reload the listing. A late listing must not resurrect a deleted subtree or hide a newly created entry. A newly created folder should read its contents on first expansion; successfully recreating an externally removed folder at the same path should clear its old subtree and descendant preview. Successful deletion should restore focus to a surviving file row. With no directory capabilities, hovering a folder should not expose an inert Options button.

Evidence (Before & After)

Before, the Files toolbar offered Refresh and folder menus did not offer these management actions. After, the toolbar and folder menus support creation, and folders have confirmed recursive deletion. No unmodified latest-main browser baseline was captured; the installed global CLI 0.22.0 lacks Files.

These are actual browser E2E captures using a simulated daemon, visually inspected after implementation. They establish UI states, not actual disk or Git operations. Creation and recursive deletion were verified separately against a real bundled daemon with isolated temporary workspaces.

Root creation actions and completed tree Create inside a folder
Toolbar and new entries Folder creation dialog
Irreversible folder-deletion confirmation Horizontally centered initial loading
Folder deletion confirmation Centered loading

Creation and deletion coexist with main's existing uploads. Deletion confirmation waits for uploads to finish; new drops are rejected during deletion. The capture below uses a simulated daemon.

Create/upload/delete coordination

Images are pinned to an immutable commit on a separate fork assets branch and are not part of the implementation branch.

Tested on

OS Status
🍏 macOS ✅ tested
🪟 Windows ⚠️ not tested
🐧 Linux ⚠️ not tested

Environment (optional)

Node.js 22.14.0, Playwright Chromium with a simulated daemon for browser tests, and a real bundled daemon with isolated primary, secondary and untrusted fixture workspaces for disk assertions. Build, typecheck, bundle, lint/format, 395 CLI tests, 138 artifact-panel tests, 3 file-browser unit tests, 34 build-artifact tests, 18 reference-contract tests, 5 SDK tests, 43 Files browser tests, 23 real-daemon creation cases and 20 real-daemon folder-deletion cases passed. A separate comment contains the E2E report.

Risk & Scope

  • Main risk or tradeoff: folder deletion is permanent and recursive failures may leave partial deletion. Portable path-based filesystem mutations retain the existing limitation around an external process replacing a parent directory concurrently.
  • Not validated / out of scope: SSH creation/deletion, Windows/Linux execution, injected concurrent external filesystem replacement, regular-file deletion in this change, and a latest-main browser baseline.
  • Breaking changes / migration notes: none. Actions require the advertised capabilities and an exact trusted local workspace owner; older or unsupported daemons retain browsing behavior.
  • Synchronized design: English · 简体中文.

Linked Issues

Related: #14158 provides regular-file deletion; this change adds folder deletion separately.

中文说明

本 PR 的改动

在 Files 顶部和文件夹菜单中添加新建文件、新建文件夹。顶部操作始终作用于选定工作区的根目录;文件夹菜单作用于该文件夹。名称弹窗显示创建位置,禁止意外覆盖,并保留失败提示供修改或重试。

在文件夹菜单中添加删除,二次确认显示目标文件夹,并明确提示文件夹及全部内容将永久删除且不可恢复,默认聚焦取消。成功后移除子树及其中的当前预览,保留其他目录的展开和筛选。普通文件删除仍由 #14158 提供。

新建文件使用 sticky-note-plus,刷新使用 rotate-cw,首次打开 Files 的加载提示水平居中。新建和文件夹删除经过鉴权,仅作用于选定的可信本地工作区,禁止回退主工作区。

Review 后续修复还在不提高体积上限的前提下从只读 transcript 包移除工作区变更动作,恢复删除后的可见行焦点,新建文件夹首次展开时重新读取,同路径重建时清理旧状态,并补齐目录错误/审计元数据及协议文档。

为什么需要

Files 已支持浏览、预览和上传,但创建空文件和文件夹、删除不需要的文件夹仍需借助其他工具。本次将常用文件管理操作放入目录树,并让破坏性操作有明确确认。

评审者验证计划

如何验证

  1. 在可信本地工作区打开 Files,通过顶部按钮创建空文件和文件夹。即使已选中其他条目,也应创建在工作区根目录。图标应与上述选择一致。
  2. 悬停文件夹打开行尾菜单,或右键该文件夹。新建文件和新建文件夹应显示该目录为创建位置,并创建在其中。非法名称和已有条目不能覆盖数据;取消不发送变更,失败应能重试。
  3. 对非空文件夹选择删除。应显示相对路径、全部内容不可恢复的警告,并默认聚焦取消。取消或 Escape 应保留目录;确认后删除整棵子树并关闭其中当前预览,其他展开目录保持展开。请求中禁止取消和重复提交,失败提示保留供重试。文件树上传进行中时,删除确认应等待上传完成;删除处理中拒绝新的文件拖放。
  4. 在次工作区创建及删除文件夹时,主工作区同名条目应保持完整。根目录、越界路径、末级符号链接必须拒绝;被删除子树中的链接不能删除其外部目标。SSH 工作区和缺少必要能力的 daemon 不应显示不支持的操作。
  5. 冷启动首次打开时,加载提示应水平居中,刷新仍能重载列表。迟到的列表不能使已删除子树重现,也不能隐藏新建条目。新建文件夹首次展开应读取实际内容;外部删除后同路径重建成功应清理旧子树和后代预览。成功删除后焦点应恢复到仍存在的文件行。没有目录能力时,悬停文件夹不应显示无效的 Options 按钮。

证据(改动前后)

改动前,Files 顶部只有刷新,文件夹菜单没有这些管理操作。改动后,顶部和文件夹菜单支持创建,文件夹支持二次确认递归删除。未捕获未修改的最新 main 浏览器基线;全局安装的 CLI 0.22.0 没有 Files。

以下为使用模拟 daemon 的实际浏览器 E2E 截图,已在实现后目视检查。截图仅证明 UI 状态,不证明实际磁盘或 Git 操作。创建及递归删除另由真实打包 daemon 和隔离临时工作区验证。

根目录创建操作及完成后的文件树 在文件夹内创建
顶部操作与新建条目 文件夹内创建弹窗
文件夹删除不可恢复确认 首次加载提示水平居中
文件夹删除确认 加载提示居中

新建和删除与 main 已有上传共存:删除确认等待上传完成,删除处理中拒绝新拖放。下图使用模拟 daemon。

新建/上传/删除协调

图片固定到 fork 独立素材分支的不可变 commit,不进入实现分支。

测试平台

系统 状态
🍏 macOS ✅ 已测试
🪟 Windows ⚠️ 未测试
🐧 Linux ⚠️ 未测试

环境

Node.js 22.14.0;浏览器测试使用 Playwright Chromium 和模拟 daemon;磁盘断言使用真实打包 daemon,主、次及不可信工作区均为隔离测试目录。构建、类型检查、打包、lint/格式、395 项 CLI 测试、138 项 artifact 面板测试、3 项文件树单元测试、34 项构建产物测试、18 项文档契约测试、5 项 SDK 测试、43 项 Files 浏览器测试、23 项真实 daemon 创建用例和 20 项真实 daemon 文件夹删除用例均通过。E2E 报告另附评论。

风险与范围

  • 主要风险或取舍:文件夹永久删除,递归删除失败可能已经移除部分内容。可移植路径变更沿用外部进程并发替换父目录的既有局限。
  • 未验证或范围外:SSH 创建/删除、Windows/Linux 运行、注入外部并发文件系统替换、本次变更中的普通文件删除,以及最新 main 浏览器基线。
  • 兼容性与迁移:无破坏性变更。操作要求已公布能力和准确的可信本地工作区所有者,旧版或不支持的 daemon 仍保留浏览行为。
  • 同步设计:English · 简体中文。

关联 Issue

相关:#14158 提供普通文件删除,本次单独添加文件夹删除。

@ytahdn

ytahdn commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

E2E verification report / E2E 验证报告

Verified locally on macOS with Node.js 22.14.0. Browser tests use a simulated daemon; real API and disk checks use an actual bundled daemon with newly created isolated temporary workspaces and configuration. Screenshots are UI evidence only.

Check Result
Root build, typecheck and bundle Passed
Final icon asset rebuild and bundle Passed
Changed-file lint and formatting; pre-commit hooks Passed
CLI filesystem, path/policy, write routes, qualified routes and SSH regression tests 390/390 passed
Artifact panel/workspace authority tests 130/130 passed
SDK qualified mutation REST tests 5/5 passed
Files Chromium browser suite 31/31 passed
Confirmation capture after opening animation 1/1 passed
Real-daemon creation API + disk cases 23/23 passed
Real-daemon recursive folder deletion API + disk cases 20/20 passed
Final self-audit and two independent reviews No unresolved findings

Browser coverage: root and folder-target creation, correct qualified workspace paths, invalid names, cancellation, collision/retry/busy behavior, capability/owner revocation, late listings, focus restoration, irreversible recursive-deletion confirmation, Cancel focus, subtree and descendant preview cleanup, unrelated expansion preservation, centered initial loading, sticky-note-plus and rotate-cw icons.

Real daemon coverage: empty root/nested files and folders in the selected secondary workspace; no-clobber collisions and live/dangling final symlink protection; empty/nonempty/nested recursive folder deletion including binary data, empty descendants and links; all protected primary/sibling/inside/outside targets preserved. Root/traversal/absolute/outside-ancestor/final-link/file targets, missing/bad auth and unknown/untrusted workspace cases were rejected without a primary fallback. Repeated or absent folder deletion returned 404. Only harness-owned fixture daemons were stopped; all destructive targets were newly created temporary data.

Limitations: the installed global CLI 0.22.0 lacks Files, so there is no installed-version feature baseline or unmodified latest-main browser baseline. Windows/Linux, SSH creation/deletion and concurrent external parent-replacement races were not executed. Recursive failures can leave partial deletion.

中文验证说明

本地使用 macOS、Node.js 22.14.0。浏览器测试使用模拟 daemon;实际 API 与磁盘检查使用真实打包 daemon,新建并隔离临时工作区及配置。截图只作为 UI 证据。

根目录构建、类型检查、打包、最终图标资源重建/打包、变更文件 lint/格式及提交钩子通过;CLI 390/390、artifact 面板与所有权 130/130、SDK 5/5、Files Chromium 31/31、弹窗动画完成后的截图验证 1/1、真实 daemon 创建 23/23、真实 daemon 文件夹递归删除 20/20 均通过。最终自审及两轮独立 review 无遗留发现。

浏览器覆盖根目录/指定文件夹创建、工作区限定路径、非法名称、取消、冲突/重试/忙碌、能力与所有权撤销、迟到列表、焦点恢复、递归删除不可恢复警告、默认取消焦点、子树与后代预览清理、其他目录展开保留、首次加载居中及两项新图标。

真实 daemon 验证选定次工作区内的根/嵌套空文件及文件夹创建、冲突不覆盖、末级有效/悬空链接保留;空/非空/嵌套文件夹递归删除,涵盖二进制、空后代与符号链接。主工作区同名条目、无关兄弟条目和内部/外部链接目标保持完整。根目录、路径穿越、绝对越界、外部链接祖先、末级链接、文件目标、缺失/错误鉴权和未知/不可信工作区均拒绝,没有主工作区回退。重复或不存在的目录删除返回 404。只停止测试自建 daemon,破坏性操作仅针对新建临时数据。

局限:全局 CLI 0.22.0 没有 Files,未执行已安装版本功能基线或未修改最新 main 浏览器基线。未执行 Windows/Linux、SSH 创建/删除及外部并发替换父目录竞态。递归失败可能已经移除部分内容。

@qwen-code-review-bot

qwen-code-review-bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

🩺 serve daemon A/B

Built the PR base vs this PR head b878361, drove a fixed endpoint set against each, and diffed the JSON responses. Only fields that changed are shown.

capabilities

field PR base (before) this PR (after)
features[] — "workspace_directory_create"
features[] — "workspace_directory_delete"

health-deep-with-session

field PR base (before) this PR (after)
activeWorkStaleMs 7 5

— Qwen Code · serve A/B

@qwen-code-review-bot

qwen-code-review-bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Qwen Triage finished — view run. See the stage comments in this thread for the result.

✅ Qwen Triage 已完成 —— 查看运行。结果见本线程中的各阶段评论。

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Thanks for the PR — this is a substantial, well-documented change, and the design doc in both languages made the intent easy to follow.

Template looks good ✓ — every required heading is present, Risk & Scope is filled in honestly (including the "simulated daemon" caveat on the screenshots, which I appreciate), and the design doc is linked in both English and Chinese with matching section structure.

Problem: this is a capability gap rather than a bug, so there's no reproduction to ask for — Files can browse and preview but cannot create an entry or remove a folder, and the PR says so plainly. Worth noting there is no linked issue (closingIssuesReferences is empty); #14158 is referenced as related for regular-file deletion, not as a closing reference. That's fine for a feature, but it means nothing here is tied to a user report — the demand is inferred. If there's an issue where users asked for this, linking it would strengthen the case.

Direction: aligned. Workspace file management belongs in the Files tree, and making the destructive path an explicit confirmed dialog is the right instinct. The security posture is where I focused most of my attention, since this adds authenticated recursive deletion to the daemon — see the code review for what I verified there.

Size: this spans three packages (packages/cli, packages/sdk-typescript, packages/web-shell), so it counts as a core-path change under the two-tier gate. It's a feat, so size does not block it — but the breakdown is worth putting in front of a maintainer:

lines
production logic 957
tests (*.test.*, *.spec.*) 1,630
design docs 153

At 957 production lines this is past the 500-line mark where a core-touching feature gets flagged for maintainer awareness (it stays just under the 1,000-line split advisory). The test-to-production ratio is healthy, and I'm flagging scale, not objecting to it.

Approach: the core of it is well-scoped, but a few things ride along beyond the stated goal:

  • The Refresh icon swap (RefreshCwIcon → RotateCwIcon) and the loading-label centering (text-center + role="status") are cosmetic changes to existing controls, unrelated to creation or deletion. They're disclosed in the description, which is good, but they'd be cleaner as their own small PR — right now a revert of this feature also reverts them.
  • The new mode === 'create' branch in the file-write route re-implements validation that resolveWithinWorkspace already performs (it calls hasSuspiciousPathPattern unconditionally, and 'write' is already in ENOENT_TOLERATING_INTENTS with a documented "walk up to the first existing ancestor, realpath it, re-attach the tail" path). Have you considered resolving the leaf through the existing resolver instead of resolving the parent and re-joining? Fewer parallel validation paths to keep in sync.
  • Splitting folder deletion from feat(web-shell): add file-tree deletion with confirmation #14158's file deletion is defensible, but the two will ship two very similar confirmation dialogs. Worth confirming they converge rather than diverge.

Risk: no elevated-risk paths — this doesn't touch the revert-correlated set (no shell.ts, sandbox.ts, geminiChat, MCP client, ACP, etc.). The real risk is inherent to the feature rather than to its location: permanent recursive deletion behind an authenticated route. That's exactly why I'm not treating "the direction looks right" as sufficient confidence here.

Moving on to code review. 🔍

中文说明

感谢贡献!这是一个体量不小、文档也很完整的改动,中英双语设计文档让意图很容易理解。

模板完整 ✓ —— 所有必需小节都在,Risk & Scope 填得很诚实(包括明确标注截图用的是模拟 daemon,这点很好),设计文档中英双版都有链接且章节结构一致。

问题:这是能力缺口而不是 bug,所以不需要复现 —— Files 能浏览和预览,但无法创建条目或删除文件夹,PR 里说得很清楚。需要说明的是本 PR 没有关联 issue(closingIssuesReferences 为空);#14158 是作为普通文件删除的相关 PR 提到的,并非闭合引用。对 feature 来说这没问题,但意味着这里的诉求不是来自用户报告,而是推断出来的。如果有用户提过这个需求的 issue,关联上会更有说服力。

方向:对齐。工作区文件管理本来就应该在 Files 树里,把破坏性操作做成显式二次确认弹窗也是正确的思路。我的注意力主要放在安全面上,因为这给 daemon 增加了带鉴权的递归删除——具体验证结果见代码审查。

规模:改动横跨三个包(packages/cli、packages/sdk-typescript、packages/web-shell),按两级门禁算属于核心路径改动。类型是 feat,所以规模不构成阻塞——但拆分数据值得让维护者看到:生产逻辑 957 行、测试 1,630 行、设计文档 153 行。957 行生产代码已超过 500 行这条「触及核心的 feature 需提请维护者关注」的线(尚未到 1,000 行的拆分建议线)。测试与生产代码比例是健康的,我这里只是提示规模,并不反对。

**方案:**主体范围是合理的,但有几处超出了既定目标:

  • 刷新图标替换(RefreshCwIcon → RotateCwIcon)和加载文案居中(text-center + role="status")是对已有控件的外观改动,与创建/删除无关。描述里已如实说明,这点很好,但拆成独立小 PR 会更干净——现在如果回滚这个 feature,这两处也会一起被回滚。
  • 文件写入路由里新增的 mode === 'create' 分支,重新实现了 resolveWithinWorkspace 已有的校验(它会无条件调用 hasSuspiciousPathPattern,且 'write' 本就在 ENOENT_TOLERATING_INTENTS 中,并有「向上走到第一个存在的祖先、realpath 后重新拼接尾部」的既定路径)。有没有考虑过直接用现有 resolver 解析末级路径,而不是解析父目录再拼接?这样需要同步维护的并行校验路径会更少。
  • 把文件夹删除与 feat(web-shell): add file-tree deletion with confirmation #14158 的文件删除拆开是可以理解的,但两者最终会各自实现一套非常相似的确认弹窗。建议确认它们是收敛而不是分叉。

**风险:**未命中高风险路径——没有触及与回滚相关的那组文件(shell.ts、sandbox.ts、geminiChat、MCP client、ACP 等)。真正的风险来自功能本身而非改动位置:鉴权路由背后的永久递归删除。这也正是为什么我不把「方向看起来对」当作足够的信心。

进入代码审查 🔍

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at d64daba275d5092e96012b7ef0b0ad017a841ebc · re-run with @qwen-code /triage

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Code review

I read the serve layer first, since this adds authenticated recursive deletion to the daemon. What I could verify from the diff and the base source:

The filesystem layer is genuinely careful. deleteDirectory uses lstat, not stat, so a symlink pointing at a directory is rejected as symlink_escape instead of being followed — the outside target survives. The parent goes through resolveWithinWorkspace(..., 'delete'), and realpath(parent) === parent plus realpath(target) === target are both re-checked inside the per-path lock. Workspace roots are explicitly refused, and trust + generation guards are asserted three separate times — before resolution, after acquiring the lock, and again immediately before rm — so a workspace that loses trust mid-flight cannot complete the delete. rm runs with force: false, so a vanished target surfaces as an error rather than a silent success. createDirectory mirrors this: existing entries and symlinks are rejected before mkdir, and the non-recursive mkdir plus post-lstat check close the race.

Route ownership classification (the thing AGENTS.md asks reviewers to name): both new routes are selected-runtime + live-session-owner scoped, and they stay inside the resolved runtime. The chain is mutate({ strict: true }) → getWorkspaceRouteContext(req), which throws internal_error when absent rather than falling back to the primary workspace → context.runtime.routeFileSystemFactory → factory.forRequest({ originatorClientId, route }). SSH is refused with 422 before any filesystem call, and the optional-method presence check gives an older daemon a 422 instead of a crash. Capabilities are registered and the integration test's expected envelope is updated in the same diff.

The UI handles the awkward cases. Pending guards disable both submit and cancel and block Escape mid-delete, so there's no double-submit and no dismissal in flight. Results are bound to lifetimeRef, so a response arriving after teardown or a workspace switch is dropped instead of applied to a stale tree. Stale-listing protection is two-sided: superseded responses are discarded via the request token, deletedPaths filters a late parent listing so a deleted subtree can't resurrect, and createdEntries merges into late listings so a new entry can't be hidden. The active preview is cleared only when it's actually a descendant of the deleted path.

One thing that looked like a regression and isn't. writeWorkspaceFile was switched from the this.post(...) helper to workspaceJsonRequest(..., { mode: 'rest' }). That matters because fetchWithTimeout defaults to mode='transport' and dispatches through this.transport.fetch, while 'rest' uses the raw _fetch — so an injected DaemonTransport is bypassed. But the new SDK test pins exactly this: it injects a transport whose restFetch succeeds and whose fetch returns 404, so the assertion fails if the method takes the transport path. Deliberate and covered. It does change an existing public method for all callers rather than just the new create flow, so it deserves a line in the PR description.

Concerns

1. Blocking — CI is red and this PR caused it. Details in the testing section below.

2. Duplicated path validation, and a branded type built by hand. The new mode === 'create' branch re-implements checks resolveWithinWorkspace already performs unconditionally (hasSuspiciousPathPattern), and 'write' is already in ENOENT_TOLERATING_INTENTS with a documented "walk up to the first existing ancestor, realpath it, re-attach the tail" path. Both that branch and createDirectory/deleteDirectory then construct a branded path via path.join(parent, basename) as ResolvedPath, while paths.ts documents the brand as the contract that routes "may not construct one without going through this function." Containment does hold transitively because the parent is resolved first, so I'm not calling this a security hole — but it is a second validation path that can drift from the canonical resolver, and the cast defeats the compile-time guarantee the brand exists to provide.

3. An inconsistent suspicious-pattern gate worth confirming. The route checks !factory.sshWorkspace && hasSuspiciousPathPattern(queryPath), exempting SSH. But the parent is then resolved through resolveWithinWorkspace, which calls the same check unconditionally — so for an SSH workspace the exemption may not actually exempt anything. Which behaviour is intended here?

4. Drive-by cosmetic changes (the Refresh icon swap and the loading-label centering) are unrelated to creation or deletion — noted in the gate comment; splitting them out would keep this revertable as one unit.

sequenceDiagram
    participant P1 as User
    participant P2 as Files UI
    participant P3 as DaemonClient
    participant P4 as Directory Route
    participant P5 as WorkspaceFileSystem
    participant P6 as Filesystem
    P1->>P2: choose Delete on a folder row
    P2->>P2: confirm dialog opens, Cancel focused
    P1->>P2: confirm
    P2->>P3: deleteWorkspaceDirectory, relative path
    P3->>P4: POST directory delete, mode rest
    P4->>P4: strict mutation gate, resolve workspace owner
    P4->>P5: deleteDirectory
    P5->>P5: assert generation open, workspace trusted
    P5->>P6: resolve parent within workspace
    P5->>P5: refuse workspace roots
    P5->>P5: acquire per-path exclusive lock
    P5->>P6: realpath parent, lstat target, realpath target
    P5->>P6: rm recursive, force false
    P5-->>P4: deleted absolute path
    P4-->>P3: 200 directory_delete
    P3-->>P2: resolved
    P2->>P2: drop subtree, close descendant preview
Loading
Files changed (21 of 21 shown)
File Churn
packages/web-shell/client/components/artifacts/WorkspaceFileBrowser.tsx +462 / -59 — the bulk of the UI: create/delete dialogs, folder menus, tree mutation and stale-listing guards
packages/web-shell/client/e2e/web-shell.files.spec.ts +595 — new Playwright coverage against a simulated daemon
packages/cli/src/serve/fs/workspace-file-system.ts +135 — the two new fs primitives, with locking and symlink rejection
packages/cli/src/serve/routes/workspace-file-write.ts +138 / -1 — two new routes plus the create-mode resolution branch
packages/cli/src/serve/workspace-qualified-rest.test.ts +298 — route-level tests for the new endpoints
packages/cli/src/serve/fs/workspace-file-system.test.ts +327 — fs primitive tests
packages/web-shell/client/components/artifacts/ArtifactPanel.test.tsx +224 — panel-level tests
packages/sdk-typescript/test/unit/DaemonClient.directory-create.test.ts +115 — pins the qualified-REST transport choice
packages/sdk-typescript/src/daemon/DaemonClient.ts +27 / -3 — two new methods, and the existing write method moved to rest mode
packages/web-shell/client/components/artifacts/useArtifactWorkspaceTarget.ts +82 / -2 — capability gating and the create/delete action plumbing
docs/design/web-shell-file-create.md +87 — English design doc
docs/design/web-shell-file-create.zh-CN.md +66 — Chinese design doc, structurally synchronized
packages/cli/src/serve/routes/workspace-file-write.test.ts +60 / -1
packages/web-shell/client/components/artifacts/files-messages.ts +26 — 13 new i18n keys in both locales
packages/cli/src/serve/fs/paths.ts +8 / -1 — adds the delete intent
packages/cli/src/serve/fs/policy.test.ts +7
packages/web-shell/client/components/artifacts/ArtifactPanel.tsx +5 / -1 — centered loading fallback
packages/cli/src/serve/fs/policy.ts +3 / -2 — classifies delete as a mutating intent
packages/cli/src/serve/capabilities.ts +2 — registers the two capabilities
integration-tests/cli/qwen-serve-routes.test.ts +2 — expected capability envelope
packages/cli/src/serve/server.test.ts +2

Testing

This was an unattended CI run, so I did not build, run, or execute any PR-derived code — per the skill's rules the review is static. The evidence below is the PR's own CI check-runs for d64daba275d5092e96012b7ef0b0ad017a841ebc, fetched through the API.

One check is red and I believe this PR caused it. Test (ubuntu-latest, Node 22.x) fails on the web-shell bundle-size budget:

FAIL  build-artifact.test.ts > build artifact — transcript entry (#11031) > keeps the transcript entry a fraction of the interactive entry
AssertionError: expected 1331718 to be less than 1331500
 ❯ build-artifact.test.ts:520:23
    520|     expect(js.length).toBeLessThan(1_331_500);
 Test Files  1 failed | 438 passed (439)
      Tests  1 failed | 11813 passed (11814)

It failed identically on all three attempts (the suite runs --retry=2), so this is deterministic rather than flaky. I classified it as PR-caused from the diff and the base source rather than from anything the log claims: I read packages/web-shell/client/build-artifact.test.ts on main, where the ceiling's own comment says it "leaves 1,489 units of margin" and documents that new copy lands in "the shared i18n table every entry ships." This PR adds 13 new keys to both locales in files-messages.ts — 218 units over a 1,489-unit margin is consistent with that. The fix is the convention the comment already states: re-measure and raise the ceiling.

The three Java failures are unrelated. EventTransport broker gates / RocketMQ 5.5.1, Hosted process fault gates / MySQL 8.4 and Runtime Broker and Managed Agent MariaDB fail in com.alibaba.qwen.code.managedagent.EventTransportBrokerGate.thePostCommitPathDoesNotRegress and broker-gate territory. This PR touches zero Java files and nothing under the managed-agent tree, so I'm reading these as pre-existing infra noise, not a regression — though they do mean the commit isn't green overall.

Still running: web-shell E2E Smoke (ubuntu-latest, Node 22.x) was in progress at fetch time. That's the check most directly relevant to this PR, so its result matters and I'm not guessing at it. Test (macos-latest) and Test (windows-latest) were skipped, and Integration Tests (CLI, No Sandbox) was skipped — so the author's "not tested on Windows/Linux" caveat is not covered by CI either.

Check Conclusion
Test (ubuntu-latest, Node 22.x) failure
web-shell E2E Smoke (ubuntu-latest, Node 22.x) ⏳ pending
Lint & Static (ubuntu-latest, Node 22.x) success
Serve A/B (ubuntu-latest, Node 22.x) success
Capture web-shell visuals (ubuntu-latest, Node 22.x) success
Integration Tests (no-AK, No Sandbox) success
Integration Tests (CLI, No Sandbox) skipped
Test (macos-latest, Node 22.x) skipped
Test (windows-latest, Node 22.x) skipped
EventTransport broker gates / RocketMQ 5.5.1 / Java 21 failure
Hosted process fault gates / MySQL 8.4 / Java 21 failure
Runtime Broker and Managed Agent MariaDB / Java 21 failure
Desktop Shell (ubuntu-22.04) success
Desktop Shell (windows-2022) success
OpenTUI no-flicker gate success
TUI parity snapshots (ink vs opentui) success
Real daemon E2E / Java 11 success
Flyway migration version uniqueness success
ubuntu-latest / Java 11 success
ubuntu-latest / Java 17 success
ubuntu-latest / Java 21 success
macos-latest / Java 21 success
windows-latest / Java 21 success
Classify PR success
assign success
label success
Remind on force-push success

Sandboxed verification would settle the part CI cannot. The central claims here are behavioural and destructive: that recursive deletion never follows a symlink out of the subtree, that a secondary workspace's operation can't touch same-named primary entries, and that a late listing can't resurrect a deleted folder. None of that is observable from the diff, and the PR's own browser evidence was captured against a simulated daemon — the author says so explicitly, and it establishes UI states rather than disk effects. The 23 real-daemon creation cases and 20 real-daemon deletion cases are the author's claim, not something I re-ran. The author has write access, so both lanes are available: @qwen-code /verify for A/B proof that the symlink and workspace-isolation guards actually fail closed (a suite that passes with the realpath re-check removed would tell us they don't), and @qwen-code /tmux if the confirmation dialog's focus and dismissal behaviour needs a real terminal capture.

中文说明

代码审查

我先看了 serve 层,因为这个 PR 给 daemon 增加了带鉴权的递归删除。以下是我能从 diff 和基线源码验证到的:

文件系统层写得确实谨慎。 deleteDirectory 用的是 lstat 而非 stat,所以指向目录的符号链接会被判为 symlink_escape 拒绝,而不是被跟随——外部目标得以保留。父目录经 resolveWithinWorkspace(..., 'delete') 解析,并且 realpath(parent) === parent 与 realpath(target) === target 都在每路径锁内部重新校验。工作区根目录被显式拒绝;信任与代际保护一共断言了三次——解析前、取锁后、以及 rm 之前——因此中途失去信任的工作区无法完成删除。rm 使用 force: false,目标消失会报错而非静默成功。createDirectory 同样处理:mkdir 之前先拒绝已存在条目和符号链接,非递归 mkdir 加上事后 lstat 校验封住了竞态。

路由归属分类(AGENTS.md 要求审查者点名的一项):两个新路由都是选定运行时 + 活跃会话所有者作用域,并且留在已解析的运行时内。调用链为 mutate({ strict: true }) → getWorkspaceRouteContext(req)(缺失时抛 internal_error,不回退主工作区)→ context.runtime.routeFileSystemFactory → factory.forRequest({ originatorClientId, route })。SSH 在任何文件系统调用之前就以 422 拒绝;可选方法存在性检查让旧版 daemon 得到 422 而不是崩溃。能力已注册,且集成测试的期望能力清单在同一 diff 中同步更新。

UI 处理了那些棘手情况。 pending 保护同时禁用提交与取消,并在删除中阻止 Escape,因此不会重复提交、也不会在请求中被关闭。结果绑定到 lifetimeRef,所以拆卸或切换工作区之后到达的响应会被丢弃,而不会应用到已过期的树上。迟到列表的防护是双向的:通过请求令牌丢弃被取代的响应,deletedPaths 过滤迟到的父目录列表以防已删除子树复活,createdEntries 合并进迟到列表以防新条目被隐藏。仅当当前预览确实是被删路径的后代时才清除它。

有一处看起来像回归,实际不是。 writeWorkspaceFile 从 this.post(...) 辅助方法改成了 workspaceJsonRequest(..., { mode: 'rest' })。这点很关键,因为 fetchWithTimeout 默认 mode='transport' 并走 this.transport.fetch,而 'rest' 走原始 _fetch——也就是说注入的 DaemonTransport 会被绕过。但新增的 SDK 测试正是钉住了这一点:它注入的 transport 中 restFetch 返回成功、fetch 返回 404,所以一旦该方法走了 transport 路径断言就会失败。这是有意为之且有测试覆盖的。不过它改变的是一个已有公开方法对所有调用方的行为,而不只是新的创建流程,所以值得在 PR 描述里写一句。

顾虑

**1. 阻塞项——CI 是红的,且由本 PR 引起。**详见下方测试部分。

2. 路径校验重复,且手工构造了带品牌类型。 新增的 mode === 'create' 分支重新实现了 resolveWithinWorkspace 已经无条件执行的检查(hasSuspiciousPathPattern),而 'write' 本就在 ENOENT_TOLERATING_INTENTS 中,并有既定的「向上走到第一个存在的祖先、realpath、重新拼接尾部」路径。该分支以及 createDirectory/deleteDirectory 都通过 path.join(parent, basename) as ResolvedPath 构造带品牌的路径,而 paths.ts 把这个品牌记录为路由「不得绕过本函数自行构造」的契约。由于父目录先被解析,包含关系在传递意义上是成立的,所以我不认为这是安全漏洞——但这确实是第二条可能与规范 resolver 逐渐分叉的校验路径,而且这个 cast 抵消了品牌类型本应提供的编译期保证。

3. 一处值得确认的不一致。 路由检查 !factory.sshWorkspace && hasSuspiciousPathPattern(queryPath),对 SSH 豁免。但父目录随后经 resolveWithinWorkspace 解析,而它会无条件调用同一检查——所以对 SSH 工作区而言,这个豁免可能实际上什么也没豁免。这里的预期行为是哪一种?

4. 顺手带上的外观改动(刷新图标替换、加载文案居中)与创建/删除无关——已在门禁评论中提到;拆出去能让本 PR 作为一个整体被回滚。

测试

本次是无人值守 CI 运行,因此我没有构建、运行或执行任何 PR 派生代码——按技能规则,审查是静态的。下方证据是 PR 自身针对 d64daba275d5092e96012b7ef0b0ad017a841ebc 的 CI 检查结果,通过 API 获取。

有一项检查是红的,我认为是本 PR 引起的。 Test (ubuntu-latest, Node 22.x) 在 web-shell 打包体积预算上失败:断言 expect(js.length).toBeLessThan(1_331_500),实际为 1,331,718,超出 218。三次尝试(该套件以 --retry=2 运行)失败完全一致,因此是确定性的,不是 flaky。我是依据 diff 和基线源码而非日志中的说法做出归因的:我在 main 上读了 packages/web-shell/client/build-artifact.test.ts,该上限自身的注释写明它「留出了 1,489 单位的余量」,并说明新增文案会进入「每个入口都会打包的共享 i18n 表」。本 PR 在 files-messages.ts 中为两种语言各新增了 13 个键——在 1,489 单位余量上超出 218 与此相符。修复方式就是该注释已写明的惯例:重新测量并提高上限。

三项 Java 失败与本 PR 无关。 EventTransport broker gates / RocketMQ 5.5.1、Hosted process fault gates / MySQL 8.4 与 Runtime Broker and Managed Agent MariaDB 失败于 com.alibaba.qwen.code.managedagent.EventTransportBrokerGate.thePostCommitPathDoesNotRegress 及 broker gate 相关范围。本 PR 未触及任何 Java 文件,也未触及 managed-agent 目录,因此我将其判为既有基础设施噪声而非回归——但这确实意味着该 commit 整体并非全绿。

仍在运行: 抓取时 web-shell E2E Smoke (ubuntu-latest, Node 22.x) 尚在进行中。这是与本 PR 最直接相关的检查,所以它的结果很重要,我不做猜测。Test (macos-latest) 与 Test (windows-latest) 被跳过,Integration Tests (CLI, No Sandbox) 也被跳过——因此作者「未在 Windows/Linux 测试」的说明同样没有 CI 覆盖。

沙箱验证可以解决 CI 无法判定的部分。 这里的核心主张是行为性且具破坏性的:递归删除绝不会沿符号链接逃出子树、次工作区操作不会碰到主工作区同名条目、迟到的列表不会让已删除文件夹复活。这些都无法从 diff 观察到,而 PR 自身的浏览器证据是针对模拟 daemon 采集的——作者已明确说明,它证明的是 UI 状态而非磁盘效果。23 项真实 daemon 创建用例和 20 项真实 daemon 删除用例属于作者的声明,我没有重新运行。作者具备写权限,因此两条通道都可用:@qwen-code /verify 用于 A/B 证明符号链接与工作区隔离防护确实失败关闭(如果移除 realpath 重新校验后测试仍然通过,就说明它们没起作用);若确认弹窗的焦点与关闭行为需要真实终端采集,则用 @qwen-code /tmux。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at d64daba275d5092e96012b7ef0b0ad017a841ebc · re-run with @qwen-code /triage

@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Confidence: 3/5 — the deletion guards are careful enough that I'd trust them in production, but this is capped by the core-path escalation and by a red CI check that this PR caused, so it isn't mine to approve.

Stepping back: I sketched what I'd do from the title and the "Why it's needed" section before reading the diff, and the PR lands close to it — reuse the existing qualified file/write route with mode: 'create' rather than inventing a create-file endpoint, add exactly two new qualified routes behind new capabilities, implement the primitives in workspace-file-system.ts on top of the existing resolveWithinWorkspace / pathLocks / generationGuard / audit machinery, and gate the UI actions per capability. It does all of that. In places it's more rigorous than I would have been: adding 'delete' to the Intent union forces the exhaustive trust switch to classify it explicitly instead of defaulting to allowed, and the two-sided stale-listing guards (drop deleted subtrees, merge created entries) are the kind of thing that usually gets missed and then resurfaces as a ghost folder.

Three honest reservations, in the order they matter:

The red check was avoidable, and the test warned about it. build-artifact.test.ts chronicles PR after PR consuming the same bundle-budget margin — its comment is effectively a ledger of past collisions, and it states the margin was down to 1,489 units. Adding 13 i18n keys in both locales puts strings into exactly the shared table that ledger describes, and the result is 218 units over. Re-measuring was part of the work, not a follow-up. That's the one miss here I'd call a process gap rather than a judgment call.

It's one of five stacked PRs drawing on the same budget. #14143, #14145, #14158, #14159 and this one all touch web-shell Files. Each that adds copy to the shared i18n table consumes from the same 1,489-unit margin, so whoever merges second and third will hit the same wall. Worth deciding the ceiling once for the stack rather than bumping it five times — and #14158's file-deletion dialog and this one's folder-deletion dialog should converge on a single confirmation component instead of shipping two near-identical ones.

The duplicated validation is the part I'd push back on. I'm not worried about the security of the create path — containment holds transitively because the parent is resolved first. I'm worried about maintainability: the route now carries a second copy of the suspicious-pattern and dot-name checks, and constructs a ResolvedPath by cast where paths.ts documents that routes must go through the resolver. Six months from now someone hardening resolveWithinWorkspace will fix the canonical path and miss this one. Same question stands on the !factory.sshWorkspace exemption, which the unconditional check downstream may make inert.

Would I curse or thank them in six months? Thank them for the fs layer and for 1,630 lines of tests against 957 lines of production code — that ratio is why I was willing to believe the symlink and root-refusal claims from the diff alone. The route-level duplication is the part that would annoy me.

Not approving, and why. Two independent reasons. First, CI is red on this commit from a failure I attribute to the PR (evidence in the review comment), so there is nothing green to approve against. Second, this spans three packages and carries 957 production logic lines, which puts it past the 500-line mark where a core-touching feature is flagged for maintainer awareness — that cap means the call isn't mine even once the budget is fixed. I'm not requesting changes either: the blockers are a one-line budget re-measure and two questions, not a rethink.

To the author — you have write access, so the path forward is short: re-measure and raise the transcript-entry ceiling, say whether the SSH suspicious-pattern exemption is intended to be effective, and consider whether the create-mode branch can just use the resolver. web-shell E2E Smoke was still running when I fetched; its result is worth waiting for since it's the check closest to this change.

On escalation: I could not resolve a maintainer to @mention, and I'm not going to guess a login. The resolver matches areas on labels, this PR has none, QWEN_MAINTAINER_HANDLE is unset, and there are no human reviews yet to fall back on. So this is an open defer with no one pinged — a human needs to pick this up from the queue. If a maintainer wants the mention to work on a re-run, adding the relevant scope/ or category/ label would let the resolver route it.

中文说明

信心:3/5 —— 删除相关的防护写得足够谨慎,我愿意在生产环境中信任它;但由于核心路径改动需提请维护者关注,且本次 CI 有一项由该 PR 引起的红灯,所以这不取决于我来批准。

退一步看:我在读 diff 之前,先根据标题和「为什么需要」一节勾勒了自己的方案,结果与本 PR 相当接近——复用已有的限定 file/write 路由配合 mode: 'create',而不是新造一个创建文件端点;只新增两个带新能力门控的限定路由;在 workspace-file-system.ts 中基于既有的 resolveWithinWorkspace / pathLocks / generationGuard / 审计机制实现原语;并按能力门控 UI 操作。这些它都做到了。有些地方比我会写的更严谨:把 'delete' 加入 Intent 联合类型,迫使穷尽式的信任 switch 显式分类,而不是默认放行;双向的迟到列表防护(丢弃已删除子树、合并新建条目)正是通常会被漏掉、随后以「幽灵文件夹」形式复现的那类问题。

三点真实的保留意见,按重要性排序:

这项红灯本可避免,而且测试自己已经预警过。 build-artifact.test.ts 逐条记录了不同 PR 消耗同一份打包体积余量的历史——它的注释实际上就是一部过往冲突的账本,并写明余量已降至 1,489 单位。为两种语言各新增 13 个 i18n 键,恰恰会把字符串放进该账本描述的那张共享表,结果是超出 218 单位。重新测量本应属于本次工作的一部分,而不是后续跟进。这是我认为唯一属于流程疏漏、而非判断取舍的问题。

它是五个叠加 PR 中的一个,共用同一份预算。 #14143、#14145、#14158、#14159 和本 PR 都改动了 web-shell Files。凡是向共享 i18n 表新增文案的,都会从同样的 1,489 单位余量中扣减,因此第二个、第三个合入的人都会撞上同一堵墙。建议为这一组 PR 一次性决定上限,而不是分五次提高;同时 #14158 的文件删除弹窗与本 PR 的文件夹删除弹窗应当收敛为同一个确认组件,而不是各自实现两套高度相似的弹窗。

重复的校验是我会明确反对的部分。 我并不担心创建路径的安全性——因为父目录先被解析,包含关系在传递意义上成立。我担心的是可维护性:路由现在多了一份可疑模式与点名称检查的副本,并且在 paths.ts 明文规定路由必须经由 resolver 的地方,用 cast 构造了 ResolvedPath。六个月后有人加固 resolveWithinWorkspace 时,会修好规范路径而漏掉这一份。关于 !factory.sshWorkspace 豁免的疑问同样成立——下游那个无条件检查可能使它形同虚设。

六个月后我会感谢还是埋怨作者?会感谢——感谢文件系统层的实现,以及在 957 行生产代码之外写了 1,630 行测试。正是这个比例,让我仅凭 diff 就愿意相信符号链接与根目录拒绝的相关主张。真正会让我烦恼的是路由层的重复。

不予批准,以及原因。 有两个相互独立的理由。其一,该 commit 的 CI 是红的,且我将失败归因于本 PR(证据见审查评论),因此没有可供批准的绿色结果。其二,改动横跨三个包、含 957 行生产逻辑代码,已超过「触及核心的 feature 需提请维护者关注」的 500 行门槛——即使预算问题修好,这一上限也意味着决定权不在我。我也不会提交 request changes:阻塞项只是一行体积预算的重新测量和两个问题,而不是需要重新设计。

给作者——你具备写权限,所以推进路径很短:重新测量并提高 transcript 入口的体积上限;说明 SSH 的可疑模式豁免是否有意生效;并考虑创建模式分支能否直接复用 resolver。我抓取时 web-shell E2E Smoke 仍在运行,由于它是与本改动最相关的检查,其结果值得等待。

**关于升级:**我无法解析出可 @ 的维护者,也不会去猜一个登录名。解析器依据标签匹配领域,而本 PR 没有标签;QWEN_MAINTAINER_HANDLE 未设置;也还没有人类审查可供回退。因此这是一次没有点名的公开 defer —— 需要有人从队列中接手。 若维护者希望 re-run 时点名生效,补上相应的 scope/ 或 category/ 标签即可让解析器完成路由。

— Qwen Code · qwen3.8-max-2026-09-02

Reviewed at d64daba275d5092e96012b7ef0b0ad017a841ebc · re-run with @qwen-code /triage

@qwen-code-review-bot

qwen-code-review-bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

🖼️ web-shell visual preview

Rendered against a mock daemon (no real backend): the PR base vs this PR head e054cd0. Only screenshots that changed are shown (flows below, if any, are head-only) — refreshes on every push.

Screenshots · before / after

ℹ️ No screenshot changed against the PR base — but this PR edits 2 render-shaping files:

  • packages/web-shell/client/components/artifacts/ArtifactPanel.tsx
  • packages/web-shell/client/components/artifacts/WorkspaceFileBrowser.tsx

Either the change has no visual effect (logic, plumbing, a state the scenarios never reach), or no scenario renders this UI — in which case the preview cannot see it, and an empty result is a coverage gap rather than a clean bill of health. To make it visible, add a scenario to packages/web-shell/client/e2e/visuals/screenshots.spec.ts that seeds whatever state the UI is gated on; it then appears here as a head-only (NEW) capture.

Full-resolution recordings (.webm) are attached to the workflow run.

— Qwen Code · web-shell visuals

@qwen-code-review-bot qwen-code-review-bot 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.

[Critical] Blocking finding(s) follow.

Partially reviewed — gaps disclosed. Suggestions are inline.

Unresolved, please confirm:

  • [Critical] Prior triage blocker 'CI is red — this PR's 13 new files-messages i18n keys push the web-shell transcript bundle over build-artifact.test.ts's 1_331_500 ceiling': the PR-causation is code-refuted (vite.lib.config.ts TRANSCRIPT_STUBS maps fi…

Not reviewed: build-and-test — Integration Tests (CLI, No Sandbox) was skipped in CI and Agent 7's local test run never executed (the build phase consumed the whole budget), so the new cli/serve unit suites and the integration suite were not run end-to-end; verifiers ran targeted subsets only (web-shell.files.spec.ts 31 passed, workspace-file-system.test.ts deleteDirectory/createDirectory subsets passed). The build itself is green (all 19 workspaces compile)..

Not explored to full depth (tool budget reached): chunk 8: I could not execute the Playwright specs in web-shell.files.spec.ts (requires a browser install and a built web-shell bundle), so my conclusion that the reduc…; "agent reverse-audit (round 2)": did not execute packages/cli vitest against the two new describes (the worktree has no built workspace deps), so finding 1's mechanism rests on reading fsp.r…; "agent reverse-audit (round 2)": did not open paths.ts:77 ( ENOENT_TOLERATING_INTENTS ) to confirm whether 'list' / 'delete' are ENOENT-tolerating, so the create/delete parent-intent asymme…; "agent reverse-audit (round 2)": did not read the route/SDK consumers of these two methods (chunk 3 / other chunks) beyond what finding S13 already states, so the client-side consequence in fin….

Not reviewed: reverse audit — stopped before round 4 by the review time budget.

中文说明

仅完成部分审查,审查缺口已披露。 建议见行内评论。

未决,请确认:共 1 条(原文未翻译,列表见上方英文部分)。

未审查(原文为英文):build-and-test — Integration Tests (CLI, No Sandbox) was skipped in CI and Agent 7's local test run never executed (the build phase consumed the whole budget), so the new cli/serve unit suites and the integration suite were not run end-to-end; verifiers ran targeted subsets only (web-shell.files.spec.ts 31 passed, workspace-file-system.test.ts deleteDirectory/createDirectory subsets passed). The build itself is green (all 19 workspaces compile)..

未探索到全部深度(达到工具调用预算):chunk 8:I could not execute the Playwright specs in web-shell.files.spec.ts (requires a browser install and a built web-shell bundle), so my conclusion that the reduc…;"agent reverse-audit (round 2)":did not execute packages/cli vitest against the two new describes (the worktree has no built workspace deps), so finding 1's mechanism rests on reading fsp.r…;"agent reverse-audit (round 2)":did not open paths.ts:77 ( ENOENT_TOLERATING_INTENTS ) to confirm whether 'list' / 'delete' are ENOENT-tolerating, so the create/delete parent-intent asymme…;"agent reverse-audit (round 2)":did not read the route/SDK consumers of these two methods (chunk 3 / other chunks) beyond what finding S13 already states, so the client-side consequence in fin…。

未审查:反向审计——评审时间预算不足,未能开始第 4 轮。

— qwen3.8-max via Qwen Code /review (v0.25.1)

Comment thread packages/cli/src/serve/capabilities.ts Resolved
) {
throw new FsError(
'path_outside_workspace',
'Cannot delete a workspace root',

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.

[Suggestion] R1-2: The deleteDirectory workspace-root guard has no test witness — the test named for it never reaches it.

workspace-file-system.test.ts:2705 calls deleteDirectory(h.workspace) (absolute). deleteDirectory resolves path.dirname(input) first, which for the harness root is outside every bound root, so resolveWithinWorkspace throws path_outside_workspace before the guard at :1650-1657 runs. The guard's second clause (workspaces.some(w => w.path === target)) only fires for nested bound roots, which assertNoNestedWorkspaces forbids at construction. Deleting the guard keeps the suite green. (See also the low-confidence Critical in the terminal report: the guard IS load-bearing for the exempt live-conversation runtime root.)

Witness:

probe: deleteDirectory('/…/repo') threw {kind:'path_outside_workspace'} from resolveWithinWorkspace(dirname), NOT the guard
'Cannot delete a workspace root' occurs exactly once repo-wide (workspace-file-system.ts:1655) and in no test
vitest run -t deleteDirectory -> 13 passed

Fix: add a case that actually reaches the guard (e.g. a multi-root harness where one bound root is the target, or a relative input resolving to a bound root) and asserts the 'Cannot delete a workspace root' rejection. The new case must go red when the guard at :1650-1657 is removed.

中文说明

deleteDirectory 的“禁止删除工作区根目录”守卫没有任何测试覆盖。命名对应的测试(:2705)传入绝对根路径,deleteDirectory 先对 path.dirname(input) 做解析,该父目录落在所有绑定根之外,于是 resolveWithinWorkspace 先抛出 path_outside_workspace,守卫根本到不了;第二个分支需要嵌套绑定根,而 assertNoNestedWorkspaces 在构造时就禁止了。删除该守卫测试仍全绿。建议补一个真正触达守卫的用例,并在守卫被删除时变红。

— qwen3.8-max via Qwen Code /review (v0.25.1)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changed / deferred — R1-2

No code change; keeping this thread open. The existing test verifies root deletion is rejected by parent containment before this defensive guard. At this commit, assertNoNestedWorkspaces rejects nested bound roots without a live-conversation exemption. The proposed nested-root witness is therefore unsupported. Root-refusal behavior remains covered; we have not fabricated an invalid factory to exercise an otherwise unreachable branch.

未修改,保留线程。现有测试验证根目录删除先被父目录边界拒绝;当前 assertNoNestedWorkspaces 无 live-conversation 豁免,嵌套根构造不受支持。保留根目录拒绝覆盖,未为触达防御分支伪造非法 factory。

size="icon-sm"
aria-label={t('files.newFile')}
title={t('files.newFile')}
onClick={() => openCreate('file', '')}

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.

[Suggestion] R1-16: A successful create gives no visible confirmation when the tree filter is active and the new name does not match it — the file is created on disk but the tree stays hidden behind "No matches in loaded paths", so the create looks like a no-op.

With a filter like readme active (tree.setSearch, noMatches true, tree host hidden at :877), the toolbar New file button is a sibling of the hidden tree host and stays enabled. Creating notes.txt succeeds; createdRef's tree.add fires the subscription (:277) but getSearchMatchingPaths() is still empty (the new name doesn't match), so noMatches stays true and the node stays hidden. The dialog closes, the tree is still hidden showing "No matches in loaded paths", and the user has no evidence the file exists; a retry hits the daemon's mode:'create' 409 and shows a raw error for a file the UI never displayed.

Witness:

headless FileTreeController probe (fileTreeSearchMode:'hide-non-matches'):
  filter 'zzz' + create 'newfile.txt' -> matchingPaths [] (noMatches still true)
  filter 'app.ts' + create 'unrelated.txt' -> visible rows ['src/app.ts'], 'unrelated.txt' visible=false
  CONTROL create of a matching name -> matchingPaths grows (probe flips)

Fix: on a successful create, reveal the result — call setFilter('') in confirmCreate right after createdRef.current?.(path, kind) (before setCreateTarget(undefined)), or add the created path to the search matches and scroll/select it. The reveal must go through setFilter('') (calling tree.setSearch(null) directly is overwritten by the [filter, version, actions] effect at :355-357).

中文说明

当树过滤器处于激活状态且新文件名不匹配时,创建成功也没有任何可见反馈——文件已写入磁盘,但树仍隐藏在“No matches in loaded paths”之后,看起来像什么都没发生。过滤器(如 readme)激活时(noMatches 为真、树容器在 :877 被隐藏),工具栏的 New file 按钮是隐藏容器的兄弟节点,仍可点击。创建 notes.txt 成功后,createdRef 的 tree.add 触发订阅,但 getSearchMatchingPaths() 仍为空,noMatches 保持为真,节点保持隐藏;对话框关闭后树依旧隐藏,用户无从得知文件已存在,重试还会撞上 409 并对一个从未显示的文件报错。建议在创建成功后调用 setFilter('') 让结果可见。

— qwen3.8-max via Qwen Code /review (v0.25.1)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Not changed / deferred — R1-16

Deferred; keeping this thread open. Preserving the active filter is an explicit acceptance criterion in both design languages. Clearing it on create would change that behavior. A filtered-out successful creation can merit a separate success indicator, but this PR keeps the existing filter semantics and does not force the result into search matches.

延后,保留线程。双语设计明确要求保留当前筛选,创建后清空会改变已定行为。被筛选隐藏的成功创建可另行增加成功提示;本 PR 保留筛选语义,不强制修改搜索匹配。

@ytahdn

ytahdn commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

CI and review follow-up / CI 与 review 后续处理

The confirmed transcript regression is fixed without increasing the existing 1,331,500-unit ceiling: the original PR head measured 1,331,718 UTF-16 code units; the paired main-parent control measured 1,330,293; the fixed build measures 1,330,497. Mutation actions were entering the read-only transcript through its shared workspace hook. They are now excluded at build time; the interactive package retains all three mutation methods and transcript retains directory reads. The earlier attribution to new translation keys was incorrect.

Fixed the inert folder Options trigger without mutation capabilities, successful-delete focus fallback, and stale subtree/cache/preview after successful exclusive same-path folder recreation. Newly created folders now list actual contents on first expansion. Recursive removal's ENOTEMPTY is classified locally as retryable 503 io_error; audit metadata and suspicious-path error kinds match the existing boundary. Parent-only resolution and lexical final-leaf protection are preserved.

Existing review disposition

  • R1-1, R1-3–7: synchronized four protocol/reference inventories; local ENOTEMPTY classification; ignored-directory audit metadata; direct suspicious-leaf preservation coverage; accurate concurrency-test title; aligned error kinds without changing final-leaf resolution.
  • R1-10–13 and R1-17–20: conditional folder Options, late ancestor-list coverage, first-expansion revalidation and same-path recreation cleanup, surviving-row focus, additive capability fixtures, a genuinely absent conflict filename, positive menu controls, and unrelated-preview preservation.
  • R1-2 and R1-8: no supported-production defect established. The resolver already rejects roots before the defensive guard; nested bound roots are forbidden. Production REST factories are single-root and distinct from the multi-root ACP factory. Fabricating either unsupported construction would not verify normal daemon behavior.
  • R1-9, R1-14–16: deferred beyond this PR. The unchanged preview-loading announcement is separate from first Files loading. Unconditional trimming changes legal filenames; treating every 404 as success hides unsupported endpoints; clearing the filter contradicts the agreed preserve-filter behavior. Existing server validation, typed failures and filters are retained.

Verification

Check Result
Root build, typecheck, bundle; changed-file lint/format Passed
CLI filesystem, policy/path, write, qualified-route and SSH regressions 395/395
Artifact panel/workspace ownership 130/130
Build artifacts, including unchanged transcript ceiling and positive controls 34/34
Protocol/reference contracts 18/18
Files Chromium browser suite, simulated daemon 35/35
Real bundled-daemon creation API and disk assertions 23/23
Real bundled-daemon recursive folder deletion API and disk assertions 20/20
Final self-audit and two independent source reviews No unresolved findings

The capability/focus and same-path recreation regressions were observed failing before their respective source fixes and passing afterward. Browser captures in the updated Summary were visually checked and remain UI-only evidence from a simulated daemon. Real daemon checks used isolated newly created temporary workspaces and confirmed selected-secondary ownership, primary/sibling preservation, auth/trust rejection, no overwrite, final-symlink refusal and preservation of nested-link targets. Only harness-owned daemons and data were affected.

Other old CI failures remain distinct: all five Hosted Harness/Hook failures passed when rerun locally (also nine cases including adjacent controls), and those implementations/tests match the main parent. This supports a timing/load hypothesis, not a proven sole root cause. MariaDB failed acquiring a host lock before tests; MySQL session-recovery timed out on the unrelated session lifecycle routes; RocketMQ failed a publish-p95 threshold. No unrelated Java or hosted-runtime source was changed. New-head CI results must be checked separately; local passes do not claim those lanes green.

Limitations: macOS only; no local Java/MySQL/MariaDB/RocketMQ reproduction, Windows/Linux, SSH mutations or injected external parent-directory replacement race. Recursive removal failures may be partial. The installed global CLI 0.22.0 lacks Files and no unmodified latest-main browser baseline was captured.

中文说明

已修复确认的 transcript 回归,保持既有 1,331,500 上限:原 PR head 为 1,331,718 个 UTF-16 单位,配对 main 父提交对照为 1,330,293,修复后为 1,330,497。原因是共享工作区 hook 将变更动作带入只读 transcript,现已在构建时排除;交互产物保留三项变更方法,transcript 仍保留目录读取。此前归因到新增翻译键不准确。

修复了缺少能力时无效的文件夹 Options、成功删除后的焦点回退、同路径独占重建成功后的旧子树/缓存/预览保留。新文件夹首次展开读取实际目录内容。递归删除的 ENOTEMPTY 局部归类为可重试 503 io_error,补齐审计元数据及可疑路径错误类型;保留父目录解析和末级名称保护。

既有评论处理:R1-1、R1-3~7 已补齐四份协议/参考文档、错误分类、忽略目录审计、可疑末级路径保护测试、准确的并发测试标题及错误类型。R1-10~13、R1-17~20 已补齐条件菜单、迟到祖先列表、首次展开与同路径重建清理、剩余行焦点、追加式能力 fixture、真正不存在的冲突名称、菜单正向对照及无关预览保留。

R1-2、R1-8 未确认支持场景中的缺陷:resolver 已提前拒绝根路径,嵌套根不受支持;生产 REST factory 为单根,与多根 ACP factory 分离,不为覆盖而伪造不支持的构造。R1-9、R1-14~16 延后:未改动的 preview 加载播报与首次 Files 加载不同;无条件 trim 改变合法名称,全体 404 当成功会掩盖缺失接口,清空筛选与保留筛选的约定冲突。保留现有服务端校验、类型化错误及筛选行为。

根目录 build/typecheck/bundle 和变更文件 lint/格式通过;CLI 395/395、artifact 面板/所有权 130/130、构建产物 34/34、协议文档契约 18/18、模拟 daemon 的 Files Chromium 35/35、真实 daemon 创建 23/23、递归文件夹删除 20/20 通过。最终自审及两轮独立源码复核无遗留发现。能力/焦点与同路径重建回归均先确认失败,再验证修复通过。

Summary 截图已重新目视检查,明确为模拟 daemon 的 UI 证据。真实 daemon 使用新建隔离临时工作区,验证次工作区所有权、主/兄弟条目保留、鉴权/信任拒绝、不覆盖、末级链接拒绝及嵌套链接外部目标保留。只操作测试自建 daemon 与数据。

其他旧 CI 失败单独保留结论:五个 Hosted Harness/Hook 失败用例本地重跑通过,另含相邻对照的九项也通过,相关实现与测试和 main 父提交一致;支持时序/负载假设,但未证明唯一根因。MariaDB 在测试前等待主机锁失败,MySQL 在无关会话生命周期路由恢复超时,RocketMQ 发布 p95 超阈值。未修改无关 Java/Hosted 源码,新 head 的 CI 需要单独检查,不能用本地通过宣称这些作业变绿。

局限:仅 macOS;未本地复现 Java/MySQL/MariaDB/RocketMQ,未执行 Windows/Linux、SSH 变更和外部并发替换父目录。递归删除失败可能已部分完成。全局 CLI 0.22.0 没有 Files,未捕获未修改最新 main 浏览器基线。

@ytahdn

ytahdn commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Lint freshness follow-up / lint 门禁同步

The latest failure at b19dd2 was the lint-gate freshness check, before ESLint: main changed the CI gate at70407feeb97e, which the feature branch had not incorporated. Merged main6d61d2e78a without conflicts and pushed e788056620. No lint rule or check was weakened.

Reproduced the old stale verdict, then verified the exported checker using gh-backed responses for all8 gate files: zero stale entries at the new head, against main snapshot1fb9c8313e. Full local lint:ci, experimental Prettier check, build/typecheck/bundle passed; freshness unit tests9/9, related workflow suites136/136, core extension suites220/220, rebuilt-artifact tests34/34 and the exact five former Hosted failures5/5 passed. The initial helper invocation used the wrong runner for six Vitest files; it was replaced with the repository's dedicated script-test runner and is not counted as a product failure or green evidence.

Web Shell, TypeScript SDK, filesystem and file-write route sources are byte-identical to the previously verified fix, so existing UI screenshots and the 35-case browser/43-case real-daemon evidence remain applicable. All20 original review threads now have individual bilingual replies:14 fixed threads are resolved; R1-2/8/9/14/15/16 remain open with specific reasons.

The new remote lint job has now passed the originally failing “Check lint gate freshness” step. The remaining lint stages and CI suite are still running; full remote success is not yet claimed.

中文说明

b19dd2 的最新失败发生在 ESLint 之前的 lint 门禁新鲜度检查:main 的70407feeb97e 更新了 CI 门禁,而功能分支尚未合入。现已无冲突合入 main6d61d2e78a,推送 e788056;未削弱任何 lint 规则或检查。

先复现旧 head 的过期判定,再用 gh 返回的真实数据验证新 head 的全部8项门禁文件:对 main 快照1fb9c8313e,过期项为0。完整本地 lint:ci、实验版 Prettier 检查、build/typecheck/bundle 通过;门禁单测9/9、相关 workflow 套件136/136、core 扩展套件220/220、重建产物测试34/34、此前五个 Hosted 失败用例5/5 通过。首次辅助测试为六个 Vitest 文件用了错误 runner,已改用仓库专用 script-test runner;该次不作为产品失败或通过证据。

Web Shell、TypeScript SDK、文件系统及文件写入路由源码与此前验证的修复完全一致,现有 UI 截图及35项浏览器、43项真实 daemon 证据仍适用。原有20条 review 线程均已逐条双语回复:14条修复已关闭;R1-2/8/9/14/15/16 保持打开,并各自说明原因。

新一轮远端 lint 已通过原先失败的“Check lint gate freshness”步骤。其余 lint 阶段及 CI 仍在运行,尚未宣称全部远端检查通过。

@ytahdn

ytahdn commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator Author

Merge conflict resolution / 合并冲突处理

Merged main's file-tree upload change (#14145) with this PR's creation and confirmed folder deletion, resolving five Web Shell content conflicts. Preserved both parents' tests, capability/owner checks, upload progress/errors and collision paths, creation/deletion dialogs, focus recovery, stale-list protection and exclusive-recreation cleanup. Uploaded files join the confirmed-entry overlay without automatically expanding their folder. All four mutation actions stay outside the read-only transcript entry and the size ceiling is unchanged.

The combined workflow now waits for file-tree uploads before enabling folder-deletion confirmation and rejects new drops while deletion is pending. This coordinates this pane's operations without claiming cross-client or external-filesystem serialization. Synchronized both design languages and refreshed the Summary's five screenshots on the separate fork assets branch.

Validation after integration Result
Root build, typecheck and bundle Passed
Full lint:ci and experimental Prettier check Passed
Artifact panel/workspace authority 138/138
File-browser upload unit cases 3/3
Build artifacts and unchanged transcript ceiling 34/34
CLI filesystem, policy/path, write, qualified-route and SSH regressions 395/395
Complete Files Chromium suite 43/43, 2.9 minutes
Focused new-folder/upload/delete case 1/1
Two self-audit passes and independent integration review No unresolved findings

Browser tests use a simulated daemon. Five final captures were visually checked; they establish UI states rather than actual disk or Git operations. The first focused run exposed a test-only accessible-name mismatch after Delete changed to Deleting…; the locator was corrected and both the focused and complete suites passed. Backend routes/SDK implementation did not change during resolution, so the previous real-daemon disk evidence was retained rather than rerun. Windows/Linux, actual SSH upload and Java container suites were not executed locally in this merge verification. The 5198 browser fixture was stopped; existing user services were preserved. New-head CI is checked separately.

中文说明

将 main 的文件树上传(#14145)与本 PR 的新建、文件夹删除确认合并,解决五处 Web Shell 内容冲突。保留双方测试、能力/所有权检查、上传进度/错误及冲突名称、新建/删除弹窗、焦点恢复、迟到列表保护和同路径重建清理。上传成功条目加入已确认集合,不自动展开文件夹。四项变更动作均排除在只读 transcript 入口外,体积上限保持不变。

组合流程在文件树上传完成后才启用文件夹删除确认,删除处理中拒绝新拖放。这只协调当前面板内的操作,不宣称串行化其他客户端或外部文件系统变更。双语设计已同步,Summary 五张截图已更新到 fork 独立素材分支。

集成后根目录 build/typecheck/bundle、完整 lint:ci 和实验版 Prettier 检查通过;artifact 面板/所有权138/138、文件树上传单测3/3、构建产物34/34、CLI 文件系统/策略/路径/写入/限定路由/SSH 回归395/395、Files Chromium43/43(2.9分钟)、新建文件夹/上传/删除组合用例1/1通过。两遍自审及独立集成复查无遗留问题。

浏览器使用模拟 daemon,五张最终截图均已目视检查,只证明 UI 状态,不证明实际磁盘或 Git 操作。首次组合用例暴露的是测试名称匹配问题:Delete 进入处理中改为 Deleting…;定位器修正后,单用例及整套测试均通过。冲突处理未改动后端路由/SDK 实现,因此保留此前真实 daemon 磁盘证据,未重复执行。本轮未在本地执行 Windows/Linux、真实 SSH 上传及 Java 容器套件。5198 测试服务已停止,用户现有服务保留。新 head 的 CI 状态另行核对。

@chiga0 chiga0 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.

No blocking findings. Approved.

What was checked

Tier: Deep — permanent filesystem mutations (create/delete), capability gating, trust gates, symlink escape prevention, TOCTOU guards, cross-file contract coverage.

Capability gating (cross-file)

  • Client gates each action independently: canCreateFile ← workspace_file_write; canCreateDirectory ← workspace_directory_create; canDeleteDirectory ← workspace_directory_delete. All three plus workspace_qualified_rest_core and !ssh must hold.
  • Both new capabilities are in SERVE_CAPABILITY_REGISTRY and in the protocol doc capability list. The client correctly prevents exposing these actions to older daemons that omit them.
  • import.meta.env.MODE !== 'transcript' guard keeps all mutation actions out of the read-only transcript bundle — confirmed by the new build-artifact.test.ts assertion.

Trust gate and path validation

  • deleteDirectory calls assertTrustedForIntent(trusted, 'delete') at entry and again inside the lock — twice. ✓
  • createDirectory calls assertTrustedForIntent(trusted, 'write') at entry and again inside the lock. ✓
  • Both methods check null bytes, trailing separators, and ./.. basename. hasSuspiciousPathPattern is also checked in both fs methods.
  • Symlink escape: deleteDirectory verifies realpath(parent) === parent and realpath(target) === target before calling rm. createDirectory verifies realpath(parent) === parent after lstat confirms the parent is a directory.
  • Workspace root guard in deleteDirectory prevents workspaces.some(w => w.path === target). ✓

TOCTOU and concurrency

  • Both methods use pathLocks.runExclusive(target, ...) — exclusive locks prevent interleaved operations on the same path.
  • generationGuard.assertOpen() is called three times in each locked section.
  • deleteDirectory catches ENOTEMPTY explicitly and surfaces it as io_error with a retry hint. The UI keeps the dialog open for retry. ✓

Client-side state management

  • deletedPaths set prevents late listings from resurrecting deleted entries: filter in load checks !deletedPaths.has(…) for each listing entry. ✓
  • createdRef.current does NOT seed a cache entry for the newly created directory — the bot's R1-12 is refuted. The new dir has no cache entry, so the first expansion triggers a real load. ✓
  • Stale-request guard: loads.set(path, request = {}) with identity comparison; deletedRef clears loads for deleted paths, marking in-flight loads as stale. ✓
  • Same-path recreation: createdRef first calls deletedRef to clear old state, then re-adds the entry. ✓
  • Upload-during-delete coordination: deleting flag blocks new drops and sets dropEffect: 'none'. isBusy` (from upload) blocks the Delete Confirm button. ✓

Cross-check against bot findings

  • R1-8 (workspaceRelative after async): Refuted. workspaceRelative(req, deleted) is called synchronously after await — the Express req object persists through the request lifetime. Normal pattern.
  • R1-12 (createdRef seeds cache): Refuted. createdRef updates only the parent's cache entry, not the new directory's. New dir has no cache entry; first expansion loads it.
  • R1-17 (openFiles replaces features): Refuted. The fixture uses scenario.capabilities.features.push(...) — additive, not a replacement.
  • R1-14 (untrimmed name in path): Confirmed as minor UX. createName.trim() is checked for emptiness, but createName (untrimmed) is used in the path. A name like " hello " passes validation and creates a file with leading/trailing spaces. Non-blocking; server-side validation is correct.
  • R1-15 (404 on delete shown as error): Confirmed as minor UX. If the target was already removed externally, the route returns 404 (path_not_found) and confirmDelete's catch shows the error instead of treating it as success. Non-blocking; tree self-corrects on next refresh.
  • R1-3 (ENOTEMPTY during concurrent write): Handled — caught and re-thrown as io_error with retry hint. Documented in the protocol doc. Acceptable.

Bot's unresolved triage blocker

The bot's earlier triage concern about the transcript bundle ceiling is refuted by the code: useArtifactWorkspaceTarget gates all three mutation actions on import.meta.env.MODE !== 'transcript', and the new build-artifact.test.ts test confirms these methods are absent from the transcript bundle while present in the main package bundle.

Not checked

  • Windows/Linux filesystem behavior (SSH workspace path handling, ENOTEMPTY behavior)
  • Browser E2E Playwright run (requires browser install + built bundle)

Reviewed with AI assistance.

@yiliang114 yiliang114 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. Reviewed at head b878361f — no blocking findings. The write/delete surface is gated correctly end to end:

  • The fs policy classifies delete explicitly: Intent gains the variant and assertTrustedForIntent throws untrusted_workspace for it on untrusted workspaces — the exhaustive switch means no silent default.
  • deleteDirectory is fail-closed on every edge that matters: refuses empty/null/trailing-separator/./.. paths and suspicious patterns, refuses a workspace root, takes an exclusive path lock, realpath-checks the parent and the target (symlink → symlink_escape), and classifies ENOTEMPTY as a retryable io_error — a directory whose contents changed mid-removal is reported for retry, never silently deleting siblings. The audit entry is recorded.
  • createDirectory mirrors it: same parse validation, parent-resolved-within-workspace, exclusive lock, existing-target handling (symlink → symlink_escape, otherwise file_already_exists), parent realpath check, mkdir 0o755, post-create lstat verify, audit recorded.
  • The routes keep the boundaries: both /workspaces/:workspace/directory/{create,delete} resolve the client identity and refuse SSH-backed workspaces with 422; the mode === 'create' write path resolves only the parent so no-clobber checks see the requested leaf.
  • The new capabilities (workspace_directory_create / workspace_directory_delete) are registered, and the UI uses a confirmation dialog for deletion.

chiga0 already approved this exact head; CI on it shows 0 failures so far (several lanes still in flight at review time).

中文说明

LGTM。在 head b878361f 完成评审:无阻塞项。写/删面的门禁端到端正确——fs policy 给 delete 单列 intent 且在未信任 workspace 上 fail-closed;deleteDirectory 在每个承重边界都不放行(拒绝空/null/尾分隔符/../可疑模式、拒绝 workspace 根、独占路径锁、parent 与 target 各做一次 realpath 核对、symlink 一律 symlink_escape、ENOTEMPTY 归类为可重试的 io_error 而绝不误删兄弟、审计在案);createDirectory 同样一套守卫。路由层保留边界(client 身份解析、sshWorkspace 一律 422)。新 capability 已注册,UI 用确认对话框做删除。chiga0 已在该 head APPROVED;CI 暂无红。

@yiliang114 yiliang114 added type/feature-request New feature or enhancement request scope/web-shell labels Oct 16, 2026

@chiga0 chiga0 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.

Review — head b878361 (Deep tier)

No blockers. Two Major findings about the SSH test contract (inline). Approving.


Findings (2 × Major)

F1 / F2 — SSH directory operations: implementation returns 422 + parse_error, tests expect 501 + ssh_workspace_operation_unsupported

Both handlePostDirectoryDelete and handlePostDirectoryCreate handle SSH workspaces by throwing FsError("parse_error", ..., {status: 422}). sendFsError in workspace-file-read.ts serialises this to res.status(422).json({ errorKind: "parse_error", ... }) — the field is errorKind, not code.

The new tests in workspace-qualified-rest.test.ts (kind === "ssh" branches) assert:

expect(result.status).toBe(501);
expect(result.body.code).toBe("ssh_workspace_operation_unsupported");

ssh_workspace_operation_unsupported is absent from FsErrorKind, errors.ts, and every implementation file. FsErrorStatus has no 501.

Fix: introduce a dedicated FsErrorKind value ("ssh_workspace_operation_unsupported"), add 501 to FsErrorStatus, and throw it for the SSH branches — matching the test contract.


Checked dimensions

  • Auth gate, resolveWithinWorkspace, pathLocks.runExclusive, TOCTOU triple-realpath — correct.
  • Workspace root guard — present.
  • Symlink escape detection — present.
  • assertTrustedForIntent("delete"/"write") in policy.ts — correctly updated.
  • hasSuspiciousPathPattern in deleteDirectory — present.
  • Capability registry (workspace_directory_create/delete) — correct.
  • Client-side localOwner gate (!ssh && workspace_qualified_rest_core) — correctly excludes SSH.
  • SDK surface (DaemonClient.createWorkspaceDirectory/deleteWorkspaceDirectory) — correct.
  • Cross-check: two human approvers (yiliang114, prior chiga0 @ e054cd0) did not flag the SSH mismatch.

? undefined
: factory.forRequest({ originatorClientId, route: ROUTE });
if (!fs?.deleteDirectory) {
throw new FsError('parse_error', 'Directory deletion is not supported', {

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.

F1 (Major) — SSH delete: throws FsError("parse_error", ..., {status: 422}). sendFsError serialises to { errorKind: "parse_error" } with HTTP 422. Tests at workspace-qualified-rest.test.ts expect result.status === 501 and result.body.code === "ssh_workspace_operation_unsupported" — both fail. ssh_workspace_operation_unsupported does not exist in FsErrorKind or FsErrorStatus. Suggested fix: add "ssh_workspace_operation_unsupported" to FsErrorKind, add 501 to FsErrorStatus, and throw it here instead of parse_error.

}
const factory = context.runtime.routeFileSystemFactory;
if (factory.sshWorkspace) {
throw new FsError('parse_error', 'Directory creation is not supported', {

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.

F2 (Major) — SSH create: same contract mismatch as the delete handler. This branch throws FsError("parse_error", ..., {status: 422}), but the SSH test branch asserts 501 + code: "ssh_workspace_operation_unsupported". The fix is the same: a dedicated error kind and status for unsupported SSH workspace operations.

@ytahdn
ytahdn enabled auto-merge (squash) October 16, 2026 02:41
@ytahdn
ytahdn merged commit 17d5f77 into QwenLM:main Oct 16, 2026
95 of 96 checks passed
@qwen-code-review-bot

Copy link
Copy Markdown
Collaborator

Released in v0.25.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/web-shell type/feature-request New feature or enhancement request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants