dsh-better-ask-user 0.1.7 → 0.3.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
  /**
@@ -41,6 +42,7 @@ export function parseRecommendedLabel(label: string): { label: string; recommend
41
42
 
42
43
  /** Only a marked first choice is an implicit draft; the user still submits it. */
43
44
  function recommendedFirstOption(question: PendingQuestion['questions'][number]): string | undefined {
45
+ if (question.intent?.kind === 'approval' || question.intent?.kind === 'plan-review') return undefined
44
46
  const label = question.options?.[0]?.label
45
47
  return label !== undefined && parseRecommendedLabel(label).recommended ? label : undefined
46
48
  }
@@ -75,6 +77,8 @@ interface AnswerFieldProps {
75
77
  value: string
76
78
  /** Empty-field prompt. */
77
79
  placeholder: string
80
+ /** The visible question that labels this answer. */
81
+ labelledBy: string
78
82
  /** Whether a submission in flight has frozen the field. */
79
83
  disabled: boolean
80
84
  /** Whether this field takes focus on mount. */
@@ -114,6 +118,7 @@ function AnswerField(props: AnswerFieldProps) {
114
118
  disabled={props.disabled}
115
119
  rows={1}
116
120
  placeholder={props.placeholder}
121
+ aria-labelledby={props.labelledBy}
117
122
  onFocus={props.onFocus}
118
123
  onChange={props.onChange}
119
124
  onKeyDown={props.onKeyDown}
@@ -150,7 +155,7 @@ export function QuestionComposer(props: QuestionComposerProps) {
150
155
  actions={props.actions}
151
156
  />
152
157
  )
153
- : <PlanReviewPanel key={question.key} pending={question} review={review} t={props.t} renderSlot={props.renderSlot} />
158
+ : <PlanReviewPanel key={question.key} pending={question} review={review} t={props.t} renderSlot={props.renderSlot} useQuestionCard={props.useQuestionCard} />
154
159
  }
155
160
 
156
161
  type QuestionFlowProps =
@@ -196,7 +201,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
196
201
  const [busy, setBusy] = useState<'answer' | 'cancel' | null>(null)
197
202
  const [error, setError] = useState<Feedback | null>(null)
198
203
  const card = useQuestionCard(pending.key, snapshot => snapshot ?? REMOVED_CARD)
199
- const canSubmit = card.channel !== 'none'
204
+ const canSubmit = !card.closed && card.channel !== 'none'
200
205
  // The answer surface freezes while a submission is in flight, and for good on
201
206
  // a review card: its call has already settled.
202
207
  const locked = busy !== null || review !== undefined
@@ -236,13 +241,15 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
236
241
  // collapsed question must not steal focus from the expand toggle back into
237
242
  // the input, so focus is granted once per question index.
238
243
  const focusedQuestions = useRef(new Set<number>())
239
- const answerSurface = useRef<HTMLDivElement>(null)
244
+ const answerSurface = useRef<HTMLElement>(null)
240
245
  // Every navigation write stays in bounds and drafts mirrors questions 1:1.
241
246
  // oxlint-disable-next-line typescript/no-non-null-assertion
242
247
  const question = questions[index]!
243
248
  // oxlint-disable-next-line typescript/no-non-null-assertion
244
249
  const draft = drafts[index]!
245
250
  const hasOptions = (question.options?.length ?? 0) > 0
251
+ const fixedActions = question.intent?.kind === 'approval'
252
+ const questionId = `question-${pending.key}-${String(index)}`
246
253
 
247
254
  const replaceProgress = (nextIndex: number, nextDrafts: QuestionDraftAnswer[]): void => {
248
255
  // Every real answer input (option click, text edit, page navigation, skip)
@@ -262,11 +269,11 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
262
269
  replaceProgress(index, drafts)
263
270
  }
264
271
 
265
- const focusAnswerSurface = (event: FocusEvent<HTMLDivElement>): void => {
272
+ const focusAnswerSurface = (event: FocusEvent<HTMLElement>): void => {
266
273
  if (!event.currentTarget.contains(event.relatedTarget)) pending.holdFocus()
267
274
  }
268
275
 
269
- const blurAnswerSurface = (event: FocusEvent<HTMLDivElement>): void => {
276
+ const blurAnswerSurface = (event: FocusEvent<HTMLElement>): void => {
270
277
  if (!event.currentTarget.contains(event.relatedTarget)) pending.releaseFocus()
271
278
  }
272
279
 
@@ -318,7 +325,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
318
325
  setError(null)
319
326
  }
320
327
 
321
- const choose = (label: string): void => {
328
+ const choose = (label: string, advance = true): void => {
322
329
  updateDraft((current) => {
323
330
  if (question.multiSelect === true) {
324
331
  const selected = current.selected.includes(label)
@@ -327,7 +334,23 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
327
334
  return { ...current, selected, skipped: false }
328
335
  }
329
336
  return { selected: [label], custom: '', skipped: false }
330
- }, question.multiSelect !== true && index < questions.length - 1 ? index + 1 : index)
337
+ }, advance && question.multiSelect !== true && index < questions.length - 1 ? index + 1 : index)
338
+ }
339
+
340
+ const navigateOptions = (event: KeyboardEvent<HTMLButtonElement>, optionIndex: number): void => {
341
+ if (question.multiSelect === true || locked || event.defaultPrevented) return
342
+ const options = question.options ?? []
343
+ let next: number
344
+ if (event.key === 'ArrowDown' || event.key === 'ArrowRight') next = (optionIndex + 1) % options.length
345
+ else if (event.key === 'ArrowUp' || event.key === 'ArrowLeft') next = (optionIndex - 1 + options.length) % options.length
346
+ else if (event.key === 'Home') next = 0
347
+ else if (event.key === 'End') next = options.length - 1
348
+ else return
349
+ event.preventDefault()
350
+ event.stopPropagation()
351
+ event.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>('[role="radio"]')[next]?.focus()
352
+ // Arrow navigation changes the choice without advancing to another question.
353
+ choose(options[next]!.label, false)
331
354
  }
332
355
 
333
356
  const answered = (item: QuestionDraftAnswer): boolean =>
@@ -406,7 +429,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
406
429
  }
