dsh-better-ask-user 0.1.6 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@ import { planReviewOf, type QuestionAnswer, type QuestionCardSnapshot, type Ques
12
12
  import type { PendingQuestion } from './contract/slots.ts'
13
13
  import type { QuestionDraftAnswer, QuestionDraftProgress } from './draft-store.ts'
14
14
  import { PlanReviewPanel } from './PlanReviewPanel.tsx'
15
+ import { QuestionWaitBar } from './QuestionWaitBar.tsx'
15
16
  import css from './QuestionComposer.module.css'
16
17
 
17
18
  /**
@@ -75,6 +76,8 @@ interface AnswerFieldProps {
75
76
  value: string
76
77
  /** Empty-field prompt. */
77
78
  placeholder: string
79
+ /** The visible question that labels this answer. */
80
+ labelledBy: string
78
81
  /** Whether a submission in flight has frozen the field. */
79
82
  disabled: boolean
80
83
  /** Whether this field takes focus on mount. */
@@ -114,6 +117,7 @@ function AnswerField(props: AnswerFieldProps) {
114
117
  disabled={props.disabled}
115
118
  rows={1}
116
119
  placeholder={props.placeholder}
120
+ aria-labelledby={props.labelledBy}
117
121
  onFocus={props.onFocus}
118
122
  onChange={props.onChange}
119
123
  onKeyDown={props.onKeyDown}
@@ -150,7 +154,7 @@ export function QuestionComposer(props: QuestionComposerProps) {
150
154
  actions={props.actions}
151
155
  />
152
156
  )
153
- : <PlanReviewPanel key={question.key} pending={question} review={review} t={props.t} renderSlot={props.renderSlot} />
157
+ : <PlanReviewPanel key={question.key} pending={question} review={review} t={props.t} renderSlot={props.renderSlot} useQuestionCard={props.useQuestionCard} />
154
158
  }
155
159
 
156
160
  type QuestionFlowProps =
@@ -243,6 +247,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
243
247
  // oxlint-disable-next-line typescript/no-non-null-assertion
244
248
  const draft = drafts[index]!
245
249
  const hasOptions = (question.options?.length ?? 0) > 0
250
+ const questionId = `question-${pending.key}-${String(index)}`
246
251
 
247
252
  const replaceProgress = (nextIndex: number, nextDrafts: QuestionDraftAnswer[]): void => {
248
253
  // Every real answer input (option click, text edit, page navigation, skip)
@@ -427,18 +432,19 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
427
432
  <div className={css.frame} data-question-key={pending.key}>
428
433
  <section
429
434
  className={clsx(css.card, minimized && css.cardMinimized)}
430
- aria-labelledby={`question-${pending.key}-${String(index)}`}
435
+ aria-labelledby={questionId}
436
+ aria-busy={busy !== null}
431
437
  >
432
438
  <header className={css.header}>
433
439
  <div className={css.headingBlock}>
434
- {question.header !== undefined && (
440
+ {question.header !== undefined && question.header.trim() !== question.question.trim() && (
435
441
  <div className={css.eyebrow}>
436
442
  <MarkdownText text={question.header} variant="compact" labels={markdownLabels} />
437
443
  </div>
438
444
  )}
439
445
  <div
440
446
  className={css.title}
441
- id={`question-${pending.key}-${String(index)}`}
447
+ id={questionId}
442
448
  role="heading"
443
449
  aria-level={2}
444
450
  >
@@ -446,30 +452,6 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
446
452
  </div>
447
453
  </div>
448
454
  <div className={css.headerActions}>
449
- {countdown !== undefined && card.waitState !== 'waiting' && card.waitState !== 'editing' && card.waitState !== 'continued' && (
450
- <span className={css.waitStatus}>
451
- {t(countdown.running ? 'wait.countdown' : 'wait.paused', {
452
- seconds: Math.ceil(countdown.remainingMs / 1000),
453
- })}
454
- </span>
455
- )}
456
- {countdown !== undefined && card.waitState !== 'waiting' && card.waitState !== 'editing' && card.waitState !== 'continued' && (
457
- <span className={css.waitStatus}>
458
- {t(card.timeoutMode === 'default' ? 'wait.auto' : 'wait.extend')}
459
- </span>
460
- )}
461
- {countdown !== undefined && card.waitState !== 'waiting' && card.waitState !== 'editing' && card.waitState !== 'continued' && (
462
- <Button variant="outline" className={css.waitButton} onClick={takeTime}>
463
- {t('wait.takeTime')}
464
- </Button>
465
- )}
466
- {card.state === 'continued' && <span className={css.waitStatus}>{t('wait.continued')}</span>}
467
- {/* A held or frozen countdown says so; a request that never carried
468
- one waits silently, as the blocking question always has. */}
469
- {countdown !== undefined && (card.waitState === 'waiting' || card.waitState === 'editing') && (
470
- <span className={css.waitStatus}>{t('wait.held')}</span>
471
- )}
472
- {review !== undefined && <span className={css.waitStatus}>{t('review.status')}</span>}
473
455
  <button
474
456
  type="button" className={css.iconButton}
475
457
  aria-label={t(minimized ? 'nav.maximize' : 'nav.minimize')}
@@ -490,6 +472,8 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
490
472
  </button>
491
473
  </div>
492
474
  </header>
475
+ <QuestionWaitBar card={card} t={t} busy={busy !== null} onTakeTime={takeTime} />
476
+ {review !== undefined && <div className={css.reviewStatus}>{t('review.status')}</div>}
493
477
 
494
478
  {!minimized && (
495
479
  <>
@@ -503,24 +487,20 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
503
487
  {question.detail !== undefined && (
504
488
  <div className={css.detail}><MarkdownText text={question.detail} labels={markdownLabels} /></div>
505
489
  )}
506
- <div className={css.options} role={question.multiSelect === true ? 'group' : 'radiogroup'}>
490
+ <div className={css.options} role={hasOptions && question.multiSelect !== true ? 'radiogroup' : 'group'} aria-labelledby={questionId}>
507
491
  {(question.options ?? []).map((option, optionIndex) => {
508
492
  const selected = draft.selected.includes(option.label)
509
493
  const display = parseRecommendedLabel(option.label)
510
494
  return (
511
495
  <button
512
496
  type="button" key={`${option.label}-${String(optionIndex)}`}
513
- className={clsx(css.option, selected && question.multiSelect !== true && css.optionSelected)}
497
+ className={clsx(css.option, selected && css.optionSelected)}
514
498
  role={question.multiSelect === true ? 'checkbox' : 'radio'}
515
499
  aria-checked={selected}
516
- aria-label={display.label}
500
+ aria-label={display.recommended ? `${display.label}, ${t('option.recommended')}` : display.label}
501
+ aria-describedby={option.description === undefined ? undefined : `${questionId}-option-${String(optionIndex)}`}
517
502
  disabled={locked}
518
503
  onClick={() => { choose(option.label) }}
519
- onKeyDown={(event) => {
520
- if (event.key !== 'Enter') return
521
- event.preventDefault()
522
- submitDrafts(drafts)
523
- }}
524
504
  >
525
505
  {question.multiSelect === true
526
506
  ? (
@@ -528,7 +508,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
528
508
  {selected && <IconCheckOutlineRegular size={12} />}
529
509
  </span>
530
510
  )
531
- : <span className={css.number}>{optionIndex + 1}</span>}
511
+ : <span className={clsx(css.radio, selected && css.radioChecked)} aria-hidden="true" />}
532
512
  <span className={css.optionCopy}>
533
513
  <span className={css.optionLine}>
534
514
  <span className={css.optionLabel}>
@@ -537,12 +517,12 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
537
517
  {display.recommended && (
538
518
  <span className={css.badge}>{t('option.recommended')}</span>
539
519
  )}
540
- {option.description !== undefined && (
541
- <span className={css.description}>
542
- <MarkdownText text={option.description} variant="compact" labels={markdownLabels} />
543
- </span>
544
- )}
545
520
  </span>
521
+ {option.description !== undefined && (
522
+ <span className={css.description} id={`${questionId}-option-${String(optionIndex)}`}>
523
+ <MarkdownText text={option.description} variant="compact" labels={markdownLabels} />
524
+ </span>
525
+ )}
546
526
  </span>
547
527
  </button>
548
528
  )
@@ -561,7 +541,6 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
561
541
  className={clsx(
562
542
  css.customRow,
563
543
  draft.custom !== '' && css.customRowActive,
564
- question.multiSelect !== true && draft.selected.length > 0 && css.customRowYielded,
565
544
  )}
566
545
  >
567
546
  {question.multiSelect === true
@@ -574,7 +553,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
574
553
  </span>
575
554
  )
576
555
  : (
577
- <span className={css.number} aria-hidden="true">
556
+ <span className={css.customIcon} aria-hidden="true">
578
557
  <IconEditOutlineRegular size={12} />
579
558
  </span>
580
559
  )}
@@ -583,6 +562,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
583
562
  value={draft.custom}
584
563
  disabled={locked}
585
564
  placeholder={t('custom.placeholder')}
565
+ labelledBy={questionId}
586
566
  onChange={draftCustom}
587
567
  onKeyDown={continueFromCustom}
588
568
  />
@@ -597,6 +577,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
597
577
  value={draft.custom}
598
578
  disabled={locked}
599
579
  placeholder={t('custom.placeholder')}
580
+ labelledBy={questionId}
600
581
  onFocus={() => { focusedQuestions.current.add(index) }}
601
582
  onChange={draftCustom}
602
583
  onKeyDown={continueFromCustom}
@@ -606,24 +587,26 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
606
587
  </div>
607
588
 
608
589
  <footer className={css.footer}>
609
- <div className={css.pager}>
610
- <button
611
- type="button" className={css.iconButton} aria-label={t('nav.prev')}
612
- disabled={index === 0 || busy !== null}
613
- onClick={() => { replaceProgress(index - 1, drafts); setError(null) }}
614
- >
615
- <IconChevronLeftOutlineRegular />
616
- </button>
617
- <span className={css.progress}>{index + 1} / {questions.length}</span>
618
- <button
619
- type="button" className={css.iconButton} aria-label={t('nav.next')}
620
- disabled={index === questions.length - 1 || busy !== null}
621
- onClick={() => { replaceProgress(index + 1, drafts); setError(null) }}
622
- >
623
- <IconChevronRightOutlineRegular />
624
- </button>
625
- </div>
626
- <div className={css.feedback} role="status">
590
+ {questions.length > 1 && (
591
+ <div className={css.pager}>
592
+ <button
593
+ type="button" className={css.iconButton} aria-label={t('nav.prev')}
594
+ disabled={index === 0 || busy !== null}
595
+ onClick={() => { replaceProgress(index - 1, drafts); setError(null) }}
596
+ >
597
+ <IconChevronLeftOutlineRegular />
598
+ </button>
599
+ <span className={css.progress}>{index + 1} / {questions.length}</span>
600
+ <button
601
+ type="button" className={css.iconButton} aria-label={t('nav.next')}
602
+ disabled={index === questions.length - 1 || busy !== null}
603
+ onClick={() => { replaceProgress(index + 1, drafts); setError(null) }}
604
+ >
605
+ <IconChevronRightOutlineRegular />
606
+ </button>
607
+ </div>
608
+ )}
609
+ <div className={css.feedback} role="status" aria-atomic="true">
627
610
  {error === null ? null : 'key' in error ? t(error.key) : error.text}
628
611
  </div>
629
612
  {/* A review card has nothing to send: the pager alone walks the record. */}
@@ -633,7 +616,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
633
616
  {t('action.skip')}
634
617
  </Button>
635
618
  <Button
636
- variant="primary"
619
+ variant="primary" className={css.primaryButton}
637
620
  disabled={busy !== null || !answered(draft) || (index === questions.length - 1 && !canSubmit)}
638
621
  onClick={continueFlow}
639
622
  >
@@ -1,193 +1,37 @@
1
- .row {
2
- display: flex;
3
- flex-direction: column;
4
- justify-content: flex-end;
5
- align-items: flex-end;
6
- gap: 6px;
7
- padding: 4px 0;
8
- }
9
-
10
- .bubble {
11
- max-width: 72%;
12
- padding: 10px 16px;
13
- border-radius: var(--dsw-radius-xl);
14
- background: var(--dsw-specific-bubble);
15
- color: var(--dsw-alias-label-primary);
16
- cursor: pointer;
17
- font-size: var(--dsh-content-font-size, 14px);
18
- line-height: calc(22px + var(--dsh-content-font-delta, 0px));
19
- text-align: left;
20
- overflow-wrap: anywhere;
21
- white-space: pre-wrap;
22
- }
23
-
24
- .toggle {
25
- width: 100%;
26
- padding: 0;
27
- border: 0;
28
- background: transparent;
29
- color: inherit;
30
- cursor: pointer;
31
- font: inherit;
32
- text-align: left;
33
- }
34
-
35
- .toggle:focus-visible {
36
- outline: 2px solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
37
- outline-offset: 2px;
38
- }
39
-
40
- .bubble:has(.toggle:focus-visible) {
41
- box-shadow: 0 0 0 2px var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
42
- }
43
-
44
- .labelRow {
45
- display: flex;
46
- align-items: center;
47
- gap: 3px;
48
- }
49
-
50
- .caret {
51
- display: inline-flex;
52
- color: var(--dsw-alias-label-secondary);
53
- }
54
-
55
- .caret svg {
56
- width: 12px;
57
- height: 12px;
58
- }
59
-
60
- .label {
61
- color: var(--dsw-alias-label-secondary);
62
- display: block;
63
- font-size: var(--dsh-content-font-size-secondary, 13px);
64
- line-height: calc(18px + var(--dsh-content-font-delta-secondary, 0px));
65
- }
66
-
67
- .summary {
68
- display: block;
69
- margin-top: 3px;
70
- color: var(--dsw-alias-label-primary);
71
- font-size: var(--dsh-content-font-size, 14px);
72
- }
73
-
74
- .text {
75
- margin: 8px 0 0;
76
- }
77
-
78
- .details {
79
- margin: 8px 0 0;
80
- padding-top: 8px;
81
- border-top: 1px solid color-mix(in srgb, var(--dsw-alias-label-secondary) 24%, transparent);
82
- }
83
-
84
- .details > div + div {
85
- margin-top: 12px;
86
- }
87
-
88
- .details dt {
89
- color: var(--dsw-alias-label-secondary);
90
- font-size: 12px;
91
- }
92
-
93
- .question {
94
- display: grid;
95
- gap: 3px;
96
- }
97
-
98
- .header,
99
- .detail,
100
- .options {
101
- color: var(--dsw-alias-label-secondary);
102
- font-size: 11px;
103
- }
104
-
105
- .questionText {
106
- color: var(--dsw-alias-label-primary);
107
- }
108
-
109
- .options {
110
- margin: 0;
111
- padding-left: 16px;
112
- }
113
-
114
- .details dd {
115
- margin: 4px 0 0;
116
- }
117
-
118
- .answer {
119
- font-size: 14px;
120
- }
121
-
122
- .answerLabel {
123
- margin-right: 4px;
124
- color: var(--dsw-alias-label-secondary);
125
- font-size: 12px;
126
- }
127
-
128
- .actions {
129
- display: flex;
130
- align-items: center;
131
- gap: 8px;
132
- height: 28px;
133
- padding-right: 4px;
134
- color: var(--dsw-alias-label-tertiary);
135
- }
136
-
137
- .time {
138
- padding-right: 4px;
139
- font-size: 13px;
140
- line-height: 24px;
141
- white-space: nowrap;
142
- }
143
-
144
- .action {
145
- display: inline-flex;
146
- align-items: center;
147
- justify-content: center;
148
- width: 28px;
149
- height: 28px;
150
- padding: 6px;
151
- border: none;
152
- border-radius: var(--dsw-radius-sm);
153
- background: transparent;
154
- color: inherit;
155
- cursor: pointer;
156
- }
157
-
158
- .action svg {
159
- width: 15px;
160
- height: 15px;
161
- }
162
-
163
- .action:hover {
164
- background: var(--dsw-alias-interactive-bg-hover);
165
- color: var(--dsw-alias-label-secondary);
166
- }
167
-
168
- /* Better ask-user: long reply text and narrow screens. */
169
- .row,
170
- .summary,
171
- .text,
172
- .question,
173
- .questionText,
174
- .answer,
175
- .details {
176
- min-width: 0;
177
- overflow-wrap: anywhere;
178
- word-break: break-word;
179
- }
180
-
181
- @media (max-width: 720px) {
182
- .bubble {
183
- max-width: 100%;
184
- }
185
-
186
- .labelRow {
187
- flex-wrap: wrap;
188
- }
189
-
190
- .details {
191
- max-width: 100%;
192
- }
193
- }
1
+ .row { --ask-accent: #3388BB; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; padding: 8px 0; }
2
+ .bubble { max-width: 85%; min-width: 0; overflow: hidden; border: 0.5px solid var(--dsw-alias-border-l3); border-radius: 12px; background: var(--dsw-alias-bg-layer-3); color: var(--dsw-alias-label-primary); font-size: 13px; line-height: 20px; text-align: left; overflow-wrap: anywhere; }
3
+ .toggle { display: block; width: 100%; min-height: 32px; padding: 10px 12px; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; text-align: left; transition: background-color 100ms ease; }
4
+ .toggle:hover { background: var(--dsw-alias-interactive-bg-hover); }
5
+ .toggle:active { background: color-mix(in srgb, var(--ask-accent) 10%, transparent); }
6
+ .toggle:focus-visible { outline: 2px solid var(--ask-accent); outline-offset: -2px; border-radius: 8px; }
7
+ .labelRow { display: flex; align-items: center; gap: 8px; }
8
+ .caret { display: inline-flex; flex: none; color: var(--dsw-alias-label-secondary); }
9
+ .caret svg { width: 12px; height: 12px; }
10
+ .label { color: var(--dsw-alias-label-secondary); font-size: 12px; font-weight: 500; }
11
+ .summary { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; margin-top: 4px; white-space: pre-wrap; }
12
+ .text { margin: 0; padding: 0 12px 12px; white-space: pre-wrap; }
13
+ .details { max-height: min(50vh, 400px); margin: 0; padding: 0 12px 12px; overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; scrollbar-gutter: stable; }
14
+ .details > div { padding-top: 16px; border-top: 1px solid var(--dsw-alias-border-l2); }
15
+ .details > div + div { margin-top: 16px; }
16
+ .question { display: grid; gap: 4px; font-size: 13px; }
17
+ .questionText { font-weight: 500; }
18
+ .header, .detail { color: var(--dsw-alias-label-secondary); font-size: 12px; }
19
+ .detail { white-space: pre-wrap; }
20
+ .options { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; color: var(--dsw-alias-label-secondary); font-size: 12px; }
21
+ .options li { display: flex; align-items: flex-start; gap: 8px; padding: 8px; border-radius: 6px; }
22
+ .options li[data-selected] { background: color-mix(in srgb, var(--ask-accent) 9%, transparent); color: var(--dsw-alias-label-primary); }
23
+ .selection { display: grid; place-items: center; width: 16px; height: 18px; flex: none; color: color-mix(in srgb, var(--ask-accent) 72%, var(--dsw-alias-label-primary)); }
24
+ .optionCopy { display: grid; min-width: 0; gap: 4px; }
25
+ .optionDescription { color: var(--dsw-alias-label-secondary); }
26
+ .answer { margin: 12px 0 0; white-space: pre-wrap; }
27
+ .answerLabel { margin-right: 8px; color: var(--dsw-alias-label-secondary); font-size: 12px; }
28
+ .actions { display: flex; align-items: center; gap: 8px; color: var(--dsw-alias-label-tertiary); }
29
+ .time { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; font-variant-numeric: tabular-nums; }
30
+ .action { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; }
31
+ .action svg { width: 14px; height: 14px; }
32
+ .action:hover { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
33
+ .action:active { background: color-mix(in srgb, var(--ask-accent) 10%, transparent); }
34
+ .action:focus-visible { outline: 2px solid var(--ask-accent); outline-offset: 2px; }
35
+ .question, .answer, .text { min-width: 0; overflow-wrap: anywhere; }
36
+ @media (max-width: 640px) { .bubble { max-width: 100%; } .toggle { min-height: 44px; } .action { width: 44px; height: 44px; } }
37
+ @media (prefers-reduced-motion: reduce) { .toggle { transition: none; } }
@@ -1,4 +1,4 @@
1
- import { memo, useCallback, useState } from 'react'
1
+ import { memo, useCallback, useEffect, useRef, useState } from 'react'
2
2
  import type {} from '@deepseek-ai/dsh-client-ui-chat/client'
3
3
  import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'
4
4
  import {
@@ -31,15 +31,19 @@ export function QuestionReplyBubble({ data, t }: { data: QuestionReplyData; t: P
31
31
  const label = t('reply.label')
32
32
  const [open, setOpen] = useState(false)
33
33
  const toggleLabel = t(open ? 'reply.close' : 'reply.open')
34
- const summary = data.questions.map(question => replyAnswerValues(data, question.id)).flat().join(', ')
34
+ const summary = data.questions.length === 0
35
+ ? data.text
36
+ : data.questions.flatMap(question => replyAnswerValues(data, question.id)).join(', ')
35
37
  const copyText = replyClipboardText(data, t)
36
38
  const [copied, setCopied] = useState(false)
39
+ const copyTimer = useRef<ReturnType<typeof setTimeout>>()
40
+ useEffect(() => () => { window.clearTimeout(copyTimer.current) }, [])
37
41
  const onCopy = useCallback(() => {
38
42
  if (copied) return
39
43
  void writeClipboard(copyText).then((ok) => {
40
44
  if (!ok) return
41
45
  setCopied(true)
42
- window.setTimeout(() => { setCopied(false) }, 1000)
46
+ copyTimer.current = window.setTimeout(() => { setCopied(false) }, 1000)
43
47
  })
44
48
  }, [copied, copyText])
45
49
  return (
@@ -76,7 +80,12 @@ export function QuestionReplyBubble({ data, t }: { data: QuestionReplyData; t: P
76
80
  {question.detail && <span className={css.detail}>{question.detail}</span>}
77
81
  {question.options && question.options.length > 0 && (
78
82
  <ul className={css.options}>
79
- {question.options.map(option => <li key={option.label}>{option.label}{option.description && ` — ${option.description}`}</li>)}
83
+ {question.options.map(option => (
84
+ <li key={option.label} data-selected={values.includes(option.label) || undefined}>
85
+ <span className={css.selection} aria-hidden="true">{values.includes(option.label) ? <IconCheckOutlineRegular size={12} /> : null}</span>
86
+ <span className={css.optionCopy}><span>{option.label}</span>{option.description && <span className={css.optionDescription}>{option.description}</span>}</span>
87
+ </li>
88
+ ))}
80
89
  </ul>
81
90
  )}
82
91
  </dt>
@@ -0,0 +1,30 @@
1
+ .bar {
2
+ --ask-accent: #3388BB;
3
+ display: flex;
4
+ align-items: center;
5
+ flex-shrink: 0;
6
+ gap: 8px;
7
+ min-height: 36px;
8
+ margin: 0 16px 12px;
9
+ padding: 2px 4px 2px 8px;
10
+ border: 0.5px solid var(--dsw-alias-border-l2);
11
+ border-radius: 8px;
12
+ background: var(--dsw-alias-bg-layer-2);
13
+ color: var(--dsw-alias-label-primary);
14
+ }
15
+ .clock { position: relative; display: grid; place-items: center; width: 24px; height: 24px; flex: none; }
16
+ .ring { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke-width: 2; transform: rotate(-90deg); }
17
+ .track { stroke: var(--dsw-alias-border-l2); }
18
+ .remaining { stroke: var(--ask-accent); }
19
+ .clockHand { width: 8px; height: 9px; margin-top: -4px; margin-left: 5px; border-left: 1.5px solid var(--dsw-alias-label-secondary); border-bottom: 1.5px solid var(--dsw-alias-label-secondary); }
20
+ .pause { width: 16px; height: 16px; color: var(--dsw-alias-label-secondary); }
21
+ .status { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; min-width: 0; }
22
+ .time { font-size: 12px; line-height: 20px; }
23
+ .bar[data-wait-state='counting'] .time, .bar[data-wait-state='paused'] .time { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
24
+ .policy { color: var(--dsw-alias-label-secondary); font-size: 12px; line-height: 20px; }
25
+ .takeTime { flex: none; margin-left: auto; min-height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: transparent; color: var(--dsw-alias-label-secondary); font: inherit; font-size: 12px; cursor: pointer; }
26
+ .takeTime:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover); color: var(--dsw-alias-label-primary); }
27
+ .takeTime:active:not(:disabled) { background: color-mix(in srgb, var(--ask-accent) 10%, transparent); }
28
+ .takeTime:focus-visible { outline: 2px solid var(--ask-accent); outline-offset: 2px; }
29
+ .takeTime:disabled { opacity: .4; cursor: default; }
30
+ @media (max-width: 720px) { .bar { gap: 8px; margin: 0 16px 12px; padding: 4px 8px; } .status { display: grid; gap: 0; } .takeTime { min-height: 44px; } }
@@ -0,0 +1,41 @@
1
+ import { useRef } from 'react'
2
+ import type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'
3
+ import type { QuestionCardSnapshot } from './contract/slots.ts'
4
+ import css from './QuestionWaitBar.module.css'
5
+
6
+ /** A view of the carrier's countdown; the carrier owns every timing decision. */
7
+ export function QuestionWaitBar({ card, t, busy, onTakeTime }: {
8
+ card: QuestionCardSnapshot | undefined
9
+ t: PropsLocale<'question'>['t']
10
+ busy: boolean
11
+ onTakeTime: () => void
12
+ }) {
13
+ const countdown = card?.countdown
14
+ const initialWindow = useRef(countdown?.remainingMs)
15
+ if (card === undefined || (countdown === undefined && card.state !== 'continued')) return null
16
+ const continued = card.state === 'continued'
17
+ const held = card.waitState === 'waiting' || card.waitState === 'editing'
18
+ const running = !held && !continued && countdown?.running === true
19
+ const seconds = Math.max(0, Math.ceil((countdown?.remainingMs ?? 0) / 1000))
20
+ const duration = card.waitMs ?? initialWindow.current
21
+ const fraction = duration === undefined || duration <= 0 ? undefined : Math.min(1, Math.max(0, (countdown?.remainingMs ?? 0) / duration))
22
+ const status = continued ? t('wait.continued') : held ? t('wait.held')
23
+ : t(!running ? 'wait.paused' : card.timeoutMode === 'default' ? 'wait.autoCountdown' : 'wait.countdown', { seconds })
24
+ return (
25
+ <div className={css.bar} data-question-wait data-wait-state={continued ? 'continued' : held ? 'held' : running ? 'counting' : 'paused'}>
26
+ <span className={css.clock} aria-hidden="true">
27
+ <svg viewBox="0 0 32 32" className={css.ring}>
28
+ <circle className={css.track} cx="16" cy="16" r="13" />
29
+ {!held && !continued && fraction !== undefined && <circle className={css.remaining} cx="16" cy="16" r="13" pathLength="100" strokeDasharray="100" strokeDashoffset={100 * (1 - fraction)} />}
30
+ </svg>
31
+ {!running ? <svg className={css.pause} viewBox="0 0 16 16" fill="none" stroke="currentColor" strokeWidth="1.5">{continued ? <path d="m3 8 3 3 7-7" /> : <path d="M6 4v8M10 4v8" />}</svg> : <span className={css.clockHand} /> }
32
+ </span>
33
+ <div className={css.status} role={held || continued ? 'status' : undefined} aria-atomic="true">
34
+ <span className={css.time} aria-label={status}>{held || continued ? status : `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, '0')}`}</span>
35
+ {!held && !continued && !running && <span className={css.policy}>{t('wait.pauseLabel')}</span>}
36
+ {!held && !continued && <span className={css.policy}>{t(card.timeoutMode === 'default' ? 'wait.auto' : 'wait.extend')}</span>}
37
+ </div>
38
+ {!held && !continued && <button type="button" className={css.takeTime} disabled={busy} onClick={onTakeTime}>{t('wait.takeTime')}</button>}
39
+ </div>
40
+ )
41
+ }
@@ -419,6 +419,11 @@ export function apply(ctx: ClientContext): void {
419
419
  name: 'tool.call.toolview',
420
420
  key: 'ask_user_question',
421
421
  locale: NS,
422
+ // The shipped `@deepseek-ai/dsh-client-ui-tool` already registers
423
+ // `ask-question-toolview` for this key at priority 0, and the slot registry
424
+ // rejects a second entry at the same priority (which failed the whole client
425
+ // boot). A lower priority shadows it: lowest renders.
426
+ priority: -1,
422
427
  inject: (sessionId: SessionId) => ({
423
428
  revealPanel: (callId: string) => ctx.get('userQuestionPanels')?.reveal(sessionId, callId) ?? false,
424
429
  reviewPanel: (callId: string, record: UserQuestionRecord) => ctx.get('userQuestionPanels')?.review(sessionId, callId, record) ?? false,
@@ -448,4 +453,4 @@ export function apply(ctx: ClientContext): void {
448
453
  }
449
454
 
450
455
  // Exported for the built-closure behavior tests; the client loader ignores it.
451
- export { PendingQuestion }
456
+ export { PendingQuestion, SettingsEntry }
@@ -12,6 +12,8 @@ export const zh = {
12
12
  'history.reopen': '打开',
13
13
  'wait.takeTime': '慢慢回答',
14
14
  'wait.countdown': '{seconds} 秒后继续工作',
15
+ 'wait.autoCountdown': '{seconds} 秒后自动选择默认项',
16
+ 'wait.pauseLabel': '已暂停',
15
17
  'wait.paused': '已暂停 · 剩余 {seconds} 秒',
16
18
  'wait.held': '会一直等你回答',
17
19
  'wait.extend': '输入会自动续期',
@@ -19,7 +21,7 @@ export const zh = {
19
21
  'wait.continued': '已继续工作,仍可回答',
20
22
  'review.status': '已回答',
21
23
  'review.skipped': '这道问题当时被跳过。',
22
- 'reply.label': '回答先前等待中的问题',
24
+ 'reply.label': '问题回复',
23
25
  'reply.open': '展开问题详情',
24
26
  'reply.close': '收起问题详情',
25
27
  'reply.answerLabel': '回答:',
@@ -55,6 +57,8 @@ export const en = {
55
57
  'history.reopen': 'Open',
56
58
  'wait.takeTime': 'Take time',
57
59
  'wait.countdown': 'Continuing in {seconds}s',
60
+ 'wait.autoCountdown': 'Defaults selected in {seconds}s',
61
+ 'wait.pauseLabel': 'Paused',
58
62
  'wait.paused': 'Paused · {seconds}s remaining',
59
63
  'wait.held': 'Waiting until you answer',
60
64
  'wait.extend': 'Typing extends the wait',
@@ -62,7 +66,7 @@ export const en = {
62
66
  'wait.continued': 'Work continued — you can still answer',
63
67
  'review.status': 'Answered',
64
68
  'review.skipped': 'This question was skipped.',
65
- 'reply.label': 'Reply to earlier pending questions',
69
+ 'reply.label': 'Question reply',
66
70
  'reply.open': 'Open question details',
67
71
  'reply.close': 'Close question details',
68
72
  'reply.answerLabel': 'Answer: ',