'use client' import React, { useState } from 'react' import { motion } from 'framer-motion' import { Upload, Robot, FileText, CheckCircle, Warning, Info, Copy, Download } from '@phosphor-icons/react' interface ClaudeIntegrationProps { file: File | null onClose: () => void } export function ClaudeIntegration({ file, onClose }: ClaudeIntegrationProps) { const [uploadMethod, setUploadMethod] = useState<'direct' | 'chunked' | 'reference'>('direct') const [processing, setProcessing] = useState(false) const [result, setResult] = useState('') const handleProcess = async () => { if (!file) return setProcessing(true) try { if (uploadMethod === 'direct') { // Direct upload - best for small files < 1MB const content = await file.text() setResult(`File: ${file.name}\n\nContent:\n${content}`) } else if (uploadMethod === 'chunked') { // Chunked upload - for larger files, split into manageable chunks const CHUNK_SIZE = 50000 // 50KB chunks const content = await file.text() const chunks = [] for (let i = 0; i < content.length; i += CHUNK_SIZE) { chunks.push(content.slice(i, i + CHUNK_SIZE)) } setResult( `File: ${file.name}\n` + `Total chunks: ${chunks.length}\n` + `Chunk size: ${CHUNK_SIZE} characters\n\n` + `Instructions for Claude:\n` + `This file has been split into ${chunks.length} chunks.\n` + `You can process each chunk sequentially.\n\n` + `First chunk:\n${chunks[0].slice(0, 500)}...` ) } else { // Reference method - store file and provide reference setResult( `File Reference Created:\n` + `Name: ${file.name}\n` + `Size: ${formatFileSize(file.size)}\n` + `Type: ${file.type}\n\n` + `This file has been stored in the system.\n` + `You can reference it by name in your conversation with Claude.\n` + `Claude can access and analyze the file content when needed.` ) } } catch (error) { console.error('Error processing file:', error) setResult('Error processing file') } finally { setProcessing(false) } } const formatFileSize = (bytes: number) => { const units = ['B', 'KB', 'MB', 'GB'] let size = bytes let unitIndex = 0 while (size >= 1024 && unitIndex < units.length - 1) { size /= 1024 unitIndex++ } return `${size.toFixed(2)} ${units[unitIndex]}` } const copyToClipboard = () => { navigator.clipboard.writeText(result) } return ( e.stopPropagation()} > {/* Header */}

Claude Integration

Optimize file upload for Claude to preserve context

{/* Content */}
{file && (

{file.name}

{formatFileSize(file.size)}

)} {/* Upload Methods */}

Upload Method

{/* Info Box */}

Context Preservation Tips:

  • • Use direct upload for code files and short documents
  • • Use chunked upload for large documents or datasets
  • • Use reference method for binary files or archives
{/* Result */} {result && (
Ready for Claude
                {result}
              
)}
{/* Footer */}
) }