mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-11 04:00:38 +00:00
A claimed slash command consumed only the text half of the composer submission: /goal with reference images executed, cleared the draft, and silently stranded the images in the rail. Model-visible attachment intent had no route through the command plane. The submission envelope is now modeled end to end. CommandDefinition input.images declares acceptance; the declaration rides the descriptor to every client, onto the minted CommandClaim, and into the input machine's claim snapshot. commands.execute carries the submission's base64 images and enforces the declaration in the executor: non-declaring commands, a missing attachment store, and exceeded batch limits settle as logged error results before the handler runs. Admission reuses the attachment package's new admitEncodedImages, extracted from api-proxy's prompt path so both wire endpoints share one limits/validation/commit sequence. Producers own model visibility: /goal submits one user followup (image blocks + a fixed reference line) after a successful create/edit so goal rounds read the images from session history; /plan folds them into its steered message. Grammar misfits (/goal pause, bare /plan, /plan off) return direct errors and the composer keeps the images. On the client, enter adjudication carries a SubmitEnvelope and every command route that cannot consume images throws a localized refusal that renders as one composer notice with draft and images retained; the claimed pre-gate applies the same copy. An accepting claim serializes the draft images, forwards them to commands.execute, and clears plus releases them only on a success outcome. The assembled web test roster gains the ui-input-trigger and ui-commands plugins, mirroring the shipped composition, so slash submissions exercise the command plane; a new keyless snapshot pins the refusal banner and the accepting /goal flow over the built client graph.
89 lines
3.7 KiB
TypeScript
89 lines
3.7 KiB
TypeScript
/**
|
|
* ui-plan browser half on a real SlotRegistry: the plugin occupies the
|
|
* conversation-declared `conversation.input.plan` single seat with the active
|
|
* plan status chip; the injected face executes /plan off and folds admission
|
|
* outcomes into null (admitted) or a user-visible failure line; teardown
|
|
* empties the seat (HMR safety).
|
|
*/
|
|
import { Context } from '@deepseek-ai/cordis'
|
|
import { describe, expect, it, vi } from 'vitest'
|
|
import { SlotRegistry } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import type { SessionId } from '@deepseek-ai/dsh-client-runtime/client'
|
|
import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
|
|
import { PlanChip } from '../src/client/PlanModeControl.tsx'
|
|
import type { PlanChipInjected } from '../src/client/index.ts'
|
|
import { apply, inject } from '../src/client/index.ts'
|
|
import { apply as nodeApply } from '../src/index.ts'
|
|
|
|
const SID = 's-plan' as SessionId
|
|
|
|
async function bench() {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotRegistry).await()
|
|
const slots = ctx.get('slots') as SlotRegistry
|
|
slots.register({
|
|
name: 'root',
|
|
children: { 'conversation.input.plan': { kind: 'single', scope: 'session' } },
|
|
} as never, () => null)
|
|
const execute = vi.fn((_sessionId: SessionId, _line: string) =>
|
|
Promise.resolve({ ok: true, value: { commandId: 'c1', result: { kind: 'success' as const } } }))
|
|
const commandsRemote = { execute }
|
|
ctx.provide('remote', { commands: commandsRemote })
|
|
ctx.provide('remote.commands', commandsRemote)
|
|
ctx.provide('locale', new LocaleRuntime(ctx))
|
|
return { ctx, slots, execute }
|
|
}
|
|
|
|
describe('ui-plan browser apply', () => {
|
|
it('declares every service it binds', () => {
|
|
expect(inject).toEqual(['slots', 'remote', 'remote.commands', 'locale'])
|
|
})
|
|
|
|
it('node-half apply is an intentional no-op', () => {
|
|
expect(() => { nodeApply() }).not.toThrow()
|
|
})
|
|
|
|
it('waits until conversation declares the plan seat', async () => {
|
|
const ctx = new Context()
|
|
await ctx.plugin(SlotRegistry).await()
|
|
ctx.provide('remote', { commands: {} })
|
|
ctx.provide('remote.commands', {})
|
|
ctx.provide('locale', new LocaleRuntime(ctx))
|
|
const fiber = ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
expect(ctx.slots.entries('conversation.input.plan')).toHaveLength(0)
|
|
ctx.slots.register({
|
|
name: 'root', children: { 'conversation.input.plan': { kind: 'single', scope: 'session' } },
|
|
} as never, () => null)
|
|
await Promise.resolve()
|
|
expect(ctx.slots.entries('conversation.input.plan')).toHaveLength(1)
|
|
})
|
|
|
|
it('registers the chip, executes /plan off, and unregisters on teardown', async () => {
|
|
const b = await bench()
|
|
const fiber = b.ctx.plugin({ inject: [...inject], apply })
|
|
await fiber.await()
|
|
const entry = b.slots.entries('conversation.input.plan')[0]!
|
|
expect(entry.component).toBe(PlanChip)
|
|
const injected = (entry.inject as unknown as (id: SessionId) => PlanChipInjected)(SID)
|
|
|
|
await expect(injected.exitPlanMode()).resolves.toBeNull()
|
|
expect(b.execute).toHaveBeenLastCalledWith(SID, '/plan off', [])
|
|
|
|
// Business failure folds to the composer-visible line: the generated method
|
|
// reports the RPC failure in its error branch.
|
|
b.execute.mockResolvedValueOnce({
|
|
ok: false,
|
|
error: { code: 'session-not-found', message: 'gone', details: {} },
|
|
} as never)
|
|
await expect(injected.exitPlanMode()).resolves.toBe('gone (session-not-found)')
|
|
|
|
// Unmatched admission (plan-mode not composed host-side) is also a failure line.
|
|
b.execute.mockResolvedValueOnce({ ok: true, value: undefined } as never)
|
|
await expect(injected.exitPlanMode()).resolves.toBe('unknown command: /plan off')
|
|
|
|
await fiber.dispose()
|
|
expect(b.slots.entries('conversation.input.plan')).toHaveLength(0)
|
|
})
|
|
})
|