From 453797b6de5e9c066861b7e2d031aefce76c9513 Mon Sep 17 00:00:00 2001 From: Bruno Fargnoli Date: Fri, 3 Jul 2026 19:35:33 +0200 Subject: [PATCH] Notification -> click on it redirect to the project --- .claude/settings.json | 31 +++++++++++++++ src/components/Header.css | 24 +++++++++++ src/components/Header.jsx | 61 +++++++++++++++++++++------- src/context/NotificationContext.jsx | 4 ++ src/context/WorkflowJobsContext.jsx | 11 ++++- src/pages/GraphPage.jsx | 62 ++++++++++++++++++++++++++++- src/pages/KanbanPage.css | 20 ++++++++++ src/pages/KanbanPage.jsx | 29 +++++++++++++- src/pages/ProjectsPage.jsx | 10 +++++ 9 files changed, 233 insertions(+), 19 deletions(-) create mode 100644 .claude/settings.json diff --git a/.claude/settings.json b/.claude/settings.json new file mode 100644 index 0000000..39af2cc --- /dev/null +++ b/.claude/settings.json @@ -0,0 +1,31 @@ +{ + "permissions": { + "allow": [ + "WebSearch", + "WebFetch(domain:citeseerx.ist.psu.edu)", + "WebFetch(domain:arxiv.org)", + "WebFetch(domain:tympanus.net)", + "WebFetch(domain:www.gcc.tu-darmstadt.de)", + "WebFetch(domain:ndotl.wordpress.com)", + "WebFetch(domain:raw.githubusercontent.com)", + "WebFetch(domain:github.com)", + "WebFetch(domain:learnopengl.com)", + "WebFetch(domain:www.cs.jhu.edu)", + "WebFetch(domain:webglfundamentals.org)", + "WebFetch(domain:www.semanticscholar.org)", + "WebFetch(domain:developer.download.nvidia.com)", + "WebFetch(domain:discourse.threejs.org)", + "WebFetch(domain:www.pauldebevec.com)", + "WebFetch(domain:deepwiki.com)", + "WebFetch(domain:ar5iv.labs.arxiv.org)", + "WebFetch(domain:en.m.wikipedia.org)", + "WebFetch(domain:www.yumpu.com)", + "WebFetch(domain:www.creativeshrimp.com)", + "WebFetch(domain:en.wikipedia.org)", + "WebFetch(domain:webgpufundamentals.org)", + "WebFetch(domain:wiki.polycount.com)", + "WebFetch(domain:nvlabs.github.io)", + "WebFetch(domain:blog.maximeheckel.com)" + ] + } +} diff --git a/src/components/Header.css b/src/components/Header.css index 9a7c817..776eedb 100644 --- a/src/components/Header.css +++ b/src/components/Header.css @@ -297,6 +297,30 @@ color: var(--on-surface-variant); } +.header__notifications-card-hint { + margin: 0.35rem 0 0 0; + font-size: 0.72rem; + font-weight: 600; + color: var(--primary, #9cc3ff); + opacity: 0.85; +} + +.header__notifications-card--clickable { + cursor: pointer; + transition: transform 0.12s ease, border-color 0.12s ease, filter 0.12s ease; +} + +.header__notifications-card--clickable:hover { + transform: translateY(-1px); + border-color: rgba(255, 255, 255, 0.22); + filter: brightness(1.08); +} + +.header__notifications-card--clickable:focus-visible { + outline: 2px solid var(--primary, #9cc3ff); + outline-offset: 2px; +} + .header__notifications-card--success { background: linear-gradient(145deg, rgba(49, 93, 101, 0.28), rgba(18, 29, 34, 0.65)); } diff --git a/src/components/Header.jsx b/src/components/Header.jsx index 64b8441..75d2856 100644 --- a/src/components/Header.jsx +++ b/src/components/Header.jsx @@ -1,5 +1,5 @@ import { useEffect, useRef, useState } from 'react' -import { Link, useLocation } from 'react-router-dom' +import { Link, useLocation, useNavigate } from 'react-router-dom' import { useNotifications } from '../context/NotificationContext' import './Header.css' import localVersionInfo from '../../version.json' @@ -57,7 +57,8 @@ function getNotificationIcon(tone) { export default function Header({ showSearch = false, showCreateNew = false, onSettingsClick, title = '', centerTitle = false, searchValue = '', onSearchChange, searchPlaceholder = 'Search Assets' }) { const location = useLocation() - const { notifications, clearNotifications } = useNotifications() + const navigate = useNavigate() + const { notifications, clearNotifications, removeNotification } = useNotifications() const [showNotifications, setShowNotifications] = useState(false) const [isCheckingVersion, setIsCheckingVersion] = useState(true) const [versionCheckError, setVersionCheckError] = useState('') @@ -113,6 +114,18 @@ export default function Header({ showSearch = false, showCreateNew = false, onSe } }, [showNotifications]) + const handleNotificationClick = (notification) => { + if (!notification.projectId) return + // Dismiss the alert, close the panel, then deep-link to the project. The + // focus target travels in router state so the destination page can center + // (Graph) or scroll to (Kanban) the originating card once it has loaded. + removeNotification(notification.id) + setShowNotifications(false) + navigate(`/projects/${notification.projectId}`, { + state: { focusTargetId: notification.targetId ?? null, focusNonce: Date.now() } + }) + } + return (
@@ -211,20 +224,38 @@ export default function Header({ showSearch = false, showCreateNew = false, onSe
- {notifications.map(notification => ( -
- {getNotificationIcon(notification.tone)} -
-

{notification.title}

- {notification.source && ( -

{notification.source}

- )} - {notification.message && ( -

{notification.message}

- )} + {notifications.map(notification => { + const isClickable = Boolean(notification.projectId) + return ( +
handleNotificationClick(notification) : undefined} + role={isClickable ? 'button' : undefined} + tabIndex={isClickable ? 0 : undefined} + onKeyDown={isClickable ? (event) => { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault() + handleNotificationClick(notification) + } + } : undefined} + > + {getNotificationIcon(notification.tone)} +
+

{notification.title}

+ {notification.source && ( +

{notification.source}

+ )} + {notification.message && ( +

{notification.message}

+ )} + {isClickable && ( +

Click to open the card

+ )} +
-
- ))} + ) + })} {isCheckingVersion && (
diff --git a/src/context/NotificationContext.jsx b/src/context/NotificationContext.jsx index 004ec26..120fdd7 100644 --- a/src/context/NotificationContext.jsx +++ b/src/context/NotificationContext.jsx @@ -31,6 +31,10 @@ export function NotificationProvider({ children }) { message: String(notification.message || '').trim(), tone: normalizeTone(notification.tone), source: String(notification.source || '').trim(), + // Optional navigation metadata: lets the notifications panel deep-link + // back to the project and focus the originating card/graph node on click. + projectId: notification.projectId ?? null, + targetId: notification.targetId != null ? String(notification.targetId) : null, createdAt: Date.now() } diff --git a/src/context/WorkflowJobsContext.jsx b/src/context/WorkflowJobsContext.jsx index abc07a6..7da8622 100644 --- a/src/context/WorkflowJobsContext.jsx +++ b/src/context/WorkflowJobsContext.jsx @@ -106,6 +106,9 @@ export function WorkflowJobsProvider({ children }) { const label = current?.label || result.label || 'Workflow' const projectName = current?.projectName || result.projectName || '' const suffix = projectName ? ` — ${projectName}` : '' + // Carry the job's origin so the notification can deep-link back to the card. + const projectId = current?.projectId ?? result.projectId ?? null + const targetId = current?.targetId ?? (result.targetId != null ? String(result.targetId) : null) if (current) { store.set(id, { @@ -124,14 +127,18 @@ export function WorkflowJobsProvider({ children }) { title: 'Workflow completed', message: `${label}${suffix}`, source: 'ComfyUI', - tone: 'success' + tone: 'success', + projectId, + targetId }) } else { addNotification({ title: 'Workflow failed', message: `${result.error || label}${suffix}`, source: 'ComfyUI', - tone: 'error' + tone: 'error', + projectId, + targetId }) } }, [store, closeSubscription, addNotification]) diff --git a/src/pages/GraphPage.jsx b/src/pages/GraphPage.jsx index f64e34f..bbe1c8a 100644 --- a/src/pages/GraphPage.jsx +++ b/src/pages/GraphPage.jsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react' +import { useLocation } from 'react-router-dom' import { addEdge, BaseEdge, @@ -132,6 +133,7 @@ export default function GraphPage({ project }) { } = useProjects() const { settings } = useSettings() const { addNotification } = useNotifications() + const location = useLocation() const { jobs: workflowJobs, registerJob, completeJob, removeJobsForTarget } = useWorkflowJobs() const [showSettings, setShowSettings] = useState(false) @@ -2680,6 +2682,13 @@ export default function GraphPage({ project }) { return } + // If we arrived via a workflow notification, let the focus effect center on + // the target node instead of doing a generic fit-all-nodes on load. + if (location.state?.focusTargetId != null) { + hasAutoFitOnLoadRef.current = true + return + } + hasAutoFitOnLoadRef.current = true const fitWorkflow = () => { @@ -2701,7 +2710,58 @@ export default function GraphPage({ project }) { window.cancelAnimationFrame(frameId) window.clearTimeout(timeoutId) } - }, [edges.length, loading, nodes.length, project.id, reactFlowInstance]) + }, [edges.length, loading, nodes.length, project.id, reactFlowInstance, location.state?.focusTargetId]) + + // Deep-link focus: when the user clicks a workflow notification, the Header + // navigates here with a focus target in router state. Once the graph and its + // nodes are ready, center the viewport on the originating node. + // + // The guard is keyed on both the notification nonce AND the React Flow + // instance identity. React 18 StrictMode remounts , which + // re-applies defaultViewport (jumping back to the origin) and hands us a new + // instance; keying on the instance lets us re-center on that fresh instance + // instead of a one-shot guard leaving the viewport stuck at the origin. + const focusAppliedRef = useRef({ nonce: null, instance: null }) + useEffect(() => { + const focus = location.state + const focusTargetId = focus?.focusTargetId != null ? String(focus.focusTargetId) : null + if (!focusTargetId || !reactFlowInstance || nodes.length === 0) return + + // Guard on nonce + instance identity: StrictMode remounts and + // hands over a fresh instance, so re-center on the new one instead of a + // one-shot guard leaving the viewport stuck. + const applied = focusAppliedRef.current + if (applied.nonce === focus.focusNonce && applied.instance === reactFlowInstance) return + + const targetNode = nodes.find(node => String(node.id) === focusTargetId) + if (!targetNode) return // nodes still loading — retry once they update + + const instance = reactFlowInstance + // setCenter is deterministic: it uses the node's stored position, so it works + // even with onlyRenderVisibleElements (the target node may be off-screen and + // thus unmeasured, which breaks fitView). Estimate the centre from its size. + const width = targetNode.measured?.width ?? targetNode.width ?? 260 + const height = targetNode.measured?.height ?? targetNode.height ?? 140 + const centerX = targetNode.position.x + width / 2 + const centerY = targetNode.position.y + height / 2 + + const centerOnNode = () => { + focusAppliedRef.current = { nonce: focus.focusNonce, instance } + try { + instance.setCenter(centerX, centerY, { zoom: 1, duration: 500 }) + } catch { + // Instance was torn down (e.g. StrictMode remount) before this fired. + } + } + + const frameId = window.requestAnimationFrame(centerOnNode) + const timeoutIds = [260, 700].map(delay => window.setTimeout(centerOnNode, delay)) + + return () => { + window.cancelAnimationFrame(frameId) + timeoutIds.forEach(window.clearTimeout) + } + }, [location.key, location.state, nodes, reactFlowInstance]) const showEmptyState = !loading && nodes.length === 0 const minimapNodeColor = useCallback((node) => { diff --git a/src/pages/KanbanPage.css b/src/pages/KanbanPage.css index 1720e7f..472e4c1 100644 --- a/src/pages/KanbanPage.css +++ b/src/pages/KanbanPage.css @@ -333,6 +333,26 @@ opacity: 0.45; } +/* Brief highlight when a card is focused via a workflow notification. */ +.image-card--focus-flash { + animation: image-card-focus-flash 1.8s ease-out; +} + +@keyframes image-card-focus-flash { + 0% { + border-color: rgba(143, 245, 255, 0.9); + box-shadow: 0 0 0 3px rgba(143, 245, 255, 0.55), 0 12px 28px rgba(0, 0, 0, 0.35); + } + 70% { + border-color: rgba(143, 245, 255, 0.9); + box-shadow: 0 0 0 3px rgba(143, 245, 255, 0.3), 0 12px 28px rgba(0, 0, 0, 0.3); + } + 100% { + border-color: rgba(71, 72, 74, 0.05); + box-shadow: none; + } +} + .image-card__actions { position: absolute; top: 0.75rem; diff --git a/src/pages/KanbanPage.jsx b/src/pages/KanbanPage.jsx index 63777d0..a28e93c 100644 --- a/src/pages/KanbanPage.jsx +++ b/src/pages/KanbanPage.jsx @@ -1,5 +1,5 @@ import { Fragment, useState, useEffect, useMemo, useRef, useCallback } from 'react' -import { useParams, useNavigate } from 'react-router-dom' +import { useParams, useNavigate, useLocation } from 'react-router-dom' import { useProjects } from '../context/ProjectContext' import { useSettings } from '../context/SettingsContext.shared' import { useNotifications } from '../context/NotificationContext' @@ -57,6 +57,7 @@ const MESH_GEN_COLUMN_ID = 3 export default function KanbanPage() { const { projectId } = useParams() const navigate = useNavigate() + const location = useLocation() const { getProject, getProjectAssets, @@ -1383,6 +1384,32 @@ export default function KanbanPage() { ] } + // Deep-link focus: when the user clicks a workflow notification, the Header + // navigates here with a focus target in router state. Once the cards have + // loaded, scroll the originating card into view and flash it. + const handledFocusNonceRef = useRef(null) + useEffect(() => { + const focus = location.state + const focusTargetId = focus?.focusTargetId != null ? String(focus.focusTargetId) : null + if (!focusTargetId) return + if (handledFocusNonceRef.current === focus.focusNonce) return + + const targetCard = imageCards.find(card => String(card.id) === focusTargetId) + if (!targetCard) return // cards still loading — retry once imageCards updates + + handledFocusNonceRef.current = focus.focusNonce + + requestAnimationFrame(() => { + requestAnimationFrame(() => { + const el = document.getElementById(`image-card-${targetCard.id}`) + if (!el) return + el.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' }) + el.classList.add('image-card--focus-flash') + window.setTimeout(() => el.classList.remove('image-card--focus-flash'), 1800) + }) + }) + }, [location.key, location.state, imageCards]) + useEffect(() => { const pendingFocus = pendingResultFocusRef.current diff --git a/src/pages/ProjectsPage.jsx b/src/pages/ProjectsPage.jsx index 0398e19..f8505ca 100644 --- a/src/pages/ProjectsPage.jsx +++ b/src/pages/ProjectsPage.jsx @@ -23,6 +23,16 @@ const PRESETS = [ ] const CHANGE_LOG_ENTRIES = [ + { + version: 'v1.3.0', + date: '2026-07-05', + items: [ + 'Projects can be exported/imported', + 'DB has been restructured and simplified', + 'SetupWizard: Added Sam3.1 Segmentation + Gen Mesh with Hy2.1', + 'Notification: Click on it to be redirected to the project' + ], + }, { version: 'v1.2.1', date: '2026-07-03',