mirror of
https://github.com/deepseek-ai/deepseek-harness
synced 2026-08-15 21:04:50 +00:00
The data layer no longer depends on the React glue package, and business plugins no longer depend on web-react at all: - The store engine (zustand vanilla + immer + persist + dev freeze), defineStore, and shallowEqual move to @deepseek-ai/dsh-client-runtime, exported from the ./client main entry — no ./store subpath survives on either package (the web-react one is deleted, none is opened on runtime). - Store products are bare snapshot sources: useSelector leaves SnapshotStore/StoreInstance and Session; every hook is composed at the binding site in web-react's renderer (per-source cached uSES binding). The SlotRendererHost sessions face carries bare observables only. - SessionProvider becomes a standard-kit seat: an entry whose children declare a session-scope slot receives the framework component as a prop, retiring the last value import of web-react from plugin packages. UseSession and the session-area types now live in ui-slots. - web-react shrinks to the shell-only React glue (renderer, providers, uSES bridge); zustand/immer belong to runtime alone; the module-table seed and tsdown externals drop the web-react/store seat. - NODE_ENV replacement is defined once in the shared tsdown client preset (browser bundles inline the engine and lost vite's define); the 3-line process.env typecheck shim moves to runtime with the engine. - Stray tsc artifacts (.js/.d.ts/.d.ts.map beside sources under src/) swept repo-wide; they shadow real sources under vitest resolution. Verified: both aggregate typecheck programs at zero; 604 client tests green; repo-wide grep for web-react/store at zero; real-host playwright run 7/7 including persist round-trip. ci: fix test/docs
76 lines
2.8 KiB
TypeScript
76 lines
2.8 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)
|
|
// The snapshot-store engine lives with runtime now; the status-store stub
|
|
// uses the same channel production code does.
|
|
import { createSnapshotStore, type ObservableSnapshot } from '@deepseek-ai/dsh-client-runtime/client'
|
|
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)
|
|
})
|
|
})
|