feat: implement democratic code execution voting in collaborative roo… - #240
Merged
vijaypatil477 merged 2 commits intoMay 28, 2026
Merged
Conversation
|
@omnipotentchaos is attempting to deploy a commit to the omkh4242g-1671's projects Team on Vercel. A member of the Team first needs to authorize it. |
omnipotentchaos
marked this pull request as ready for review
May 27, 2026 14:25
Contributor
Author
|
@vijaypatil477 Please see and tell if any change is required. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds a “democratic execution” flow for collaborative rooms: running code in a multi-user room starts a vote, and execution results are synchronized back to all participants.
Changes:
- Added room-level vote state management and execution result syncing (Firestore updates).
- Updated
useExecutionto start votes in collaborative rooms and react to approved/rejected votes + synced results. - Introduced a new
VotePopupmodal UI and wired it intoEditorPage.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
src/hooks/useRoom.js |
Adds vote lifecycle helpers (startExecutionVote, castVote, clearVote) and execution result sync helpers. |
src/hooks/useExecution.js |
Routes “Run” into vote flow in rooms; triggers execution on approval; syncs remote results into local output UI. |
src/components/Editor/VotePopup.jsx |
New modal to display voting progress and allow approve/reject actions with code preview. |
src/components/Editor/VotePopup.css |
Styling for the vote modal overlay (glassmorphic UI). |
src/components/Editor/EditorPage.jsx |
Renders VotePopup and passes user/room into useExecution. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+310
to
+337
| const castVote = useCallback(async (voteType) => { | ||
| if (!roomId || !user || !roomData?.activeVote) return; | ||
| const activeVote = { ...roomData.activeVote }; | ||
| const approvals = [...(activeVote.approvals || [])]; | ||
| const rejections = [...(activeVote.rejections || [])]; | ||
|
|
||
| if (voteType === 'approve') { | ||
| if (!approvals.includes(user.uid)) approvals.push(user.uid); | ||
| const rejIdx = rejections.indexOf(user.uid); | ||
| if (rejIdx > -1) rejections.splice(rejIdx, 1); | ||
| } else if (voteType === 'reject') { | ||
| if (!rejections.includes(user.uid)) rejections.push(user.uid); | ||
| const appIdx = approvals.indexOf(user.uid); | ||
| if (appIdx > -1) approvals.splice(appIdx, 1); | ||
| } | ||
|
|
||
| activeVote.approvals = approvals; | ||
| activeVote.rejections = rejections; | ||
|
|
||
| const totalUsersCount = activeUsers.length; | ||
| if (approvals.length > totalUsersCount / 2) { | ||
| activeVote.status = 'approved'; | ||
| } else if (rejections.length >= totalUsersCount / 2) { | ||
| activeVote.status = 'rejected'; | ||
| } | ||
|
|
||
| await updateDoc(doc(db, 'rooms', roomId), { activeVote }); | ||
| }, [roomId, user, roomData?.activeVote, activeUsers]); |
Comment on lines
+329
to
+334
| const totalUsersCount = activeUsers.length; | ||
| if (approvals.length > totalUsersCount / 2) { | ||
| activeVote.status = 'approved'; | ||
| } else if (rejections.length >= totalUsersCount / 2) { | ||
| activeVote.status = 'rejected'; | ||
| } |
Comment on lines
+295
to
+306
| const activeVote = { | ||
| initiatorUid: user.uid, | ||
| initiatorName: user.displayName || 'Guest', | ||
| code, | ||
| language, | ||
| stdin, | ||
| approvals: [user.uid], // initiator pre-approves | ||
| rejections: [], | ||
| status: 'voting', | ||
| createdAt: new Date().toISOString(), | ||
| }; | ||
| await updateDoc(doc(db, 'rooms', roomId), { activeVote }); |
Comment on lines
+146
to
+153
| // Effect: Watch for vote approval and trigger compile if current user is the initiator | ||
| useEffect(() => { | ||
| if (!room?.roomId || !room.roomData?.activeVote || !user) return; | ||
| const vote = room.roomData.activeVote; | ||
| if (vote.status === 'approved' && vote.initiatorUid === user.uid) { | ||
| executeVotedCode(vote.code, vote.language, vote.stdin); | ||
| } | ||
| }, [room?.roomId, room?.roomData?.activeVote, user, executeVotedCode]); |
Comment on lines
+58
to
+66
| const executionResult = { | ||
| executionId: crypto.randomUUID(), | ||
| stdout: result.stdout || '(No output)', | ||
| stderr: result.stderr || '', | ||
| execTime: elapsed + 's', | ||
| execStatus: isSuccess | ||
| ? EXEC_STATUS.SUCCESS | ||
| : { type: 'error', text: result.status?.description || 'Error' }, | ||
| }; |
Comment on lines
+179
to
+182
| const isSuccess = | ||
| result.execStatus === 'success' || | ||
| result.execStatus?.type === 'success' || | ||
| (typeof result.execStatus === 'object' && result.execStatus.text === 'Success'); |
Comment on lines
+68
to
+69
| // Broadcast compilation results to room | ||
| await room.syncExecutionResult(executionResult); |
Comment on lines
+31
to
+33
| return ( | ||
| <div className="vp-overlay"> | ||
| <div className="vp-container"> |
Pcmhacker-piro
pushed a commit
to Pcmhacker-piro/Debugra
that referenced
this pull request
Jun 23, 2026
Fix: Resolve merge conflicts in restructured project
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[FEAT] Synced Screen Sharing & Democratic Voting within Collaborative Rooms #144
✦ Description
This Pull Request implements Democratic Code Execution Voting inside active collaborative rooms. Before compiling code that consumes API budgets, team participants are presented with a real-time, interactive Vote Box.
Key Accomplishments & Features:
useRoom.js): Added real-time Firestore sync mechanisms to publish active votes (activeVote), record approvals/rejections, and calculate consensus (>50% approval threshold).useExecution.js): Once consensus is achieved, the initiator client compiles the exact code snapshot and broadcasts outputs (stdout,stderr, chimes) to all room participants using a race-condition-freeexecutionIdmechanism.VotePopup.jsx&VotePopup.css): Implemented a glassmorphic dark-theme overlay containing:2/3 (66%)).Fixes #144
⟡ Type of Change
✦ Checklist
npm run lintandnpm run formatlocally before pushing.⟡ Screenshots / Screen Recordings (Required for UI changes)