Repository navigation
feat(artifacts): add permanent deletion and file pane controls - #169
bryantderosier merged 5 commits into
Conversation
bryantderosier
left a comment
There was a problem hiding this comment.
Review summary
I reviewed this at ed708fd against j5/main. The server boundary is in good shape: the trash route sits behind the operate scope, it goes through the existing J5 authenticated aggregate, path containment mirrors read, and failures never leak filesystem paths. Moving the artifact watch RPC out of upstream's WS_METHODS into a merged J5 group is also a real fork-hygiene improvement. The findings below are what I want fixed before this lands.
Should fix
-
trashwill not work from the packaged server on macOS or Windows (apps/server/package.json).trash@10shells out tolib/macos-trashandlib/windows-trash.exe, located withnew URL(name, import.meta.url). Our server bundle inlines every dependency that is not inCLI_RUNTIME_EXTERNAL_PREFIXES, andtrashis not listed. I built this branch's server bundle withvp pack:dist/macos-DOmjZT4Q.mjsanddist/windows-DDNmG0Rj.mjsstill containnew URL("macos-trash", import.meta.url)andnew URL("windows-trash.exe", import.meta.url), and neither binary is anywhere underdist/, so at runtime the path resolves beside the emitted chunk where nothing exists. The macOS fallback intrashonly fires on a specific "don't have permission" message, so ENOENT surfaces as "The artifact could not be moved to the Trash." Linux is fine because that path is pure JS. "Production server bundle passed" in the description means it built, not that it can trash a file. Fix: addtrashand its runtime closure toCLI_RUNTIME_EXTERNAL_PREFIXESso it is staged like the other native packages, and verify from a builtdist/bin.mjs. ThehasNativeLoaderMarkerscheck in the desktop build only looks forbinding.gyp/prebuilds, so it will not catch this on its own. -
Trash completion writes stale state (
ArtifactsPage.tsx:280). The success path callsartifactSelectionAfterTrash(entries, path)with theentriescaptured when the click happened and thensetEntries(...)unconditionally. Confirm a delete in project A, click project B while the request is in flight, and A's remaining files replace B's list once the response lands. A watcher refresh that arrives mid-request is overwritten the same way. Use a functional update against current state and drop the result if the project changed, or skip the local mutation and let the change stream refresh the list. -
The embedded file pane can push the preview to zero width (
ArtifactsPage.tsx:338). The persisted pane width is clamped to 480px, but the right-panel sheet ismin-w-80 max-w-[28rem](320px to 448px). Drag the pane wide in the standalone route, and the embedded grid'sminmax(0,1fr)column collapses with the resize handle off-screen. Clamp against the container, or give the embedded layout its own smaller max. -
Trashing a handoff leaves its
writtenstatus behind (ArtifactHttp.ts:192).agentHandoffObserveronly re-checks at run finalization, so a handoff record stayswrittenand the chip links to a file that is gone. Either reconcile the record when ahandoffs/path is trashed or document that the badge reflects the last finalization. -
FORK.md is now inaccurate (
FORK.md:100). Case 33 still describes the J5 aggregate as appending "artifact read routes". This PR adds an operate-scoped mutation and a new runtime dependency with platform binaries, and neither is recorded.
Nits
ArtifactWorkspace.ts:554: validation is onrealPath, but the trash call takesrequestedPath, so a local writer swapping an ancestor for a symlink between the two can redirect the move. Same-host, needs write access to the state dir, so low value; noting it because the comment explains the choice and the window could be closed withlstaton the final component.ArtifactsPage.tsx:287: a failed trash setscontentState("error"), which replaces the still-present document with the error text until the next refresh. Show the error without hiding the preview.packages/contracts/src/artifacts.ts:70: the new trash request/response schemas and path constant were added to the old contracts file while this PR createssrc/j5/artifacts.ts. Putting them in the J5 module keeps the upstream-shaped file from growing.ArtifactsPage.test.ts:19: the replacement test still asserts source strings. It passes whether or not the fetch actually waits for the connection.- The resize handle has no keyboard path. Upstream's
RightPanelResizeHandlehas the same limitation, so I am not blocking on it.
Scope
The first commit, 931b9ba, is the PR 109 follow-up: transport, connection lifetime, preview refresh, and moving the watcher RPC. None of that is deletion or resizing. My rule is one concern per PR, and I would rather land those fixes on their own so they are not tied to the trash rollback decision. If you want to keep them here, at least split the description so it is clear what is foundation and what is feature.
Recommendation: request changes for 1 through 5, then I am happy to re-review.
ed708fd to
0ca0ad3
Compare
|
Addressed the requested changes in
Also moved the trash contracts into the J5 module, preserved the document preview on deletion failure, rejected Trash operations through symlinks, and replaced the connection source-string assertion with tested fetch-gating logic. PR #169 is now stacked on #145, so the earlier PR #109 follow-up is no longer part of this feature diff. Validation: 42 focused tests, server/web/contracts typechecks, and the production bundle runtime-helper check all pass. |
Jacksondr5
left a comment
There was a problem hiding this comment.
Review summary
Reviewed at 3fdc09b0 against the stacked base crews/01-artifacts-pr109-findings. Every finding from the previous round is addressed: the trash route sits behind the operate scope, the refresh path is race-safe, the embedded pane has its own bound, errors no longer hide the preview, the symlink case is rejected, and the contract schemas and FORK.md case 33 are in the right places. Thank you for the thorough follow-up.
The one change I want before this lands is the deletion mechanism itself. Everything in the delete path that matters for safety (containment, symlink rejection, file-type check, confirm dialog, handoff reconciliation) is needed for a hard delete too. Only one line does the Trash move, and that line is what drags in everything below. Jackson has said a hard delete behind the confirm is fine; the confirm is the UX answer, not a recovery feature.
Should fix
-
Replace the Trash move with a hard delete (
ArtifactWorkspace.ts:560). What exists only because this is a Trash move: the[email protected]dependency with ~44 transitive packages and 224 lockfile lines; a 726 KB macOS binary and a Windows exe shipped in the server package; a 46-entry closure list inscripts/lib/cli-external-packages.ts, an upstream-owned file the fork had never touched, which the closure test will force us to edit on every transitive bump; platform failure modes (WSL rejects without PowerShell interop, macOS falls back only on one permission message); and avi.mockoftrashin the workspace test. The recovery story is also mostly theoretical for J5: servers are commonly headless or reached over T3 Connect, so "recover it from the host account's Trash" means SSHing in and finding a UUID-named file under~/.local/share/Trash/files. The package's own readme says the Linux implementation is "not very good and not maintained" and may be removed. Swap the call for a non-recursive filesystem remove, drop the dependency, lockfile growth, and packaging list, and rename route, service method, UI copy, user docs, and FORK.md case 33 from Trash to Delete with explicit permanent-deletion wording in the confirm. -
Reconcile on the canonical path (
ArtifactHttp.ts:197). The workspace normalizes separators andpath.resolvecollapses./segments before the delete, but the reconciler receives the raw request path and matches it exactly in SQL. A request using./handoffs/x.mdor backslashes deletes the file and leaves the handoff markedwritten. The UI always sends the listed path, so this is low in practice, but it is a one-line fix. -
Collapse the reconciler into one conditional UPDATE (
agentHandoffArtifactTrash.ts:37). Read-then-upsert can overwrite a newer row: a run finalization that records the recreated artifact aswrittenbetween the list and the upsert loses itsrunIdand status. A singleUPDATE ... SET status='missing', checked_at=? WHERE project_id=? AND path=? AND status != 'missing'closes the window and is less code than the list, filter, and per-row upsert.
Nits
ArtifactsPage.tsx:289: a failure from a delete started in project A lands in the banner after the user has switched to project B. Drop the error if the selection changed while the request was in flight, the same way the list effect drops superseded reads.ArtifactsPage.tsx:465: copy-path yields the artifact-relative path (plan.md) while chat chips referenceartifacts/plan.md. Worth deciding which form users paste back into chat. Also, copy-path and the filename toolbar are outside "deletion and resizing"; at least call them out in the description.- The ancestor-swap window between
realPathvalidation and the move still exists. I am not asking for a change: it needs write access to the server's state directory, at which point the attacker can already delete the file directly, and a hard delete does not change that.
Once the Trash mechanism is gone, the fork-discipline footprint of this PR is zero upstream files outside FORK.md, which is where I would like it to be.
Reviewed by Claude Fable 5.1 in T3 Code, with a parallel GPT-6-Astra review in the Codex harness.
* fix(artifacts): address the PR 109 review findings The artifact change subscription moves out of upstream's WebSocket method table into a J5 RPC group merged beside the persona group, with its scopes and handlers spread from J5-owned modules. The artifact HTTP route reports not-found through a typed reason instead of matching an error string, the Artifacts page holds its own environment connection and re-reads a preview only when that file changed or the person asks, and listing sorts before it truncates while keeping the size guard that fails fast on an absurd directory. Co-Authored-By: Claude Fable 5.1 <[email protected]> * feat(artifacts): add permanent deletion and file pane controls (#169) * feat(artifacts): add file management controls * fix(artifacts): move actions into document header * fix(artifacts): address deletion review findings * test(artifacts): exercise connection-gated loading * fix(artifacts): delete files permanently and preserve current state --------- Co-authored-by: Bryant Derosier <[email protected]> --------- Co-authored-by: Claude Fable 5.1 <[email protected]> Co-authored-by: Tyler Barton <[email protected]>
Artifacts now support confirmed permanent deletion, a filename/copy-path toolbar, and persisted file-pane resizing. This PR is stacked on #145.
The operate-scoped endpoint validates containment, rejects links and directories, and removes only the selected file. It returns the canonical artifact path for an atomic handoff-status update. Late failures from another selection are ignored, errors preserve the preview, and copied paths use
artifacts/for chat chips. Embedded pane width is capped separately. No Trash dependency or platform helper is needed.Validation: 32 focused artifact, handoff, client, and packaging tests passed; server and web typechecks passed. A disposable browser run verified the permanent-delete confirmation and actual file removal/list refresh. Targeted lint has existing hook warnings only.
Implemented with Codex.