Load/render workspace alignment (#182)
* docs: plan load render workspace alignment * fix: normalize workspace status hydration * fix: avoid duplicate backlog hydration load * refactor: use sprint store active story * refactor: migrate solo to workspace store * chore: stabilize verification ignores
This commit is contained in:
parent
98ee05d458
commit
3b5cee823c
28 changed files with 1845 additions and 577 deletions
55
components/solo/solo-hydration-wrapper.tsx
Normal file
55
components/solo/solo-hydration-wrapper.tsx
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect, useRef } from 'react'
|
||||
import { useSoloStore } from '@/stores/solo-store'
|
||||
import type { SoloWorkspaceSnapshot } from '@/stores/solo-workspace/types'
|
||||
|
||||
interface SoloHydrationWrapperProps {
|
||||
initialData: SoloWorkspaceSnapshot
|
||||
children: React.ReactNode
|
||||
}
|
||||
|
||||
function fingerprint(data: SoloWorkspaceSnapshot): string {
|
||||
const taskPart = data.tasks
|
||||
.map((task) => [
|
||||
task.id,
|
||||
task.status,
|
||||
task.sort_order,
|
||||
task.title,
|
||||
task.implementation_plan ?? '',
|
||||
task.verify_only ? '1' : '0',
|
||||
task.verify_required,
|
||||
task.story_id,
|
||||
task.story_title,
|
||||
task.story_code ?? '',
|
||||
].join(':'))
|
||||
.join(',')
|
||||
const unassignedPart = data.unassignedStories
|
||||
.map((story) => [
|
||||
story.id,
|
||||
story.title,
|
||||
story.code ?? '',
|
||||
story.tasks.map((task) => `${task.id}:${task.status}:${task.title}`).join('|'),
|
||||
].join(':'))
|
||||
.join(',')
|
||||
return [
|
||||
data.product.id,
|
||||
data.sprint.id,
|
||||
data.activeUserId,
|
||||
taskPart,
|
||||
unassignedPart,
|
||||
].join('||')
|
||||
}
|
||||
|
||||
export function SoloHydrationWrapper({ initialData, children }: SoloHydrationWrapperProps) {
|
||||
const lastFingerprint = useRef<string>('')
|
||||
|
||||
useEffect(() => {
|
||||
const fp = fingerprint(initialData)
|
||||
if (fp === lastFingerprint.current) return
|
||||
lastFingerprint.current = fp
|
||||
useSoloStore.getState().hydrateSnapshot(initialData)
|
||||
}, [initialData])
|
||||
|
||||
return <>{children}</>
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue