Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ function DashboardContent({
const [showWorkspaceSettings, setShowWorkspaceSettings] = useState(false);
const [showWorkspaceShare, setShowWorkspaceShare] = useState(false);

// Manual open state for the raffle popup (re-opened via the share-count badge).
const [showRafflePopup, setShowRafflePopup] = useState(false);

@cubic-dev-ai cubic-dev-ai Bot Apr 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Reset showRafflePopup on workspace change; otherwise manual-open state can leak across workspaces and reopen the raffle popup unintentionally.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/app/dashboard/page.tsx, line 147:

<comment>Reset `showRafflePopup` on workspace change; otherwise manual-open state can leak across workspaces and reopen the raffle popup unintentionally.</comment>

<file context>
@@ -143,6 +143,9 @@ function DashboardContent({
   const [showWorkspaceShare, setShowWorkspaceShare] = useState(false);
 
+  // Manual open state for the raffle popup (re-opened via the share-count badge).
+  const [showRafflePopup, setShowRafflePopup] = useState(false);
+
   const showSignInPrompt =
</file context>
Fix with Cubic


const showSignInPrompt =
!!session?.user?.isAnonymous &&
!isLoadingWorkspace &&
Expand Down Expand Up @@ -289,6 +292,8 @@ function DashboardContent({
currentWorkspaceId={currentWorkspaceId}
isLoadingWorkspace={isLoadingWorkspace}
onOpenFullShare={() => setShowWorkspaceShare(true)}
manuallyOpen={showRafflePopup}
onManuallyClose={() => setShowRafflePopup(false)}
/>
<DashboardLayout
currentWorkspaceId={currentWorkspaceId}
Expand Down Expand Up @@ -353,6 +358,7 @@ function DashboardContent({
}
googleLoginHint={session?.user?.email ?? null}
isWorkspaceOwner={isWorkspaceOwner}
onShowRaffleDetails={() => setShowRafflePopup(true)}

@cubic-dev-ai cubic-dev-ai Bot Apr 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2: Custom agent: Flag AI Slop and Fabricated Changes

A new raffle-popup reopen behavior was added without regression-style test coverage, which Rule 1 explicitly flags for behavior changes.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/app/dashboard/page.tsx, line 361:

<comment>A new raffle-popup reopen behavior was added without regression-style test coverage, which Rule 1 explicitly flags for behavior changes.</comment>

<file context>
@@ -353,6 +358,7 @@ function DashboardContent({
               }
               googleLoginHint={session?.user?.email ?? null}
               isWorkspaceOwner={isWorkspaceOwner}
+              onShowRaffleDetails={() => setShowRafflePopup(true)}
             />
           ) : undefined
</file context>
Fix with Cubic

/>
) : undefined
}
Expand Down
32 changes: 22 additions & 10 deletions src/components/modals/RafflePopup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ interface RafflePopupProps {
currentWorkspaceId: string | null;
isLoadingWorkspace: boolean;
onOpenFullShare?: () => void;
/** Force the popup open regardless of dismissal state (e.g. user clicked the share-count badge). */
manuallyOpen?: boolean;
/** Called when a manually-opened popup is closed; parent should clear its manual-open state. */

@cubic-dev-ai cubic-dev-ai Bot Apr 23, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P3: Custom agent: Flag AI Slop and Fabricated Changes

The new comment claims onManuallyClose only runs for manually-opened popups, but the code calls it on every close path without checking manuallyOpen.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/components/modals/RafflePopup.tsx, line 28:

<comment>The new comment claims `onManuallyClose` only runs for manually-opened popups, but the code calls it on every close path without checking `manuallyOpen`.</comment>

<file context>
@@ -23,6 +23,10 @@ interface RafflePopupProps {
   onOpenFullShare?: () => void;
+  /** Force the popup open regardless of dismissal state (e.g. user clicked the share-count badge). */
+  manuallyOpen?: boolean;
+  /** Called when a manually-opened popup is closed; parent should clear its manual-open state. */
+  onManuallyClose?: () => void;
 }
</file context>
Suggested change
/** Called when a manually-opened popup is closed; parent should clear its manual-open state. */
/** Optional callback fired when the popup closes. */
Fix with Cubic

onManuallyClose?: () => void;
}

const FEATURE_KEY = "midterms-raffle-2026-04";
Expand All @@ -33,6 +37,8 @@ export function RafflePopup({
currentWorkspaceId,
isLoadingWorkspace,
onOpenFullShare,
manuallyOpen = false,
onManuallyClose,
}: RafflePopupProps) {
const { data: session } = useSession();
const { isNew, dismiss } = useNewFeature({
Expand All @@ -46,16 +52,17 @@ export function RafflePopup({
const [isLoadingShareLink, setIsLoadingShareLink] = useState(false);
const [copied, setCopied] = useState(false);

const canRender =
const canShowPopup =
!!currentWorkspaceId &&
!isLoadingWorkspace &&
!!workspace &&
session?.user?.isAnonymous !== true &&
workspace?.userId === session?.user?.id &&
isNew;
workspace?.userId === session?.user?.id;

const isOpen = canShowPopup && (isNew || manuallyOpen);

useEffect(() => {
if (!canRender || !workspace) return;
if (!isOpen || !workspace) return;

const controller = new AbortController();
setIsLoadingShareLink(true);
Expand All @@ -81,12 +88,17 @@ export function RafflePopup({
return () => {
controller.abort();
};
}, [canRender, workspace]);
}, [isOpen, workspace]);

if (!canRender || !workspace) {
if (!canShowPopup || !workspace) {
return null;
}

const handleClose = () => {
if (isNew) dismiss();
onManuallyClose?.();
};
Comment on lines +97 to +100

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 onManuallyClose called unconditionally on auto-popup close

handleClose always calls onManuallyClose?.(), but onManuallyClose is wired to reset showRafflePopup in the parent. When the popup opens automatically (first visit, manuallyOpen=false) and the user dismisses it, onManuallyClose fires and sets showRafflePopup(false) on a state that was never set to true. This is harmless today since it's a no-op state transition, but the semantics are off — onManuallyClose should only be called when the popup was opened manually.

Suggested change
const handleClose = () => {
if (isNew) dismiss();
onManuallyClose?.();
};
const handleClose = () => {
if (isNew) dismiss();
if (manuallyOpen) onManuallyClose?.();
};

Fix in Cursor


const deepCopyUrl = `${typeof window !== "undefined" ? window.location.origin : ""}/share-copy/${workspace.id}`;
const activeUrl = linkMode === "collaborate" ? shareLinkUrl : deepCopyUrl;
const isActiveLoading = linkMode === "collaborate" && isLoadingShareLink;
Expand All @@ -106,9 +118,9 @@ export function RafflePopup({

return (
<Dialog
open={isNew}
open={isOpen}
onOpenChange={(next) => {
if (!next) dismiss();
if (!next) handleClose();
}}
>
<DialogContent className="sm:max-w-md" overlayClassName="bg-black/70">
Expand Down Expand Up @@ -199,7 +211,7 @@ export function RafflePopup({
type="button"
variant="outline"
onClick={() => {
dismiss();
handleClose();
onOpenFullShare();
}}
>
Expand All @@ -209,7 +221,7 @@ export function RafflePopup({
) : (
<span />
)}
<Button type="button" onClick={dismiss}>
<Button type="button" onClick={handleClose}>
Got it
</Button>
</DialogFooter>
Expand Down
7 changes: 5 additions & 2 deletions src/components/workspace-canvas/WorkspaceHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ interface WorkspaceHeaderProps {
// Workspace actions
onOpenSettings?: () => void;
onOpenShare?: () => void;
/** Open the raffle details popup (reopens the "Win a $50 Amazon gift card" dialog). */
onShowRaffleDetails?: () => void;

/** Item shown in the fullscreen workspace viewer (`openMode === "single"`) — breadcrumbs + header actions */
activeOpenWorkspaceItem?: Item | null;
Expand Down Expand Up @@ -286,6 +288,7 @@ export function WorkspaceHeader({
onRenameFolder,
onOpenSettings,
onOpenShare,
onShowRaffleDetails,

activeOpenWorkspaceItem = null,
onCloseActiveItem,
Expand Down Expand Up @@ -1240,10 +1243,10 @@ export function WorkspaceHeader({
Feedback
</button>

{isWorkspaceOwner && currentWorkspaceId && onOpenShare && (
{isWorkspaceOwner && currentWorkspaceId && (
<ShareCountBadge
workspaceId={currentWorkspaceId}
onClick={onOpenShare}
onClick={onShowRaffleDetails}
/>
)}
Comment on lines +1246 to 1251

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 ShareCountBadge renders without click guard

The condition was previously onOpenShare && ( which ensured the badge only appeared when its click action was wired up. After this change, ShareCountBadge will render for any workspace owner even when onShowRaffleDetails is not passed, leaving the badge visible but its onClick as undefined (silent no-op). Any existing or future call site of WorkspaceHeader that doesn't supply onShowRaffleDetails will get a clickable-looking badge that does nothing.

Suggested change
{isWorkspaceOwner && currentWorkspaceId && (
<ShareCountBadge
workspaceId={currentWorkspaceId}
onClick={onOpenShare}
onClick={onShowRaffleDetails}
/>
)}
{isWorkspaceOwner && currentWorkspaceId && onShowRaffleDetails && (
<ShareCountBadge
workspaceId={currentWorkspaceId}
onClick={onShowRaffleDetails}
/>
)}

Fix in Cursor

{onOpenShare && (
Expand Down
Loading