Skip to content

Refactor the UI and add Documents back.#777

Merged
sean-esk merged 5 commits intomainfrom
refactor/projects-ui
Oct 11, 2025
Merged

Refactor the UI and add Documents back.#777
sean-esk merged 5 commits intomainfrom
refactor/projects-ui

Conversation

@sean-esk
Copy link
Copy Markdown
Collaborator

@sean-esk sean-esk commented Oct 10, 2025

Pull Request

Summary

Complete Projects Feature UI Refactor implementing UI_STANDARDS.md compliance, primitive library adoption, and full document CRUD functionality. This PR modernizes the entire Projects feature with glassmorphism consistency, accessibility improvements, responsive design, and adds comprehensive project document management.

Changes Made

  • Phase 0-4: UI Standards Compliance - Fixed 21/24 violations from UI consistency review

    • Added dark mode variants to all color utility functions
    • Added aria-pressed, aria-label, and aria-hidden attributes for accessibility
    • Made BoardView responsive (grid-cols-1 md:grid-cols-2 lg:grid-cols-4)
    • Made ProjectCard pills responsive (flex-col sm:flex-row)
    • Converted all dynamic class construction to cn() helper
    • Removed hardcoded glassmorphism in favor of centralized tokens
    • Standardized TableView row styling with rowVariants
    • Removed KanbanColumn backgrounds (transparent columns, colored underlines only)
  • Primitive Library Migration

    • Migrated ProjectCard to SelectableCard primitive with aurora glow
    • Migrated TaskCard to use glassmorphism tokens (removed hardcoded styles)
    • Migrated DocumentCard to Card primitive with type-colored inner glow
    • Migrated ViewControls to Card primitive
    • Migrated DocsTab sidebar to Card primitive
  • Layout Toggle System

    • Added horizontal vs sidebar layout modes in ProjectsView
    • Created SidebarProjectCard component with StatPills
    • Replaced Tabs with PillNavigation (orange variant, centered)
    • Added collapsible sidebar with proper min-w-0 on main content
    • Layout toggle integrated into ProjectHeader (right side, inline with buttons)
  • Project Search

    • Added search input in ProjectHeader (filters projects by title)
    • Search works in both horizontal and sidebar layout modes
    • Includes clear button (X) when search has text
  • Document Browser Feature (Complete CRUD)

    • Connected to /api/projects/{projectId}/docs endpoints
    • Full-width DocumentCards with type-colored internal glow
    • Simple list + viewer layout matching reference implementation
    • ReactMarkdown rendering with custom component styling
    • Edit/Preview toggle (Edit3/Eye icons)
    • Save button (appears when editing with changes)
    • Add Document button and modal
    • Delete with Trash icon and confirmation modal
    • TanStack Query mutations with proper cache invalidation
  • Code Quality

    • Exported PillNavigation from primitives/index.ts
    • Created documentService with getDocumentsByProject, updateDocument, deleteDocument
    • Created useUpdateDocument, useCreateDocument, useDeleteDocument hooks
    • Added DocumentUpdateData interface for type safety
    • Fixed accessibility: nested interactive elements, proper ARIA attributes
    • Added null-safety checks with descriptive error messages
    • Changed any to unknown for type safety

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Code refactoring
  • Performance improvement

Affected Services

  • Frontend (React UI)

Testing

  • All existing tests pass
  • Manually tested affected user flows
  • Docker builds succeed for all services

Test Evidence

# TypeScript validation - zero errors in modified files
npx tsc --noEmit 2>&1 | grep "src/features/projects" | grep -v "test"
# Result: Only pre-existing test file warnings

# Production build successful
npm run build
# Result: ✓ built in 2.26s (no errors)

# UI Standards compliance validation
grep -rn "className.*\`.*\${" archon-ui-main/src/features/projects/ --include="*.tsx" | grep -v "test"
# Result: 0 violations (all dynamic classes converted to cn())

grep -rn "grid-cols-[2-9]" archon-ui-main/src/features/projects/ --include="*.tsx" | grep -v "md:\|lg:\|test"
# Result: 0 violations (all grids responsive)

