fix: stabilize maintenance flow run/resume and procedural scrolling
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the navigation path for starting or resuming a tree/session.
|
||||
* Get the default navigation path for starting a flow from the library.
|
||||
*/
|
||||
export function getTreeNavigatePath(
|
||||
treeId: string,
|
||||
@@ -20,6 +20,20 @@ export function getTreeNavigatePath(
|
||||
return `/trees/${treeId}/navigate`
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the navigation path for resuming an existing session.
|
||||
* Maintenance and procedural sessions both resume in procedural navigation.
|
||||
*/
|
||||
export function getSessionResumePath(
|
||||
treeId: string,
|
||||
treeType?: string
|
||||
): string {
|
||||
if (treeType === 'procedural' || treeType === 'maintenance') {
|
||||
return `/flows/${treeId}/navigate`
|
||||
}
|
||||
return `/trees/${treeId}/navigate`
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the editor path for a tree.
|
||||
*/
|
||||
|
||||
@@ -23,6 +23,11 @@ export default function MaintenanceFlowDetailPage() {
|
||||
const load = async () => {
|
||||
try {
|
||||
const treeData = await treesApi.get(id)
|
||||
if (treeData.tree_type !== 'maintenance') {
|
||||
toast.error('This page is only for maintenance flows')
|
||||
navigate('/trees?type=maintenance')
|
||||
return
|
||||
}
|
||||
setTree(treeData)
|
||||
|
||||
// Load recent sessions for this tree
|
||||
|
||||
@@ -97,7 +97,7 @@ export function ProceduralNavigationPage() {
|
||||
setIsLoading(true)
|
||||
try {
|
||||
const treeData = await treesApi.get(id)
|
||||
if (treeData.tree_type !== 'procedural') {
|
||||
if (treeData.tree_type !== 'procedural' && treeData.tree_type !== 'maintenance') {
|
||||
navigate(`/trees/${id}/navigate`, { replace: true })
|
||||
return
|
||||
}
|
||||
@@ -116,7 +116,7 @@ export function ProceduralNavigationPage() {
|
||||
await startSession(id, {})
|
||||
}
|
||||
} catch {
|
||||
toast.error('Failed to load procedure')
|
||||
toast.error('Failed to load flow')
|
||||
navigate('/my-trees')
|
||||
} finally {
|
||||
setIsLoading(false)
|
||||
@@ -340,7 +340,7 @@ export function ProceduralNavigationPage() {
|
||||
const currentStepState = currentStep ? stepStates.get(currentStep.id) : undefined
|
||||
|
||||
return (
|
||||
<div className="flex h-full flex-col">
|
||||
<div className="flex h-full min-h-0 flex-col">
|
||||
{/* Top bar */}
|
||||
<div className="border-b border-border px-4 py-3 sm:px-6">
|
||||
<div className="flex items-center justify-between gap-4">
|
||||
@@ -370,8 +370,8 @@ export function ProceduralNavigationPage() {
|
||||
{/* Left sidebar - step checklist */}
|
||||
<div
|
||||
className={cn(
|
||||
'border-r border-border bg-card transition-all duration-200',
|
||||
sidebarOpen ? 'w-72 p-3' : 'w-0 overflow-hidden p-0'
|
||||
'min-h-0 border-r border-border bg-card transition-all duration-200',
|
||||
sidebarOpen ? 'w-72 overflow-y-auto p-3' : 'w-0 overflow-hidden p-0'
|
||||
)}
|
||||
>
|
||||
{sidebarOpen && (
|
||||
|
||||
@@ -8,7 +8,7 @@ import { SessionFilters } from '@/components/session/SessionFilters'
|
||||
import type { SessionFilterState } from '@/components/session/SessionFilters'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { toast } from '@/lib/toast'
|
||||
import { getTreeNavigatePath } from '@/lib/routing'
|
||||
import { getSessionResumePath } from '@/lib/routing'
|
||||
|
||||
export function SessionHistoryPage() {
|
||||
const navigate = useNavigate()
|
||||
@@ -285,7 +285,7 @@ export function SessionHistoryPage() {
|
||||
</button>
|
||||
{!session.completed_at && (
|
||||
<button
|
||||
onClick={() => navigate(getTreeNavigatePath(session.tree_id, session.tree_snapshot?.tree_type), { state: { sessionId: session.id } })}
|
||||
onClick={() => navigate(getSessionResumePath(session.tree_id, session.tree_snapshot?.tree_type), { state: { sessionId: session.id } })}
|
||||
className={cn(
|
||||
'rounded-md bg-gradient-brand px-3 py-2 text-sm font-medium text-white shadow-lg shadow-primary/20',
|
||||
'hover:opacity-90'
|
||||
|
||||
@@ -14,7 +14,7 @@ import { TreeTableView } from '@/components/library/TreeTableView'
|
||||
import { ViewToggle } from '@/components/library/ViewToggle'
|
||||
import { SortDropdown } from '@/components/library/SortDropdown'
|
||||
import { cn, safeGetItem } from '@/lib/utils'
|
||||
import { getTreeNavigatePath } from '@/lib/routing'
|
||||
import { getSessionResumePath } from '@/lib/routing'
|
||||
import { usePermissions } from '@/hooks/usePermissions'
|
||||
import { useUserPreferencesStore } from '@/store/userPreferencesStore'
|
||||
import { toast } from '@/lib/toast'
|
||||
@@ -425,7 +425,7 @@ export function TreeLibraryPage() {
|
||||
</div>
|
||||
<div className="flex items-center gap-2">
|
||||
<button
|
||||
onClick={() => navigate(getTreeNavigatePath(s.tree_id, s.tree_snapshot?.tree_type), { state: { sessionId: s.id } })}
|
||||
onClick={() => navigate(getSessionResumePath(s.tree_id, s.tree_snapshot?.tree_type), { state: { sessionId: s.id } })}
|
||||
className="flex items-center gap-1.5 rounded-md bg-gradient-brand px-3 py-1.5 text-sm font-medium text-white shadow-lg shadow-primary/20 hover:opacity-90"
|
||||
>
|
||||
<Play className="h-3.5 w-3.5" />
|
||||
|
||||
Reference in New Issue
Block a user