Skip to content

feat: implement democratic code execution voting in collaborative roo… - #240

Merged
vijaypatil477 merged 2 commits into
vijaypatil477:mainfrom
omnipotentchaos:feat/collab-voting-144
May 28, 2026
Merged

feat: implement democratic code execution voting in collaborative roo…#240
vijaypatil477 merged 2 commits into
vijaypatil477:mainfrom
omnipotentchaos:feat/collab-voting-144

Conversation

@omnipotentchaos

Copy link
Copy Markdown
Contributor

[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:

  1. Vote Interception: Intercepted the "Run" code compilation flow when inside a collaborative room with multiple active participants.
  2. Collaborative Room State Hooks (useRoom.js): Added real-time Firestore sync mechanisms to publish active votes (activeVote), record approvals/rejections, and calculate consensus (>50% approval threshold).
  3. Robust Compile and Sync (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-free executionId mechanism.
  4. Interactive Vote Box UI Component (VotePopup.jsx & VotePopup.css): Implemented a glassmorphic dark-theme overlay containing:
    • Live progress bars illustrating real-time approval and rejection rates.
    • Collapsible previews of the exact source code and stdin inputs being run.
    • Live counts and consensus metrics (e.g. 2/3 (66%)).
  5. Rigorous Quality Checks: Cleaned up React Hooks order boundaries and resolved ES Lint dependency warnings. Production builds compile successfully without issues.

Fixes #144

⟡ Type of Change

  • New feature (non-breaking change which adds functionality)

✦ Checklist

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my code.
  • I have commented my code, particularly in hard-to-understand areas.
  • My changes generate no new warnings or console errors.
  • I have verified that my changes work correctly on both desktop and mobile viewports.
  • (If applicable) I have run npm run lint and npm run format locally before pushing.

⟡ Screenshots / Screen Recordings (Required for UI changes)

Interactive Real-time Vote Box Collapsible Source Code Preview
Seamless glassmorphic modal containing green approval & red rejection progress bars indicating consensus. Collapsible code container showing exact snapshot of code being run.

@vercel

vercel Bot commented May 27, 2026

Copy link
Copy Markdown

@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
omnipotentchaos marked this pull request as ready for review May 27, 2026 14:25
Copilot AI review requested due to automatic review settings May 27, 2026 14:25
@omnipotentchaos

Copy link
Copy Markdown
Contributor Author

@vijaypatil477 Please see and tell if any change is required.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 useExecution to start votes in collaborative rooms and react to approved/rejected votes + synced results.
  • Introduced a new VotePopup modal UI and wired it into EditorPage.

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 thread src/hooks/useRoom.js Outdated
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 thread src/hooks/useRoom.js Outdated
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 thread src/hooks/useRoom.js
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 thread src/hooks/useExecution.js Outdated
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 thread src/hooks/useExecution.js
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 thread src/hooks/useExecution.js Outdated
Comment on lines +179 to +182
const isSuccess =
result.execStatus === 'success' ||
result.execStatus?.type === 'success' ||
(typeof result.execStatus === 'object' && result.execStatus.text === 'Success');
Comment thread src/hooks/useExecution.js Outdated
Comment on lines +68 to +69
// Broadcast compilation results to room
await room.syncExecutionResult(executionResult);
Comment thread src/components/Editor/VotePopup.jsx Outdated
Comment on lines +31 to +33
return (
<div className="vp-overlay">
<div className="vp-container">
@vijaypatil477 vijaypatil477 added gssoc:approved GSSoC '26 Approved issue level:advanced GSSoC '26 Advanced difficulty issue quality:clean Clean code structure standards labels May 28, 2026
@vijaypatil477
vijaypatil477 merged commit fe16dfc into vijaypatil477:main May 28, 2026
7 of 8 checks passed
Pcmhacker-piro pushed a commit to Pcmhacker-piro/Debugra that referenced this pull request Jun 23, 2026
Fix: Resolve merge conflicts in restructured project
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC '26 Approved issue level:advanced GSSoC '26 Advanced difficulty issue quality:clean Clean code structure standards

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Synced Screen Sharing within Collaborative Rooms

3 participants