From 66a37ec92c151ca23bab43c2ffee7297169806b0 Mon Sep 17 00:00:00 2001 From: "shakespeare.diy" Date: Tue, 11 Nov 2025 13:58:18 -0600 Subject: [PATCH] Add debug logging and lower threshold for testing push reminders - Reduced MESSAGE_THRESHOLD from 5 to 2 for easier testing - Added console.log statements to track: - Message counter increments - shouldShowReminder checks and conditions - Git status (uncommitted changes, commits ahead, remotes) - Added useEffect to watch shouldShowReminder changes - Fixed async state update issue by watching effect dependency This will help debug why the reminder dialog may not be appearing. --- src/hooks/usePushReminder.ts | 40 ++++++++++++++++++++++++++++-------- src/pages/ProjectView.tsx | 8 +++++--- 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/hooks/usePushReminder.ts b/src/hooks/usePushReminder.ts index 65ddbca7..027a8ad9 100644 --- a/src/hooks/usePushReminder.ts +++ b/src/hooks/usePushReminder.ts @@ -21,7 +21,7 @@ const DEFAULT_STATE: PushReminderState = { }; /** Number of messages before showing push reminder */ -const MESSAGE_THRESHOLD = 5; +const MESSAGE_THRESHOLD = 2; // Lowered to 2 for easier testing /** Minimum time in ms between showing reminders (5 minutes) */ const MIN_REMINDER_INTERVAL = 5 * 60 * 1000; @@ -49,33 +49,57 @@ export function usePushReminder(projectId: string | null) { // Check if should show reminder const shouldShowReminder = useCallback(() => { if (!state.enabled || !projectId || !gitStatus?.isGitRepo) { + console.log('[PushReminder] Should NOT show - enabled:', state.enabled, 'projectId:', projectId, 'isGitRepo:', gitStatus?.isGitRepo); return false; } // Don't show if user recently interacted with push reminder const timeSinceLastInteraction = Date.now() - state.lastInteraction; if (timeSinceLastInteraction < MIN_REMINDER_INTERVAL) { + console.log('[PushReminder] Should NOT show - too soon since last interaction:', Math.round(timeSinceLastInteraction / 1000), 'seconds'); return false; } // Show if: - // 1. There are uncommitted changes OR commits ahead of remote + // 1. There are uncommitted changes OR commits ahead of remote OR no remote configured // 2. Enough messages have been sent since last interaction - const hasUnpushedWork = gitStatus.hasUncommittedChanges || gitStatus.ahead > 0; + const hasUnpushedWork = + gitStatus.hasUncommittedChanges || + gitStatus.ahead > 0 || + gitStatus.remotes.length === 0; const enoughMessages = state.messagesSinceLastPush >= MESSAGE_THRESHOLD; - return hasUnpushedWork && enoughMessages; + console.log('[PushReminder] Check:', { + hasUnpushedWork, + enoughMessages, + messageCount: state.messagesSinceLastPush, + threshold: MESSAGE_THRESHOLD, + hasUncommittedChanges: gitStatus.hasUncommittedChanges, + ahead: gitStatus.ahead, + remotesCount: gitStatus.remotes.length, + }); + + const shouldShow = hasUnpushedWork && enoughMessages; + console.log('[PushReminder] Should show reminder:', shouldShow); + + return shouldShow; }, [state, projectId, gitStatus]); // Increment message counter const incrementMessages = useCallback(() => { - if (!state.enabled || !projectId) return; + if (!state.enabled || !projectId) { + console.log('[PushReminder] Not incrementing - enabled:', state.enabled, 'projectId:', projectId); + return; + } + + const newCount = state.messagesSinceLastPush + 1; + console.log('[PushReminder] Incrementing message counter to:', newCount); setState((prev) => ({ ...prev, messagesSinceLastPush: prev.messagesSinceLastPush + 1, })); - }, [state.enabled, projectId, setState]); + }, [state.enabled, projectId, setState, state.messagesSinceLastPush]); // Reset counter (called after push or dismiss) const resetReminder = useCallback(() => { @@ -98,8 +122,8 @@ export function usePushReminder(projectId: string | null) { // Check if there's unpushed work that should trigger warning icon const hasUnpushedWork = gitStatus?.isGitRepo && ( - gitStatus.hasUncommittedChanges || - gitStatus.ahead > 0 || + gitStatus.hasUncommittedChanges || + gitStatus.ahead > 0 || gitStatus.remotes.length === 0 ); diff --git a/src/pages/ProjectView.tsx b/src/pages/ProjectView.tsx index bea2b6c3..1f469392 100644 --- a/src/pages/ProjectView.tsx +++ b/src/pages/ProjectView.tsx @@ -113,12 +113,14 @@ export function ProjectView() { // Handle message sent - increment push reminder counter const handleMessageSent = useCallback(() => { pushReminder.incrementMessages(); + }, [pushReminder]); - // Check if we should show the reminder - if (pushReminder.shouldShowReminder) { + // Watch for when we should show the reminder (after state updates) + useEffect(() => { + if (pushReminder.shouldShowReminder && !isPushReminderOpen) { setIsPushReminderOpen(true); } - }, [pushReminder]); + }, [pushReminder.shouldShowReminder, isPushReminderOpen]); // Handle first user interaction to enable audio context const handleFirstInteraction = () => {