mirror of
https://github.com/HKUDS/DeepTutor.git
synced 2026-12-03 09:20:08 +08:00
Adapted the migration foundation from PR #1384 while preserving current workspace, caption and turn-admission safeguards. Co-authored-by: XZH <cto@xzh.ai>
20 lines
710 B
TypeScript
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>
|
|
}
|