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.
- package/LICENSE +202 -674
- package/NOTICE +23 -1
- package/README.md +23 -4
- package/lib/client.js +772 -360
- package/package.json +14 -13
- package/src/ask-tool.js +7 -1
- package/src/client/AskHistoryRow.module.css +21 -45
- package/src/client/AskHistoryRow.tsx +25 -19
- package/src/client/PlanReviewPanel.module.css +198 -68
- package/src/client/PlanReviewPanel.tsx +69 -13
- package/src/client/QuestionComposer.module.css +289 -357
- package/src/client/QuestionComposer.tsx +92 -85
- package/src/client/QuestionReplyView.module.css +79 -171
- package/src/client/QuestionReplyView.tsx +36 -17
- package/src/client/QuestionWaitBar.module.css +50 -0
- package/src/client/QuestionWaitBar.tsx +39 -0
- package/src/client/contract/slots.ts +19 -4
- package/src/client/index.ts +6 -6
- package/src/client/locales.ts +10 -2
- package/src/client/settings-locales.ts +44 -28
- package/src/client/settings.module.css +119 -0
- package/src/client/settings.tsx +120 -84
- package/src/index.js +2 -14
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { memo, useCallback, useState } from 'react'
|
|
1
|
+
import { memo, useCallback, useEffect, useId, 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,17 +31,27 @@ 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.
|
|
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
|
-
const
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const detailsId = useId()
|
|
39
|
+
const [copyState, setCopyState] = useState<'idle' | 'copying' | 'copied' | 'error'>('idle')
|
|
40
|
+
const copyTimer = useRef<ReturnType<typeof setTimeout>>()
|
|
41
|
+
useEffect(() => () => { window.clearTimeout(copyTimer.current) }, [])
|
|
42
|
+
const onCopy = useCallback(async () => {
|
|
43
|
+
if (copyState === 'copying' || copyState === 'copied') return
|
|
44
|
+
window.clearTimeout(copyTimer.current)
|
|
45
|
+
setCopyState('copying')
|
|
46
|
+
try {
|
|
47
|
+
const ok = await writeClipboard(copyText)
|
|
48
|
+
setCopyState(ok ? 'copied' : 'error')
|
|
49
|
+
if (ok) copyTimer.current = window.setTimeout(() => { setCopyState('idle') }, 1500)
|
|
50
|
+
} catch {
|
|
51
|
+
setCopyState('error')
|
|
52
|
+
}
|
|
53
|
+
}, [copyState, copyText])
|
|
54
|
+
const copyLabel = copyState === 'copied' ? t('copied') : t('copy')
|
|
45
55
|
return (
|
|
46
56
|
<div className={css.row} data-question-reply={data.callId} data-reply-outcome={data.outcome} role="group" aria-label={label}>
|
|
47
57
|
<div className={css.bubble}>
|
|
@@ -49,6 +59,7 @@ export function QuestionReplyBubble({ data, t }: { data: QuestionReplyData; t: P
|
|
|
49
59
|
type="button"
|
|
50
60
|
className={css.toggle}
|
|
51
61
|
aria-expanded={open}
|
|
62
|
+
aria-controls={open ? detailsId : undefined}
|
|
52
63
|
aria-label={`${label} · ${toggleLabel}`}
|
|
53
64
|
onClick={() => { setOpen(value => !value) }}
|
|
54
65
|
>
|
|
@@ -63,9 +74,9 @@ export function QuestionReplyBubble({ data, t }: { data: QuestionReplyData; t: P
|
|
|
63
74
|
{!open && <span className={css.summary}>{summary === '' ? t('reply.skipped') : summary}</span>}
|
|
64
75
|
</button>
|
|
65
76
|
{open && (data.questions.length === 0
|
|
66
|
-
? <p className={css.text}>{data.text}</p>
|
|
77
|
+
? <p className={css.text} id={detailsId}>{data.text}</p>
|
|
67
78
|
: (
|
|
68
|
-
<dl className={css.details}>
|
|
79
|
+
<dl className={css.details} id={detailsId}>
|
|
69
80
|
{data.questions.map((question) => {
|
|
70
81
|
const values = replyAnswerValues(data, question.id)
|
|
71
82
|
return (
|
|
@@ -76,7 +87,12 @@ export function QuestionReplyBubble({ data, t }: { data: QuestionReplyData; t: P
|
|
|
76
87
|
{question.detail && <span className={css.detail}>{question.detail}</span>}
|
|
77
88
|
{question.options && question.options.length > 0 && (
|
|
78
89
|
<ul className={css.options}>
|
|
79
|
-
{question.options.map(option =>
|
|
90
|
+
{question.options.map(option => (
|
|
91
|
+
<li key={option.label} data-selected={values.includes(option.label) || undefined}>
|
|
92
|
+
<span className={css.selection} aria-hidden="true">{values.includes(option.label) ? <IconCheckOutlineRegular size={12} /> : null}</span>
|
|
93
|
+
<span className={css.optionCopy}><span>{option.label}</span>{option.description && <span className={css.optionDescription}>{option.description}</span>}</span>
|
|
94
|
+
</li>
|
|
95
|
+
))}
|
|
80
96
|
</ul>
|
|
81
97
|
)}
|
|
82
98
|
</dt>
|
|
@@ -94,11 +110,14 @@ export function QuestionReplyBubble({ data, t }: { data: QuestionReplyData; t: P
|
|
|
94
110
|
<span className={css.time}>
|
|
95
111
|
{new Intl.DateTimeFormat(undefined, { hour: '2-digit', minute: '2-digit', hour12: false }).format(data.time)}
|
|
96
112
|
</span>
|
|
97
|
-
<Tooltip label={
|
|
98
|
-
<button type="button" className={css.action} aria-label={
|
|
99
|
-
{copied ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}
|
|
113
|
+
<Tooltip label={copyLabel} side="bottom">
|
|
114
|
+
<button type="button" className={css.action} aria-label={copyLabel} aria-busy={copyState === 'copying'} disabled={copyState === 'copying'} onClick={() => { void onCopy() }}>
|
|
115
|
+
{copyState === 'copying' ? <span className={css.spinner} aria-hidden="true" /> : copyState === 'copied' ? <IconCheckOutlineRegular /> : <IconCopyOutlineRegular />}
|
|
100
116
|
</button>
|
|
101
117
|
</Tooltip>
|
|
118
|
+
<span className={css.copyFeedback} role={copyState === 'error' ? 'alert' : 'status'}>
|
|
119
|
+
{copyState === 'error' ? t('reply.copyFailed') : copyState === 'copied' ? t('copied') : null}
|
|
120
|
+
</span>
|
|
102
121
|
</div>
|
|
103
122
|
</div>
|
|
104
123
|
)
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/* Compact countdown strip: ring, tabular time, one ghost action. */
|
|
2
|
+
.bar {
|
|
3
|
+
--ui-accent: #3388bb;
|
|
4
|
+
--ui-accent-text: #14587f;
|
|
5
|
+
--ui-ink-1: var(--dsw-alias-label-primary, #0f1115);
|
|
6
|
+
--ui-ink-2: var(--dsw-alias-label-secondary, #61666b);
|
|
7
|
+
--ui-ink-3: var(--dsw-alias-label-tertiary, #81858c);
|
|
8
|
+
--ui-line-1: var(--dsw-alias-border-l1, #0000000a);
|
|
9
|
+
--ui-line-2: var(--dsw-alias-border-l2, #0000001a);
|
|
10
|
+
--ui-raised: var(--dsw-alias-bg-layer-2, #fff);
|
|
11
|
+
--ui-hover: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, var(--ui-ink-1) 5%, transparent));
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
flex-shrink: 0;
|
|
15
|
+
gap: 8px;
|
|
16
|
+
min-width: 0;
|
|
17
|
+
min-height: 36px;
|
|
18
|
+
margin: 0 16px 10px;
|
|
19
|
+
padding: 4px 6px 4px 10px;
|
|
20
|
+
border: 1px solid var(--ui-line-2);
|
|
21
|
+
border-radius: 8px;
|
|
22
|
+
background: var(--ui-raised);
|
|
23
|
+
color: var(--ui-ink-1);
|
|
24
|
+
}
|
|
25
|
+
.clock { position: relative; display: grid; place-items: center; width: 24px; height: 24px; flex: none; }
|
|
26
|
+
.ring { position: absolute; inset: 0; width: 100%; height: 100%; fill: none; stroke-width: 2; transform: rotate(-90deg); }
|
|
27
|
+
.track { stroke: var(--ui-line-2); }
|
|
28
|
+
.remaining { stroke: var(--ui-accent); }
|
|
29
|
+
.clockHand { width: 8px; height: 9px; margin-top: -4px; margin-left: 5px; border-left: 1.5px solid var(--ui-ink-2); border-bottom: 1.5px solid var(--ui-ink-2); }
|
|
30
|
+
.pause { width: 16px; height: 16px; color: var(--ui-ink-2); }
|
|
31
|
+
.status { display: flex; align-items: center; min-width: 0; }
|
|
32
|
+
.time { color: var(--ui-ink-1); font-size: 12px; line-height: 20px; font-variant-numeric: tabular-nums; white-space: nowrap; }
|
|
33
|
+
.bar[data-wait-state='counting'] .time { font-weight: 500; }
|
|
34
|
+
.takeTime { appearance: none; display: inline-flex; align-items: center; justify-content: center; flex: none; margin-left: auto; min-height: 28px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--ui-ink-3); font: inherit; font-size: 12px; line-height: 18px; font-weight: 500; cursor: pointer; transition: background-color 140ms ease, color 140ms ease; }
|
|
35
|
+
.takeTime:hover:not(:disabled) { background: var(--ui-hover); color: var(--ui-ink-1); }
|
|
36
|
+
.takeTime:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
|
|
37
|
+
.takeTime:disabled { opacity: .4; cursor: default; }
|
|
38
|
+
@media (max-width: 720px) {
|
|
39
|
+
.bar { margin: 0 12px 8px; padding: 4px 6px 4px 8px; }
|
|
40
|
+
}
|
|
41
|
+
@media (pointer: coarse) {
|
|
42
|
+
.takeTime { min-height: 44px; }
|
|
43
|
+
}
|
|
44
|
+
@media (prefers-reduced-motion: reduce) {
|
|
45
|
+
.takeTime { transition: none; }
|
|
46
|
+
}
|
|
47
|
+
[data-ds-dark-theme] .bar {
|
|
48
|
+
--ui-accent: #4eb0e8;
|
|
49
|
+
--ui-accent-text: #6fc0ee;
|
|
50
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
</div>
|
|
36
|
+
{!held && !continued && <button type="button" className={css.takeTime} disabled={busy} onClick={onTakeTime}>{t('wait.takeTime')}</button>}
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -281,6 +281,7 @@ export class PendingQuestion {
|
|
|
281
281
|
readonly #siblings: (() => readonly string[]) | undefined
|
|
282
282
|
readonly #listeners = new Set<() => void>()
|
|
283
283
|
#snapshot: QuestionCardSnapshot
|
|
284
|
+
readonly #requiresDecision: boolean
|
|
284
285
|
#waitMs: number | undefined
|
|
285
286
|
#timeoutMode: 'native' | 'default' = 'native'
|
|
286
287
|
#defaultAnswer: QuestionAnswer | undefined
|
|
@@ -302,6 +303,9 @@ export class PendingQuestion {
|
|
|
302
303
|
) {
|
|
303
304
|
this.sessionId = sessionId
|
|
304
305
|
this.questions = questions
|
|
306
|
+
// Intent, not presentation narrowing: a multi-question plan review still needs a human decision.
|
|
307
|
+
this.#requiresDecision = questions.some(question =>
|
|
308
|
+
question.intent?.kind === 'plan-review' || question.intent?.kind === 'approval')
|
|
305
309
|
this.#waitMs = settings?.waitMs
|
|
306
310
|
this.#timeoutMode = settings?.timeoutMode ?? 'native'
|
|
307
311
|
this.#defaultAnswer = settings?.defaultAnswer
|
|
@@ -343,6 +347,14 @@ export class PendingQuestion {
|
|
|
343
347
|
return () => { this.#listeners.delete(listener) }
|
|
344
348
|
}
|
|
345
349
|
|
|
350
|
+
/** Apply timing policy when the forwarded request arrives after its projection created the card. */
|
|
351
|
+
configure(settings: BetterAskConfig): void {
|
|
352
|
+
this.#waitMs = settings.waitMs
|
|
353
|
+
this.#timeoutMode = settings.timeoutMode ?? 'native'
|
|
354
|
+
this.#defaultAnswer = settings.defaultAnswer
|
|
355
|
+
this.publish()
|
|
356
|
+
}
|
|
357
|
+
|
|
346
358
|
/** Read the stable current card state. */
|
|
347
359
|
readonly snapshot = (): QuestionCardSnapshot => this.#snapshot
|
|
348
360
|
|
|
@@ -414,11 +426,12 @@ export class PendingQuestion {
|
|
|
414
426
|
*/
|
|
415
427
|
attachWaterfall(channel: QuestionWaterfallChannel): void {
|
|
416
428
|
this.#waterfall = channel
|
|
417
|
-
this.#
|
|
429
|
+
const deadline = this.#requiresDecision ? undefined : channel.deadline
|
|
430
|
+
this.#timedWait = deadline !== undefined
|
|
418
431
|
if (!this.#held && !this.#engaged) {
|
|
419
|
-
this.#deadline =
|
|
420
|
-
if (this.#focused &&
|
|
421
|
-
this.#remainingMs = Math.max(0,
|
|
432
|
+
this.#deadline = deadline
|
|
433
|
+
if (this.#focused && deadline !== undefined) {
|
|
434
|
+
this.#remainingMs = Math.max(0, deadline - Date.now())
|
|
422
435
|
this.#deadline = undefined
|
|
423
436
|
}
|
|
424
437
|
}
|
|
@@ -538,6 +551,7 @@ export class PendingQuestion {
|
|
|
538
551
|
|
|
539
552
|
/** Settle with the host-authored default answer in default timeout mode. */
|
|
540
553
|
autoSelect(): void {
|
|
554
|
+
if (this.#requiresDecision) return
|
|
541
555
|
if (this.#held || this.#engaged || this.#focused) return
|
|
542
556
|
const channel = this.#waterfall
|
|
543
557
|
if (channel === undefined) return
|
|
@@ -555,6 +569,7 @@ export class PendingQuestion {
|
|
|
555
569
|
|
|
556
570
|
/** Local countdown reached zero: default-select or settle with `ASK_TIMED_OUT`. */
|
|
557
571
|
timeout(): void {
|
|
572
|
+
if (this.#requiresDecision) return
|
|
558
573
|
if (this.#held || this.#engaged || this.#focused) return
|
|
559
574
|
if (this.#timeoutMode === 'default' && this.#defaultAnswer !== undefined) {
|
|
560
575
|
this.autoSelect()
|
package/src/client/index.ts
CHANGED
|
@@ -117,7 +117,10 @@ class QuestionCards {
|
|
|
117
117
|
): QuestionCard {
|
|
118
118
|
if (callId !== undefined) {
|
|
119
119
|
const existing = this.byCallId(sessionId, callId)
|
|
120
|
-
if (existing !== undefined)
|
|
120
|
+
if (existing !== undefined) {
|
|
121
|
+
if (settings !== undefined) existing.pending.configure(settings)
|
|
122
|
+
return existing
|
|
123
|
+
}
|
|
121
124
|
}
|
|
122
125
|
return this.#create(new PendingQuestion(sessionId, questions, callId, () => this.keysFor(sessionId), undefined, settings))
|
|
123
126
|
}
|
|
@@ -419,10 +422,7 @@ export function apply(ctx: ClientContext): void {
|
|
|
419
422
|
name: 'tool.call.toolview',
|
|
420
423
|
key: 'ask_user_question',
|
|
421
424
|
locale: NS,
|
|
422
|
-
// The
|
|
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.
|
|
425
|
+
// The host already owns this key at priority 0; lower priority shadows it.
|
|
426
426
|
priority: -1,
|
|
427
427
|
inject: (sessionId: SessionId) => ({
|
|
428
428
|
revealPanel: (callId: string) => ctx.get('userQuestionPanels')?.reveal(sessionId, callId) ?? false,
|
|
@@ -453,4 +453,4 @@ export function apply(ctx: ClientContext): void {
|
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
// Exported for the built-closure behavior tests; the client loader ignores it.
|
|
456
|
-
export { PendingQuestion }
|
|
456
|
+
export { PendingQuestion, SettingsEntry }
|
package/src/client/locales.ts
CHANGED
|
@@ -10,8 +10,12 @@ export const zh = {
|
|
|
10
10
|
'history.title': '问题',
|
|
11
11
|
'history.review': '查看',
|
|
12
12
|
'history.reopen': '打开',
|
|
13
|
+
'history.unavailable': '问题暂时无法打开,请重试。',
|
|
14
|
+
'reply.copyFailed': '复制失败,请重试。',
|
|
13
15
|
'wait.takeTime': '慢慢回答',
|
|
14
16
|
'wait.countdown': '{seconds} 秒后继续工作',
|
|
17
|
+
'wait.autoCountdown': '{seconds} 秒后自动选择默认项',
|
|
18
|
+
'wait.pauseLabel': '已暂停',
|
|
15
19
|
'wait.paused': '已暂停 · 剩余 {seconds} 秒',
|
|
16
20
|
'wait.held': '会一直等你回答',
|
|
17
21
|
'wait.extend': '输入会自动续期',
|
|
@@ -19,7 +23,7 @@ export const zh = {
|
|
|
19
23
|
'wait.continued': '已继续工作,仍可回答',
|
|
20
24
|
'review.status': '已回答',
|
|
21
25
|
'review.skipped': '这道问题当时被跳过。',
|
|
22
|
-
'reply.label': '
|
|
26
|
+
'reply.label': '问题回复',
|
|
23
27
|
'reply.open': '展开问题详情',
|
|
24
28
|
'reply.close': '收起问题详情',
|
|
25
29
|
'reply.answerLabel': '回答:',
|
|
@@ -53,8 +57,12 @@ export const en = {
|
|
|
53
57
|
'history.title': 'Question',
|
|
54
58
|
'history.review': 'Review',
|
|
55
59
|
'history.reopen': 'Open',
|
|
60
|
+
'history.unavailable': 'Cannot open this question right now. Try again.',
|
|
61
|
+
'reply.copyFailed': 'Copy failed. Try again.',
|
|
56
62
|
'wait.takeTime': 'Take time',
|
|
57
63
|
'wait.countdown': 'Continuing in {seconds}s',
|
|
64
|
+
'wait.autoCountdown': 'Defaults selected in {seconds}s',
|
|
65
|
+
'wait.pauseLabel': 'Paused',
|
|
58
66
|
'wait.paused': 'Paused · {seconds}s remaining',
|
|
59
67
|
'wait.held': 'Waiting until you answer',
|
|
60
68
|
'wait.extend': 'Typing extends the wait',
|
|
@@ -62,7 +70,7 @@ export const en = {
|
|
|
62
70
|
'wait.continued': 'Work continued — you can still answer',
|
|
63
71
|
'review.status': 'Answered',
|
|
64
72
|
'review.skipped': 'This question was skipped.',
|
|
65
|
-
'reply.label': '
|
|
73
|
+
'reply.label': 'Question reply',
|
|
66
74
|
'reply.open': 'Open question details',
|
|
67
75
|
'reply.close': 'Close question details',
|
|
68
76
|
'reply.answerLabel': 'Answer: ',
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
/** Settings-page dictionaries. */
|
|
2
2
|
|
|
3
3
|
export const settingsZh = {
|
|
4
|
-
summary: '
|
|
5
|
-
title: '
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
summary: '等待与超时',
|
|
5
|
+
title: '提问',
|
|
6
|
+
waitLabel: '等待',
|
|
7
|
+
durationLabel: '等待时长(秒)',
|
|
8
|
+
timed: '倒计时',
|
|
9
|
+
unlimited: '不限时',
|
|
10
|
+
seconds: '秒',
|
|
11
|
+
waitHint: '输入时重新计时。',
|
|
12
|
+
unlimitedHint: '一直等待回答,输入无需续期。',
|
|
13
|
+
timeoutTitle: '超时后',
|
|
14
|
+
behaviorLabel: '普通会话',
|
|
15
|
+
goalBehaviorLabel: 'Goal 活跃时',
|
|
16
|
+
native: '继续工作',
|
|
17
|
+
default: '选择默认答案',
|
|
18
|
+
advanced: '高级',
|
|
19
|
+
discard: '放弃改动',
|
|
20
|
+
nativeHint: '超时后仍可回答,不会自动同意。',
|
|
21
|
+
defaultHint: '超时后自动提交默认答案。',
|
|
22
|
+
timeoutDisabled: '不限时模式下不触发超时行为,保留以下次使用。',
|
|
15
23
|
readonly: '当前配置为只读。',
|
|
16
24
|
loading: '正在读取设置…',
|
|
17
25
|
unavailable: '当前连接下该配置不可用。',
|
|
18
|
-
waiting: '
|
|
19
|
-
invalidWait: '
|
|
26
|
+
waiting: '正在等待宿主配置…',
|
|
27
|
+
invalidWait: '等待时长须为 1 到 2147483 的整数。',
|
|
20
28
|
save: '保存',
|
|
21
29
|
saving: '保存中…',
|
|
22
|
-
saved: '
|
|
30
|
+
saved: '已保存,对新提问生效',
|
|
23
31
|
conflict: '设置已被其他窗口修改,请重试。',
|
|
24
32
|
saveFailed: '保存失败:',
|
|
25
33
|
dirty: '有未保存的修改',
|
|
@@ -28,25 +36,33 @@ export const settingsZh = {
|
|
|
28
36
|
export type SettingsKey = keyof typeof settingsZh
|
|
29
37
|
|
|
30
38
|
export const settingsEn = {
|
|
31
|
-
summary: '
|
|
32
|
-
title: '
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
summary: 'Wait and timeout',
|
|
40
|
+
title: 'Questions',
|
|
41
|
+
waitLabel: 'Wait',
|
|
42
|
+
durationLabel: 'Wait duration in seconds',
|
|
43
|
+
timed: 'Countdown',
|
|
44
|
+
unlimited: 'Unlimited',
|
|
45
|
+
seconds: 'sec',
|
|
46
|
+
waitHint: 'Typing restarts the countdown.',
|
|
47
|
+
unlimitedHint: 'Wait until answered, with no countdown to extend.',
|
|
48
|
+
timeoutTitle: 'At timeout',
|
|
49
|
+
behaviorLabel: 'Standard session',
|
|
50
|
+
goalBehaviorLabel: 'Active Goal',
|
|
51
|
+
native: 'Continue work',
|
|
52
|
+
default: 'Use defaults',
|
|
53
|
+
advanced: 'Advanced',
|
|
54
|
+
discard: 'Discard',
|
|
55
|
+
nativeHint: 'You can still answer after timeout. Nothing is automatically approved.',
|
|
56
|
+
defaultHint: 'Submits default answers when the countdown ends.',
|
|
57
|
+
timeoutDisabled: 'Timeout behavior is inactive while waiting without a limit. Your choices are kept.',
|
|
42
58
|
readonly: 'This configuration is read-only.',
|
|
43
59
|
loading: 'Loading settings…',
|
|
44
60
|
unavailable: 'This configuration is unavailable on the current connection.',
|
|
45
|
-
waiting: 'Waiting for
|
|
46
|
-
invalidWait: '
|
|
61
|
+
waiting: 'Waiting for host configuration…',
|
|
62
|
+
invalidWait: 'Enter a whole number from 1 to 2147483 seconds.',
|
|
47
63
|
save: 'Save',
|
|
48
64
|
saving: 'Saving…',
|
|
49
|
-
saved: 'Saved
|
|
65
|
+
saved: 'Saved for new questions',
|
|
50
66
|
conflict: 'The settings changed in another window; try again.',
|
|
51
67
|
saveFailed: 'Save failed: ',
|
|
52
68
|
dirty: 'Unsaved changes',
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/* Ask-user settings: one 920px column, section rows, flat 1px surfaces. */
|
|
2
|
+
.cfg {
|
|
3
|
+
--ui-accent: #3388bb;
|
|
4
|
+
--ui-accent-solid: #20709e;
|
|
5
|
+
--ui-accent-text: #14587f;
|
|
6
|
+
--ui-accent-fg: #fff;
|
|
7
|
+
--ui-accent-soft: color-mix(in srgb, var(--ui-accent) 10%, transparent);
|
|
8
|
+
--ui-ink-1: var(--dsw-alias-label-primary, #0f1115);
|
|
9
|
+
--ui-ink-2: var(--dsw-alias-label-secondary, #61666b);
|
|
10
|
+
--ui-ink-3: color-mix(in srgb, var(--dsw-alias-label-tertiary, #81858c) 80%, var(--dsw-alias-label-primary, #0f1115));
|
|
11
|
+
--ui-line-1: var(--dsw-alias-border-l1, #0000000a);
|
|
12
|
+
--ui-line-2: var(--dsw-alias-border-l2, #0000001a);
|
|
13
|
+
--ui-line-3: var(--dsw-alias-border-l3, #0000001f);
|
|
14
|
+
--ui-canvas: var(--dsw-alias-bg-layer-1, #fff);
|
|
15
|
+
--ui-raised: var(--dsw-alias-bg-layer-2, #fff);
|
|
16
|
+
--ui-sunken: color-mix(in srgb, var(--ui-ink-1) 4%, var(--ui-canvas));
|
|
17
|
+
--ui-hover: var(--dsw-alias-interactive-bg-hover, color-mix(in srgb, var(--ui-ink-1) 5%, transparent));
|
|
18
|
+
--ui-danger: var(--dsw-alias-state-error-primary, #c8322b);
|
|
19
|
+
--ui-radius-sm: 6px;
|
|
20
|
+
--ui-radius-md: 8px;
|
|
21
|
+
display: flex;
|
|
22
|
+
flex-direction: column;
|
|
23
|
+
gap: 20px;
|
|
24
|
+
width: 100%;
|
|
25
|
+
max-width: 920px;
|
|
26
|
+
margin: 0 auto;
|
|
27
|
+
min-width: 0;
|
|
28
|
+
color: var(--ui-ink-1);
|
|
29
|
+
font: inherit;
|
|
30
|
+
line-height: 20px;
|
|
31
|
+
font-variant-numeric: tabular-nums;
|
|
32
|
+
}
|
|
33
|
+
.cfg *,
|
|
34
|
+
.cfg { box-sizing: border-box; }
|
|
35
|
+
.pageHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
|
|
36
|
+
.title { margin: 0; font-size: 20px; line-height: 28px; font-weight: 500; letter-spacing: -.01em; }
|
|
37
|
+
.badge { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border: 1px solid var(--ui-line-2); border-radius: 999px; background: var(--ui-raised); color: var(--ui-ink-3); font-size: 11px; line-height: 18px; white-space: nowrap; }
|
|
38
|
+
.group { display: flex; flex-direction: column; min-width: 0; border-top: 1px solid var(--ui-line-2); }
|
|
39
|
+
.row { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 44px; min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--ui-line-1); }
|
|
40
|
+
.rowText { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
|
|
41
|
+
.rowTitle { color: var(--ui-ink-1); font-size: 13px; line-height: 20px; font-weight: 500; }
|
|
42
|
+
.rowDesc { color: var(--ui-ink-3); font-size: 12px; line-height: 18px; }
|
|
43
|
+
.control { display: flex; align-items: center; gap: 8px; flex: none; min-width: 0; }
|
|
44
|
+
.choices { display: inline-flex; flex: none; gap: 2px; height: 32px; padding: 1px; border: 1px solid var(--ui-line-2); border-radius: var(--ui-radius-md); background: var(--ui-sunken); }
|
|
45
|
+
.choice { position: relative; display: inline-flex; min-width: 0; }
|
|
46
|
+
.choice input { appearance: none; position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
|
|
47
|
+
.choice span { display: flex; align-items: center; justify-content: center; min-height: 28px; padding: 0 12px; border-radius: var(--ui-radius-sm); color: var(--ui-ink-3); font-size: 13px; line-height: 20px; white-space: nowrap; transition: background-color 140ms ease, color 140ms ease, box-shadow 140ms ease; }
|
|
48
|
+
.choice:has(input:checked) span { background: var(--ui-raised); box-shadow: inset 0 0 0 1px var(--ui-line-2); color: var(--ui-accent-text); font-weight: 500; }
|
|
49
|
+
.choice:has(input:hover:not(:disabled):not(:checked)) span { background: var(--ui-hover); color: var(--ui-ink-1); }
|
|
50
|
+
.choice:has(input:focus-visible) span { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
|
|
51
|
+
.choice:has(input:disabled) { opacity: .4; }
|
|
52
|
+
.choice input:disabled { cursor: not-allowed; }
|
|
53
|
+
.input { appearance: none; width: 76px; min-width: 0; height: 32px; padding: 0 8px; border: 1px solid var(--ui-line-2); border-radius: var(--ui-radius-md); background: var(--ui-raised); color: var(--ui-ink-1); font: inherit; font-size: 13px; line-height: 20px; font-variant-numeric: tabular-nums; transition: border-color 140ms ease, box-shadow 140ms ease; }
|
|
54
|
+
.input:hover:not(:disabled) { border-color: var(--ui-line-3); }
|
|
55
|
+
.input:focus-visible { outline: none; border-color: var(--ui-accent); box-shadow: 0 0 0 2px var(--ui-accent-soft); }
|
|
56
|
+
.input[aria-invalid=true] { border-color: var(--ui-danger); }
|
|
57
|
+
.input:disabled { opacity: .4; cursor: not-allowed; }
|
|
58
|
+
.duration { display: inline-flex; align-items: center; gap: 6px; flex: none; }
|
|
59
|
+
.unit { color: var(--ui-ink-3); font-size: 12px; line-height: 18px; }
|
|
60
|
+
.srOnly { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
|
|
61
|
+
.fieldError { margin: 6px 0 0; color: var(--ui-danger); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
|
|
62
|
+
.sectionLabel { margin: 20px 0 0; padding-bottom: 6px; border-bottom: 1px solid var(--ui-line-2); color: var(--ui-ink-3); font-size: 12px; line-height: 18px; font-weight: 500; letter-spacing: .02em; }
|
|
63
|
+
.advanced { margin-top: 12px; border-top: 1px solid var(--ui-line-1); }
|
|
64
|
+
.advanced summary { display: flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 0; color: var(--ui-ink-2); font-size: 13px; line-height: 20px; font-weight: 500; list-style: none; cursor: pointer; }
|
|
65
|
+
.advanced summary::-webkit-details-marker { display: none; }
|
|
66
|
+
.advanced summary:hover { color: var(--ui-ink-1); }
|
|
67
|
+
.advanced summary:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; border-radius: 4px; }
|
|
68
|
+
.advancedValue { margin-left: auto; color: var(--ui-ink-3); font-size: 11px; line-height: 18px; font-weight: 400; white-space: nowrap; }
|
|
69
|
+
.chevron { width: 6px; height: 6px; margin: 0 4px 3px auto; border-right: 1px solid currentColor; border-bottom: 1px solid currentColor; transform: rotate(45deg); transition: transform 140ms ease; }
|
|
70
|
+
.advancedValue + .chevron { margin-left: 0; }
|
|
71
|
+
.advanced[open] .chevron { transform: rotate(225deg); margin-bottom: -3px; }
|
|
72
|
+
.status { margin: 0; color: var(--ui-ink-3); font-size: 12px; line-height: 18px; overflow-wrap: anywhere; }
|
|
73
|
+
.footer { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 0; border-top: 1px solid var(--ui-line-2); background: var(--ui-canvas); margin-top: auto; }
|
|
74
|
+
.footer .status { flex: 1; min-width: 0; }
|
|
75
|
+
.button,
|
|
76
|
+
.primary { appearance: none; display: inline-flex; align-items: center; justify-content: center; flex: none; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--ui-line-2); border-radius: var(--ui-radius-md); background: var(--ui-raised); color: var(--ui-ink-1); font: inherit; font-size: 13px; line-height: 20px; font-weight: 500; cursor: pointer; transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease; }
|
|
77
|
+
.button:hover:not(:disabled) { background: var(--ui-hover); }
|
|
78
|
+
.button:active:not(:disabled) { background: var(--ui-sunken); }
|
|
79
|
+
.primary { min-width: 96px; border-color: transparent; background: var(--ui-accent-solid); color: var(--ui-accent-fg); }
|
|
80
|
+
.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--ui-accent-solid) 88%, black); }
|
|
81
|
+
.primary:active:not(:disabled) { background: color-mix(in srgb, var(--ui-accent-solid) 80%, black); }
|
|
82
|
+
.button:focus-visible,
|
|
83
|
+
.primary:focus-visible { outline: 2px solid var(--ui-accent); outline-offset: 2px; }
|
|
84
|
+
.button:disabled,
|
|
85
|
+
.primary:disabled { opacity: .4; cursor: not-allowed; }
|
|
86
|
+
.spinner { width: 12px; height: 12px; border: 1px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 800ms linear infinite; }
|
|
87
|
+
@keyframes spin { to { transform: rotate(360deg); } }
|
|
88
|
+
@media (max-width: 640px) {
|
|
89
|
+
.title { font-size: 18px; line-height: 26px; }
|
|
90
|
+
.row { align-items: stretch; flex-direction: column; gap: 8px; }
|
|
91
|
+
.control { width: 100%; flex-wrap: wrap; }
|
|
92
|
+
.choice { flex: 1; }
|
|
93
|
+
.choice span { width: 100%; }
|
|
94
|
+
.footer { flex-wrap: wrap; }
|
|
95
|
+
.footer .status { flex-basis: 100%; }
|
|
96
|
+
.advancedValue { max-width: 65%; text-align: right; white-space: normal; }
|
|
97
|
+
}
|
|
98
|
+
@media (pointer: coarse) {
|
|
99
|
+
.choices { height: auto; }
|
|
100
|
+
.choice span,
|
|
101
|
+
.input,
|
|
102
|
+
.button,
|
|
103
|
+
.primary { min-height: 44px; }
|
|
104
|
+
}
|
|
105
|
+
@media (prefers-reduced-motion: reduce) {
|
|
106
|
+
.spinner { animation: none; }
|
|
107
|
+
.input,
|
|
108
|
+
.choice span,
|
|
109
|
+
.button,
|
|
110
|
+
.primary,
|
|
111
|
+
.chevron { transition: none; }
|
|
112
|
+
}
|
|
113
|
+
[data-ds-dark-theme] .cfg {
|
|
114
|
+
--ui-accent: #4eb0e8;
|
|
115
|
+
--ui-accent-solid: #4eb0e8;
|
|
116
|
+
--ui-accent-text: #6fc0ee;
|
|
117
|
+
--ui-accent-fg: #0e1014;
|
|
118
|
+
--ui-accent-soft: color-mix(in srgb, var(--ui-accent) 14%, transparent);
|
|
119
|
+
}
|