Skip to content

Commit fca6eb2

Browse files
committed
feat: implement collaborative workspace with real-time code editing, WebRTC voice chat, and socket-based session management
1 parent 18455d5 commit fca6eb2

2 files changed

Lines changed: 11 additions & 6 deletions

File tree

client/src/pages/CollaborativeWorkspace.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,9 +573,14 @@ export default function CollaborativeWorkspace() {
573573
const handleSendMessage = () => {
574574
if (!chatInput.trim() && !mediaPreview) return;
575575

576+
const localGemini = localStorage.getItem('codeforge_gemini_api_key');
577+
const localGroq = localStorage.getItem('codeforge_groq_api_key');
578+
576579
socket.emit('send-message', {
577580
text: chatInput,
578-
media: mediaPreview
581+
media: mediaPreview,
582+
userApiKey: localGemini,
583+
userGroqKey: localGroq
579584
});
580585

581586
setChatInput('');

server/sockets/collaborativeWorkspace.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function initCollaborativeWorkspace(io) {
134134
});
135135

136136
// Ephemeral session chat messages (includes media)
137-
socket.on('send-message', ({ text, media }) => {
137+
socket.on('send-message', ({ text, media, userApiKey, userGroqKey }) => {
138138
const { roomId } = socket;
139139
if (!roomId) return;
140140

@@ -159,7 +159,7 @@ function initCollaborativeWorkspace(io) {
159159

160160
// Trigger ForgeAI if message targets the agent
161161
if (text && text.trim().toLowerCase().startsWith('@forgeai')) {
162-
handleForgeAIMessage(roomId, io, text);
162+
handleForgeAIMessage(roomId, io, text, userApiKey, userGroqKey);
163163
}
164164
});
165165

@@ -396,7 +396,7 @@ function parseJsonResponse(text) {
396396
}
397397

398398
// Background handler for ForgeAI interaction
399-
async function handleForgeAIMessage(roomId, io, text) {
399+
async function handleForgeAIMessage(roomId, io, text, userApiKey, userGroqKey) {
400400
const workspace = workspaces.get(roomId);
401401
if (!workspace) return;
402402

@@ -415,8 +415,8 @@ async function handleForgeAIMessage(roomId, io, text) {
415415
io.to(roomId).emit('new-message', tempMessageObj);
416416

417417
try {
418-
const geminiApiKey = process.env.GEMINI_API_KEY;
419-
const groqApiKey = process.env.GROQ_API_KEY;
418+
const geminiApiKey = process.env.GEMINI_API_KEY || userApiKey;
419+
const groqApiKey = process.env.GROQ_API_KEY || userGroqKey;
420420

421421
if (!geminiApiKey && !groqApiKey) {
422422
throw new Error("No Gemini or Groq API key configured on the server.");

0 commit comments

Comments
 (0)