Compare commits

...
5 Commits
Author SHA1 Message Date
shakespeare.diy 262414257a Fix ESLint errors: remove unused navigate imports
Removed unused `useNavigate` imports from:
- PushReminderDialog.tsx
- PushWarningButton.tsx

These were causing ESLint errors. The navigate hook was imported
but never used in either component.

ESLint should now pass without errors.
2025-11-14 10:17:52 -06:00
shakespeare.diy c25517a58f Remove debug logging and restore production settings
- Removed all console.log debug statements
- Changed MESSAGE_THRESHOLD back to 5 (from 2 for testing)
- Cleaned up code for production

Push reminder features are now fully functional:
- Warning icon appears in header when there's unpushed work
- Popup appears after 5 messages if conditions are met
- 5-minute cooldown between reminders
- User can disable in Settings > Preferences
2025-11-11 14:06:43 -06:00
shakespeare.diy a7164c0292 Fix push reminder not showing - remove initial cooldown
The issue was that DEFAULT_STATE set lastInteraction to Date.now(),
which meant the 5-minute cooldown started immediately on first load,
preventing reminders from ever showing.

Changes:
- Set initial lastInteraction to 0 instead of Date.now()
- Don't reset lastInteraction when switching projects (keep cooldown)
- This allows reminders to show immediately after threshold is met

Users may need to clear localStorage key 'push-reminder-state' to
reset if they already have the old state saved.
2025-11-11 14:01:46 -06:00
shakespeare.diy 66a37ec92c 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.
2025-11-11 13:58:18 -06:00
shakespeare.diy 5de01c6130 Add push reminder features to encourage users to push code
Implements two key features to prevent data loss:

1. Push Warning Button
   - Icon button in project header that appears when:
     - No remote is configured
     - There are commits ahead of remote
     - There are uncommitted changes
   - Click opens Git dialog for one-click push or remote configuration
   - Visual indicators with tooltips showing status

2. Periodic Push Reminder Dialog
   - Dismissible popup appears after 5 messages if there's unpushed work
   - Shows different content based on git status:
     - No remote: Prompts to configure remote
     - Commits ahead: Prompts to push
     - Uncommitted changes: Prompts to commit and push
   - Can be disabled with "Don't show again" checkbox
   - Setting in Preferences to re-enable reminders
   - Respects 5-minute cooldown between reminders

3. User Preferences
   - Added "Push reminders" toggle in Settings > Preferences
   - Enabled by default to encourage best practices
   - Stored in local storage for persistence

Technical implementation:
- Created usePushReminder hook for state management
- Tracks message count and last interaction timestamp
- Integrates with existing useGitStatus hook
- Added onMessageSent callback to ChatPane
- PushWarningButton component with icon/full variants
- PushReminderDialog with contextual messaging
- Translations added to English locale
2025-11-11 13:43:16 -06:00
7 changed files with 507 additions and 1 deletions

No files matched your search

