Skip to content

Add artifact folders and web artifact sorting#40

Merged
jfox85 merged 3 commits into
mainfrom
jf-artifact-folders-web-sorting
May 10, 2026
Merged

Add artifact folders and web artifact sorting#40
jfox85 merged 3 commits into
mainfrom
jf-artifact-folders-web-sorting

Conversation

@jfox85

@jfox85 jfox85 commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • add optional artifact folder metadata and store foldered files under .artifacts/<folder>/...
  • add CLI folder support for artifact add and artifact list, including grouped tree output
  • group artifacts by folder in DevX Web and show relative created times with sort controls
  • add docs and test coverage for folder validation, nested paths, list filtering, and URL handling

Testing

  • go vet ./...
  • go test -race ./...
  • cd web/app && npm run build

Summary by CodeRabbit

  • New Features
    • Organize artifacts into folders via a new --folder option when adding
    • Tree view to display artifacts grouped by folder and folder-based filtering/searching
    • Web UI: grouped folder view, improved artifact search including folder matches
  • Documentation
    • Comprehensive "Artifacts" docs describing storage, folder rules, listing, URLs, and examples
  • Tests
    • Added tests for folder validation, manifest compatibility, nested folders, collision handling, and serving nested artifact URLs

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 360d58e7-2685-46fa-92bf-a06cade4bb44

📥 Commits

Reviewing files that changed from the base of the PR and between 8df0767 and 9203d47.

📒 Files selected for processing (3)
  • artifact/manifest.go
  • artifact/manifest_test.go
  • cmd/artifact_add.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • cmd/artifact_add.go
  • artifact/manifest.go

📝 Walkthrough

Walkthrough

This PR adds folder-based organization for session artifacts: manifest and validation changes, Add/Filter support for a Folder field, CLI flags and tree output, web API upload/list folder passthrough, UI grouping/sorting/search updates, tests, and documentation.

Changes

Artifact Folder Organization

Layer / File(s) Summary
Data Model and Folder Validation
artifact/manifest.go
Artifact adds optional folder JSON field; NormalizeFolderPath() and hasWindowsVolumeName() validate and normalize folder inputs; manifest validation ensures artifact files are contained under their folder.
Manifest and Path Safety Tests
artifact/manifest_test.go
Tests for NormalizeFolderPath rejection/normalization, backward-compatible LoadManifest when folder is missing, and canonicalization on save/load.
Artifact Add with Folder Support
artifact/add.go
AddOptions gains Folder; addLocked normalizes folder, joins it with destination relative path, and records Folder on created Artifact.
Add Tests (nested, collisions, unsafe)
artifact/manifest_test.go
Tests verify nested folder creation on disk, collision suffixing for duplicate names, and rejection of unsafe/traversal folder inputs.
Artifact Filter with Folder Support
artifact/filter.go
FilterOptions gains Folder; Filter normalizes folder and excludes artifacts whose Folder doesn't match; search includes folder field.
CLI Add Command with Folder Flag
cmd/artifact_add.go
Adds --folder flag, wires flag into artifactpkg.AddOptions, and updates help text.
CLI List Command with Folder Filtering and Tree Output
cmd/artifact_list.go
Adds --folder and --tree; normalizes --folder, filters by Folder, and printArtifactTree groups artifacts by folder with "Unfiled" fallback.
CLI Integration Tests
cmd/artifact_test.go
TestArtifactAddListFolderAndTree creates artifacts across folders, asserts folder-filtered JSON, verifies nested artifact URL, and checks tree output grouping.
Web API Artifact Handler Integration
web/artifacts_api.go, web/artifacts_api_test.go
handleListArtifacts reads folder query param; handleUploadArtifact reads folder form field and passes it to artifactpkg.Add; test ensures nested artifact URLs serve correctly.
Web UI Search Integration
web/app/src/lib/Terminal.svelte
Artifact search overlay now includes artifact folder in searchable text.
Web UI Artifact Display and Grouping
web/app/src/lib/artifacts/ArtifactPane.svelte
Adds sorting (newest/oldest/title), computes grouped artifactGroups (folder headers with "Unfiled"), relative/absolute time helpers with 60s refresh, and grouped rendering.
Documentation
README.md, docs/artifacts.md
README and docs/artifacts.md document artifact storage layout, --folder usage and safety rules, listing and URL behavior, and Web grouping semantics.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • jfox85/devx#38: Introduced the initial artifact subsystem that this PR extends with folder organization and folder-aware validation/filtering.

Poem

🐰 I hopped through folders, tidy and bright,
Saved plans and screenshots in folders just right,
Grouped in the web where "Unfiled" sits near,
Paths are safe, collisions disappear,
A rabbit's small cheer for artifacts clear!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding artifact folder functionality and web-based artifact sorting.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jf-artifact-folders-web-sorting

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
artifact/manifest_test.go (1)

62-72: ⚠️ Potential issue | 🟠 Major

Pre-existing Windows test failure in path validation (not introduced by this PR).

