diff --git a/.agents/skills/dsh-session-projection/SKILL.md b/.agents/skills/dsh-session-projection/SKILL.md index 90d483f4ac..f2820d7454 100644 --- a/.agents/skills/dsh-session-projection/SKILL.md +++ b/.agents/skills/dsh-session-projection/SKILL.md @@ -13,6 +13,8 @@ Keep recoverable session facts in Projection and expose them through their ownin 2. Do not expose projection definitions or handles as production read APIs. Keep the ready handle private; consumers use the owning service's domain methods. A handle is a process-local reader, recreated during activation. Require `sessionProjections` when the service depends on it; optional registration is only for optional contributions. Do not hide a missing required dependency with another recovery path. + A runtime that needs several projected states receives one typed object of callbacks created with `handle.readerFor(session)`. Add properties instead of a constructor parameter or feature-specific reader for each state. Each callback has type `() => S`; single-purpose collaborators receive it directly. These host-state readers are separate from wire snapshots and live Cordis Context; they own no registration, disposal, cache or I/O. Registration, Session preparation and handle lifetimes stay with their owners. Rule 9 defines synchronous API compatibility. + 3. State recovery through `init` and `apply` is synchronous and deterministic. Do not perform I/O or trigger Cordis hooks, models, or tools. Runtime hooks own those effects. Replay must not repeat them. Return the same state reference for unrelated events. Keep views synchronous and preserve their references when visible values do not change. 4. Persist JSON state that its schema accepts. Follow the README's state-version and checkpoint-watermark rules. Restoring a checkpoint and replaying its suffix must match full replay. Change the version when state fields or recovery semantics change. diff --git a/apps/web/tests/question-composer-recommended.e2e.ts b/apps/web/tests/question-composer-recommended.e2e.ts new file mode 100644 index 0000000000..96ebc2c15a --- /dev/null +++ b/apps/web/tests/question-composer-recommended.e2e.ts @@ -0,0 +1,92 @@ +/** A multi-select question opens with every option marked as recommended already chosen, wherever it sits in the list. */ +import { readFile } from 'node:fs/promises' +import { join } from 'node:path' +import { fileURLToPath } from 'node:url' +import { chromium, type Browser, type Page } from 'playwright' +import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest' +import type { SessionEvent } from '@deepseek-ai/dsh-session' +import { + assertFixtureInventory, captureStableAria, compareOrRefreshGolden, fixtureUserPrompts, + launchWebScaffold, recordFixture, watchConsole, webSnapshotMode, type WebScaffold, +} from './scaffold.ts' +import { + connectFreshWorkspace, newEnglishPage, pinBrowserClock, pinHostClock, saveFailureShot, +} from './support.ts' + +const SNAPSHOT_DIR = fileURLToPath(new URL('../../../snapshots/web/question-composer-recommended', import.meta.url)) +const FIXTURE = join(SNAPSHOT_DIR, 'session.v4.jsonl') +const UI_EXPECTED = join(SNAPSHOT_DIR, 'ui.expected.md') +const MODE = webSnapshotMode() + +const PROMPT = 'Use the ask_user_question tool to ask me exactly one multi-select question with id "checks", question "Which checks should run before merging?", header "Checks", and three options in this order: label "Unit tests (Recommended)", label "Full e2e suite", and label "Type check (Recommended)". Set multi_select to true. After I answer, reply with the single word DONE and stop.' + +describe('web e2e: recommended multi-select options', () => { + let scaffold: WebScaffold + let browser: Browser + let page: Page + let tripwire: ReturnType + const sessionEvents: SessionEvent[] = [] + let hostClock: ReturnType | undefined + + beforeAll(async () => { + if (MODE !== 'record') hostClock = pinHostClock() + scaffold = await launchWebScaffold(MODE === 'record' ? {} : { replayFixture: FIXTURE, paceMs: 15, compareReplaySession: true }) + scaffold.ctx.on('session/event', (_session, event: SessionEvent) => { sessionEvents.push(event) }) + browser = await chromium.launch() + page = await newEnglishPage(browser) + if (MODE !== 'record') await pinBrowserClock(page) + tripwire = watchConsole(page) + await page.goto(scaffold.authenticatedUrl, { waitUntil: 'load' }) + await page.waitForSelector('[class*="frame"]', { timeout: 30_000 }) + await connectFreshWorkspace(page, scaffold.workspaceCwd) + }, 120_000) + + afterAll(async () => { + try { + await browser?.close() + } finally { + try { await scaffold?.close() } + finally { hostClock?.mockRestore() } + } + }) + + it('preselects every recommended option and submits them unchanged', async () => { + onTestFailed(() => saveFailureShot(page, 'web-e2e-question-recommended')) + if (MODE !== 'record') { + expect(fixtureUserPrompts(await readFile(FIXTURE, 'utf8'))).toEqual([PROMPT]) + } + const input = page.locator('[data-composer-input]').first() + await input.waitFor({ timeout: 10_000 }) + const settled = scaffold.whenTurnSettled(MODE === 'record' ? 180_000 : 30_000) + await input.fill(PROMPT) + await input.press('Enter') + + const composer = page.locator('[data-question-key]') + await composer.waitFor({ timeout: MODE === 'record' ? 120_000 : 30_000 }) + await composer.getByRole('heading', { name: 'Which checks should run before merging?' }).waitFor({ timeout: 10_000 }) + const checked = await composer.getByRole('checkbox').evaluateAll(nodes => + nodes.map(node => node.getAttribute('aria-checked'))) + expect(checked).toEqual(['true', 'false', 'true']) + if (MODE !== 'record') { + const snapshot = await captureStableAria(page, '[data-question-key]', scaffold.workspaceCwd) + await compareOrRefreshGolden(UI_EXPECTED, snapshot, MODE) + } + + await composer.getByRole('button', { name: 'Submit', exact: true }).click() + const sessionId = await settled + if (MODE === 'record') { + await recordFixture(scaffold, sessionId, FIXTURE) + return + } + const answerText = sessionEvents.filter(event => event.type === 'tool/result') + .flatMap(event => event.data.message.content.filter(item => item.type === 'text').map(item => item.text)) + .at(-1) + expect(JSON.parse(answerText ?? '')).toEqual({ + answers: [{ id: 'checks', selected: ['Unit tests (Recommended)', 'Type check (Recommended)'] }], + }) + await expect.poll(() => page.getByText('DONE', { exact: true }).count(), { timeout: 15_000 }).toBeGreaterThanOrEqual(1) + expect(tripwire.pageErrors).toEqual([]) + expect(tripwire.warnings).toEqual([]) + await assertFixtureInventory(SNAPSHOT_DIR, ['session.v4.jsonl', 'ui.expected.md']) + }, 200_000) +}) diff --git a/apps/web/tests/smoke-real.e2e.ts b/apps/web/tests/smoke-real.e2e.ts index a980c2d02d..0bbaa2c1d3 100644 --- a/apps/web/tests/smoke-real.e2e.ts +++ b/apps/web/tests/smoke-real.e2e.ts @@ -17,7 +17,7 @@ import type { ChildProcess } from 'node:child_process' import { spawn } from 'node:child_process' import { randomUUID } from 'node:crypto' -import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' +import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs' import { createServer } from 'node:http' import { createRequire, SourceMap } from 'node:module' import { tmpdir } from 'node:os' @@ -27,7 +27,7 @@ import type { Browser, Page } from 'playwright' import { chromium } from 'playwright' import { afterAll, beforeAll, describe, expect, it, onTestFailed } from 'vitest' import WebSocket from 'ws' -import { REPO_ROOT, connectFreshWorkspace, newEnglishPage, probeFreePort, requireDist, saveFailureShot } from './support.ts' +import { REPO_ROOT, newEnglishPage, probeFreePort, requireDist, saveFailureShot } from './support.ts' const WEB_SURFACE_PROMPT = fileURLToPath(new URL('./expected/web-runtime-context/web-surface-prompt.expected.md', import.meta.url)) /** Framed user text that marks the auxiliary title request's own messages. */ @@ -284,31 +284,18 @@ async function screen(page: Page, name: string): Promise { /** First column track (px string) of the frame grid. */ async function firstTrack(page: Page): Promise { - return (await page.locator('[class*="frame"]').evaluate( + return (await page.locator('[class*="frame"]').first().evaluate( el => getComputedStyle(el).gridTemplateColumns)).split(' ')[0]! } /** Last column track (details) as a number of pixels. */ async function detailsTrack(page: Page): Promise { - const cols = await page.locator('[class*="frame"]').evaluate( + const cols = await page.locator('[class*="frame"]').first().evaluate( el => getComputedStyle(el).gridTemplateColumns) return Number(cols.split(' ').pop()!.replace('px', '')) } -// Readiness gate: `dsh web` serves every production manifest plugin; until every UI -// plugin's client bundle exists and exports apply, the loader fail-louds and -// the frame never appears. -const UI_PLUGIN_DIRS = [ - 'connection', 'ui-theme', 'locale', 'ui-layout', 'ui-renderer', 'ui-session', 'ui-sidebar', - 'ui-settings', 'ui-settings-general', 'ui-settings-models', 'ui-conversation', 'ui-approval', 'ui-chat', - 'ui-model-selection', 'ui-user-questions', 'ui-trajectory', '../session-query/session-log-export', -] const ROUND_DONE_MARKER = 'WEB_ROUND_DONE' -const notReady = UI_PLUGIN_DIRS.filter((dir) => { - const bundle = join(REPO_ROOT, 'packages/client', dir, 'lib/client.js') - return !existsSync(bundle) || !readFileSync(bundle, 'utf8').includes('exports.apply') -}) -if (notReady.length > 0) console.warn(`[smoke-real] skipped — client bundles not ready: ${notReady.join(', ')}`) describe('dsh web keyless CLI smoke', () => { it('serves a usable app from three immutable plugin batches', async () => { @@ -686,7 +673,7 @@ describe('dsh web keyless CLI smoke', () => { }) }) -describe.skipIf(!process.env.DEEPSEEK_API_KEY || notReady.length > 0)('web smoke (real host, real key)', () => { +describe.skipIf(!process.env.DEEPSEEK_API_KEY)('web smoke (real host, real key)', () => { let child: ChildProcess let sessionsDir: string let baseUrl: string @@ -730,6 +717,9 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY || notReady.length > 0)('web smoke page = await newEnglishPage(browser) page.on('pageerror', e => pageErrors.push(String(e))) await page.goto(baseUrl, { waitUntil: 'load' }) + const welcome = page.getByRole('dialog', { name: 'Preview Notice' }) + await welcome.getByRole('button', { name: 'Continue' }).click() + await welcome.waitFor({ state: 'detached' }) }, 120_000) afterAll(async () => { @@ -747,18 +737,13 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY || notReady.length > 0)('web smoke onTestFailed(() => saveFailureShot(page, 'w5-cold-start')) await page.waitForSelector('[class*="frame"]', { timeout: 30_000 }) expect(await page.locator('text=Failed to load plugins').count()).toBe(0) - const template = await page.locator('[class*="frame"]').evaluate(el => getComputedStyle(el).gridTemplateColumns) + const template = await page.locator('[class*="frame"]').first().evaluate(el => getComputedStyle(el).gridTemplateColumns) expect(template.split(' ').length).toBe(3) await screen(page, '01-cold-start') }) it('empty-state first send completes a real model round', async () => { onTestFailed(() => saveFailureShot(page, 'w5-first-round')) - // This scenario spawns its own server against a fresh $DSH_HOME with the - // DeepSeek credential inherited from the environment, so no onboarding - // step mounts and the page is immediately interactive. - // Fresh world: connect a Workspace so the composer starts live. - await connectFreshWorkspace(page, sessionsDir) const input = page.locator('[data-composer-input]').first() await input.waitFor({ timeout: 10_000 }) const productTitle = await page.title() @@ -839,7 +824,7 @@ describe.skipIf(!process.env.DEEPSEEK_API_KEY || notReady.length > 0)('web smoke it('sidebar drag widens the column and resets across reload', async () => { onTestFailed(() => saveFailureShot(page, 'w5-drag')) const before = await firstTrack(page) - const handle = page.locator('[class*="handle"]').first() + const handle = page.locator('[data-side="sidebar"]') const box = await handle.boundingBox() expect(box).not.toBeNull() await page.mouse.move(box!.x + box!.width / 2, box!.y + 300) diff --git a/apps/web/tests/startup-rpc-budget.e2e.ts b/apps/web/tests/startup-rpc-budget.e2e.ts index f6655ffbf3..80b2630328 100644 --- a/apps/web/tests/startup-rpc-budget.e2e.ts +++ b/apps/web/tests/startup-rpc-budget.e2e.ts @@ -1,6 +1,6 @@ -// Cold boot may issue at most two settings/describe calls regardless of client -// plugin count. No model call or replay fixture is involved. -import type { Browser, Page } from 'playwright' +// Cold boot bounds shared settings reads and the Web Search credential reads +// caused by their publication waves. No model call or replay fixture is involved. +import type { Browser, Page, Request, Route } from 'playwright' import { chromium } from 'playwright' import { afterAll, beforeAll, describe, expect, it } from 'vitest' import { launchWebScaffold, watchConsole, type WebScaffold } from './scaffold.ts' @@ -8,6 +8,8 @@ import { newEnglishPage } from './support.ts' /** One eager read plus one first-connection reset closes the pre-subscription commit window. */ const DESCRIBE_BUDGET = 2 +/** One eager Web Search credential read plus one per settings publication wave. */ +const WEB_SEARCH_CREDENTIAL_BUDGET = 3 let scaffold: WebScaffold let browser: Browser @@ -25,20 +27,58 @@ afterAll(async () => { }) describe('startup RPC budget', () => { - it('keeps cold-boot settings.describe at the mirror count', async () => { + it('keeps settings and Web Search credential reads at their publication counts', async () => { page = await newEnglishPage(browser) watchConsole(page) const calls: string[] = [] + const credentials: string[][] = [] + const pending = new Set() + const webSearchRequests = new Set() + const credentialStarted = Promise.withResolvers() + let settingsFinished = 0 + let webSearchFinished = 0 + // Both settings answers must reach the card after it subscribes, regardless + // of plugin load order. The eager credential request proves that subscription. + const holdSettings = async (route: Route): Promise => { + await credentialStarted.promise + await route.continue() + } + await page.route('**/api/settings/describe', holdSettings) page.on('request', (request) => { const url = new URL(request.url()) - if (url.pathname.startsWith('/api/')) calls.push(url.pathname.slice('/api/'.length)) + if (!url.pathname.startsWith('/api/')) return + const method = url.pathname.slice('/api/'.length) + calls.push(method) + pending.add(request) + if (method === 'credentials/describe') { + const body = request.postDataJSON() as { payload: { args: { refs: string[] } } } + const refs = body.payload.args.refs + credentials.push(refs) + // Models requests batch references; the Web Search card asks for this one key. + if (refs.length === 1 && refs[0] === 'DEEPSEEK_API_KEY') { + webSearchRequests.add(request) + credentialStarted.resolve(undefined) + } + } }) - await page.goto(scaffold.authenticatedUrl) - // Boot settles when the workspace picker is interactive; the trailing wait - // absorbs the first-connection reset wave the budget must include. - await page.getByRole('textbox', { name: 'Choose workspace' }).waitFor({ timeout: 30_000 }) - await page.waitForTimeout(3000) - const describeCount = calls.filter(method => method === 'settings/describe').length - expect(describeCount, `startup /api calls:\n${calls.join('\n')}`).toBe(DESCRIBE_BUDGET) + page.on('requestfinished', (request) => { + pending.delete(request) + if (new URL(request.url()).pathname === '/api/settings/describe') settingsFinished++ + if (webSearchRequests.has(request)) webSearchFinished++ + }) + page.on('requestfailed', request => pending.delete(request)) + try { + await page.goto(scaffold.authenticatedUrl) + await page.getByRole('textbox', { name: 'Choose workspace' }).waitFor({ timeout: 30_000 }) + await expect.poll(() => settingsFinished, { timeout: 30_000 }).toBeGreaterThanOrEqual(DESCRIBE_BUDGET) + await expect.poll(() => webSearchFinished, { timeout: 30_000 }).toBeGreaterThanOrEqual(WEB_SEARCH_CREDENTIAL_BUDGET) + await expect.poll(() => pending.size, { timeout: 30_000 }).toBe(0) + const describeCount = calls.filter(method => method === 'settings/describe').length + expect(describeCount, `startup /api calls:\n${calls.join('\n')}`).toBe(DESCRIBE_BUDGET) + expect(webSearchRequests.size, `startup credential references:\n${JSON.stringify(credentials)}`).toBe(WEB_SEARCH_CREDENTIAL_BUDGET) + } finally { + credentialStarted.resolve(undefined) + await page.unrouteAll({ behavior: 'wait' }) + } }) }) diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json index e9df1e11f1..3de8b1fb68 100644 --- a/apps/web/tsconfig.json +++ b/apps/web/tsconfig.json @@ -67,6 +67,7 @@ "tests/subagent-fork-schedule.snapshot.ts", "tests/live-interactions.e2e.ts", "tests/question-composer.e2e.ts", + "tests/question-composer-recommended.e2e.ts", "tests/question-ptc.e2e.ts", "tests/approval-composer.e2e.ts", "tests/ptc-escalation.e2e.ts", diff --git a/docs/architecture.i18n.yaml b/docs/architecture.i18n.yaml index c8543cdc36..72dc6b08a6 100644 --- a/docs/architecture.i18n.yaml +++ b/docs/architecture.i18n.yaml @@ -27,8 +27,8 @@ en: 1a79a70b62c04cdb zh: c86d765e21430405 /deepseek-harness-architecture/session-log: - en: 8a7f19b95d426c99 - zh: d5bb0538404e20ea + en: b3b63d8fe7cab9fe + zh: 3703fcf30b1639d0 /deepseek-harness-architecture/capability-seams: en: a5bc20c3f2a1b370 zh: 91773a281410b2f4 diff --git a/docs/architecture.md b/docs/architecture.md index e6bede8d0e..e3f5cd24a3 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -127,7 +127,7 @@ Session consumers know only the current logical format. Header-only `stat` and ` **Model-visible means logged.** Every model request must be reconstructable from the log. New model-visible inputs require session events. Plugins changing existing message content register [pure message projections](subsystems/session.md#plugin-owned-message-projections); detached readers supply the same definitions explicitly. Tool changes are capability-independent; [Session tool history](../packages/core/session/README.md) supplies provider declarations. -**Projection seam.** `dsh-session-projection` owns `ctx.sessionProjections`: registered units fold committed events incrementally, and carriers batch cropped client views with `snapshot()`. Domain services await registration during activation, retain private handles, and expose business methods for other plugins. Releasing registration removes global participation; retained handles continue folding Session events. `AgentRegistry` owns turn and step state and exposes `turnBoundaryOf(session)` ([registration lifecycle](../packages/session/session-projection/README.md)). `AgentLoop` owns `modelSelection` and constructs each Agent’s `model` instance alongside its inbox. +**Projection seam.** `dsh-session-projection` owns `ctx.sessionProjections`: registered units fold committed events; carriers read selected client views through `snapshot()`. Domain services await registration, retain private handles, and expose business methods ([registration lifecycle](../packages/session/session-projection/README.md)). `AgentRegistry` exposes turn and step state through `turnBoundaryOf(session)`. `AgentLoop` owns `modelSelection` and inbox state ([loop lifecycle](../packages/core/agent-loop/README.md)). [Working directories](subsystems/working-directory.md) supply user context and execution paths without changing original project identity, sandbox write roots, or existing process directories. diff --git a/docs/architecture.zh.md b/docs/architecture.zh.md index 8863c8047c..4ab73a419d 100644 --- a/docs/architecture.zh.md +++ b/docs/architecture.zh.md @@ -131,7 +131,7 @@ Session 消费方只了解当前逻辑格式。仅 header 的 `stat` 与 `list` **模型可见即已记录。** 每个模型请求都必须能从日志重建。新增模型可见输入需要会话事件。修改现有消息内容的插件注册[纯消息投影](subsystems/session.zh.md#plugin-owned-message-projections),独立读取器显式传入相同的处理器。 工具变更不依赖能力;[Session 工具历史](../packages/core/session/README.zh.md)提供提供方声明。 -**投影 seam。** `dsh-session-projection` 提供 `ctx.sessionProjections`:已注册单元增量折叠已提交事件,载体通过 `snapshot()` 批量取得裁剪后的客户端视图。领域服务在激活时等待注册完成,在内部保留句柄,并向其他插件提供业务方法。释放注册会移除全局参与关系;已有句柄仍可继续折叠 Session 事件。`AgentRegistry` 持有轮次和步骤状态,并提供 `turnBoundaryOf(session)`([注册生命周期](../packages/session/session-projection/README.zh.md))。 `AgentLoop` 持有 `modelSelection`,并与 inbox 一起构建每个 Agent 的 `model` 实例。 +**投影 seam。** `dsh-session-projection` 提供 `ctx.sessionProjections`:已注册单元折叠已提交事件,载体通过 `snapshot()` 读取选定的客户端视图。领域服务等待注册完成,在内部保留句柄,并提供业务方法([注册生命周期](../packages/session/session-projection/README.zh.md))。`AgentRegistry` 通过 `turnBoundaryOf(session)` 提供轮次和步骤状态。`AgentLoop` 持有 `modelSelection` 和 inbox 状态([Loop 生命周期](../packages/core/agent-loop/README.zh.md))。 [工作目录](subsystems/working-directory.zh.md) 提供用户上下文和执行路径,不改变原始项目标识、沙箱写入根目录或已有进程目录。 diff --git a/docs/subsystems/session-projection.i18n.yaml b/docs/subsystems/session-projection.i18n.yaml index 29991cd13f..b38666ddb4 100644 --- a/docs/subsystems/session-projection.i18n.yaml +++ b/docs/subsystems/session-projection.i18n.yaml @@ -3,8 +3,8 @@ # After editing either side, bring the other along and re-record with: # pnpm run verify-translation-pairing --write docs/subsystems/session-projection.md /session-projections: - en: 45e5f8cb8ca18d6b - zh: 4ecfad40ec9e221c + en: b2789f5257a935c5 + zh: 12d430a9cd454592 /session-projections/the-unit: en: d48814d3ab0e997f zh: d0337d8eba097a63 diff --git a/docs/subsystems/session-projection.md b/docs/subsystems/session-projection.md index e56896f455..cee8103ef0 100644 --- a/docs/subsystems/session-projection.md +++ b/docs/subsystems/session-projection.md @@ -18,6 +18,13 @@ interface ProjectionHandle { * @returns the projection state at the Session's current cursor. */ stateOf(session: Session): S + /** + * Create a reader for one exact Session without reading state or preparing it. + * The reader retains this unit after unregistration and owns no disposal. + * @param session - Session whose committed events the bound reader folds. + * @returns a synchronous callback with the same state and failures as `stateOf(session)`. + */ + readerFor(session: Session): () => S /** * Unregister from global drives and snapshots without invalidating this reader. * @returns a promise that resolves when this registration is released. @@ -28,6 +35,8 @@ interface ProjectionHandle { The [compatibility rules](../../packages/session/session-projection/README.md#deprecated-plugin-compatibility) define legacy disposal, keyed reads, and their once-per-key deprecation warnings. +`ProjectionHandle.readerFor(session)` returns a `() => S` callback for one exact Session. Calling it reads the original unit and preserves borrowed state, readiness requirements and synchronous failures. Owners can compose several readers in a typed object; domain services keep them private. See [binding several states](../../packages/session/session-projection/README.md#bind-several-states-to-one-session). + ## The unit `ProjectionDefinition` carries each unit's host state type locally; registration infers `S` from `stateSchema` and returns `ProjectionHandle`. Only client-visible keys merge into `SessionProjectionMap`, which types their whole values. A `wire` block makes a unit client-visible, and rendering belongs to the slot system, never this layer: diff --git a/docs/subsystems/session-projection.zh.md b/docs/subsystems/session-projection.zh.md index da53b76a7e..6e076a18a3 100644 --- a/docs/subsystems/session-projection.zh.md +++ b/docs/subsystems/session-projection.zh.md @@ -18,6 +18,13 @@ interface ProjectionHandle { * @returns the projection state at the Session's current cursor. */ stateOf(session: Session): S + /** + * Create a reader for one exact Session without reading state or preparing it. + * The reader retains this unit after unregistration and owns no disposal. + * @param session - Session whose committed events the bound reader folds. + * @returns a synchronous callback with the same state and failures as `stateOf(session)`. + */ + readerFor(session: Session): () => S /** * Unregister from global drives and snapshots without invalidating this reader. * @returns a promise that resolves when this registration is released. @@ -28,6 +35,8 @@ interface ProjectionHandle { [兼容规则](../../packages/session/session-projection/README.zh.md#deprecated-plugin-compatibility)规定旧释放操作、按键读取及其每个键一次的弃用警告。 +`ProjectionHandle.readerFor(session)` 为一个确切的 Session 返回 `() => S` 回调。调用它会读取原有单元,保留借用状态、就绪要求和同步失败。所有者可将多个读取函数组合成一个类型化对象;领域服务将它们保留在内部。参见[绑定多个状态](../../packages/session/session-projection/README.zh.md#bind-several-states-to-one-session)。 + ## 投影单元 `ProjectionDefinition` 在各单元内部携带宿主状态类型;注册从 `stateSchema` 推导 `S`,并返回 `ProjectionHandle`。只有客户端可见的 key 合并到 `SessionProjectionMap`,由它约束对应的全量值。`wire` 块使单元对客户端可见,渲染归 slot 体系管,永远不归本层: diff --git a/packages/client/AGENTS.md b/packages/client/AGENTS.md index 85d5d69354..80d9702f14 100644 --- a/packages/client/AGENTS.md +++ b/packages/client/AGENTS.md @@ -85,7 +85,7 @@ A dynamic browser half either carries a module privately or requests the shared 3. **Silence means a private copy.** Third-party implementation libraries outside the baseline may be bundled independently. A value reached only through `import type` is erased and creates no request. 4. **A request has two possible suppliers.** A dynamic package supplies its own row; `PLATFORM_MODULES` supplies an exact static-table key. There is no `dsh.client.provide` alias protocol. 5. **Validate both sides.** The dynamic build preset externalizes the baseline and rejects undeclared workspace value imports; [`verify-client-packages`](../../scripts/verify-client-packages.ts) rejects malformed or redundant requests, missing suppliers, and synchronous request cycles. -6. **Package-local dynamic chunks are self-contained.** Source uses `import()` and the shared preset emits `require.async("./client..js")`; an entry or chunk must not retain a synchronous relative `require("./client*.js")`. Keep every static relative dependency inside its owning output chunk rather than relying on a sibling-chunk graph the runtime does not support. +6. **Package-local dynamic chunks are self-contained.** Source uses `import()` and the shared preset calls the factory loader's `.async` method with a literal `./client..js` path; an entry or chunk must not retain a synchronous relative `require("./client*.js")`. Keep every static relative dependency inside its owning output chunk rather than relying on a sibling-chunk graph the runtime does not support. ### The module graph sits below cordis DI diff --git a/packages/client/modules/README.i18n.yaml b/packages/client/modules/README.i18n.yaml index eb264da002..258d5971f7 100644 --- a/packages/client/modules/README.i18n.yaml +++ b/packages/client/modules/README.i18n.yaml @@ -24,8 +24,8 @@ en: 529af1eb8bf1acf2 zh: 7d891a5dfa90c625 /deepseek-ai-dsh-client-modules/use-this-package/what-the-browser-loads: - en: 1383d68472b3c057 - zh: 94dd7d9abbdbccf3 + en: 3c372e9d65e294a8 + zh: 00f82efab7071258 /deepseek-ai-dsh-client-modules/use-this-package/live-plugin-composition: en: 45740a56e931d094 zh: fa44cf77c86019af @@ -36,8 +36,8 @@ en: 1778b5a63ecde5e8 zh: 537b4f8c755af8ad /deepseek-ai-dsh-client-modules/use-this-package/build-requirements: - en: b6a4d3b901c89efe - zh: 615b5f3eec41f281 + en: 15aa99a9df72e51e + zh: 3324596fb5d3588d /deepseek-ai-dsh-client-modules/understand-the-implementation: en: 7ab11d2c2bdc6eaa zh: 54c3c9091cf59711 diff --git a/packages/client/modules/README.md b/packages/client/modules/README.md index 6048a73939..10af92132b 100644 --- a/packages/client/modules/README.md +++ b/packages/client/modules/README.md @@ -40,7 +40,7 @@ The same `/plugins` route serves the images a client package publishes through i ### What the browser loads -The application combo scripts carry only each plugin's `client.js` entry and register those factories once during boot; module bodies remain lazy and run only at first import or materialization. A source `import()` split by tsdown compiles to `require.async("./client..js")`; its versioned sibling script arrives only when that expression runs. Rows that share a combo URL share one in-flight script task. A combo whose `