+176
View File
@@ -0,0 +1,176 @@
import { useState, useEffect } from 'react';
import {
Dialog,
DialogContent,
DialogDescription,
DialogHeader,
DialogTitle,
DialogFooter,
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Checkbox } from '@/components/ui/checkbox';
import { Label } from '@/components/ui/label';
import { GitBranch, Upload, AlertTriangle, X } from 'lucide-react';
import { useGitStatus } from '@/hooks/useGitStatus';
import { GitDialog } from '@/components/GitDialog';
interface PushReminderDialogProps {
projectId: string;
open: boolean;
onOpenChange: (open: boolean) => void;
onDisableReminders: () => void;
onDismiss: () => void;
}
export function PushReminderDialog({
projectId,
open,
onOpenChange,
onDisableReminders,
onDismiss,
}: PushReminderDialogProps) {
const [dontShowAgain, setDontShowAgain] = useState(false);
const [isGitDialogOpen, setIsGitDialogOpen] = useState(false);
const { data: gitStatus } = useGitStatus(projectId);
// Close the reminder dialog when git dialog opens
useEffect(() => {
if (isGitDialogOpen) {
onOpenChange(false);
onDismiss();
}
}, [isGitDialogOpen, onOpenChange, onDismiss]);
if (!gitStatus?.isGitRepo) {
return null;
}
const hasNoRemote = gitStatus.remotes.length === 0;
const hasCommitsAhead = gitStatus.ahead > 0;
const hasUncommittedChanges = gitStatus.hasUncommittedChanges;
const handleDismiss = () => {
if (dontShowAgain) {
onDisableReminders();
}
onDismiss();
onOpenChange(false);
};
const handlePrimaryAction = () => {
if (dontShowAgain) {
onDisableReminders();
}
if (hasNoRemote) {
// Close reminder dialog and open git dialog
onOpenChange(false);
setIsGitDialogOpen(true);
} else {
// Close reminder dialog and open git dialog for push
onOpenChange(false);
setIsGitDialogOpen(true);
}
};
// Determine dialog content based on git status
let icon = AlertTriangle;
let iconColor = 'text-amber-600 dark:text-amber-500';
let title = '';
let description = '';
let primaryActionLabel = '';
if (hasNoRemote) {
icon = GitBranch;
iconColor = 'text-yellow-600 dark:text-yellow-500';
title = 'No Remote Repository Configured';
description = 'Your work is only stored locally in your browser. Configure a remote repository to prevent data loss if you clear your browser data.';
primaryActionLabel = 'Configure Remote';
} else if (hasCommitsAhead) {
icon = Upload;
iconColor = 'text-blue-600 dark:text-blue-500';
title = 'Unpushed Commits';
description = `You have ${gitStatus.ahead} commit${gitStatus.ahead !== 1 ? 's' : ''} that ${gitStatus.ahead !== 1 ? 'haven\'t' : 'hasn\'t'} been pushed to your remote repository. Push your changes to prevent data loss.`;
primaryActionLabel = 'Push Changes';
} else if (hasUncommittedChanges) {
icon = AlertTriangle;
iconColor = 'text-amber-600 dark:text-amber-500';
title = 'Uncommitted Changes';
description = `You have ${gitStatus.changedFiles.length} uncommitted change${gitStatus.changedFiles.length !== 1 ? 's' : ''}. Commit and push your changes to keep your work safe.`;
primaryActionLabel = 'Commit & Push';
}
const Icon = icon;
return (
<>
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<div className="flex items-start gap-3">
<div className={`rounded-full p-2 bg-muted ${iconColor}`}>
<Icon className="h-5 w-5" />
</div>
<div className="flex-1">
<DialogTitle className="text-left">{title}</DialogTitle>
<DialogDescription className="text-left mt-2">
{description}
</DialogDescription>
</div>
<Button
variant="ghost"
size="sm"
className="h-6 w-6 p-0 -mt-1"
onClick={handleDismiss}
>
<X className="h-4 w-4" />
</Button>
</div>
</DialogHeader>
<div className="flex items-start gap-2 p-3 rounded-md bg-muted/50 border">
<Checkbox
id="dont-show"
checked={dontShowAgain}
onCheckedChange={(checked) => setDontShowAgain(checked === true)}
/>
<div className="grid gap-1.5 leading-none">
<Label
htmlFor="dont-show"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Don't show this again
</Label>
<p className="text-xs text-muted-foreground">
You can re-enable push reminders in Settings &gt; Preferences
</p>
</div>
</div>
<DialogFooter className="flex-col sm:flex-row gap-2">
<Button
variant="outline"
onClick={handleDismiss}
className="w-full sm:w-auto"
>
Remind Me Later
</Button>
<Button
onClick={handlePrimaryAction}
className="w-full sm:w-auto"
>
{primaryActionLabel}
</Button>
</DialogFooter>
</DialogContent>
</Dialog>
{/* Git Dialog - opened when user clicks primary action */}
<GitDialog
projectId={projectId}
open={isGitDialogOpen}
onOpenChange={setIsGitDialogOpen}
/>
</>
);
}
+138
View File
@@ -0,0 +1,138 @@
import { useState } from 'react';
import { Button } from '@/components/ui/button';
import { GitDialog } from '@/components/GitDialog';
import { AlertTriangle, Upload, GitBranch } from 'lucide-react';
import { cn } from '@/lib/utils';
import { useGitStatus } from '@/hooks/useGitStatus';
import {
Tooltip,
TooltipContent,
TooltipProvider,
TooltipTrigger,
} from '@/components/ui/tooltip';
interface PushWarningButtonProps {
projectId: string;
className?: string;
variant?: 'icon' | 'full';
}
export function PushWarningButton({
projectId,
className,
variant = 'icon'
}: PushWarningButtonProps) {
const [isGitDialogOpen, setIsGitDialogOpen] = useState(false);
const { data: gitStatus } = useGitStatus(projectId);
if (!gitStatus?.isGitRepo) {
return null;
}
// Determine warning state
const hasNoRemote = gitStatus.remotes.length === 0;
const hasUncommittedChanges = gitStatus.hasUncommittedChanges;
const hasCommitsAhead = gitStatus.ahead > 0;
// Don't show if everything is synced
if (!hasNoRemote && !hasUncommittedChanges && !hasCommitsAhead) {
return null;
}
// Determine icon and message
let icon = AlertTriangle;
let message = '';
let action = '';
if (hasNoRemote) {
icon = GitBranch;
message = 'No remote configured';
action = 'Configure remote to prevent data loss';
} else if (hasCommitsAhead) {
icon = Upload;
message = `${gitStatus.ahead} commit${gitStatus.ahead !== 1 ? 's' : ''} not pushed`;
action = 'Push to remote';
} else if (hasUncommittedChanges) {
icon = AlertTriangle;
message = `${gitStatus.changedFiles.length} uncommitted change${gitStatus.changedFiles.length !== 1 ? 's' : ''}`;
action = 'Commit and push your changes';
}
const Icon = icon;
const handleClick = () => {
if (hasNoRemote) {
// If no remote, open git dialog to configure
setIsGitDialogOpen(true);
} else {
// If remote exists, open git dialog for push/commit
setIsGitDialogOpen(true);
}
};
if (variant === 'icon') {
return (
<>
<TooltipProvider>
<Tooltip>
<TooltipTrigger asChild>
<Button
variant="ghost"
size="sm"
onClick={handleClick}
className={cn(
"h-8 w-8 p-0",
hasNoRemote && "text-yellow-600 hover:text-yellow-700 dark:text-yellow-500 dark:hover:text-yellow-400",
hasCommitsAhead && "text-blue-600 hover:text-blue-700 dark:text-blue-500 dark:hover:text-blue-400",
hasUncommittedChanges && !hasCommitsAhead && "text-amber-600 hover:text-amber-700 dark:text-amber-500 dark:hover:text-amber-400",
className
)}
>
<Icon className="h-4 w-4 animate-pulse" />
</Button>
</TooltipTrigger>
<TooltipContent>
<div className="space-y-1">
<p className="font-medium">{message}</p>
<p className="text-xs text-muted-foreground">{action}</p>
</div>
</TooltipContent>
</Tooltip>
</TooltipProvider>
<GitDialog
projectId={projectId}
open={isGitDialogOpen}
onOpenChange={setIsGitDialogOpen}
/>
</>
);
}
// Full button variant
return (
<>
<Button
variant="outline"
size="sm"
onClick={handleClick}
className={cn(
"gap-2 border-2",
hasNoRemote && "border-yellow-500/50 bg-yellow-50 hover:bg-yellow-100 dark:bg-yellow-950/20 dark:hover:bg-yellow-950/30 text-yellow-700 dark:text-yellow-400",
hasCommitsAhead && "border-blue-500/50 bg-blue-50 hover:bg-blue-100 dark:bg-blue-950/20 dark:hover:bg-blue-950/30 text-blue-700 dark:text-blue-400",
hasUncommittedChanges && !hasCommitsAhead && "border-amber-500/50 bg-amber-50 hover:bg-amber-100 dark:bg-amber-950/20 dark:hover:bg-amber-950/30 text-amber-700 dark:text-amber-400",
className
)}
>
<Icon className="h-4 w-4 animate-pulse" />
<span className="text-sm font-medium">{message}</span>
</Button>
<GitDialog
projectId={projectId}
open={isGitDialogOpen}
onOpenChange={setIsGitDialogOpen}
/>
</>
);
}
+8 -1
View File
@@ -52,6 +52,7 @@ interface ChatPaneProps {
onNewChat: () => void;
onFirstInteraction?: () => void;
onLoadingChange?: (isLoading: boolean) => void;
onMessageSent?: () => void;
isLoading?: boolean;
isBuildLoading?: boolean;
consoleError?: ProjectPreviewConsoleError | null;
@@ -67,6 +68,7 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
onNewChat,
onFirstInteraction,
onLoadingChange,
onMessageSent,
isLoading: externalIsLoading,
isBuildLoading: externalIsBuildLoading,
consoleError,
@@ -478,7 +480,12 @@ export const ChatPane = forwardRef<ChatPaneRef, ChatPaneProps>(({
// Send as text parts if we have multiple parts, otherwise send as string for simplicity
const messageContent = contentParts.length === 1 ? contentParts[0].text : contentParts;
await sendMessage(messageContent, modelToUse);
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath]);
// Notify parent that a message was sent (for push reminder tracking)
if (onMessageSent) {
onMessageSent();
}
}, [addRecentlyUsedModel, fs, isConfigured, isLoading, providerModel, sendMessage, tmpPath, onMessageSent]);
// Handle textarea focus - show onboarding if not configured
const handleTextareaFocus = useCallback(() => {
+118
View File
@@ -0,0 +1,118 @@
import { useEffect, useCallback } from 'react';
import { useLocalStorage } from './useLocalStorage';
import { useGitStatus } from './useGitStatus';
interface PushReminderState {
/** Whether push reminders are enabled */
enabled: boolean;
/** Number of messages since last push */
messagesSinceLastPush: number;
/** Timestamp when user last pushed or dismissed a reminder */
lastInteraction: number;
/** Project ID being tracked */
currentProjectId: string | null;
}
const DEFAULT_STATE: PushReminderState = {
enabled: true,
messagesSinceLastPush: 0,
lastInteraction: 0, // Start at 0 so reminders can show immediately
currentProjectId: null,
};
/** Number of messages before showing push reminder */
const MESSAGE_THRESHOLD = 5;
/** Minimum time in ms between showing reminders (5 minutes) */
const MIN_REMINDER_INTERVAL = 5 * 60 * 1000;
export function usePushReminder(projectId: string | null) {
const [state, setState] = useLocalStorage<PushReminderState>(
'push-reminder-state',
DEFAULT_STATE
);
const { data: gitStatus } = useGitStatus(projectId);
// Reset counter when switching projects
useEffect(() => {
if (projectId && state.currentProjectId !== projectId) {
setState((prev) => ({
...prev,
currentProjectId: projectId,
messagesSinceLastPush: 0,
// Don't reset lastInteraction - keep the cooldown across project switches
}));
}
}, [projectId, state.currentProjectId, setState]);
// Check if should show reminder
const shouldShowReminder = useCallback(() => {
if (!state.enabled || !projectId || !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) {
return false;
}
// Show if:
// 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 ||
gitStatus.remotes.length === 0;
const enoughMessages = state.messagesSinceLastPush >= MESSAGE_THRESHOLD;
return hasUnpushedWork && enoughMessages;
}, [state, projectId, gitStatus]);
// Increment message counter
const incrementMessages = useCallback(() => {
if (!state.enabled || !projectId) return;
setState((prev) => ({
...prev,
messagesSinceLastPush: prev.messagesSinceLastPush + 1,
}));
}, [state.enabled, projectId, setState]);
// Reset counter (called after push or dismiss)
const resetReminder = useCallback(() => {
setState((prev) => ({
...prev,
messagesSinceLastPush: 0,
lastInteraction: Date.now(),
}));
}, [setState]);
// Enable/disable reminders
const setEnabled = useCallback((enabled: boolean) => {
setState((prev) => ({
...prev,
enabled,
messagesSinceLastPush: 0,
lastInteraction: Date.now(),
}));
}, [setState]);
// Check if there's unpushed work that should trigger warning icon
const hasUnpushedWork = gitStatus?.isGitRepo && (
gitStatus.hasUncommittedChanges ||
gitStatus.ahead > 0 ||
gitStatus.remotes.length === 0
);
return {
shouldShowReminder: shouldShowReminder(),
incrementMessages,
resetReminder,
enabled: state.enabled,
setEnabled,
hasUnpushedWork: hasUnpushedWork || false,
gitStatus,
};
}
+2
View File
@@ -57,6 +57,8 @@
"temporaryDirectoryDescription": "Filesystem path for temporary files",
"sentryDsn": "Sentry DSN",
"sentryDsnDescription": "Sentry Data Source Name (DSN) for error reporting. Leave empty to disable Sentry.",
"pushReminders": "Push reminders",
"pushRemindersDescription": "Show periodic reminders to push your code to a remote repository to prevent data loss.",
"shareErrorReports": "Share error reports",
"shareErrorReportsDescription": "Help improve this app by automatically sending crash and error reports.",
"english": "English",
+22
View File
@@ -8,12 +8,14 @@ import { Label } from "@/components/ui/label";
import { useIsMobile } from "@/hooks/useIsMobile";
import { useNavigate } from "react-router-dom";
import { useAppContext } from "@/hooks/useAppContext";
import { usePushReminder } from "@/hooks/usePushReminder";
export function Preferences() {
const { t } = useTranslation();
const isMobile = useIsMobile();
const navigate = useNavigate();
const { config, updateConfig } = useAppContext();
const pushReminder = usePushReminder(null);
return (
<div className="p-6 space-y-6">
@@ -73,6 +75,26 @@ export function Preferences() {
</p>
</div>
<div className="space-y-2">
<div className="flex items-center justify-between">
<div className="space-y-0.5">
<Label htmlFor="push-reminders" className="text-sm font-medium">
{t('pushReminders')}
</Label>
</div>
<Switch
id="push-reminders"
checked={pushReminder.enabled}
onCheckedChange={(checked) => {
pushReminder.setEnabled(checked);
}}
/>
</div>
<p className="text-sm text-muted-foreground">
{t('pushRemindersDescription')}
</p>
</div>
<div className="space-y-2">
<div className="flex items-center justify-between">
<div className="space-y-0.5">
+43
View File
@@ -15,11 +15,14 @@ import { useNavigate } from 'react-router-dom';
import { ActionsMenu } from '@/components/ActionsMenu';
import { useIsMobile } from '@/hooks/useIsMobile';
import { GitStatusIndicator } from '@/components/GitStatusIndicator';
import { PushWarningButton } from '@/components/PushWarningButton';
import { PushReminderDialog } from '@/components/PushReminderDialog';
import { StarButton } from '@/components/StarButton';
import { useBuildProject } from '@/hooks/useBuildProject';
import { useIsProjectPreviewable } from '@/hooks/useIsProjectPreviewable';
import { useConsoleError } from '@/hooks/useConsoleError';
import { useAutoBuild } from '@/hooks/useAutoBuild';
import { usePushReminder } from '@/hooks/usePushReminder';
export function ProjectView() {
const { projectId } = useParams<{ projectId: string }>();
@@ -30,6 +33,7 @@ export function ProjectView() {
const [mobileView, setMobileView] = useState<'chat' | 'preview' | 'code'>('chat');
const [isAILoading, setIsAILoading] = useState(false);
const [isProjectDetailsOpen, setIsProjectDetailsOpen] = useState(false);
const [isPushReminderOpen, setIsPushReminderOpen] = useState(false);
// Use console error state from provider
const { consoleError, dismissConsoleError, clearErrors } = useConsoleError();
@@ -43,6 +47,7 @@ export function ProjectView() {
const build = useBuildProject(projectId!);
const { data: isPreviewable = false } = useIsProjectPreviewable(projectId!);
const pushReminder = usePushReminder(projectId || null);
// Enable auto-build for previewable projects
useAutoBuild({
@@ -105,6 +110,18 @@ export function ProjectView() {
setIsAILoading(loading);
};
// Handle message sent - increment push reminder counter
const handleMessageSent = useCallback(() => {
pushReminder.incrementMessages();
}, [pushReminder]);
// Watch for when we should show the reminder (after state updates)
useEffect(() => {
if (pushReminder.shouldShowReminder && !isPushReminderOpen) {
setIsPushReminderOpen(true);
}
}, [pushReminder.shouldShowReminder, isPushReminderOpen]);
// Handle first user interaction to enable audio context
const handleFirstInteraction = () => {
// This will be handled automatically by the useKeepAlive hook
@@ -165,6 +182,7 @@ export function ProjectView() {
<div className="flex items-center gap-2">
{project ? (
<>
<PushWarningButton projectId={project.id} className="h-8" />
<StarButton
projectId={project.id}
projectName={project.name}
@@ -227,6 +245,7 @@ export function ProjectView() {
onNewChat={handleNewChat}
onFirstInteraction={handleFirstInteraction}
onLoadingChange={handleAILoadingChange}
onMessageSent={handleMessageSent}
isLoading={isAILoading}
isBuildLoading={build.isPending}
consoleError={consoleError}
@@ -307,6 +326,17 @@ export function ProjectView() {
onProjectDeleted={handleProjectDeleted}
/>
)}
{/* Push Reminder Dialog */}
{project && (
<PushReminderDialog
projectId={project.id}
open={isPushReminderOpen}
onOpenChange={setIsPushReminderOpen}
onDisableReminders={() => pushReminder.setEnabled(false)}
onDismiss={pushReminder.resetReminder}
/>
)}
</div>
);
}
@@ -374,6 +404,7 @@ export function ProjectView() {
<div className="flex items-center gap-2">
{project ? (
<>
<PushWarningButton projectId={project.id} className="h-8" />
<StarButton
projectId={project.id}
projectName={project.name}
@@ -408,6 +439,7 @@ export function ProjectView() {
onNewChat={handleNewChat}
onFirstInteraction={handleFirstInteraction}
onLoadingChange={handleAILoadingChange}
onMessageSent={handleMessageSent}
isLoading={isAILoading}
isBuildLoading={build.isPending}
consoleError={consoleError}
@@ -461,6 +493,17 @@ export function ProjectView() {
onProjectDeleted={handleProjectDeleted}
/>
)}
{/* Push Reminder Dialog */}
{project && (
<PushReminderDialog
projectId={project.id}
open={isPushReminderOpen}
onOpenChange={setIsPushReminderOpen}
onDisableReminders={() => pushReminder.setEnabled(false)}
onDismiss={pushReminder.resetReminder}
/>
)}
</div>
);
}