2026-05-18-upload-component-library.md 3.45 KB

Upload Component Library Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Add the approved Upload design pattern to the shared Web desktop UI component library.

Architecture: Implement Upload as two focused React components inside packages/ui: UploadDragger for file uploads and task records, and MediaWall for image/video thumbnails. Keep upload transport outside the component; the library renders states and emits callbacks.

Tech Stack: React, TypeScript, CSS Modules, Vitest, React Testing Library, existing design tokens.


Task 1: Spec And Scope

Files:

  • Modify: architecture-spec/openspec/changes/define-ui-component-library/proposal.md
  • Modify: architecture-spec/openspec/changes/define-ui-component-library/design.md
  • Modify: architecture-spec/openspec/changes/define-ui-component-library/specs/ui-component-library/spec.md
  • Modify: architecture-spec/openspec/changes/define-ui-component-library/tasks.md

  • Replace the old Upload exclusion with the confirmed Upload scope: file dragger plus media wall.

  • Add file upload rules: 500px by 208px dragger, helper text inside the drop zone, validation failure via Toast, uploading/cancel, failed retry/delete, completed preview/download/delete.

  • Add media wall rules: 96px tiles, image thumbnails, video cover plus play icon, upload tile last, helper text below the wall, modal preview behavior left to consumers.

Task 2: Component Tests

Files:

  • Create: workspace/agent-admin/web/packages/ui/src/components/upload.test.tsx

  • Add tests for UploadDragger rendering the helper text, dimensions class, completed operations, failed operations, and uploading progress.

  • Add tests for UploadDragger file selection calling onSelectFiles.

  • Add tests for MediaWall rendering image thumbnails, video cover thumbnails with a play marker, upload tile last, helper text below the wall, and media preview callbacks.

Task 3: Component Implementation

Files:

  • Create: workspace/agent-admin/web/packages/ui/src/components/Upload.tsx
  • Create: workspace/agent-admin/web/packages/ui/src/components/Upload.module.css
  • Modify: workspace/agent-admin/web/packages/ui/src/components/Icon.tsx
  • Modify: workspace/agent-admin/web/packages/ui/src/index.ts

  • Add icon names for upload, file, eye, download, retry, trash, plus, and play.

  • Implement UploadDragger with controlled files, hidden file input, drag-over visual state, and action callbacks.

  • Implement MediaWall with controlled items, upload tile last, hidden media input, preview callback, and video play overlay.

  • Export component and prop types from the package entry.

Task 4: Demo And Verification

Files:

  • Modify: workspace/agent-admin/web/src/routes/components/ComponentsDemoPage.tsx
  • Modify: workspace/agent-admin/web/src/routes/components/ComponentsDemoPage.module.css
  • Modify: workspace/agent-admin/web/src/routes/components/ComponentsDemoPage.test.tsx

  • Add an Upload demo group showing file upload states and media wall.

  • Update the demo test so Upload is included in the component groups.

  • Run npm test, npm run typecheck, and npm run build from workspace/agent-admin/web.

  • Start the dev server and verify /components visually in a browser.