mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 08:37:22 +00:00
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
This commit is contained in:
1 parent
e116f7e9ec
commit
5de01c6130
7 files changed
+506
-1
No files matched your search
@@ -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,16 @@ export function ProjectView() {
|
||||
setIsAILoading(loading);
|
||||
};
|
||||
|
||||
// Handle message sent - increment push reminder counter
|
||||
const handleMessageSent = useCallback(() => {
|
||||
pushReminder.incrementMessages();
|
||||
|
||||
// Check if we should show the reminder
|
||||
if (pushReminder.shouldShowReminder) {
|
||||
setIsPushReminderOpen(true);
|
||||
}
|
||||
}, [pushReminder]);
|
||||
|
||||
// Handle first user interaction to enable audio context
|
||||
const handleFirstInteraction = () => {
|
||||
// This will be handled automatically by the useKeepAlive hook
|
||||
@@ -165,6 +180,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 +243,7 @@ export function ProjectView() {
|
||||
onNewChat={handleNewChat}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
onLoadingChange={handleAILoadingChange}
|
||||
onMessageSent={handleMessageSent}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
consoleError={consoleError}
|
||||
@@ -307,6 +324,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 +402,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 +437,7 @@ export function ProjectView() {
|
||||
onNewChat={handleNewChat}
|
||||
onFirstInteraction={handleFirstInteraction}
|
||||
onLoadingChange={handleAILoadingChange}
|
||||
onMessageSent={handleMessageSent}
|
||||
isLoading={isAILoading}
|
||||
isBuildLoading={build.isPending}
|
||||
consoleError={consoleError}
|
||||
@@ -461,6 +491,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