From 22452abf36c5cbe9854db3cc6567f7dde5f79059 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sat, 21 Jun 2025 14:30:11 -0300 Subject: [PATCH] feat: Add ChatProvider for managing chat state and API interactions - Implemented ChatProvider to manage chat context and user state. - Added API fetching utility for chat instance and activity handling. - Integrated chat service with methods for sending activities. - Updated Tailwind CSS configuration to include additional content paths and custom utilities. - Added client-side rendering directive to mode-toggle component. - Created README.md for settings documentation. --- app/chat/{providers => }/chat-provider.tsx | 4 +- app/chat/components/chat-layout.tsx | 23 - app/chat/components/chat/chat-header.tsx | 20 - app/chat/components/chat/chat-input.tsx | 67 --- app/chat/components/chat/chat-window.tsx | 31 -- app/chat/components/chat/message-list.tsx | 41 -- .../components/projector/image-viewer.tsx | 14 - .../components/projector/markdown-viewer.tsx | 15 - .../components/projector/projector-view.tsx | 38 -- .../components/projector/video-player.tsx | 14 - .../components/selector/person-selector.tsx | 41 -- app/chat/components/sound-initializer.tsx | 29 -- app/chat/lib/utils.ts | 14 - app/chat/page.tsx | 367 ++++++++++++++- app/chat/providers/sound-provider.tsx | 28 -- app/chat/styles/chat.css | 110 ----- app/chat/styles/layout.css | 25 - app/chat/styles/projector.css | 45 -- app/chat/styles/selector.css | 87 ---- app/chat/styles/ui.css | 137 ------ app/chat/types/index.ts | 28 -- app/client-nav.tsx | 433 +++++++++++++++++- app/layout.tsx | 10 +- app/settings/README.md | 14 + app/settings/page.tsx | 12 +- package.json | 4 +- pnpm-lock.yaml | 336 ++++++++++---- src/components/ui/mode-toggle.tsx | 2 + tailwind.config.cjs | 260 +++++++---- 29 files changed, 1233 insertions(+), 1016 deletions(-) rename app/chat/{providers => }/chat-provider.tsx (96%) delete mode 100644 app/chat/components/chat-layout.tsx delete mode 100644 app/chat/components/chat/chat-header.tsx delete mode 100644 app/chat/components/chat/chat-input.tsx delete mode 100644 app/chat/components/chat/chat-window.tsx delete mode 100644 app/chat/components/chat/message-list.tsx delete mode 100644 app/chat/components/projector/image-viewer.tsx delete mode 100644 app/chat/components/projector/markdown-viewer.tsx delete mode 100644 app/chat/components/projector/projector-view.tsx delete mode 100644 app/chat/components/projector/video-player.tsx delete mode 100644 app/chat/components/selector/person-selector.tsx delete mode 100644 app/chat/components/sound-initializer.tsx delete mode 100644 app/chat/lib/utils.ts delete mode 100644 app/chat/providers/sound-provider.tsx delete mode 100644 app/chat/styles/chat.css delete mode 100644 app/chat/styles/layout.css delete mode 100644 app/chat/styles/projector.css delete mode 100644 app/chat/styles/selector.css delete mode 100644 app/chat/styles/ui.css delete mode 100644 app/chat/types/index.ts create mode 100644 app/settings/README.md diff --git a/app/chat/providers/chat-provider.tsx b/app/chat/chat-provider.tsx similarity index 96% rename from app/chat/providers/chat-provider.tsx rename to app/chat/chat-provider.tsx index d3b3970..410b3fc 100644 --- a/app/chat/providers/chat-provider.tsx +++ b/app/chat/chat-provider.tsx @@ -1,6 +1,6 @@ "use client"; import React, { createContext, useContext, useState, useEffect } from 'react'; -import { User } from '../types'; + const ChatContext = createContext(undefined); @@ -14,7 +14,7 @@ async function apiFetch(endpoint, options = {}) { export function ChatProvider({ children }) { const [line, setLine] = useState(null); const [instance, setInstance] = useState(null); - const [user] = useState({ + const [user] = useState({ id: `user_${Math.random().toString(36).slice(2)}`, name: 'You', }); diff --git a/app/chat/components/chat-layout.tsx b/app/chat/components/chat-layout.tsx deleted file mode 100644 index dc4f338..0000000 --- a/app/chat/components/chat-layout.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import React from 'react'; -import { PersonSelector } from './selector/person-selector'; -import { ProjectorView } from './projector/projector-view'; -import { ChatWindow } from './chat/chat-window'; -import '../styles/layout.css'; - -export function ChatLayout() { - return ( -
-
- -
-
-
- -
-
- -
-
-
- ); -} diff --git a/app/chat/components/chat/chat-header.tsx b/app/chat/components/chat/chat-header.tsx deleted file mode 100644 index a73c463..0000000 --- a/app/chat/components/chat/chat-header.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from 'react'; -import { useChat } from '../../providers/chat-provider'; -import '../../styles/chat.css'; - -export function ChatHeader() { - const { instance } = useChat(); - return ( -
-
-

{instance?.name || 'Qwen Chat'}

- Online -
- -
- ); -} diff --git a/app/chat/components/chat/chat-input.tsx b/app/chat/components/chat/chat-input.tsx deleted file mode 100644 index c29908d..0000000 --- a/app/chat/components/chat/chat-input.tsx +++ /dev/null @@ -1,67 +0,0 @@ -import React from 'react'; - -import { useChat } from '../../providers/chat-provider'; -import { useSound } from '../../providers/sound-provider'; -import '../../styles/chat.css'; - -export function ChatInput() { - const [message, setMessage] = React.useState(''); - const { sendActivity } = useChat(); - const { playSound } = useSound(); - - const handleSend = () => { - if (!message.trim()) return; - playSound('send'); - sendActivity({ - type: 'message', - text: message.trim(), - }); - setMessage(''); - }; - - - return ( - <> -
- - -