dsh-better-ask-user 0.3.6 → 0.3.7-alpha.1
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/README.md +7 -7
- package/lib/ask-tool.d.ts +15 -0
- package/lib/ask-tool.js +161 -0
- package/lib/ask-tool.js.map +1 -0
- package/lib/client.js +1 -0
- package/lib/config.d.ts +29 -0
- package/lib/config.js +48 -0
- package/lib/config.js.map +1 -0
- package/lib/default-answer.d.ts +22 -0
- package/lib/default-answer.js +38 -0
- package/lib/default-answer.js.map +1 -0
- package/lib/index.d.ts +7 -0
- package/lib/index.js +48 -0
- package/lib/index.js.map +1 -0
- package/lib/ptc.d.ts +3 -0
- package/lib/ptc.js +13 -0
- package/lib/ptc.js.map +1 -0
- package/lib/settings.d.ts +36 -0
- package/lib/settings.js +81 -0
- package/lib/settings.js.map +1 -0
- package/package.json +49 -19
- package/src/ask-tool.js +0 -165
- package/src/client/AskHistoryRow.module.css +0 -26
- package/src/client/AskHistoryRow.tsx +0 -173
- package/src/client/PlanReviewPanel.module.css +0 -255
- package/src/client/PlanReviewPanel.tsx +0 -147
- package/src/client/QuestionComposer.module.css +0 -494
- package/src/client/QuestionComposer.tsx +0 -656
- package/src/client/QuestionReplyView.module.css +0 -100
- package/src/client/QuestionReplyView.tsx +0 -124
- package/src/client/QuestionWaitBar.module.css +0 -41
- package/src/client/QuestionWaitBar.tsx +0 -41
- package/src/client/contract/slots.ts +0 -650
- package/src/client/draft-store.ts +0 -64
- package/src/client/index.ts +0 -497
- package/src/client/locales.ts +0 -100
- package/src/client/question-reply.ts +0 -187
- package/src/client/settings-locales.ts +0 -79
- package/src/client/settings.module.css +0 -122
- package/src/client/settings.tsx +0 -336
- package/src/config.js +0 -54
- package/src/default-answer.js +0 -39
- package/src/index.js +0 -50
- package/src/ptc.js +0 -11
- package/src/settings.js +0 -81
|
@@ -1,255 +0,0 @@
|
|
|
1
|
-
.frame {
|
|
2
|
-
--cfg-line: var(--dsw-alias-border-l2);
|
|
3
|
-
--cfg-surface: var(--dsw-alias-bg-layer-3);
|
|
4
|
-
--cfg-ink: var(--dsw-alias-label-primary);
|
|
5
|
-
--cfg-muted: var(--dsw-alias-label-secondary);
|
|
6
|
-
--cfg-accent: var(--dsw-alias-state-business-primary, #3388bb);
|
|
7
|
-
--cfg-accent-text: color-mix(in srgb, var(--cfg-accent) 70%, var(--cfg-ink));
|
|
8
|
-
--cfg-hover: var(--dsw-alias-interactive-bg-hover);
|
|
9
|
-
--cfg-danger: var(--dsw-alias-state-error-primary);
|
|
10
|
-
--cfg-solid: var(--dsw-alias-button-primary-fill, #20709e);
|
|
11
|
-
--cfg-solid-hover: color-mix(in srgb, var(--cfg-solid) 88%, var(--cfg-on-solid));
|
|
12
|
-
--cfg-on-solid: var(--dsw-alias-label-primary-foreground, #fff);
|
|
13
|
-
display: flex;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
width: 100%;
|
|
16
|
-
min-width: 0;
|
|
17
|
-
box-sizing: border-box;
|
|
18
|
-
padding: 6px calc(var(--dsh-composer-side-clearance, 0px) + 16px) calc(10px + env(safe-area-inset-bottom));
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.card {
|
|
22
|
-
display: flex;
|
|
23
|
-
flex-direction: column;
|
|
24
|
-
width: 100%;
|
|
25
|
-
min-width: 0;
|
|
26
|
-
max-width: var(--dsh-chat-content-width);
|
|
27
|
-
max-height: min(75vh, 640px);
|
|
28
|
-
max-height: min(75dvh, 640px);
|
|
29
|
-
overflow: hidden;
|
|
30
|
-
border: 1px solid var(--dsw-alias-border-l3);
|
|
31
|
-
border-radius: 10px;
|
|
32
|
-
background: var(--cfg-surface);
|
|
33
|
-
color: var(--cfg-ink);
|
|
34
|
-
--dsh-scrollbar-thumb: var(--dsw-alias-scrollbar-bg-l2);
|
|
35
|
-
--dsh-scrollbar-thumb-hover: var(--dsw-alias-scrollbar-hover-l2);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
.card,
|
|
39
|
-
.card * {
|
|
40
|
-
box-sizing: border-box;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
.strip {
|
|
44
|
-
display: flex;
|
|
45
|
-
align-items: center;
|
|
46
|
-
flex-shrink: 0;
|
|
47
|
-
flex-wrap: wrap;
|
|
48
|
-
gap: 8px;
|
|
49
|
-
min-width: 0;
|
|
50
|
-
padding: 6px 12px;
|
|
51
|
-
border-bottom: 1px solid var(--cfg-line);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
.panelLabel {
|
|
55
|
-
color: var(--cfg-muted);
|
|
56
|
-
font-size: 12px;
|
|
57
|
-
font-weight: 500;
|
|
58
|
-
line-height: 20px;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.previewActions {
|
|
62
|
-
display: flex;
|
|
63
|
-
align-items: center;
|
|
64
|
-
flex-wrap: wrap;
|
|
65
|
-
gap: 4px;
|
|
66
|
-
min-width: 0;
|
|
67
|
-
margin-left: auto;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.summary {
|
|
71
|
-
min-width: 0;
|
|
72
|
-
min-height: 0;
|
|
73
|
-
overflow-y: auto;
|
|
74
|
-
overscroll-behavior: contain;
|
|
75
|
-
scrollbar-gutter: stable;
|
|
76
|
-
padding: 10px 12px;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.documentHeading { display: flex; align-items: flex-start; gap: 8px; }
|
|
80
|
-
.documentIcon { flex: none; width: 18px; height: 20px; color: var(--dsw-alias-label-tertiary); }
|
|
81
|
-
|
|
82
|
-
.title,
|
|
83
|
-
.description {
|
|
84
|
-
min-width: 0;
|
|
85
|
-
overflow-wrap: anywhere;
|
|
86
|
-
word-break: break-word;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.title {
|
|
90
|
-
margin: 0;
|
|
91
|
-
font-size: 14px;
|
|
92
|
-
font-weight: 500;
|
|
93
|
-
line-height: 20px;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
.description {
|
|
97
|
-
display: -webkit-box;
|
|
98
|
-
-webkit-box-orient: vertical;
|
|
99
|
-
-webkit-line-clamp: 2;
|
|
100
|
-
overflow: hidden;
|
|
101
|
-
margin: 4px 0 0;
|
|
102
|
-
color: var(--cfg-muted);
|
|
103
|
-
font-size: inherit;
|
|
104
|
-
line-height: 20px;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
.footer {
|
|
108
|
-
display: flex;
|
|
109
|
-
align-items: center;
|
|
110
|
-
justify-content: flex-end;
|
|
111
|
-
flex-shrink: 0;
|
|
112
|
-
flex-wrap: wrap;
|
|
113
|
-
gap: 8px 12px;
|
|
114
|
-
padding: 8px 12px;
|
|
115
|
-
border-top: 1px solid var(--cfg-line);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
.feedback {
|
|
119
|
-
flex: 1;
|
|
120
|
-
min-width: 0;
|
|
121
|
-
display: flex;
|
|
122
|
-
align-items: center;
|
|
123
|
-
gap: 6px;
|
|
124
|
-
color: var(--cfg-muted);
|
|
125
|
-
font-size: 12px;
|
|
126
|
-
line-height: 18px;
|
|
127
|
-
overflow-wrap: anywhere;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
.feedback[data-error] { color: var(--cfg-danger); }
|
|
131
|
-
|
|
132
|
-
.discuss, .primary, .decline {
|
|
133
|
-
appearance: none;
|
|
134
|
-
display: inline-flex;
|
|
135
|
-
align-items: center;
|
|
136
|
-
justify-content: center;
|
|
137
|
-
min-height: 32px;
|
|
138
|
-
padding: 0 10px;
|
|
139
|
-
border: 1px solid var(--cfg-line);
|
|
140
|
-
border-radius: 8px;
|
|
141
|
-
background: transparent;
|
|
142
|
-
color: var(--cfg-ink);
|
|
143
|
-
box-shadow: none;
|
|
144
|
-
font: inherit;
|
|
145
|
-
font-size: 13px;
|
|
146
|
-
font-weight: 500;
|
|
147
|
-
cursor: pointer;
|
|
148
|
-
}
|
|
149
|
-
.discuss:hover:not(:disabled) { background: var(--cfg-hover); }
|
|
150
|
-
.primary { border-color: transparent; background: var(--cfg-solid); color: var(--cfg-on-solid); }
|
|
151
|
-
.primary:hover:not(:disabled) { background: var(--cfg-solid-hover); }
|
|
152
|
-
.spinner { flex: none; width: 12px; height: 12px; border: 1px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 800ms linear infinite; }
|
|
153
|
-
@keyframes spin { to { transform: rotate(360deg); } }
|
|
154
|
-
|
|
155
|
-
.feedback:empty {
|
|
156
|
-
display: none;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
.actions {
|
|
160
|
-
display: flex;
|
|
161
|
-
align-items: center;
|
|
162
|
-
flex-wrap: wrap;
|
|
163
|
-
gap: 8px;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
.decline {
|
|
167
|
-
min-height: 32px;
|
|
168
|
-
padding: 0 10px;
|
|
169
|
-
border: 0;
|
|
170
|
-
border-radius: 8px;
|
|
171
|
-
background: transparent;
|
|
172
|
-
color: var(--cfg-muted);
|
|
173
|
-
font: inherit;
|
|
174
|
-
font-size: inherit;
|
|
175
|
-
line-height: 20px;
|
|
176
|
-
cursor: pointer;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
.decline:hover:not(:disabled),
|
|
180
|
-
.decline:active:not(:disabled) {
|
|
181
|
-
background: var(--cfg-hover);
|
|
182
|
-
color: var(--cfg-ink);
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
.discuss {
|
|
186
|
-
gap: 6px;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
.card button:focus-visible {
|
|
190
|
-
outline: 2px solid var(--cfg-accent);
|
|
191
|
-
outline-offset: -2px;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.card button:disabled {
|
|
195
|
-
opacity: 0.4;
|
|
196
|
-
cursor: default;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
.srOnly {
|
|
200
|
-
position: absolute;
|
|
201
|
-
width: 1px;
|
|
202
|
-
height: 1px;
|
|
203
|
-
overflow: hidden;
|
|
204
|
-
padding: 0;
|
|
205
|
-
border: 0;
|
|
206
|
-
clip-path: inset(50%);
|
|
207
|
-
white-space: nowrap;
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@media (max-width: 720px) {
|
|
211
|
-
.card {
|
|
212
|
-
max-height: calc(100vh - 160px);
|
|
213
|
-
max-height: calc(100dvh - 160px);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
.frame { padding-inline: 16px; }
|
|
217
|
-
.card button { min-height: 44px; }
|
|
218
|
-
|
|
219
|
-
.strip {
|
|
220
|
-
padding: 6px 12px;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
.summary {
|
|
224
|
-
padding: 10px 12px;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
.footer {
|
|
228
|
-
padding: 8px 12px;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
.feedback {
|
|
232
|
-
flex: 1 1 100%;
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
@media (max-width: 420px) {
|
|
237
|
-
.actions {
|
|
238
|
-
width: 100%;
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
.actions > button {
|
|
242
|
-
flex: 1;
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
@media (pointer: coarse) { .card button { min-height: 44px; } }
|
|
247
|
-
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
|
|
248
|
-
|
|
249
|
-
[data-ds-dark-theme] .frame {
|
|
250
|
-
--cfg-accent: var(--dsw-alias-state-business-primary, #4eb0e8);
|
|
251
|
-
--cfg-accent-text: color-mix(in srgb, var(--cfg-accent) 70%, var(--cfg-ink));
|
|
252
|
-
--cfg-solid: var(--dsw-alias-button-primary-fill, #4eb0e8);
|
|
253
|
-
--cfg-solid-hover: color-mix(in srgb, var(--cfg-solid) 88%, var(--cfg-on-solid));
|
|
254
|
-
--cfg-on-solid: var(--dsw-alias-label-primary-foreground, #0e1014);
|
|
255
|
-
}
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { useEffect, useMemo, useRef, useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
Button, extractMarkdownPlainText, IconEditOutlineRegular,
|
|
4
|
-
} from '@deepseek-ai/dsh-client-ui-primitives'
|
|
5
|
-
import type { PendingQuestion, PlanReview, QuestionComposerProps } from './contract/slots.ts'
|
|
6
|
-
import { QuestionWaitBar } from './QuestionWaitBar.tsx'
|
|
7
|
-
import css from './PlanReviewPanel.module.css'
|
|
8
|
-
|
|
9
|
-
/** The panel's own props: the question domain face, the narrowed review, and the locale seat. */
|
|
10
|
-
export type PlanReviewPanelProps =
|
|
11
|
-
{ pending: PendingQuestion; review: PlanReview } & Pick<QuestionComposerProps, 't' | 'renderSlot' | 'useQuestionCard'>
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Optional-prop spread for a decision button's tooltip: `title` is optional on
|
|
15
|
-
* the DOM props, and exactOptionalPropertyTypes rejects an explicit undefined.
|
|
16
|
-
*
|
|
17
|
-
* @param description - the asker's option description, when it carries one.
|
|
18
|
-
* @returns The `title` prop to spread, or nothing.
|
|
19
|
-
*/
|
|
20
|
-
function tooltip(description: string | undefined): { title?: string } {
|
|
21
|
-
return description === undefined ? {} : { title: description }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Render plan review controls; the submitted document opens in the sidebar.
|
|
26
|
-
*
|
|
27
|
-
* @param props - the question domain face, the narrowed plan review, and `t`.
|
|
28
|
-
* @returns The plan-review takeover for this request.
|
|
29
|
-
*/
|
|
30
|
-
export function PlanReviewPanel({ pending, review, t, renderSlot, useQuestionCard }: PlanReviewPanelProps) {
|
|
31
|
-
// Foreground decisions wait for the resolved frame; accepted Remote decisions
|
|
32
|
-
// hide the panel. A failed send re-enables the buttons and shows the error.
|
|
33
|
-
const [busy, setBusy] = useState(false)
|
|
34
|
-
const [error, setError] = useState<string | null>(null)
|
|
35
|
-
const card = useQuestionCard(pending.key, snapshot => snapshot)
|
|
36
|
-
const canDecide = card !== undefined && !card.closed && card.channel !== 'none'
|
|
37
|
-
const surface = useRef<HTMLElement>(null)
|
|
38
|
-
const sentVia = useRef<'waterfall' | null>(null)
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
if (sentVia.current !== 'waterfall' || card?.state !== 'continued') return
|
|
41
|
-
sentVia.current = null
|
|
42
|
-
setBusy(false)
|
|
43
|
-
setError(t('error.resubmit'))
|
|
44
|
-
}, [card?.state, t])
|
|
45
|
-
useEffect(() => {
|
|
46
|
-
const release = (): void => { pending.releaseFocus() }
|
|
47
|
-
const refocus = (): void => {
|
|
48
|
-
if (surface.current?.contains(document.activeElement) === true) pending.holdFocus()
|
|
49
|
-
}
|
|
50
|
-
const visibilityChanged = (): void => { if (document.hidden) release(); else refocus() }
|
|
51
|
-
window.addEventListener('blur', release)
|
|
52
|
-
window.addEventListener('focus', refocus)
|
|
53
|
-
document.addEventListener('visibilitychange', visibilityChanged)
|
|
54
|
-
return () => {
|
|
55
|
-
release()
|
|
56
|
-
window.removeEventListener('blur', release)
|
|
57
|
-
window.removeEventListener('focus', refocus)
|
|
58
|
-
document.removeEventListener('visibilitychange', visibilityChanged)
|
|
59
|
-
}
|
|
60
|
-
}, [pending])
|
|
61
|
-
const settle = (send: () => Promise<void>, remote = false): void => {
|
|
62
|
-
setBusy(true)
|
|
63
|
-
setError(null)
|
|
64
|
-
sentVia.current = pending.snapshot().channel === 'waterfall' ? 'waterfall' : null
|
|
65
|
-
void send()
|
|
66
|
-
.then(() => {
|
|
67
|
-
if (!remote) return
|
|
68
|
-
setBusy(false)
|
|
69
|
-
void pending.dismiss().catch(() => { setError(t('status.sent')) })
|
|
70
|
-
})
|
|
71
|
-
.catch((cause: unknown) => {
|
|
72
|
-
sentVia.current = null
|
|
73
|
-
setBusy(false)
|
|
74
|
-
setError(cause instanceof Error ? cause.message : String(cause))
|
|
75
|
-
})
|
|
76
|
-
}
|
|
77
|
-
const decide = (label: string): void => {
|
|
78
|
-
settle(() => pending.answer({ answers: [{ id: review.id, selected: [label] }] }), pending.snapshot().channel === 'rpc')
|
|
79
|
-
}
|
|
80
|
-
const decline = review.decline
|
|
81
|
-
const summary = useMemo(() => {
|
|
82
|
-
const title = extractMarkdownPlainText(review.plan, { mode: 'first-line' })
|
|
83
|
-
const description = extractMarkdownPlainText(review.plan, { mode: 'first-paragraph' })
|
|
84
|
-
return { title, description: description === title ? '' : description }
|
|
85
|
-
}, [review.plan])
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<div className={css.frame} data-plan-review-key={pending.key}>
|
|
89
|
-
<section
|
|
90
|
-
ref={surface} className={css.card} aria-label={review.question} aria-busy={busy}
|
|
91
|
-
onFocusCapture={(event) => { if (!event.currentTarget.contains(event.relatedTarget)) pending.holdFocus() }}
|
|
92
|
-
onBlurCapture={(event) => { if (!event.currentTarget.contains(event.relatedTarget)) pending.releaseFocus() }}
|
|
93
|
-
>
|
|
94
|
-
<div className={css.strip}>
|
|
95
|
-
<span className={css.panelLabel}>{t('plan.header')}</span>
|
|
96
|
-
<div className={css.previewActions}>
|
|
97
|
-
{renderSlot('conversation.plan-review.actions', { review, requestKey: pending.key })}
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
<QuestionWaitBar card={card} t={t} busy={busy} onTakeTime={() => { pending.takeTime() }} />
|
|
101
|
-
<div className={css.summary} data-plan-document>
|
|
102
|
-
<div className={css.documentHeading}>
|
|
103
|
-
<svg className={css.documentIcon} viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" aria-hidden="true"><path d="M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8zM14 3v5h5M9 12h6M9 16h6" /></svg>
|
|
104
|
-
<h3 className={css.title}>{summary.title}</h3>
|
|
105
|
-
</div>
|
|
106
|
-
{summary.description !== '' && <p className={css.description}>{summary.description}</p>}
|
|
107
|
-
</div>
|
|
108
|
-
<div className={css.footer} data-plan-decision>
|
|
109
|
-
<div className={css.feedback} role={error === null ? 'status' : 'alert'} aria-atomic="true" data-error={error !== null || undefined}>
|
|
110
|
-
{busy && <span className={css.spinner} aria-hidden="true" />}
|
|
111
|
-
{error ?? (busy ? t('submitting') : null)}
|
|
112
|
-
</div>
|
|
113
|
-
<div className={css.actions}>
|
|
114
|
-
{decline !== undefined && (
|
|
115
|
-
<button
|
|
116
|
-
type="button" className={css.decline} {...tooltip(decline.description)}
|
|
117
|
-
aria-describedby={decline.description === undefined ? undefined : `plan-decline-${pending.key}`}
|
|
118
|
-
disabled={busy || !canDecide} onClick={() => { decide(decline.label) }}
|
|
119
|
-
>
|
|
120
|
-
{decline.label}
|
|
121
|
-
</button>
|
|
122
|
-
)}
|
|
123
|
-
<Button
|
|
124
|
-
variant="outline" className={css.discuss} icon={<IconEditOutlineRegular size={14} />}
|
|
125
|
-
disabled={busy} onClick={() => { settle(() => pending.dismiss()) }}
|
|
126
|
-
>
|
|
127
|
-
{t('plan.discuss')}
|
|
128
|
-
</Button>
|
|
129
|
-
<Button
|
|
130
|
-
variant="primary" className={css.primary} {...tooltip(review.approve.description)}
|
|
131
|
-
aria-describedby={review.approve.description === undefined ? undefined : `plan-approve-${pending.key}`}
|
|
132
|
-
disabled={busy || !canDecide} onClick={() => { decide(review.approve.label) }}
|
|
133
|
-
>
|
|
134
|
-
{t('plan.approve')}
|
|
135
|
-
</Button>
|
|
136
|
-
</div>
|
|
137
|
-
</div>
|
|
138
|
-
{decline?.description !== undefined && (
|
|
139
|
-
<span className={css.srOnly} id={`plan-decline-${pending.key}`}>{decline.description}</span>
|
|
140
|
-
)}
|
|
141
|
-
{review.approve.description !== undefined && (
|
|
142
|
-
<span className={css.srOnly} id={`plan-approve-${pending.key}`}>{review.approve.description}</span>
|
|
143
|
-
)}
|
|
144
|
-
</section>
|
|
145
|
-
</div>
|
|
146
|
-
)
|
|
147
|
-
}
|