The test TestValidateRelativePathRejectsTraversal has a platform-specific issue at line 66. It expects /tmp/file to be rejected as an absolute path, but on Windows this assertion fails. The root cause is that filepath.IsAbs() returns false for Unix-style paths like /tmp/file on Windows, since Windows only recognizes absolute paths with drive letters (e.g., C:\). This test remains unchanged in the current PR and is a pre-existing issue in the base code that should be addressed separately.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@artifact/manifest_test.go` around lines 62 - 72, Test
TestValidateRelativePathRejectsTraversal fails on Windows because the hardcoded
Unix absolute path "/tmp/file" isn't considered absolute there; update the test
to use an OS-appropriate absolute path before calling ValidateRelativePath
(e.g., detect runtime.GOOS == "windows" and use a Windows absolute like
"C:\\tmp\\file" or construct with filepath.Join/FromSlash accordingly, else keep
"/tmp/file"), or skip that specific subcase on Windows; update only
TestValidateRelativePathRejectsTraversal to select the platform-correct absolute
path so the assertion that absolute paths are rejected holds across OSes.
🧹 Nitpick comments (1)
cmd/artifact_add.go (1)

29-49: ⚡ Quick win

Add a Cobra Example for the new --folder flow.

The flag help was updated, but devx artifact add --help still doesn't show a foldered invocation. Adding one flat example and one --folder example would make the new behavior discoverable from the CLI itself.

As per coding guidelines, "When modifying CLI commands, update help text and examples".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cmd/artifact_add.go` around lines 29 - 49, The cobra command artifactAddCmd
lacks Example text for the new --folder behavior; update the artifactAddCmd
definition (or set artifactAddCmd.Example in init) to include two concise usage
examples: one flat invocation (e.g., devx artifact add --title "..."
path/to/file) and one showing the new folder flow (e.g., devx artifact add
--folder my/group --file sub/path --title "..." <file|-> or piping from stdin
with --file relative to --folder), ensuring the examples mention the --folder
flag and relative file semantics and reference the same flags used in init
(artifactAddFlags.folder, .file, .title) so users see the new behavior in devx
artifact add --help.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@artifact/manifest.go`:
- Around line 184-193: The folder validation must also canonicalize and store
the normalized value so downstream comparisons use a single canonical
representation: in the block that calls NormalizeFolderPath(a.Folder) (the code
around the file/folder validation in artifact/manifest.go where
NormalizeFolderPath is used), replace the current pattern of only checking the
returned folder with assigning the normalized folder back to the artifact (e.g.,
set a.Folder = folder) after successful normalization, and keep the subsequent
file membership checks using that normalized value; ensure this normalization
occurs whenever manifests are loaded/saved so Folder is always canonicalized.

---

Outside diff comments:
In `@artifact/manifest_test.go`:
- Around line 62-72: Test TestValidateRelativePathRejectsTraversal fails on
Windows because the hardcoded Unix absolute path "/tmp/file" isn't considered
absolute there; update the test to use an OS-appropriate absolute path before
calling ValidateRelativePath (e.g., detect runtime.GOOS == "windows" and use a
Windows absolute like "C:\\tmp\\file" or construct with filepath.Join/FromSlash
accordingly, else keep "/tmp/file"), or skip that specific subcase on Windows;
update only TestValidateRelativePathRejectsTraversal to select the
platform-correct absolute path so the assertion that absolute paths are rejected
holds across OSes.

---

Nitpick comments:
In `@cmd/artifact_add.go`:
- Around line 29-49: The cobra command artifactAddCmd lacks Example text for the
new --folder behavior; update the artifactAddCmd definition (or set
artifactAddCmd.Example in init) to include two concise usage examples: one flat
invocation (e.g., devx artifact add --title "..." path/to/file) and one showing
the new folder flow (e.g., devx artifact add --folder my/group --file sub/path
--title "..." <file|-> or piping from stdin with --file relative to --folder),
ensuring the examples mention the --folder flag and relative file semantics and
reference the same flags used in init (artifactAddFlags.folder, .file, .title)
so users see the new behavior in devx artifact add --help.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fcd61add-f9cc-46aa-9cf0-d49666b80849

📥 Commits

Reviewing files that changed from the base of the PR and between 3d19d6c and 8df0767.

⛔ Files ignored due to path filters (5)
  • web/dist/assets/index-C-eGZceh.js is excluded by !**/dist/**
  • web/dist/assets/index-Cb9dmfi2.css is excluded by !**/dist/**
  • web/dist/assets/index-CkFD9JOf.js is excluded by !**/dist/**
  • web/dist/assets/index-D3TGCEBb.css is excluded by !**/dist/**
  • web/dist/index.html is excluded by !**/dist/**
📒 Files selected for processing (13)
  • README.md
  • artifact/add.go
  • artifact/filter.go
  • artifact/manifest.go
  • artifact/manifest_test.go
  • cmd/artifact_add.go
  • cmd/artifact_list.go
  • cmd/artifact_test.go
  • docs/artifacts.md
  • web/app/src/lib/Terminal.svelte
  • web/app/src/lib/artifacts/ArtifactPane.svelte
  • web/artifacts_api.go
  • web/artifacts_api_test.go

Comment thread artifact/manifest.go
@jfox85 jfox85 merged commit ea1e9b1 into main May 10, 2026
23 checks passed
@jfox85 jfox85 deleted the jf-artifact-folders-web-sorting branch May 10, 2026 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant