mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-03 07:57:22 +00:00
Compare commits
5
Commits
v9.16.2
...
push-reminder
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
262414257a | ||
|
|
c25517a58f | ||
|
|
a7164c0292 | ||
|
|
66a37ec92c | ||
|
|
5de01c6130 |
No files matched your search
@@ -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 > 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}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -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(() => {
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
@@ -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",
|
||||
|
||||
@@ -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">
|
||||
|
||||
@@ -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>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user