Skip to content

feat: implement unified resource gallery and industrial-grade attachm…#28

Open
muhammad-bassiouni wants to merge 4 commits intoownpilot:mainfrom
muhammad-bassiouni:feat/unified-resource-infrastructure
Open

feat: implement unified resource gallery and industrial-grade attachm…#28
muhammad-bassiouni wants to merge 4 commits intoownpilot:mainfrom
muhammad-bassiouni:feat/unified-resource-infrastructure

Conversation

@muhammad-bassiouni
Copy link
Copy Markdown

1. Unified Attachment & Resource Architecture

The Issue (Original State)

Originally, the platform's attachment system was limited strictly to image uploads via ChatInput.tsx. There was no infrastructure for handling general file types (PDFs, text files, etc.), and resources injected by AI tools (context) were not visually rendered as first-class objects in the chat interface.

The Fix Applied (Final Update)

  • Universal Upload Support: Refactored ChatInput.tsx from an image-only input to a generic file system. Added an Upload icon and multi-format preview cards for all file types.
  • Unified Resource Gallery: Built a high-fidelity gallery in MessageList.tsx using ResourceCard components with type-specific Lucide icons. This gallery merges both user-uploaded files and AI-injected context into a single, professional visual stack.
  • Data Pipeline Integration: Synchronized the entire pipeline (frontend store, gateway validation, and core message types) to support path and size metadata, ensuring resources are correctly identified and rendered across the monorepo.

Files Changed

  • packages/ui/src/components/ChatInput.tsx
  • packages/ui/src/components/MessageList.tsx
  • packages/ui/src/hooks/useChatStore.tsx
  • packages/gateway/src/services/middleware/persistence.ts
  • packages/gateway/src/types/index.ts
  • packages/core/src/services/message-types.ts
  • packages/ui/src/types/index.ts

2. Industrial-Grade File Serving & Security

The Issue (Original State)

  1. Performance: The gateway served attachments in chat.ts using synchronous readFileSync, which loaded entire files into memory—a risk for server stability with large files.
  2. Security: Attachment URLs lacked an authentication mechanism for external browser contexts (new tabs), leading to 401 Unauthorized errors when viewing original files.
  3. Build Stability: The codebase contained an unused statSync import in chat.ts which eventually caused TypeScript build failures (TS6133) under strict compiler rules.

The Fix Applied (Final Update)

  • Streaming Pipeline: Migrated the serving route to Node.js Streams (createReadStream). This provides constant, minimal memory footprint file delivery regardless of size.
  • Auth Token Injection: Updated packages/gateway/src/middleware/auth.ts to support session tokens in query parameters (?token=...) and injected these into all UI file links for secure cross-tab viewing.
  • MIME & Build Sanitization: Expanded the MIME registry to support diverse developer formats (CSV, XML, ZIP, etc.) and removed all build-breaking unused imports.

Files Changed

  • packages/gateway/src/routes/chat.ts
  • packages/gateway/src/middleware/auth.ts
  • packages/gateway/src/middleware/validation.ts
  • packages/gateway/src/routes/helpers.ts (Added hydrateAttachments for AI processing)

3. Professional UI Hardening & Layout

The Issue (Original State)

The original chat interface was designed for simple text bubbles. As we introduced the complex Resource Gallery, the layout needed hardening to maintain pixel-perfect alignment.

The Fix Applied (Final Update)

  • Deterministic Alignment: Enforced a surgical flex-row-reverse justify-start layout on user message rows. This guarantees that all content—from bubbles to multi-attachment galleries—remains perfectly pinned to the right edge and avatar axis.
  • Metadata Parity: Updated chat-streaming.ts and chat-history.ts to ensure file metadata is preserved in real-time, eliminating UI "flicker" during AI generation.

Files Changed

  • packages/ui/src/components/MessageList.tsx
  • packages/gateway/src/routes/chat-streaming.ts
  • packages/gateway/src/routes/chat-history.ts

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