diff --git a/packages/client/ui-user-questions/src/client/QuestionReplyView.module.css b/packages/client/ui-user-questions/src/client/QuestionReplyView.module.css index ecdc87c485..651fe889dc 100644 --- a/packages/client/ui-user-questions/src/client/QuestionReplyView.module.css +++ b/packages/client/ui-user-questions/src/client/QuestionReplyView.module.css @@ -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; diff --git a/packages/client/ui-user-questions/src/client/index.ts b/packages/client/ui-user-questions/src/client/index.ts index aa7b0d3aec..564a9f7a40 100644 --- a/packages/client/ui-user-questions/src/client/index.ts +++ b/packages/client/ui-user-questions/src/client/index.ts @@ -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 () => { diff --git a/packages/client/ui-user-questions/tests/browser-plugin.client.spec.ts b/packages/client/ui-user-questions/tests/browser-plugin.client.spec.ts index dd8d7c990c..4edbd64d9f 100644 --- a/packages/client/ui-user-questions/tests/browser-plugin.client.spec.ts +++ b/packages/client/ui-user-questions/tests/browser-plugin.client.spec.ts @@ -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 { diff --git a/packages/client/ui-user-questions/tests/user-questions-composer.client.spec.tsx b/packages/client/ui-user-questions/tests/user-questions-composer.client.spec.tsx index 33c9319841..db28698351 100644 --- a/packages/client/ui-user-questions/tests/user-questions-composer.client.spec.tsx +++ b/packages/client/ui-user-questions/tests/user-questions-composer.client.spec.tsx @@ -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() const field = screen.getByPlaceholderText(zh['custom.placeholder']) diff --git a/packages/interaction/user-questions/tests/user-questions.spec.ts b/packages/interaction/user-questions/tests/user-questions.spec.ts index 8f3ae28b7d..ed408cd3ea 100644 --- a/packages/interaction/user-questions/tests/user-questions.spec.ts +++ b/packages/interaction/user-questions/tests/user-questions.spec.ts @@ -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( diff --git a/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md b/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md index c0dc0cba69..61355535d2 100644 --- a/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md +++ b/packages/preset/agent-preset/skills/cordis-composition-reference/references/packages.md @@ -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 | diff --git a/snapshots/web/question-composer/late-answered.expected.md b/snapshots/web/question-composer/late-answered.expected.md index 06fa744be6..919e696628 100644 --- a/snapshots/web/question-composer/late-answered.expected.md +++ b/snapshots/web/question-composer/late-answered.expected.md @@ -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"