Files
DeepTutor/web/components/workspaces/WorkspaceRuntimeBoundary.tsx
Bingxi Zhao (Frank) 8986c31580 feat(reading): complete Watching convergence with safe legacy migration (#1378)
Adapted the migration foundation from PR #1384 while preserving current workspace, caption and turn-admission safeguards.

Co-authored-by: XZH <cto@xzh.ai>
2026-10-08 02:48:50 +08:00

20 lines
710 B
TypeScript

'use client'
import { Fragment, useEffect, type ReactNode } from 'react'
import { useSearchParams } from 'next/navigation'
import { resetReadingTurnState } from '@/lib/reading-turn-state'
function ScopeLifetime({ children }: { children: ReactNode }) {
useEffect(() => () => {
resetReadingTurnState()
}, [])
return children
}
/** Reset content state even for query-only navigation and browser back/forward. */
export function WorkspaceRuntimeBoundary({ children }: { children: ReactNode }) {
const query = useSearchParams()
const workspaceId = query.get('dt_workspace') ?? query.get('workspace') ?? ''
return <Fragment key={workspaceId}><ScopeLifetime>{children}</ScopeLifetime></Fragment>
}