Notification -> click on it redirect to the project

This commit is contained in:
Bruno Fargnoli 2026-07-03 19:35:33 +02:00
parent d5e4f73dc2
commit 453797b6de
9 changed files with 233 additions and 19 deletions

31
.claude/settings.json Normal file
View file

@ -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)"
]
}
}

View file

@ -297,6 +297,30 @@
color: var(--on-surface-variant); 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 { .header__notifications-card--success {
background: linear-gradient(145deg, rgba(49, 93, 101, 0.28), rgba(18, 29, 34, 0.65)); background: linear-gradient(145deg, rgba(49, 93, 101, 0.28), rgba(18, 29, 34, 0.65));
} }

View file

@ -1,5 +1,5 @@
import { useEffect, useRef, useState } from 'react' 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 { useNotifications } from '../context/NotificationContext'
import './Header.css' import './Header.css'
import localVersionInfo from '../../version.json' 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' }) { export default function Header({ showSearch = false, showCreateNew = false, onSettingsClick, title = '', centerTitle = false, searchValue = '', onSearchChange, searchPlaceholder = 'Search Assets' }) {
const location = useLocation() const location = useLocation()
const { notifications, clearNotifications } = useNotifications() const navigate = useNavigate()
const { notifications, clearNotifications, removeNotification } = useNotifications()
const [showNotifications, setShowNotifications] = useState(false) const [showNotifications, setShowNotifications] = useState(false)
const [isCheckingVersion, setIsCheckingVersion] = useState(true) const [isCheckingVersion, setIsCheckingVersion] = useState(true)
const [versionCheckError, setVersionCheckError] = useState('') const [versionCheckError, setVersionCheckError] = useState('')
@ -113,6 +114,18 @@ export default function Header({ showSearch = false, showCreateNew = false, onSe
} }
}, [showNotifications]) }, [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 ( return (
<header className="header" id="main-header"> <header className="header" id="main-header">
<div className="header__left"> <div className="header__left">
@ -211,20 +224,38 @@ export default function Header({ showSearch = false, showCreateNew = false, onSe
</div> </div>
</div> </div>
{notifications.map(notification => ( {notifications.map(notification => {
<div key={notification.id} className={`header__notifications-card ${getNotificationCardToneClass(notification.tone)}`}> const isClickable = Boolean(notification.projectId)
<span className="material-symbols-outlined">{getNotificationIcon(notification.tone)}</span> return (
<div> <div
<p className="header__notifications-card-title">{notification.title}</p> key={notification.id}
{notification.source && ( className={`header__notifications-card ${getNotificationCardToneClass(notification.tone)}${isClickable ? ' header__notifications-card--clickable' : ''}`}
<p className="header__notifications-card-text">{notification.source}</p> onClick={isClickable ? () => handleNotificationClick(notification) : undefined}
)} role={isClickable ? 'button' : undefined}
{notification.message && ( tabIndex={isClickable ? 0 : undefined}
<p className="header__notifications-card-text">{notification.message}</p> onKeyDown={isClickable ? (event) => {
)} if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
handleNotificationClick(notification)
}
} : undefined}
>
<span className="material-symbols-outlined">{getNotificationIcon(notification.tone)}</span>
<div>
<p className="header__notifications-card-title">{notification.title}</p>
{notification.source && (
<p className="header__notifications-card-text">{notification.source}</p>
)}
{notification.message && (
<p className="header__notifications-card-text">{notification.message}</p>
)}
{isClickable && (
<p className="header__notifications-card-hint">Click to open the card</p>
)}
</div>
</div> </div>
</div> )
))} })}
{isCheckingVersion && ( {isCheckingVersion && (
<div className="header__notifications-card header__notifications-card--neutral"> <div className="header__notifications-card header__notifications-card--neutral">

View file

@ -31,6 +31,10 @@ export function NotificationProvider({ children }) {
message: String(notification.message || '').trim(), message: String(notification.message || '').trim(),
tone: normalizeTone(notification.tone), tone: normalizeTone(notification.tone),
source: String(notification.source || '').trim(), 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() createdAt: Date.now()
} }

View file

@ -106,6 +106,9 @@ export function WorkflowJobsProvider({ children }) {
const label = current?.label || result.label || 'Workflow' const label = current?.label || result.label || 'Workflow'
const projectName = current?.projectName || result.projectName || '' const projectName = current?.projectName || result.projectName || ''
const suffix = projectName ? ` — ${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) { if (current) {
store.set(id, { store.set(id, {
@ -124,14 +127,18 @@ export function WorkflowJobsProvider({ children }) {
title: 'Workflow completed', title: 'Workflow completed',
message: `${label}${suffix}`, message: `${label}${suffix}`,
source: 'ComfyUI', source: 'ComfyUI',
tone: 'success' tone: 'success',
projectId,
targetId
}) })
} else { } else {
addNotification({ addNotification({
title: 'Workflow failed', title: 'Workflow failed',
message: `${result.error || label}${suffix}`, message: `${result.error || label}${suffix}`,
source: 'ComfyUI', source: 'ComfyUI',
tone: 'error' tone: 'error',
projectId,
targetId
}) })
} }
}, [store, closeSubscription, addNotification]) }, [store, closeSubscription, addNotification])

View file

@ -1,4 +1,5 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { useLocation } from 'react-router-dom'
import { import {
addEdge, addEdge,
BaseEdge, BaseEdge,
@ -132,6 +133,7 @@ export default function GraphPage({ project }) {
} = useProjects() } = useProjects()
const { settings } = useSettings() const { settings } = useSettings()
const { addNotification } = useNotifications() const { addNotification } = useNotifications()
const location = useLocation()
const { jobs: workflowJobs, registerJob, completeJob, removeJobsForTarget } = useWorkflowJobs() const { jobs: workflowJobs, registerJob, completeJob, removeJobsForTarget } = useWorkflowJobs()
const [showSettings, setShowSettings] = useState(false) const [showSettings, setShowSettings] = useState(false)
@ -2680,6 +2682,13 @@ export default function GraphPage({ project }) {
return 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 hasAutoFitOnLoadRef.current = true
const fitWorkflow = () => { const fitWorkflow = () => {
@ -2701,7 +2710,58 @@ export default function GraphPage({ project }) {
window.cancelAnimationFrame(frameId) window.cancelAnimationFrame(frameId)
window.clearTimeout(timeoutId) 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 <ReactFlow>, 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 <ReactFlow> 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 showEmptyState = !loading && nodes.length === 0
const minimapNodeColor = useCallback((node) => { const minimapNodeColor = useCallback((node) => {

View file

@ -333,6 +333,26 @@
opacity: 0.45; 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 { .image-card__actions {
position: absolute; position: absolute;
top: 0.75rem; top: 0.75rem;

View file

@ -1,5 +1,5 @@
import { Fragment, useState, useEffect, useMemo, useRef, useCallback } from 'react' 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 { useProjects } from '../context/ProjectContext'
import { useSettings } from '../context/SettingsContext.shared' import { useSettings } from '../context/SettingsContext.shared'
import { useNotifications } from '../context/NotificationContext' import { useNotifications } from '../context/NotificationContext'
@ -57,6 +57,7 @@ const MESH_GEN_COLUMN_ID = 3
export default function KanbanPage() { export default function KanbanPage() {
const { projectId } = useParams() const { projectId } = useParams()
const navigate = useNavigate() const navigate = useNavigate()
const location = useLocation()
const { const {
getProject, getProject,
getProjectAssets, 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(() => { useEffect(() => {
const pendingFocus = pendingResultFocusRef.current const pendingFocus = pendingResultFocusRef.current

View file

@ -23,6 +23,16 @@ const PRESETS = [
] ]
const CHANGE_LOG_ENTRIES = [ 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', version: 'v1.2.1',
date: '2026-07-03', date: '2026-07-03',