grep -n "return \"bg-" archon-ui-main/src/features/projects/tasks/utils/task-styles.tsx | grep -v "dark:"
# Result: 0 violations (all color functions have dark mode variants)

grep -rn "aria-pressed" archon-ui-main/src/features/projects/ --include="*.tsx" | grep -v "test"
# Result: 4 matches (all toggle buttons have aria-pressed)

# Manual testing completed:
# - Layout toggle: horizontal ↔ sidebar modes work correctly
# - Project search: filters projects in real-time
# - Sidebar collapse/expand: functions properly with min-w-0 preventing page expansion
# - Document CRUD: Create, Read, Update, Delete all functional
# - ReactMarkdown: Headings, lists, code blocks render with proper styling
# - Edit/Preview: Toggle works, Save button appears on changes
# - Delete confirmations: Standard modal appears, cache invalidates properly
# - Responsive: Tested at 375px (mobile), 768px (tablet), 1024px (desktop)
# - Kanban board: Columns stack properly on mobile
# - Task cards: Pills stack vertically on mobile
# - Dark mode: All components adapt correctly

Checklist

  • My code follows the service architecture patterns
  • If using an AI coding assistant, I used the CLAUDE.md rules
  • All new and existing tests pass locally
  • My changes generate no new warnings
  • I have verified no regressions in existing features

Breaking Changes

None. All changes are additive or improve existing functionality without breaking the API.

Additional Notes

UI Consistency Review

Created comprehensive review document: PRPs/reviews/ui-consistency-review-projects.md

  • Overall grade improved from F (42 violations) to B+ (3 violations)
  • 87.5% of violations resolved (21/24)
  • Remaining 3 violations are minor and don't impact functionality

Files Modified (18 files)

Core Components:

  • ProjectsView.tsx - Layout toggle system, search, PillNavigation integration
  • ProjectHeader.tsx - Added layout toggle, search input
  • ProjectCard.tsx - SelectableCard migration, responsive pills
  • ProjectList.tsx - w-full constraint
  • TaskCard.tsx - Glassmorphism tokens, cn() conversions
  • TasksTab.tsx - ViewControls Card primitive, aria-pressed
  • TableView.tsx - Row variants, aria-labels on action buttons
  • BoardView.tsx - Responsive grid
  • KanbanColumn.tsx - Transparent columns
  • task-styles.tsx - Dark mode variants

Documents Feature (New):

  • DocsTab.tsx - Complete rebuild with CRUD operations
  • DocumentCard.tsx - Full-width cards with type-colored glow, accessibility fixes
  • DocumentViewer.tsx - ReactMarkdown rendering, Edit/Preview toggle, Save functionality
  • AddDocumentModal.tsx - Create documents with error handling
  • documentService.ts - API integration with null-safety checks
  • useDocumentQueries.ts - TanStack Query hooks with proper invalidation

Primitives:

  • primitives/index.ts - Exported PillNavigation

Performance Improvements

  • Static class lookups faster than dynamic construction
  • Tailwind purging now works correctly (smaller bundle)
  • No runtime style computation
  • Browser-optimized static classes

Dependencies

No new dependencies added. Used existing:

  • react-markdown (already installed, v10.1.0)
  • All Radix UI primitives
  • TanStack Query v5

Screenshots

See PR description for before/after screenshots of:

  • Layout toggle (horizontal vs sidebar modes)
  • Document browser with cards
  • ReactMarkdown rendering
  • Responsive Kanban board

Summary by CodeRabbit

  • New Features

    • Full document management: create, edit/save, delete documents with list, search, modals, and an editable viewer; new add/delete modals and persistence hooks.
    • Header enhancements: search box, layout toggle (horizontal/sidebar), and customizable right-content area.
  • Refactor

    • Project, task, and document items now use unified card/selectable primitives and updated responsive layouts; Projects view adds sidebar mode, client-side search, and layout switching.
  • Style

    • Responsive grid/layout updates, dark-mode badge/glow tweaks, background layering adjustment, and improved ARIA/accessibility on controls.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Oct 10, 2025

