2026-07-19 21:17:57 +08:00
|
|
|
/**
|
2026-07-23 21:55:39 +08:00
|
|
|
* Real-UI assembly closure, invoked by the app-shell plugin once its inject
|
|
|
|
|
* set is active: the whole layout tree hangs off the built-in 'root' slot
|
|
|
|
|
* (ui-layout registers AppFrame there and renders the child slots
|
|
|
|
|
* internally) — the shell's render is the one ctx-level renderSlot call in
|
|
|
|
|
* the program.
|
2026-07-19 21:17:57 +08:00
|
|
|
*/
|
|
|
|
|
import type { ReactNode } from 'react'
|
|
|
|
|
import type { Context } from 'cordis'
|
2026-07-23 18:39:48 +08:00
|
|
|
import { bindSnapshotSelector } from '@deepseek-ai/dsh-client-web-react'
|
2026-07-22 23:43:53 +08:00
|
|
|
import { DocumentTitle } from './DocumentTitle.tsx'
|
2026-07-23 01:40:30 +08:00
|
|
|
// Type-only: pulls the runtime's SlotMap declaration merge (the 'root' key) into this program.
|
|
|
|
|
import type {} from '@deepseek-ai/dsh-client-runtime/client'
|
2026-07-19 21:17:57 +08:00
|
|
|
|
2026-07-23 21:55:39 +08:00
|
|
|
/** Assembly inputs: the active app-shell plugin ctx (slots/sessions/layout services provided). */
|
2026-07-19 21:17:57 +08:00
|
|
|
export interface AssemblyDeps {
|
2026-07-23 21:55:39 +08:00
|
|
|
/** Client context with the assembly's inject set active. */
|
2026-07-19 21:17:57 +08:00
|
|
|
ctx: Context
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-07-23 21:55:39 +08:00
|
|
|
* Build the renderApp factory the app-shell plugin provides to AppRoot.
|
2026-07-19 21:17:57 +08:00
|
|
|
* @param deps - assembly inputs.
|
|
|
|
|
* @returns factory producing the real UI tree (called once per AppRoot render after settled).
|
|
|
|
|
*/
|
|
|
|
|
export function buildRenderApp(deps: AssemblyDeps): () => ReactNode {
|
|
|
|
|
const { ctx } = deps
|
2026-07-27 21:49:40 +08:00
|
|
|
const sessions = ctx.get('sessions')
|
2026-07-19 21:17:57 +08:00
|
|
|
if (sessions === undefined) throw new Error('shell assembly: sessions service unavailable')
|
2026-07-23 18:39:48 +08:00
|
|
|
const useSessions = bindSnapshotSelector(sessions.list)
|
2026-07-22 23:43:53 +08:00
|
|
|
const SessionDocumentTitle = (): ReactNode => {
|
2026-07-23 18:39:48 +08:00
|
|
|
const title = useSessions((state) => {
|
|
|
|
|
const id = state.current
|
|
|
|
|
return id === undefined ? undefined : state.byId[id]?.title
|
|
|
|
|
})
|
2026-07-22 23:43:53 +08:00
|
|
|
return <DocumentTitle {...title === undefined ? {} : { title }} />
|
|
|
|
|
}
|
2026-07-19 21:17:57 +08:00
|
|
|
return () => (
|
2026-07-23 18:39:48 +08:00
|
|
|
<>
|
2026-07-22 23:43:53 +08:00
|
|
|
<SessionDocumentTitle />
|
2026-07-23 18:39:48 +08:00
|
|
|
{ctx.slots.renderSlot('root', {})}
|
|
|
|
|
</>
|
2026-07-19 21:17:57 +08:00
|
|
|
)
|
|
|
|
|
}
|