407
430
 
408
431
  const continueFromCustom = (event: KeyboardEvent<HTMLTextAreaElement>): void => {
409
- if (event.key !== 'Enter' || event.shiftKey || isComposing(event)) return
432
+ if (event.defaultPrevented || event.repeat || event.key !== 'Enter' || event.shiftKey || isComposing(event)) return
410
433
  event.preventDefault()
411
434
  continueFlow()
412
435
  }
@@ -426,50 +449,34 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
426
449
  return (
427
450
  <div className={css.frame} data-question-key={pending.key}>
428
451
  <section
452
+ ref={answerSurface}
429
453
  className={clsx(css.card, minimized && css.cardMinimized)}
430
- aria-labelledby={`question-${pending.key}-${String(index)}`}
454
+ onFocusCapture={focusAnswerSurface}
455
+ onBlurCapture={blurAnswerSurface}
456
+ aria-labelledby={questionId}
457
+ aria-busy={busy !== null}
431
458
  >
432
459
  <header className={css.header}>
433
460
  <div className={css.headingBlock}>
434
- {question.header !== undefined && (
435
- <div className={css.eyebrow}>
436
- <MarkdownText text={question.header} variant="compact" labels={markdownLabels} />
461
+ <div className={css.titleRow}>
462
+ <div
463
+ className={css.title}
464
+ id={questionId}
465
+ role="heading"
466
+ aria-level={2}
467
+ >
468
+ <MarkdownText text={question.question} variant="compact" labels={markdownLabels} />
437
469
  </div>
438
- )}
439
- <div
440
- className={css.title}
441
- id={`question-${pending.key}-${String(index)}`}
442
- role="heading"
443
- aria-level={2}
444
- >
445
- <MarkdownText text={question.question} variant="compact" labels={markdownLabels} />
470
+ {question.header !== undefined && question.header.trim() !== question.question.trim()
471
+ && !question.question.toLocaleLowerCase().includes(question.header.trim().toLocaleLowerCase()) && (
472
+ <span className={css.headerChip}>
473
+ <MarkdownText text={question.header} variant="compact" labels={markdownLabels} />
474
+ </span>
475
+ )}
476
+ {review !== undefined && <span className={css.statusChip}>{t('review.status')}</span>}
446
477
  </div>
447
478
  </div>
448
479
  <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
480
  <button
474
481
  type="button" className={css.iconButton}
475
482
  aria-label={t(minimized ? 'nav.maximize' : 'nav.minimize')}
@@ -490,37 +497,33 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
490
497
  </button>
491
498
  </div>
492
499
  </header>
500
+ <QuestionWaitBar card={card} t={t} busy={busy !== null} onTakeTime={takeTime} />
493
501
 
494
502
  {!minimized && (
495
503
  <>
496
504
  <div
497
- ref={answerSurface}
498
505
  className={css.body}
499
506
  data-question-scroll
500
- onFocusCapture={focusAnswerSurface}
501
- onBlurCapture={blurAnswerSurface}
502
507
  >
503
508
  {question.detail !== undefined && (
504
509
  <div className={css.detail}><MarkdownText text={question.detail} labels={markdownLabels} /></div>
505
510
  )}
506
- <div className={css.options} role={question.multiSelect === true ? 'group' : 'radiogroup'}>
511
+ <div className={css.options} role={hasOptions && question.multiSelect !== true ? 'radiogroup' : 'group'} aria-labelledby={questionId}>
507
512
  {(question.options ?? []).map((option, optionIndex) => {
508
513
  const selected = draft.selected.includes(option.label)
509
514
  const display = parseRecommendedLabel(option.label)
510
515
  return (
511
516
  <button
512
517
  type="button" key={`${option.label}-${String(optionIndex)}`}
513
- className={clsx(css.option, selected && question.multiSelect !== true && css.optionSelected)}
518
+ className={clsx(css.option, selected && css.optionSelected)}
514
519
  role={question.multiSelect === true ? 'checkbox' : 'radio'}
515
520
  aria-checked={selected}
516
- aria-label={display.label}
521
+ aria-label={display.recommended ? `${display.label}, ${t('option.recommended')}` : display.label}
522
+ aria-describedby={option.description === undefined ? undefined : `${questionId}-option-${String(optionIndex)}`}
517
523
  disabled={locked}
524
+ tabIndex={question.multiSelect === true || selected || (draft.selected.length === 0 && optionIndex === 0) ? 0 : -1}
525
+ onKeyDown={(event) => { navigateOptions(event, optionIndex) }}
518
526
  onClick={() => { choose(option.label) }}
519
- onKeyDown={(event) => {
520
- if (event.key !== 'Enter') return
521
- event.preventDefault()
522
- submitDrafts(drafts)
523
- }}
524
527
  >
525
528
  {question.multiSelect === true
526
529
  ? (
@@ -528,7 +531,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
528
531
  {selected && <IconCheckOutlineRegular size={12} />}
529
532
  </span>
530
533
  )
531
- : <span className={css.number}>{optionIndex + 1}</span>}
534
+ : <span className={clsx(css.radio, selected && css.radioChecked)} aria-hidden="true" />}
532
535
  <span className={css.optionCopy}>
533
536
  <span className={css.optionLine}>
534
537
  <span className={css.optionLabel}>
@@ -537,12 +540,12 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
537
540
  {display.recommended && (
538
541
  <span className={css.badge}>{t('option.recommended')}</span>
539
542
  )}
540
- {option.description !== undefined && (
541
- <span className={css.description}>
542
- <MarkdownText text={option.description} variant="compact" labels={markdownLabels} />
543
- </span>
544
- )}
545
543
  </span>
544
+ {option.description !== undefined && (
545
+ <span className={css.description} id={`${questionId}-option-${String(optionIndex)}`}>
546
+ <MarkdownText text={option.description} variant="compact" labels={markdownLabels} />
547
+ </span>
548
+ )}
546
549
  </span>
547
550
  </button>
548
551
  )
@@ -555,13 +558,12 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
555
558
  {/* A review card keeps the free-text field only when the
556
559
  recorded answer used it; an empty disabled box with a
557
560
  placeholder would read as somewhere to type. */}
558
- {(review === undefined || draft.custom !== '') && (hasOptions
561
+ {!fixedActions && (review === undefined || draft.custom !== '') && (hasOptions
559
562
  ? (
560
563
  <div
561
564
  className={clsx(
562
565
  css.customRow,
563
566
  draft.custom !== '' && css.customRowActive,
564
- question.multiSelect !== true && draft.selected.length > 0 && css.customRowYielded,
565
567
  )}
566
568
  >
567
569
  {question.multiSelect === true
@@ -574,7 +576,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
574
576
  </span>
575
577
  )
576
578
  : (
577
- <span className={css.number} aria-hidden="true">
579
+ <span className={css.customIcon} aria-hidden="true">
578
580
  <IconEditOutlineRegular size={12} />
579
581
  </span>
580
582
  )}
@@ -583,6 +585,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
583
585
  value={draft.custom}
584
586
  disabled={locked}
585
587
  placeholder={t('custom.placeholder')}
588
+ labelledBy={questionId}
586
589
  onChange={draftCustom}
587
590
  onKeyDown={continueFromCustom}
588
591
  />
@@ -597,6 +600,7 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
597
600
  value={draft.custom}
598
601
  disabled={locked}
599
602
  placeholder={t('custom.placeholder')}
603
+ labelledBy={questionId}
600
604
  onFocus={() => { focusedQuestions.current.add(index) }}
601
605
  onChange={draftCustom}
602
606
  onKeyDown={continueFromCustom}
@@ -606,37 +610,40 @@ function QuestionFlow({ pending, t, useStore, useQuestionCard, actions }: Questi
606
610
  </div>
607
611
 
608
612
  <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">
613
+ {questions.length > 1 && (
614
+ <div className={css.pager}>
615
+ <button
616
+ type="button" className={css.iconButton} aria-label={t('nav.prev')}
617
+ disabled={index === 0 || busy !== null}
618
+ onClick={() => { replaceProgress(index - 1, drafts); setError(null) }}
619
+ >
620
+ <IconChevronLeftOutlineRegular />
621
+ </button>
622
+ <span className={css.progress}>{index + 1} / {questions.length}</span>
623
+ <button
624
+ type="button" className={css.iconButton} aria-label={t('nav.next')}
625
+ disabled={index === questions.length - 1 || busy !== null}
626
+ onClick={() => { replaceProgress(index + 1, drafts); setError(null) }}
627
+ >
628
+ <IconChevronRightOutlineRegular />
629
+ </button>
630
+ </div>
631
+ )}
632
+ <div className={css.feedback} role="status" aria-atomic="true" data-error={error !== null && (!('key' in error) || error.key !== 'status.sent') || undefined}>
627
633
  {error === null ? null : 'key' in error ? t(error.key) : error.text}
628
634
  </div>
629
635
  {/* A review card has nothing to send: the pager alone walks the record. */}
630
636
  {review === undefined && (
631
637
  <div className={css.footerActions}>
632
- <Button variant="outline" disabled={busy !== null} onClick={skipQuestion}>
638
+ {!fixedActions && <Button variant="outline" className={css.button} disabled={busy !== null} onClick={skipQuestion}>
633
639
  {t('action.skip')}
634
- </Button>
640
+ </Button>}
635
641
  <Button
636
- variant="primary"
642
+ variant="primary" className={css.primary} aria-busy={busy === 'answer'}
637
643
  disabled={busy !== null || !answered(draft) || (index === questions.length - 1 && !canSubmit)}
638
644
  onClick={continueFlow}
639
645
  >
646
+ {busy === 'answer' && <span className={css.spinner} aria-hidden="true" />}
640
647
  {busy === 'answer'
641
648
  ? t('submitting')
642
649
  : index === questions.length - 1 ? t('submit') : t('action.next')}
@@ -1,193 +1,101 @@
1
1
  .row {
2
+ --cfg-line: var(--dsw-alias-border-l2);
3
+ --cfg-line-strong: var(--dsw-alias-border-l3);
4
+ --cfg-surface: var(--dsw-alias-bg-layer-2);
5
+ --cfg-sunken: color-mix(in srgb, var(--dsw-alias-label-primary) 4%, var(--dsw-alias-bg-layer-1));
6
+ --cfg-ink: var(--dsw-alias-label-primary);
7
+ --cfg-muted: var(--dsw-alias-label-secondary);
8
+ --cfg-accent: #3388bb;
9
+ --cfg-accent-text: #14587f;
10
+ --cfg-hover: var(--dsw-alias-interactive-bg-hover);
2
11
  display: flex;
3
12
  flex-direction: column;
4
- justify-content: flex-end;
5
13
  align-items: flex-end;
6
- gap: 6px;
14
+ gap: 4px;
15
+ min-width: 0;
7
16
  padding: 4px 0;
8
17
  }
9
-
10
18
  .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
+ max-width: 85%;
20
+ min-width: 0;
21
+ overflow: hidden;
22
+ border: 1px solid var(--cfg-line);
23
+ border-radius: 12px;
24
+ background: var(--cfg-surface);
25
+ color: var(--cfg-ink);
26
+ font-size: inherit;
27
+ line-height: 1.5;
19
28
  text-align: left;
20
29
  overflow-wrap: anywhere;
21
- white-space: pre-wrap;
22
30
  }
23
-
24
31
  .toggle {
32
+ appearance: none;
33
+ display: block;
25
34
  width: 100%;
26
- padding: 0;
35
+ padding: 10px 12px;
27
36
  border: 0;
28
37
  background: transparent;
29
38
  color: inherit;
30
39
  cursor: pointer;
31
40
  font: inherit;
32
41
  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
-
42
+ transition: background-color 100ms ease;
43
+ }
44
+ .toggle:hover { background: var(--cfg-hover); }
45
+ .toggle:focus-visible { outline: 2px solid var(--cfg-accent); outline-offset: -3px; border-radius: 8px; }
46
+ .labelRow { display: flex; align-items: center; gap: 6px; }
47
+ .caret { display: inline-flex; flex: none; color: var(--cfg-muted); }
48
+ .caret svg { width: 12px; height: 12px; }
49
+ .label { color: var(--cfg-muted); font-size: 11px; line-height: 18px; font-weight: 500; }
67
50
  .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;
51
+ display: -webkit-box;
52
+ -webkit-box-orient: vertical;
53
+ -webkit-line-clamp: 3;
54
+ overflow: hidden;
55
+ margin-top: 4px;
56
+ white-space: pre-wrap;
76
57
  }
77
-
58
+ .text { margin: 0; padding: 0 12px 12px; white-space: pre-wrap; }
78
59
  .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 {
60
+ max-height: min(50vh, 400px);
110
61
  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
- }
62
+ padding: 0 12px 12px;
63
+ overflow: auto;
64
+ overscroll-behavior: contain;
65
+ scrollbar-width: thin;
66
+ scrollbar-gutter: stable;
67
+ }
68
+ .details > div { padding-top: 10px; border-top: 1px solid var(--cfg-line); }
69
+ .details > div + div { margin-top: 12px; }
70
+ .question { display: grid; gap: 4px; font-size: inherit; }
71
+ .questionText { font-weight: 500; }
72
+ .header, .detail, .options { color: var(--cfg-muted); font-size: 12px; }
73
+ .detail { white-space: pre-wrap; }
74
+ .options { display: grid; gap: 4px; margin: 4px 0 0; padding: 0; list-style: none; }
75
+ .options li { display: flex; align-items: flex-start; gap: 6px; padding: 6px 8px; border: 1px solid transparent; border-radius: 8px; }
76
+ .options li[data-selected] { border-color: var(--cfg-accent); color: var(--cfg-ink); background: color-mix(in srgb, var(--cfg-accent) 8%, transparent); }
77
+ .selection { display: grid; place-items: center; width: 16px; height: 18px; flex: none; color: var(--cfg-accent); }
78
+ .optionCopy { display: grid; min-width: 0; gap: 2px; }
79
+ .optionDescription { color: var(--cfg-muted); }
80
+ .answer { margin: 8px 0 0; white-space: pre-wrap; }
81
+ .answerLabel { margin-right: 4px; color: var(--cfg-muted); font-size: 11px; line-height: 18px; }
82
+ .actions { display: flex; align-items: center; gap: 4px; padding-right: 2px; color: var(--dsw-alias-label-tertiary); }
83
+ .time { font-size: 11px; font-variant-numeric: tabular-nums; }
84
+ .action { appearance: none; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 6px; background: transparent; color: inherit; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
85
+ .action svg { width: 14px; height: 14px; }
86
+ .action:hover { background: var(--cfg-hover); color: var(--cfg-ink); }
87
+ .action:focus-visible { outline: 2px solid var(--cfg-accent); outline-offset: 2px; }
88
+ .action:disabled { opacity: .4; cursor: default; }
89
+ .copyFeedback { color: var(--cfg-muted); font-size: 12px; }
90
+ .copyFeedback[role='alert'] { color: var(--dsw-alias-state-error-primary); }
91
+ .copyFeedback:empty { display: none; }
92
+ .spinner { width: 12px; height: 12px; border: 1px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 800ms linear infinite; }
93
+ @keyframes spin { to { transform: rotate(360deg); } }
94
+ .question, .answer, .text { min-width: 0; overflow-wrap: anywhere; }
95
+ @media (max-width: 640px) {
96
+ .bubble { max-width: 100%; }
97
+ }
98
+ @media (pointer: coarse) { .toggle { min-height: 44px; } .action { width: 44px; height: 44px; } }
99
+ @media (prefers-reduced-motion: reduce) { .toggle, .action { transition: none; } .spinner { animation: none; } }
100
+
101
+ [data-ds-dark-theme] .row { --cfg-accent: #4eb0e8; --cfg-accent-text: #6fc0ee; }