mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
The definitive slot model for the web client, replacing the first-generation
define/register two-step, ScopedSlots whitelist faces, and binding handles:
- 'root' is the only a-priori slot (SlotsService built-in); the shell renders
exactly ctx.slots.renderSlot('root', {}).
- register is the single API: children = slot declaration + render
authorization + runtime spec in one options object; misconfiguration fails
loud at load (duplicate declaration, undeclared contribution, one store
handle under two scopes).
- Component props arrive in four auto-derived shares: PropsRuntime<K>
(owner params + session/global standard kits via declare-merge),
PropsRenderSlots<S>, PropsStore<H>, and the inject business face.
sessionId is framework-supplied; hooks are framework-made only.
- Framework store seat: defineStore factories declare schema/actions/persist;
read = useStore, write = baked actions only; store scope derives from the
mounting entry; per-session persist keys and clearPersisted lifecycle.
- inject factories read the apply closure's own ctx (binding handles retired;
root-ctx back door closed); SessionProvider is self-wired render-prop.
- Rendering sits behind the SlotRenderer install seam; runtime stays
React-free; ownership ledger keyed to the single entry axis closes the
stale-authority window (StaleAuthorizationError probes).
Docs: the slot type-chain note is refreshed in place as the slot system
standard RFC (bilingual pair re-recorded); the web client architecture RFC
defers its slot sections there; packages/client/AGENTS.md gains the slot and
props discipline; gui-testing/web-styling notes drop missions/ references.
Tests: suites rewritten to the standard (props fed directly, real store
engines via createXXXStore().create(), no render machinery); load-time
negative samples for declaration/authorization/store conflicts; verified by
real-host playwright run (three columns, empty state, collapse, keyed session
remount, cross-slot selection sharing).
docs(ui-sidebar): point contract reference at the committed slot standard RFC
missions/ is workspace-local and never committed; the README must not cite it.
77 lines
2.9 KiB
TypeScript
77 lines
2.9 KiB
TypeScript
// @vitest-environment jsdom
|
|
/**
|
|
* AppRoot boot-gate smoke: loading page until the settled signal flips (status
|
|
* alone never opens the gate), fail-loud plugin list, one-pass switch to the
|
|
* real UI. The full browser chain (real loader + bundles) is the e2e's job;
|
|
* this pins the shell-owned gate semantics.
|
|
*/
|
|
import { afterEach, describe, expect, it } from 'vitest'
|
|
import { act, cleanup, render } from '@testing-library/react'
|
|
|
|
afterEach(cleanup)
|
|
// createSnapshotStore left the public face (framework-internal engine); the
|
|
// status-store stub reaches it through the same ./store channel runtime uses.
|
|
import { createSnapshotStore } from '@deepseek-ai/dsh-client-web-react/store'
|
|
import type { ObservableSnapshot } from '@deepseek-ai/dsh-client-web-react'
|
|
import type { LoaderStatus } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import { AppRoot } from '@deepseek-ai/dsh-client-web/src/AppRoot.tsx'
|
|
|
|
function signal(): ObservableSnapshot<boolean> & { flip: () => void } {
|
|
let value = false
|
|
const listeners = new Set<() => void>()
|
|
return {
|
|
getSnapshot: () => value,
|
|
subscribe: (fn) => { listeners.add(fn); return () => { listeners.delete(fn) } },
|
|
flip: () => { value = true; for (const fn of [...listeners]) fn() },
|
|
}
|
|
}
|
|
|
|
function mount() {
|
|
const settled = signal()
|
|
const status = createSnapshotStore<LoaderStatus>({})
|
|
let renders = 0
|
|
const utils = render(
|
|
<AppRoot
|
|
settled={settled}
|
|
status={status}
|
|
renderApp={() => { renders += 1; return <div data-testid="real-ui" /> }}
|
|
/>,
|
|
)
|
|
return { settled, status, counts: () => renders, ...utils }
|
|
}
|
|
|
|
describe('AppRoot', () => {
|
|
it('shows the loading page and never calls renderApp before settled', () => {
|
|
const { queryByTestId, counts, getByText } = mount()
|
|
expect(getByText('HARNESS')).toBeTruthy()
|
|
expect(queryByTestId('real-ui')).toBeNull()
|
|
expect(counts()).toBe(0)
|
|
})
|
|
|
|
it('all-active status alone does not open the gate (settled signal is the only key)', () => {
|
|
const { status, queryByTestId } = mount()
|
|
act(() => {
|
|
status.update((d) => { d['a'] = 'active'; d['b'] = 'active' })
|
|
})
|
|
expect(queryByTestId('real-ui')).toBeNull()
|
|
})
|
|
|
|
it('lists failed plugins and stays on the loading page', () => {
|
|
const { status, getByText, queryByTestId } = mount()
|
|
act(() => {
|
|
status.update((d) => { d['@deepseek-ai/dsh-client-ui-theme'] = 'failed'; d['ok'] = 'active' })
|
|
})
|
|
expect(getByText('Failed to load plugins')).toBeTruthy()
|
|
expect(getByText('@deepseek-ai/dsh-client-ui-theme')).toBeTruthy()
|
|
expect(queryByTestId('real-ui')).toBeNull()
|
|
})
|
|
|
|
it('flipping settled switches to the real UI in one pass', () => {
|
|
const { settled, getByTestId, queryByText, counts } = mount()
|
|
act(() => { settled.flip() })
|
|
expect(getByTestId('real-ui')).toBeTruthy()
|
|
expect(queryByText('HARNESS')).toBeNull()
|
|
expect(counts()).toBe(1)
|
|
})
|
|
})
|