Hand fixes for the findings --fix cannot touch, mirroring the fixes already applied on the fe-docs feature branch (same file, same shape) so its eventual rebase resolves cleanly: - restore the return the no-confusing-void-expression autofix ate in useAbsentSnapshot (typed S | undefined; hook call kept for hook-order stability, undefined returned explicitly); - re-type DOM queries the no-unnecessary-type-assertion autofix broke: getByRole<HTMLButtonElement>(...) generics instead of the removed as-casts (the eslint program and the client tsconfig aggregate disagree about these casts; the generic form satisfies both); - justified eslint-disable for the deliberate legacy paths: keyCode 229 IME-composition detection, execCommand clipboard fallbacks, lib.dom clipboard optionality, and the any-typed Reflect.get/this probes in test fakes; - drop the dead react/no-danger directive (eslint-plugin-react is not loaded, so the rule never applied) keeping its shiki rationale; - delete the tautological 'Z' comparison and the renameTarget null check already implied by renameBlocked; - css-module non-null assertions replaced by type widening (Button className, TAG_CLASS Record) per the established pattern; - misc: max-len comment wraps, void generic drop in the deferred test helper, unused type imports, floating selectWorkspace promises voided, member-delimiter newlines in inline type literals.
45 lines
1.7 KiB
TypeScript
45 lines
1.7 KiB
TypeScript
/**
|
|
* 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.
|
|
*/
|
|
import type { ReactNode } from 'react'
|
|
import type { Context } from 'cordis'
|
|
import { bindSnapshotSelector } from '@deepseek-ai/dsh-client-web-react'
|
|
import { DocumentTitle } from './DocumentTitle.tsx'
|
|
// Type-only: pulls the runtime's SlotMap declaration merge (the 'root' key) into this program.
|
|
import type {} from '@deepseek-ai/dsh-client-runtime/client'
|
|
|
|
/** Assembly inputs: the active app-shell plugin ctx (slots/sessions/layout services provided). */
|
|
export interface AssemblyDeps {
|
|
/** Client context with the assembly's inject set active. */
|
|
ctx: Context
|
|
}
|
|
|
|
/**
|
|
* Build the renderApp factory the app-shell plugin provides to AppRoot.
|
|
* @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
|
|
const sessions = ctx.get('sessions')
|
|
if (sessions === undefined) throw new Error('shell assembly: sessions service unavailable')
|
|
const useSessions = bindSnapshotSelector(sessions.list)
|
|
const SessionDocumentTitle = (): ReactNode => {
|
|
const title = useSessions((state) => {
|
|
const id = state.current
|
|
return id === undefined ? undefined : state.byId[id]?.title
|
|
})
|
|
return <DocumentTitle {...title === undefined ? {} : { title }} />
|
|
}
|
|
return () => (
|
|
<>
|
|
<SessionDocumentTitle />
|
|
{ctx.slots.renderSlot('root', {})}
|
|
</>
|
|
)
|
|
}
|