fix(user-questions): align styles and cover wait cleanup

Co-authored-by: imccyu <[email protected]>
This commit is contained in:
Magolorandimccyu authored and imccyu committed 2026-09-24 19:43:16 +08:00
1 parent bb19061473
commit 652bc9d396
7 files changed
+62 -9

No files matched your search

@@ -10,7 +10,7 @@
.bubble {
max-width: 72%;
padding: 10px 16px;
border-radius: 22px;
border-radius: var(--dsw-radius-xl);
background: var(--dsw-specific-bubble);
color: var(--dsw-alias-label-primary);
cursor: pointer;
@@ -33,12 +33,12 @@
}
.toggle:focus-visible {
outline: 2px solid var(--dsw-alias-state-business-primary);
outline: 2px solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
outline-offset: 2px;
}
.bubble:has(.toggle:focus-visible) {
box-shadow: 0 0 0 2px var(--dsw-alias-state-business-primary);
box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
}
.labelRow {
@@ -149,7 +149,7 @@
height: 28px;
padding: 6px;
border: none;
border-radius: 28px;
border-radius: var(--dsw-radius-sm);
background: transparent;
color: inherit;
cursor: pointer;
@@ -241,7 +241,7 @@ async function answerQuestion(
claimSignal,
(channel) => { card.pending.detachWaterfall(channel) },
)
delegateRequest = waterfall.channel.delegate
delegateRequest = () => { waterfall.channel.delegate() }
card.pending.attachWaterfall(waterfall.channel)
if (iterator !== undefined) {
claimEnded = (async () => {
@@ -167,6 +167,31 @@ const timed = (): QuestionRequest => ({
})
describe('apply', () => {
it('delegates an expired foreground wait and releases its claim stream', async () => {
const b = await bench()
const dispose = vi.fn()
b.remoteQuestions.attachWait.mockImplementationOnce(() => ({
dispose, send: () => {}, end: () => {},
[Symbol.asyncIterator]: () => ({
next: () => Promise.resolve({ done: true as const, value: undefined }),
}),
}))
try {
const next = vi.fn(async () => ANSWER)
await expect(b.invoke(b.agent, timed(), next)).resolves.toBe(ANSWER)
expect(next).toHaveBeenCalledOnce()
expect(dispose).toHaveBeenCalledOnce()
expect(b.remoteQuestions.attachWait.mock.calls[0]![2].aborted).toBe(true)
expect(b.pending.getSnapshot()[0]?.snapshot()).toMatchObject({ channel: 'none', countdown: undefined })
b.projection.set(view([]))
expect(b.pending.getSnapshot()).toEqual([])
} finally {
await b.fiber.dispose()
}
})
it('attaches an indefinite request before publishing control back to the caller', async () => {
const b = await bench()
try {
@@ -520,7 +520,7 @@ describe('timed card', () => {
vi.useFakeTimers()
const carrier = new PendingQuestion(SID, [{ id: 'free', question: '补充说明' }], ToolCallId('claiming'))
const request = createWaterfallRequest(Date.now() + 2_000, undefined,
channel => carrier.detachWaterfall(channel))
(channel) => { carrier.detachWaterfall(channel) })
try {
render(<QuestionComposer matched={carrier} {...kit} />)
const field = screen.getByPlaceholderText(zh['custom.placeholder'])
@@ -398,6 +398,32 @@ function replyText(message: UserMessage): unknown {
}
describe('askTimed', () => {
it('keeps sibling waits independent and cancels the remaining wait when the service unloads', async () => {
vi.useFakeTimers()
onTestFinished(() => { vi.useRealTimers() })
const ctx = await timedContext()
onTestFinished(async () => { await ctx.fiber.dispose() })
const agent = liveAgent('timed-sibling-waits')
ctx.agents.enter(agent, undefined)
const service = ctx.userQuestions
const laterCallId = ToolCallId('ask-later')
const first = service.askTimed({ agent, questions: timedQuestions }, timedCallId, 1_000)
const later = service.askTimed({ agent, questions: timedQuestions }, laterCallId, 2_000)
const cancelled = expect(later).rejects.toMatchObject({ code: 'ASK_ABORTED' })
await vi.advanceTimersByTimeAsync(1_000)
await expect(first).resolves.toEqual({ pending: true, callId: timedCallId })
const claim = service.attachWait(agent, laterCallId, new AbortController().signal)[Symbol.asyncIterator]()
expect(await claim.next()).toEqual({ done: false, value: { remainingMs: 1_000 } })
const end = claim.next()
await ctx.fiber.dispose()
await cancelled
expect(await end).toEqual({ done: true, value: undefined })
expect(vi.getTimerCount()).toBe(0)
})
it('expires a forwarded request even when no Client ever responds or delegates', async () => {
vi.useFakeTimers()
onTestFinished(() => { vi.useRealTimers() })
@@ -410,7 +436,9 @@ describe('askTimed', () => {
registerAnswerer(ctx, {
ask: request => new Promise((_resolve, reject) => {
forwardedSignal = request.signal
request.signal?.addEventListener('abort', () => { reject(request.signal?.reason) }, { once: true })
request.signal?.addEventListener('abort', () => {
reject(new Error('forwarded request aborted', { cause: request.signal?.reason }))
}, { once: true })
}),
})
const result = ctx.userQuestions.askTimed(
@@ -261,7 +261,7 @@ Every package below exports a Cordis plugin that a bundle patch can name in a Lo
|---|---|---|
| `@deepseek-ai/dsh-commands` | no | Plugin-owned human command registry for DeepSeek Harness UIs |
| `@deepseek-ai/dsh-permission-presets` | yes | User-facing permission presets (ctx.permissionPresets) for the DeepSeek Harness: one product-level Permissions select bundling the sandbox-mode and approval-policy knobs, written through to their own session events |
| `@deepseek-ai/dsh-tool-ask-user` | no | Model-facing ask_user_question tool over the ctx.userQuestions seam |
| `@deepseek-ai/dsh-tool-ask-user` | yes | Model-facing ask_user_question tool over the ctx.userQuestions seam |
| `@deepseek-ai/dsh-user-approval` | yes | User-approval seam (ctx.approval) for the DeepSeek Harness: one-shot permission decisions dispatched to composed answerers over the approval/request waterfall, fail-closed by default |
| `@deepseek-ai/dsh-user-questions` | no | Abstract user-questions seam (ctx.userQuestions) for asking the human during agent runs |
@@ -13,7 +13,7 @@
- status: Worked
- button "Took {{duration}}" [expanded]
- button "Asked questions" [expanded]
- button "Think"
- button "Think The user wants me to use the ask_user_question tool with specific parameters. Let me do exactly that."
- button "Ask question 1/1 answered View answers" [expanded]:
- text: Ask question 1/1 answered
- button "View answers"