Skip to content

feat(artifacts): add permanent deletion and file pane controls - #169

Merged
bryantderosier merged 5 commits into
crews/01-artifacts-pr109-findingsfrom
codex/artifacts-recycle-bin
Sep 21, 2026
Merged

bryantderosier merged 5 commits into
crews/01-artifacts-pr109-findingsfrom
codex/artifacts-recycle-bin

Conversation

@tyler-barton-horizon

@tyler-barton-horizon tyler-barton-horizon commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

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.

Before After
Recovery confirmation Permanent deletion confirmation

Implemented with Codex.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XL 500-999 effective changed lines (test files excluded in mixed PRs). labels Sep 16, 2026

@bryantderosier bryantderosier 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 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

  1. trash will not work from the packaged server on macOS or Windows (apps/server/package.json). trash@10 shells out to lib/macos-trash and lib/windows-trash.exe, located with new URL(name, import.meta.url). Our server bundle inlines every dependency that is not in CLI_RUNTIME_EXTERNAL_PREFIXES, and trash is not listed. I built this branch's server bundle with vp pack: dist/macos-DOmjZT4Q.mjs and dist/windows-DDNmG0Rj.mjs still contain new URL("macos-trash", import.meta.url) and new URL("windows-trash.exe", import.meta.url), and neither binary is anywhere under dist/, so at runtime the path resolves beside the emitted chunk where nothing exists. The macOS fallback in trash only 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: add trash and its runtime closure to CLI_RUNTIME_EXTERNAL_PREFIXES so it is staged like the other native packages, and verify from a built dist/bin.mjs. The hasNativeLoaderMarkers check in the desktop build only looks for binding.gyp/prebuilds, so it will not catch this on its own.

  2. Trash completion writes stale state (ArtifactsPage.tsx:280). The success path calls artifactSelectionAfterTrash(entries, path) with the entries captured when the click happened and then setEntries(...) 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.

  3. 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 is min-w-80 max-w-[28rem] (320px to 448px). Drag the pane wide in the standalone route, and the embedded grid's minmax(0,1fr) column collapses with the resize handle off-screen. Clamp against the container, or give the embedded layout its own smaller max.

  4. Trashing a handoff leaves its written status behind (ArtifactHttp.ts:192). agentHandoffObserver only re-checks at run finalization, so a handoff record stays written and the chip links to a file that is gone. Either reconcile the record when a handoffs/ path is trashed or document that the badge reflects the last finalization.

  5. 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 on realPath, but the trash call takes requestedPath, 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 with lstat on the final component.
  • ArtifactsPage.tsx:287: a failed trash sets contentState("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 creates src/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 RightPanelResizeHandle has 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.

Comment thread apps/server/package.json Resolved
Comment thread packages/contracts/src/artifacts.ts Resolved
Comment thread FORK.md Resolved
@tyler-barton-horizon
tyler-barton-horizon changed the base branch from j5/main to crews/01-artifacts-pr109-findings September 17, 2026 15:15
@github-actions github-actions Bot added size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). and removed size:XL 500-999 effective changed lines (test files excluded in mixed PRs). labels Sep 17, 2026
@tyler-barton-horizon

Copy link
Copy Markdown
Collaborator Author

Addressed the requested changes in 0ca0ad3f3c:

  1. Kept trash and its complete runtime dependency closure external; verified the built dist/bin.mjs resolves both platform helper binaries.
  2. Removed captured-entry writes after deletion. Completion now refreshes the current project through the cancellable list effect.
  3. Added a separate 192px maximum for the embedded file pane.
  4. Added best-effort handoff reconciliation to missing plus the existing refresh signal.
  5. Updated FORK.md with the mutation, packaging boundary, and reconciliation behavior.

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.

@github-actions github-actions Bot added size:XL 500-999 effective changed lines (test files excluded in mixed PRs). and removed size:XXL 1,000+ effective changed lines (test files excluded in mixed PRs). labels Sep 18, 2026

@Jacksondr5 Jacksondr5 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

  1. 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 in scripts/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 a vi.mock of trash in 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.

  2. Reconcile on the canonical path (ArtifactHttp.ts:197). The workspace normalizes separators and path.resolve collapses ./ segments before the delete, but the reconciler receives the raw request path and matches it exactly in SQL. A request using ./handoffs/x.md or backslashes deletes the file and leaves the handoff marked written. The UI always sends the listed path, so this is low in practice, but it is a one-line fix.

  3. 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 as written between the list and the upsert loses its runId and status. A single UPDATE ... 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 reference artifacts/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 realPath validation 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.

Comment thread apps/server/package.json Resolved
Comment thread scripts/lib/cli-external-packages.ts Resolved
Comment thread docs/user/artifacts.md Resolved
@github-actions github-actions Bot added size:L 100-499 effective changed lines (test files excluded in mixed PRs). and removed size:XL 500-999 effective changed lines (test files excluded in mixed PRs). labels Sep 21, 2026
@bryantderosier bryantderosier changed the title feat(artifacts): add recoverable deletion and resizing feat(artifacts): add permanent deletion and file pane controls Sep 21, 2026
@bryantderosier
bryantderosier merged this pull request into crews/01-artifacts-pr109-findings Sep 21, 2026
19 checks passed
@bryantderosier
bryantderosier deleted the codex/artifacts-recycle-bin branch September 21, 2026 14:34
bryantderosier added a commit that referenced this pull request Sep 21, 2026
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants