mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-05 16:23:36 +00:00
Revert "Don't display toast on own chat page"
This reverts commit 00b476085d.
This commit is contained in:
1 file changed
+6
-7
@@ -1,7 +1,7 @@
|
||||
import { useEffect, useRef } from 'react';
|
||||
import { useSessionManager } from '@/hooks/useSessionManager';
|
||||
import { useToast } from '@/hooks/useToast';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { useNavigate, useLocation } from 'react-router-dom';
|
||||
|
||||
/**
|
||||
* Global component that monitors AI sessions and shows notifications
|
||||
@@ -11,6 +11,7 @@ export function SessionMonitor() {
|
||||
const sessionManager = useSessionManager();
|
||||
const { toast } = useToast();
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const previousLoadingStates = useRef<Map<string, boolean>>(new Map());
|
||||
|
||||
useEffect(() => {
|
||||
@@ -24,20 +25,18 @@ export function SessionMonitor() {
|
||||
if (!session) return;
|
||||
|
||||
// Check if user is currently viewing this project or chat
|
||||
// Use window.location.pathname to get the current path at the time the event fires
|
||||
const pathParts = window.location.pathname.split('/');
|
||||
const currentId = pathParts[2] ? decodeURIComponent(pathParts[2]) : ''; // /project/{projectId} or /chat/{chatId}
|
||||
const pathParts = location.pathname.split('/');
|
||||
const currentId = pathParts[2]; // /project/{projectId} or /chat/{chatId}
|
||||
const isCurrentView = session.projectId === currentId;
|
||||
|
||||
// Only show notification if user is not currently viewing this project or chat
|
||||
if (!isCurrentView) {
|
||||
const viewPath = session.isChat ? `/chat/${session.projectId}` : `/project/${session.projectId}`;
|
||||
toast({
|
||||
title: "AI Session Complete",
|
||||
description: `Finished working on ${session.projectId}`,
|
||||
action: (
|
||||
<button
|
||||
onClick={() => navigate(viewPath)}
|
||||
onClick={() => navigate(`/project/${session.projectId}`)}
|
||||
className="inline-flex h-8 shrink-0 items-center justify-center rounded-md border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus-visible:ring-destructive"
|
||||
>
|
||||
View
|
||||
@@ -74,7 +73,7 @@ export function SessionMonitor() {
|
||||
sessionManager.off('sessionCreated', handleSessionCreated);
|
||||
sessionManager.off('sessionDeleted', handleSessionDeleted);
|
||||
};
|
||||
}, [sessionManager, toast, navigate]);
|
||||
}, [sessionManager, toast, navigate, location.pathname]);
|
||||
|
||||
// This component doesn't render anything
|
||||
return null;
|
||||
|
||||
Reference in new issue
Block a user