Walkthrough

Replaces local visual containers with shared UI primitives, adds project layout modes and search, implements Documents CRUD with new service/hooks and modals, refactors Tasks UI/styling and accessibility, and re-exports a pill-navigation primitive.

Changes

Cohort / File(s) Summary
Projects — Card & Header
archon-ui-main/src/features/projects/components/ProjectCard.tsx, archon-ui-main/src/features/projects/components/ProjectHeader.tsx, archon-ui-main/src/features/projects/components/ProjectList.tsx
ProjectCard now uses SelectableCard (selection/pinned state moved to primitive); removed manual click/key handlers and motion classes. ProjectHeader props extended (layoutMode, onLayoutModeChange, rightContent, searchQuery, onSearchChange) and renders search + layout toggle. ProjectList adds w-full.
Projects — Views & Sidebar
archon-ui-main/src/features/projects/views/ProjectsView.tsx
Adds layoutMode ("horizontal"
Documents — Tab & UI Components
archon-ui-main/src/features/projects/documents/DocsTab.tsx, archon-ui-main/src/features/projects/documents/components/AddDocumentModal.tsx, archon-ui-main/src/features/projects/documents/components/DocumentCard.tsx, archon-ui-main/src/features/projects/documents/components/DocumentViewer.tsx
DocsTab refactored for CRUD: add/delete modals, selection list + viewer, wired mutations. New AddDocumentModal component. DocumentCard converted to Card, adds keyboard selection and inline delete action. DocumentViewer gains edit mode, onSave prop, markdown rendering, and save flow.
Documents — Hooks & Service
archon-ui-main/src/features/projects/documents/hooks/index.ts, archon-ui-main/src/features/projects/documents/hooks/useDocumentQueries.ts, archon-ui-main/src/features/projects/documents/services/documentService.ts
Hooks expanded and re-exported: useCreateDocument, useDeleteDocument, useUpdateDocument, and new useProjectDocument. useProjectDocuments now fetches via documentService. Added mutations (create/update/delete) using callAPIWithETag, TanStack Query invalidation, and toasts. New documentService exposes get/list/update/delete methods.
Tasks — Tabs, Columns, Cards & Styles
archon-ui-main/src/features/projects/tasks/TasksTab.tsx, archon-ui-main/src/features/projects/tasks/components/KanbanColumn.tsx, archon-ui-main/src/features/projects/tasks/components/TaskCard.tsx, archon-ui-main/src/features/projects/tasks/utils/task-styles.tsx, archon-ui-main/src/features/projects/tasks/views/BoardView.tsx, archon-ui-main/src/features/projects/tasks/views/TableView.tsx
TasksTab view-toggle wrapped in Card with aria enhancements. KanbanColumn simplified header, new status icons via getStatusInfo, removed isOver tracking. TaskCard migrated to Card + cn (styling refactor). task-styles adds dark-mode variants. BoardView becomes responsive grid; TableView centralizes rowVariants and improves ARIA.
UI Primitives & Layout
archon-ui-main/src/features/ui/primitives/index.ts, archon-ui-main/src/components/layout/MainLayout.tsx
Re-exports pill-navigation from primitives index. MainLayout removes explicit bg classes on wrapper, adds a fixed full-page background element, and adjusts z-indexing of content/background layers.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant U as User
  participant Viewer as DocumentViewer
  participant Docs as DocsTab
  participant Mut as useUpdateDocument
  participant Svc as documentService
  participant API as /api/projects/:pid/docs/:did

  U->>Viewer: edit content
  U->>Viewer: click Save
  Viewer->>Docs: onSave(documentId, content)
  Docs->>Mut: mutate({ documentId, updates })
  Mut->>Svc: updateDocument(projectId, documentId, updates)
  Svc->>API: PUT /api/projects/:pid/docs/:did
  API-->>Svc: 200 updated document
  Svc-->>Mut: ProjectDocument
  Mut-->>Docs: onSuccess (invalidate queries, toast)
  Docs-->>Viewer: save complete (exit edit mode)
Loading
sequenceDiagram
  autonumber
  participant U as User
  participant Header as ProjectHeader
  participant View as ProjectsView
  participant List as ProjectList

  U->>Header: type search
  Header->>View: onSearchChange(query)
  View->>View: filter & sort projects
  View->>List: render filtered list

  U->>Header: toggle layout
  Header->>View: onLayoutModeChange(mode)
  View->>List: render chosen layout (horizontal/sidebar)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

Suggested reviewers

  • leex279
  • coleam00

Poem

I nibble keys and hop with glee,
New cards that shimmer — click on me!
Docs grow, save, vanish with a cheer,
Tasks jump lanes and align the rear.
A twitch, a thump — the UI blooms here. 🐇✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The pull request title is concise and clearly highlights the two primary outcomes of the changeset: a broad UI refactor and the reintroduction of document management functionality, which directly reflects the main changes described in the PR.
Description Check ✅ Passed The pull request description closely follows the repository template by including all required sections—Summary, Changes Made, Type of Change, Affected Services, Testing with evidence, Checklist, Breaking Changes, and Additional Notes—while providing detailed and structured information in each.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/projects-ui

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[bot]

This comment was marked as resolved.

Developer added 2 commits October 10, 2025 17:08
Merged in PR #776 (refactor/knowledge-ui) from main.
No conflicts - different features.
coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
archon-ui-main/src/features/projects/documents/DocsTab.tsx (1)

71-83: Add error handling to ensure modal closes on failure.

If deleteDocumentMutation.mutateAsync throws, the modal cleanup code (lines 81-82) won't execute, leaving the modal open with stale state. While the mutation's onError callback shows a toast, the user experience is degraded because they must manually cancel a stuck modal.

Apply this diff to handle errors gracefully:

   const confirmDelete = async () => {
     if (!documentToDelete) return;
 
-    await deleteDocumentMutation.mutateAsync(documentToDelete.id);
-
-    // Clear selection if deleted document was selected
-    if (selectedDocument?.id === documentToDelete.id) {
-      setSelectedDocument(null);
-    }
-
-    setShowDeleteModal(false);
-    setDocumentToDelete(null);
+    try {
+      await deleteDocumentMutation.mutateAsync(documentToDelete.id);
+
+      // Clear selection if deleted document was selected
+      if (selectedDocument?.id === documentToDelete.id) {
+        setSelectedDocument(null);
+      }
+    } finally {
+      // Always clean up modal state, even on error
+      setShowDeleteModal(false);
+      setDocumentToDelete(null);
+    }
   };
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 913f47b and ef42626.

📒 Files selected for processing (1)
  • archon-ui-main/src/features/projects/documents/DocsTab.tsx (3 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
archon-ui-main/src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

archon-ui-main/src/**/*.{ts,tsx}: Frontend TypeScript must use strict mode with no implicit any
Use TanStack Query for all data fetching; avoid prop drilling
Use database values directly in the frontend; avoid mapping layers between BE and FE types

Never return null to indicate failure in frontend TypeScript; throw errors with details instead

Files:

  • archon-ui-main/src/features/projects/documents/DocsTab.tsx
archon-ui-main/src/features/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Use Biome in features: 120 character line length, double quotes, and trailing commas

Use Biome formatting/conventions in features (120 char lines, double quotes, trailing commas)

Files:

  • archon-ui-main/src/features/projects/documents/DocsTab.tsx
archon-ui-main/src/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (CLAUDE.md)

Use ESLint rules for legacy frontend code outside /src/features

Files:

  • archon-ui-main/src/features/projects/documents/DocsTab.tsx
archon-ui-main/**/*.{ts,tsx}

📄 CodeRabbit inference engine (CLAUDE.md)

TypeScript strict mode with no implicit any in the frontend

Files:

  • archon-ui-main/src/features/projects/documents/DocsTab.tsx
archon-ui-main/src/features/**/*.tsx

📄 CodeRabbit inference engine (CLAUDE.md)

Ensure no dynamic Tailwind class construction (avoid runtime-generated class strings)

Files:

  • archon-ui-main/src/features/projects/documents/DocsTab.tsx
🧠 Learnings (1)
📚 Learning: 2025-10-11T01:51:55.916Z
Learnt from: sean-eskerium
PR: coleam00/Archon#777
File: archon-ui-main/src/features/projects/documents/DocsTab.tsx:59-59
Timestamp: 2025-10-11T01:51:55.916Z
Learning: The Archon codebase is a single-user application without user authentication. Hardcoded "User" author values in document creation (e.g., in DocsTab.tsx) are intentional and serve to identify user-created content versus AI-generated content. Do not recommend adding authentication, user context, or retrieving author information from auth hooks.

Applied to files:

  • archon-ui-main/src/features/projects/documents/DocsTab.tsx
🧬 Code graph analysis (1)
archon-ui-main/src/features/projects/documents/DocsTab.tsx (7)
archon-ui-main/src/features/projects/documents/hooks/useDocumentQueries.ts (3)
  • useUpdateDocument (57-78)
  • useCreateDocument (83-114)
  • useDeleteDocument (119-137)
archon-ui-main/src/features/projects/documents/types/document.ts (1)
  • DocumentContent (8-17)
archon-ui-main/src/features/ui/primitives/button.tsx (1)
  • Button (11-130)
archon-ui-main/src/features/ui/primitives/input.tsx (1)
  • Input (8-29)
archon-ui-main/src/features/projects/documents/components/DocumentCard.tsx (1)
  • DocumentCard (67-183)
archon-ui-main/src/features/projects/documents/components/DocumentViewer.tsx (1)
  • DocumentViewer (18-279)
archon-ui-main/src/features/projects/documents/components/AddDocumentModal.tsx (1)
  • AddDocumentModal (25-136)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Backend Tests (Python + pytest)
🔇 Additional comments (3)
archon-ui-main/src/features/projects/documents/DocsTab.tsx (3)

40-51: LGTM! Type safety and error propagation improvements implemented.

The function now uses the properly typed DocumentContent interface and rethrows errors so the DocumentViewer can maintain edit mode on failure. This addresses the previous concerns about type safety and error handling.


90-97: LGTM! State reset fully addresses previous concerns.

The effect now comprehensively resets all state when switching projects, including modal flags and staged deletion. This prevents stale viewer content, failed saves, and lingering modals.


208-218: LGTM! Consistent modal control pattern implemented.

The modal now uses a clean controlled pattern with the open prop managing visibility, onOpenChange handling cleanup, and null-safe access to documentToDelete. This resolves the previous inconsistency between conditional rendering and controlled props.

@sean-esk sean-esk merged commit 4050c35 into main Oct 11, 2025
8 checks passed
leonj1 pushed a commit to leonj1/Archon that referenced this pull request Oct 13, 2025
Refactor the UI and add Documents back.
@Wirasm Wirasm deleted the refactor/projects-ui branch April 6, 2026 07:38
coleam00 added a commit that referenced this pull request Apr 7, 2026
Runs `gh auth status` as a non-blocking check after server starts.
Logs a warning if gh is not authenticated, helping diagnose expired
tokens or missing auth before workflows fail at runtime.

Closes #777

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Tyone88 pushed a commit to Tyone88/Archon that referenced this pull request Apr 16, 2026
Runs `gh auth status` as a non-blocking check after server starts.
Logs a warning if gh is not authenticated, helping diagnose expired
tokens or missing auth before workflows fail at runtime.

Closes coleam00#777

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
joaobmonteiro pushed a commit to joaobmonteiro/Archon that referenced this pull request Apr 26, 2026
Runs `gh auth status` as a non-blocking check after server starts.
Logs a warning if gh is not authenticated, helping diagnose expired
tokens or missing auth before workflows fail at runtime.

Closes coleam00#777

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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