makethisbetter 1.5.3 → 1.6.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/README.md +10 -10
- package/dist/annotate/draw-note-bar.d.ts +29 -0
- package/dist/annotate/draw-note-bar.d.ts.map +1 -0
- package/dist/annotate/draw-note-bar.test.d.ts +2 -0
- package/dist/annotate/draw-note-bar.test.d.ts.map +1 -0
- package/dist/annotate/draw.d.ts +15 -9
- package/dist/annotate/draw.d.ts.map +1 -1
- package/dist/annotate/highlighter.d.ts +2 -0
- package/dist/annotate/highlighter.d.ts.map +1 -1
- package/dist/annotate/session.d.ts +16 -2
- package/dist/annotate/session.d.ts.map +1 -1
- package/dist/api/client.d.ts +8 -5
- package/dist/api/client.d.ts.map +1 -1
- package/dist/context/breadcrumbs.d.ts +26 -0
- package/dist/context/breadcrumbs.d.ts.map +1 -0
- package/dist/context/breadcrumbs.test.d.ts +2 -0
- package/dist/context/breadcrumbs.test.d.ts.map +1 -0
- package/dist/context/dom-utils.d.ts +3 -0
- package/dist/context/dom-utils.d.ts.map +1 -0
- package/dist/context/frustration.d.ts +0 -1
- package/dist/context/frustration.d.ts.map +1 -1
- package/dist/i18n/de.d.ts +24 -0
- package/dist/i18n/de.d.ts.map +1 -1
- package/dist/i18n/en.d.ts +24 -0
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/es.d.ts +24 -0
- package/dist/i18n/es.d.ts.map +1 -1
- package/dist/i18n/fr.d.ts +24 -0
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/ja.d.ts +24 -0
- package/dist/i18n/ja.d.ts.map +1 -1
- package/dist/i18n/ko.d.ts +24 -0
- package/dist/i18n/ko.d.ts.map +1 -1
- package/dist/i18n/zh-CN.d.ts +24 -0
- package/dist/i18n/zh-CN.d.ts.map +1 -1
- package/dist/makethisbetter.cjs +51 -26
- package/dist/makethisbetter.cjs.map +1 -1
- package/dist/makethisbetter.esm.js +1124 -591
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +50 -25
- package/dist/makethisbetter.js.map +1 -1
- package/dist/popup/clarify.d.ts +28 -7
- package/dist/popup/clarify.d.ts.map +1 -1
- package/dist/popup/comment.d.ts +1 -0
- package/dist/popup/comment.d.ts.map +1 -1
- package/dist/record/replay.d.ts +7 -0
- package/dist/record/replay.d.ts.map +1 -0
- package/dist/screenshot/capture.d.ts +1 -0
- package/dist/screenshot/capture.d.ts.map +1 -1
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -1
- package/dist/types.d.ts +13 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/widget/controller.d.ts +16 -0
- package/dist/widget/controller.d.ts.map +1 -1
- package/dist/widget/dim-overlay.d.ts +8 -0
- package/dist/widget/dim-overlay.d.ts.map +1 -0
- package/dist/widget/dim-overlay.test.d.ts +2 -0
- package/dist/widget/dim-overlay.test.d.ts.map +1 -0
- package/dist/widget/payload.d.ts +2 -2
- package/dist/widget/payload.d.ts.map +1 -1
- package/dist/widget/tab.d.ts +3 -0
- package/dist/widget/tab.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/annotate/draw-note-bar.test.ts +90 -0
- package/src/annotate/draw-note-bar.ts +105 -0
- package/src/annotate/draw.test.ts +74 -84
- package/src/annotate/draw.ts +108 -65
- package/src/annotate/highlighter.test.ts +24 -1
- package/src/annotate/highlighter.ts +16 -2
- package/src/annotate/session.test.ts +112 -96
- package/src/annotate/session.ts +54 -10
- package/src/api/client.test.ts +69 -30
- package/src/api/client.ts +68 -20
- package/src/context/breadcrumbs.test.ts +154 -0
- package/src/context/breadcrumbs.ts +157 -0
- package/src/context/dom-utils.ts +16 -0
- package/src/context/frustration.ts +4 -8
- package/src/i18n/de.ts +34 -11
- package/src/i18n/en.ts +33 -10
- package/src/i18n/es.ts +34 -11
- package/src/i18n/fr.ts +33 -10
- package/src/i18n/index.test.ts +12 -0
- package/src/i18n/ja.ts +32 -9
- package/src/i18n/ko.ts +34 -11
- package/src/i18n/zh-CN.ts +35 -12
- package/src/popup/clarify.test.ts +143 -43
- package/src/popup/clarify.ts +160 -46
- package/src/popup/comment.test.ts +57 -0
- package/src/popup/comment.ts +15 -9
- package/src/record/replay.ts +115 -0
- package/src/record/session.test.ts +8 -1
- package/src/record/session.ts +1 -1
- package/src/screenshot/capture.test.ts +51 -23
- package/src/screenshot/capture.ts +101 -55
- package/src/styles/widget.css +347 -1
- package/src/styles.ts +2 -0
- package/src/types.ts +15 -0
- package/src/widget/controller.test.ts +335 -65
- package/src/widget/controller.ts +187 -35
- package/src/widget/dim-overlay.test.ts +27 -0
- package/src/widget/dim-overlay.ts +20 -0
- package/src/widget/payload.test.ts +26 -1
- package/src/widget/payload.ts +3 -1
- package/src/widget/pet.test.ts +2 -2
- package/src/widget/tab.test.ts +15 -0
- package/src/widget/tab.ts +11 -3
- package/dist/index.d.cts +0 -8
- package/dist/index.d.mts +0 -8
package/src/i18n/ko.ts
CHANGED
|
@@ -4,7 +4,7 @@ export default {
|
|
|
4
4
|
markup: '마크업',
|
|
5
5
|
record: '녹화',
|
|
6
6
|
hint: '요소를 클릭하여 주석 · 드래그하여 그리기',
|
|
7
|
-
hintRecord: '
|
|
7
|
+
hintRecord: '화면 녹화 중',
|
|
8
8
|
exit: '나가기',
|
|
9
9
|
},
|
|
10
10
|
popup: {
|
|
@@ -14,17 +14,16 @@ export default {
|
|
|
14
14
|
cancel: '취소',
|
|
15
15
|
my_feedback: '내 피드백',
|
|
16
16
|
quickOptions: [
|
|
17
|
-
{ emoji: '🐛', label: '
|
|
18
|
-
{ emoji: '💡', label: '
|
|
19
|
-
{ emoji: '🤔', label: '
|
|
20
|
-
{ emoji: '✨', label: '아이디어가 있어요' },
|
|
17
|
+
{ emoji: '🐛', label: '문제가 있어요' },
|
|
18
|
+
{ emoji: '💡', label: '제안이 있어요' },
|
|
19
|
+
{ emoji: '🤔', label: '헷갈려요' },
|
|
21
20
|
],
|
|
22
21
|
},
|
|
23
22
|
success: {
|
|
24
|
-
title: '감사합니다!',
|
|
25
|
-
message: '
|
|
26
|
-
title_no_ai: '
|
|
27
|
-
message_no_ai: '팀에서
|
|
23
|
+
title: '전송되었습니다. 감사합니다!',
|
|
24
|
+
message: '피드백과 수집된 기술 정보가 팀에 전달되었습니다. 해결되면 알려드리겠습니다.',
|
|
25
|
+
title_no_ai: '감사합니다! 피드백을 접수했습니다.',
|
|
26
|
+
message_no_ai: '팀에서 처리합니다. 해결되면 알려드리겠습니다.',
|
|
28
27
|
view_feedback: '내 피드백 보기',
|
|
29
28
|
close: '닫기',
|
|
30
29
|
email_prompt: '진행 상황이 궁금하신가요? 이메일을 남겨주시면 해결 시 알려드립니다.',
|
|
@@ -48,17 +47,41 @@ export default {
|
|
|
48
47
|
drawing: '그리기',
|
|
49
48
|
element: '요소',
|
|
50
49
|
},
|
|
50
|
+
draw: {
|
|
51
|
+
note_placeholder: '그림에 메모 추가',
|
|
52
|
+
undo: '실행 취소',
|
|
53
|
+
redo: '다시 실행',
|
|
54
|
+
cancel: '취소',
|
|
55
|
+
submit: '보내기',
|
|
56
|
+
},
|
|
51
57
|
record: {
|
|
52
58
|
stop: '중지',
|
|
53
59
|
timer_label: '녹화 중',
|
|
54
60
|
max_reached: '최대 녹화 시간에 도달했습니다',
|
|
61
|
+
replay_label: 'screen-recording.json',
|
|
62
|
+
play: '녹화 재생',
|
|
63
|
+
close: '닫기',
|
|
64
|
+
preview_unavailable: '미리보기를 사용할 수 없습니다',
|
|
55
65
|
},
|
|
56
66
|
clarify: {
|
|
57
67
|
title: 'Make This Better AI',
|
|
58
68
|
subtitle: '피드백을 다듬는 중',
|
|
59
69
|
thinking: '생각 중...',
|
|
60
|
-
placeholder: '
|
|
70
|
+
placeholder: '답변을 입력하거나 질문을 건너뛰세요',
|
|
61
71
|
send: '보내기',
|
|
62
|
-
skip: '
|
|
72
|
+
skip: '건너뛰고 보내기',
|
|
73
|
+
summary: {
|
|
74
|
+
ready: '보낼 준비 완료',
|
|
75
|
+
what_you_said: '입력한 내용',
|
|
76
|
+
clarified: 'AI로 명확화',
|
|
77
|
+
auto_captured: '자동 수집',
|
|
78
|
+
element: '요소',
|
|
79
|
+
page: '페이지',
|
|
80
|
+
browser: '브라우저',
|
|
81
|
+
captured: '수집됨',
|
|
82
|
+
send_feedback: '피드백 보내기',
|
|
83
|
+
screenshot: '스크린샷',
|
|
84
|
+
recording: '상호작용 리플레이',
|
|
85
|
+
},
|
|
63
86
|
},
|
|
64
87
|
}
|
package/src/i18n/zh-CN.ts
CHANGED
|
@@ -14,17 +14,16 @@ export default {
|
|
|
14
14
|
cancel: '取消',
|
|
15
15
|
my_feedback: '我的反馈',
|
|
16
16
|
quickOptions: [
|
|
17
|
-
{ emoji: '🐛', label: '
|
|
18
|
-
{ emoji: '💡', label: '
|
|
19
|
-
{ emoji: '🤔', label: '
|
|
20
|
-
{ emoji: '✨', label: '我有个想法' },
|
|
17
|
+
{ emoji: '🐛', label: '出问题了' },
|
|
18
|
+
{ emoji: '💡', label: '我有一个建议' },
|
|
19
|
+
{ emoji: '🤔', label: '我有点困惑' },
|
|
21
20
|
],
|
|
22
21
|
},
|
|
23
22
|
success: {
|
|
24
|
-
title: '
|
|
25
|
-
message: '
|
|
26
|
-
title_no_ai: '
|
|
27
|
-
message_no_ai: '
|
|
23
|
+
title: '已发送,感谢!',
|
|
24
|
+
message: '您的反馈和采集到的技术上下文正在发送给团队。问题解决后,您会收到通知。',
|
|
25
|
+
title_no_ai: '感谢!我们已收到您的反馈。',
|
|
26
|
+
message_no_ai: '接下来由团队处理。问题解决后,您会收到通知。',
|
|
28
27
|
view_feedback: '查看我的反馈',
|
|
29
28
|
close: '关闭',
|
|
30
29
|
email_prompt: '想了解进展?留下邮箱,问题解决后我们会通知您。',
|
|
@@ -48,17 +47,41 @@ export default {
|
|
|
48
47
|
drawing: '绘制',
|
|
49
48
|
element: '元素',
|
|
50
49
|
},
|
|
50
|
+
draw: {
|
|
51
|
+
note_placeholder: '给你的绘制添加说明',
|
|
52
|
+
undo: '撤销',
|
|
53
|
+
redo: '重做',
|
|
54
|
+
cancel: '取消',
|
|
55
|
+
submit: '提交',
|
|
56
|
+
},
|
|
51
57
|
record: {
|
|
52
58
|
stop: '停止',
|
|
53
59
|
timer_label: '录制中',
|
|
54
|
-
max_reached: '
|
|
60
|
+
max_reached: '已达到最长录制时间',
|
|
61
|
+
replay_label: 'screen-recording.json',
|
|
62
|
+
play: '播放录屏',
|
|
63
|
+
close: '关闭',
|
|
64
|
+
preview_unavailable: '暂无法预览',
|
|
55
65
|
},
|
|
56
66
|
clarify: {
|
|
57
|
-
title: '
|
|
67
|
+
title: 'Make This Better AI',
|
|
58
68
|
subtitle: '正在完善你的反馈',
|
|
59
69
|
thinking: '思考中...',
|
|
60
|
-
placeholder: '
|
|
70
|
+
placeholder: '输入回答,或跳过问题',
|
|
61
71
|
send: '发送',
|
|
62
|
-
skip: '
|
|
72
|
+
skip: '跳过并发送',
|
|
73
|
+
summary: {
|
|
74
|
+
ready: '准备发送',
|
|
75
|
+
what_you_said: '你的描述',
|
|
76
|
+
clarified: 'AI 追问澄清',
|
|
77
|
+
auto_captured: '自动采集',
|
|
78
|
+
element: '元素',
|
|
79
|
+
page: '页面',
|
|
80
|
+
browser: '浏览器',
|
|
81
|
+
captured: '已采集',
|
|
82
|
+
send_feedback: '发送反馈',
|
|
83
|
+
screenshot: '截图',
|
|
84
|
+
recording: '交互回放',
|
|
85
|
+
},
|
|
63
86
|
},
|
|
64
87
|
}
|
|
@@ -7,7 +7,6 @@ import type { ClarifyResponse } from '../types'
|
|
|
7
7
|
|
|
8
8
|
function mockApiClient(overrides: Partial<ApiClient> = {}): ApiClient {
|
|
9
9
|
return {
|
|
10
|
-
submitFeedback: vi.fn(),
|
|
11
10
|
startClarification: vi.fn().mockResolvedValue({
|
|
12
11
|
status: 'pending',
|
|
13
12
|
messages: [{ role: 'assistant', content: 'Can you tell me more?' }],
|
|
@@ -24,20 +23,21 @@ function mockApiClient(overrides: Partial<ApiClient> = {}): ApiClient {
|
|
|
24
23
|
|
|
25
24
|
function setupCard(apiOverrides: Partial<ApiClient> = {}, pos?: { x: number; y: number }) {
|
|
26
25
|
const shadow = new ShadowContainer()
|
|
27
|
-
const
|
|
26
|
+
const onFinalize = vi.fn()
|
|
28
27
|
const apiClient = mockApiClient(apiOverrides)
|
|
29
28
|
const messages = getMessages('en')
|
|
30
29
|
|
|
31
30
|
const card = new ClarifyCard(shadow, {
|
|
32
|
-
|
|
31
|
+
submissionSessionId: 'submission_123',
|
|
32
|
+
submissionToken: 'submission-secret',
|
|
33
33
|
apiClient,
|
|
34
34
|
messages,
|
|
35
|
-
|
|
35
|
+
onFinalize,
|
|
36
36
|
x: pos?.x,
|
|
37
37
|
y: pos?.y,
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
-
return { shadow, card,
|
|
40
|
+
return { shadow, card, onFinalize, apiClient, messages }
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
describe('ClarifyCard', () => {
|
|
@@ -116,9 +116,9 @@ describe('ClarifyCard', () => {
|
|
|
116
116
|
})
|
|
117
117
|
|
|
118
118
|
it('header close button ends the conversation', async () => {
|
|
119
|
-
const { shadow, card,
|
|
119
|
+
const { shadow, card, onFinalize } = setupCard()
|
|
120
120
|
shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-close')!.click()
|
|
121
|
-
expect(
|
|
121
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
122
122
|
|
|
123
123
|
card.destroy()
|
|
124
124
|
shadow.destroy()
|
|
@@ -127,7 +127,7 @@ describe('ClarifyCard', () => {
|
|
|
127
127
|
it('falls back to startClarification when streaming is unavailable', async () => {
|
|
128
128
|
const { shadow, card, apiClient } = setupCard()
|
|
129
129
|
await vi.waitFor(() => {
|
|
130
|
-
expect(apiClient.startClarification).toHaveBeenCalledWith('
|
|
130
|
+
expect(apiClient.startClarification).toHaveBeenCalledWith('submission_123', 'submission-secret')
|
|
131
131
|
})
|
|
132
132
|
|
|
133
133
|
card.destroy()
|
|
@@ -155,30 +155,38 @@ describe('ClarifyCard', () => {
|
|
|
155
155
|
shadow.destroy()
|
|
156
156
|
})
|
|
157
157
|
|
|
158
|
-
it('
|
|
159
|
-
const { shadow, card,
|
|
158
|
+
it('Skip & send calls onFinalize', async () => {
|
|
159
|
+
const { shadow, card, onFinalize, apiClient } = setupCard()
|
|
160
160
|
await vi.waitFor(() => {
|
|
161
161
|
expect(apiClient.startClarification).toHaveBeenCalled()
|
|
162
162
|
})
|
|
163
163
|
|
|
164
164
|
shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-skip')!.click()
|
|
165
|
-
expect(
|
|
165
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
166
166
|
|
|
167
167
|
card.destroy()
|
|
168
168
|
shadow.destroy()
|
|
169
169
|
})
|
|
170
170
|
|
|
171
|
-
it('send button
|
|
171
|
+
it('send button is disabled when input is empty and enabled when text is entered', async () => {
|
|
172
172
|
const { shadow, card, apiClient } = setupCard()
|
|
173
173
|
await vi.waitFor(() => {
|
|
174
174
|
expect(apiClient.startClarification).toHaveBeenCalled()
|
|
175
175
|
})
|
|
176
176
|
|
|
177
|
-
// The mockup keeps Send green at all times; the empty-input guard lives in
|
|
178
|
-
// the send handler, not a disabled attribute.
|
|
179
177
|
const sendBtn = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send')!
|
|
178
|
+
const input = shadow.root.querySelector<HTMLTextAreaElement>('.mtb-clarify-input')!
|
|
179
|
+
|
|
180
|
+
expect(sendBtn.disabled).toBe(true)
|
|
181
|
+
|
|
182
|
+
input.value = 'hello'
|
|
183
|
+
input.dispatchEvent(new Event('input'))
|
|
180
184
|
expect(sendBtn.disabled).toBe(false)
|
|
181
185
|
|
|
186
|
+
input.value = ''
|
|
187
|
+
input.dispatchEvent(new Event('input'))
|
|
188
|
+
expect(sendBtn.disabled).toBe(true)
|
|
189
|
+
|
|
182
190
|
card.destroy()
|
|
183
191
|
shadow.destroy()
|
|
184
192
|
})
|
|
@@ -219,13 +227,13 @@ describe('ClarifyCard', () => {
|
|
|
219
227
|
done: false,
|
|
220
228
|
} satisfies ClarifyResponse)
|
|
221
229
|
.mockResolvedValueOnce({
|
|
222
|
-
status: '
|
|
230
|
+
status: 'completed',
|
|
223
231
|
messages: [
|
|
224
232
|
{ role: 'assistant', content: 'Tell me more' },
|
|
225
233
|
{ role: 'user', content: 'Button does nothing' },
|
|
226
234
|
{ role: 'assistant', content: 'Got it' },
|
|
227
235
|
],
|
|
228
|
-
done:
|
|
236
|
+
done: true,
|
|
229
237
|
} satisfies ClarifyResponse)
|
|
230
238
|
|
|
231
239
|
const { shadow, card } = setupCard({ startClarification })
|
|
@@ -244,7 +252,41 @@ describe('ClarifyCard', () => {
|
|
|
244
252
|
await vi.waitFor(() => {
|
|
245
253
|
expect(startClarification).toHaveBeenCalledTimes(2)
|
|
246
254
|
})
|
|
247
|
-
expect(startClarification).toHaveBeenCalledWith('
|
|
255
|
+
expect(startClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', 'Button does nothing')
|
|
256
|
+
await vi.waitFor(() => {
|
|
257
|
+
expect(shadow.root.querySelector('.mtb-clarify-summary')).toBeTruthy()
|
|
258
|
+
})
|
|
259
|
+
|
|
260
|
+
card.destroy()
|
|
261
|
+
shadow.destroy()
|
|
262
|
+
})
|
|
263
|
+
|
|
264
|
+
it('keeps the answer editable when saving it fails', async () => {
|
|
265
|
+
const startClarification = vi.fn()
|
|
266
|
+
.mockResolvedValueOnce({
|
|
267
|
+
status: 'awaiting_response',
|
|
268
|
+
messages: [{ role: 'assistant', content: 'Tell me more' }],
|
|
269
|
+
done: false,
|
|
270
|
+
} satisfies ClarifyResponse)
|
|
271
|
+
.mockRejectedValueOnce(new Error('Network error'))
|
|
272
|
+
|
|
273
|
+
const { shadow, card, messages } = setupCard({ startClarification })
|
|
274
|
+
await vi.waitFor(() => {
|
|
275
|
+
expect(startClarification).toHaveBeenCalledOnce()
|
|
276
|
+
})
|
|
277
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
278
|
+
|
|
279
|
+
const input = shadow.root.querySelector<HTMLTextAreaElement>('.mtb-clarify-input')!
|
|
280
|
+
input.value = 'Button does nothing'
|
|
281
|
+
input.dispatchEvent(new Event('input'))
|
|
282
|
+
shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send')!.click()
|
|
283
|
+
|
|
284
|
+
await vi.waitFor(() => {
|
|
285
|
+
expect(shadow.root.querySelector('.mtb-clarify-error')?.textContent).toBe(messages.error.submit)
|
|
286
|
+
})
|
|
287
|
+
expect(shadow.root.querySelector('.mtb-clarify-summary')).toBeNull()
|
|
288
|
+
expect(input.value).toBe('Button does nothing')
|
|
289
|
+
expect(input.disabled).toBe(false)
|
|
248
290
|
|
|
249
291
|
card.destroy()
|
|
250
292
|
shadow.destroy()
|
|
@@ -277,7 +319,7 @@ describe('ClarifyCard', () => {
|
|
|
277
319
|
await vi.waitFor(() => {
|
|
278
320
|
expect(startClarification).toHaveBeenCalledTimes(2)
|
|
279
321
|
})
|
|
280
|
-
expect(startClarification).toHaveBeenCalledWith('
|
|
322
|
+
expect(startClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', 'Help me')
|
|
281
323
|
|
|
282
324
|
card.destroy()
|
|
283
325
|
shadow.destroy()
|
|
@@ -331,7 +373,7 @@ describe('ClarifyCard', () => {
|
|
|
331
373
|
await vi.advanceTimersByTimeAsync(0)
|
|
332
374
|
|
|
333
375
|
await vi.advanceTimersByTimeAsync(2000)
|
|
334
|
-
expect(getClarification).toHaveBeenCalledWith('
|
|
376
|
+
expect(getClarification).toHaveBeenCalledWith('submission_123', 'submission-secret')
|
|
335
377
|
|
|
336
378
|
await vi.advanceTimersByTimeAsync(2000)
|
|
337
379
|
expect(getClarification).toHaveBeenCalledTimes(2)
|
|
@@ -340,22 +382,26 @@ describe('ClarifyCard', () => {
|
|
|
340
382
|
shadow.destroy()
|
|
341
383
|
})
|
|
342
384
|
|
|
343
|
-
it('
|
|
385
|
+
it('shows a summary card and calls onFinalize on Send feedback when done=true from start', async () => {
|
|
344
386
|
const startClarification = vi.fn().mockResolvedValue({
|
|
345
387
|
status: 'complete',
|
|
346
388
|
messages: [{ role: 'assistant', content: 'All clear, thanks!' }],
|
|
347
389
|
done: true,
|
|
348
390
|
} satisfies ClarifyResponse)
|
|
349
391
|
|
|
350
|
-
const { shadow, card,
|
|
392
|
+
const { shadow, card, onFinalize } = setupCard({ startClarification })
|
|
351
393
|
await vi.waitFor(() => {
|
|
352
394
|
expect(startClarification).toHaveBeenCalled()
|
|
353
395
|
})
|
|
354
396
|
await vi.advanceTimersByTimeAsync(0)
|
|
355
397
|
|
|
356
|
-
expect(
|
|
357
|
-
|
|
358
|
-
expect(
|
|
398
|
+
expect(shadow.root.querySelector('.mtb-clarify-summary')).toBeTruthy()
|
|
399
|
+
const sendFeedback = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send-feedback')!
|
|
400
|
+
expect(sendFeedback).toBeTruthy()
|
|
401
|
+
expect(onFinalize).not.toHaveBeenCalled()
|
|
402
|
+
|
|
403
|
+
sendFeedback.click()
|
|
404
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
359
405
|
|
|
360
406
|
card.destroy()
|
|
361
407
|
shadow.destroy()
|
|
@@ -368,7 +414,7 @@ describe('ClarifyCard', () => {
|
|
|
368
414
|
done: true,
|
|
369
415
|
} satisfies ClarifyResponse)
|
|
370
416
|
|
|
371
|
-
const { shadow, card,
|
|
417
|
+
const { shadow, card, onFinalize } = setupCard({ getClarification })
|
|
372
418
|
await vi.waitFor(() => {
|
|
373
419
|
expect(card).toBeTruthy()
|
|
374
420
|
})
|
|
@@ -381,13 +427,16 @@ describe('ClarifyCard', () => {
|
|
|
381
427
|
await vi.advanceTimersByTimeAsync(0)
|
|
382
428
|
|
|
383
429
|
await vi.advanceTimersByTimeAsync(2000)
|
|
384
|
-
|
|
430
|
+
const sendFeedback = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send-feedback')!
|
|
431
|
+
expect(sendFeedback).toBeTruthy()
|
|
432
|
+
sendFeedback.click()
|
|
433
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
385
434
|
|
|
386
435
|
card.destroy()
|
|
387
436
|
shadow.destroy()
|
|
388
437
|
})
|
|
389
438
|
|
|
390
|
-
it('
|
|
439
|
+
it('replaces the input with a summary send-feedback button after done', async () => {
|
|
391
440
|
const startClarification = vi.fn().mockResolvedValue({
|
|
392
441
|
status: 'complete',
|
|
393
442
|
messages: [{ role: 'assistant', content: 'Resolved' }],
|
|
@@ -400,25 +449,69 @@ describe('ClarifyCard', () => {
|
|
|
400
449
|
})
|
|
401
450
|
await vi.advanceTimersByTimeAsync(0)
|
|
402
451
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
expect(input
|
|
406
|
-
expect(
|
|
452
|
+
expect(shadow.root.querySelector('.mtb-clarify-summary')).toBeTruthy()
|
|
453
|
+
expect(shadow.root.querySelector('.mtb-clarify-send-feedback')).toBeTruthy()
|
|
454
|
+
expect(shadow.root.querySelector('.mtb-clarify-input')).toBeNull()
|
|
455
|
+
expect(shadow.root.querySelector('.mtb-clarify-send')).toBeNull()
|
|
456
|
+
|
|
457
|
+
card.destroy()
|
|
458
|
+
shadow.destroy()
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
it('renders the original comment, clarified Q/A and captured context in the summary', async () => {
|
|
462
|
+
const startClarification = vi.fn().mockResolvedValue({
|
|
463
|
+
status: 'complete',
|
|
464
|
+
messages: [
|
|
465
|
+
{ role: 'assistant', content: 'What were you exporting?' },
|
|
466
|
+
{ role: 'user', content: 'The Q2 report' },
|
|
467
|
+
],
|
|
468
|
+
done: true,
|
|
469
|
+
} satisfies ClarifyResponse)
|
|
470
|
+
|
|
471
|
+
const shadow = new ShadowContainer()
|
|
472
|
+
const onFinalize = vi.fn()
|
|
473
|
+
const card = new ClarifyCard(shadow, {
|
|
474
|
+
submissionSessionId: 'submission_123',
|
|
475
|
+
submissionToken: 'submission-secret',
|
|
476
|
+
apiClient: mockApiClient({ startClarification }),
|
|
477
|
+
messages: getMessages('en'),
|
|
478
|
+
onFinalize,
|
|
479
|
+
summary: {
|
|
480
|
+
originalDescription: 'Export is broken',
|
|
481
|
+
element: 'Export PDF',
|
|
482
|
+
page: '/reports/q2',
|
|
483
|
+
browser: 'Chrome 124 · macOS',
|
|
484
|
+
captured: 'Screenshot',
|
|
485
|
+
},
|
|
486
|
+
})
|
|
487
|
+
|
|
488
|
+
await vi.waitFor(() => {
|
|
489
|
+
expect(startClarification).toHaveBeenCalled()
|
|
490
|
+
})
|
|
491
|
+
await vi.advanceTimersByTimeAsync(0)
|
|
492
|
+
|
|
493
|
+
const summary = shadow.root.querySelector('.mtb-clarify-summary')!
|
|
494
|
+
expect(summary.querySelector('.mtb-summary-quote')!.textContent).toBe('Export is broken')
|
|
495
|
+
expect(summary.querySelector('.mtb-summary-qa')!.textContent).toContain('What were you exporting?')
|
|
496
|
+
expect(summary.querySelector('.mtb-summary-qa')!.textContent).toContain('The Q2 report')
|
|
497
|
+
expect(summary.textContent).not.toContain('Export PDF')
|
|
498
|
+
expect(summary.textContent).not.toContain('/reports/q2')
|
|
407
499
|
|
|
408
500
|
card.destroy()
|
|
409
501
|
shadow.destroy()
|
|
410
502
|
})
|
|
411
503
|
|
|
412
|
-
it('
|
|
504
|
+
it('shows summary without finalizing on startClarification error', async () => {
|
|
413
505
|
const startClarification = vi.fn().mockRejectedValue(new Error('Network error'))
|
|
414
506
|
|
|
415
|
-
const { shadow, card,
|
|
507
|
+
const { shadow, card, onFinalize } = setupCard({ startClarification })
|
|
416
508
|
await vi.waitFor(() => {
|
|
417
509
|
expect(startClarification).toHaveBeenCalled()
|
|
418
510
|
})
|
|
419
511
|
await vi.advanceTimersByTimeAsync(0)
|
|
420
512
|
|
|
421
|
-
expect(
|
|
513
|
+
expect(shadow.root.querySelector('.mtb-clarify-summary')).toBeTruthy()
|
|
514
|
+
expect(onFinalize).not.toHaveBeenCalled()
|
|
422
515
|
|
|
423
516
|
card.destroy()
|
|
424
517
|
shadow.destroy()
|
|
@@ -472,7 +565,7 @@ describe('ClarifyCard', () => {
|
|
|
472
565
|
await vi.waitFor(() => {
|
|
473
566
|
expect(startClarification).toHaveBeenCalledTimes(2)
|
|
474
567
|
})
|
|
475
|
-
expect(startClarification).toHaveBeenCalledWith('
|
|
568
|
+
expect(startClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', '导出坏了')
|
|
476
569
|
|
|
477
570
|
card.destroy()
|
|
478
571
|
shadow.destroy()
|
|
@@ -542,7 +635,7 @@ describe('ClarifyCard', () => {
|
|
|
542
635
|
|
|
543
636
|
it('renders streamed deltas live and completes on the stream result', async () => {
|
|
544
637
|
const streamClarification = vi.fn().mockImplementation(
|
|
545
|
-
async (_id: string,
|
|
638
|
+
async (_id: string, _token: string, onDelta: (t: string) => void) => {
|
|
546
639
|
onDelta('What ')
|
|
547
640
|
onDelta('broke?')
|
|
548
641
|
return {
|
|
@@ -554,7 +647,7 @@ describe('ClarifyCard', () => {
|
|
|
554
647
|
|
|
555
648
|
const { shadow, card } = setupCard({ streamClarification } as never)
|
|
556
649
|
await vi.waitFor(() => {
|
|
557
|
-
expect(streamClarification).toHaveBeenCalledWith('
|
|
650
|
+
expect(streamClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', expect.any(Function))
|
|
558
651
|
})
|
|
559
652
|
await vi.advanceTimersByTimeAsync(0)
|
|
560
653
|
|
|
@@ -572,36 +665,43 @@ describe('ClarifyCard', () => {
|
|
|
572
665
|
})
|
|
573
666
|
const getClarification = vi.fn()
|
|
574
667
|
|
|
575
|
-
const { shadow, card,
|
|
668
|
+
const { shadow, card, onFinalize } = setupCard({ streamClarification, getClarification } as never)
|
|
576
669
|
await vi.waitFor(() => {
|
|
577
670
|
expect(streamClarification).toHaveBeenCalled()
|
|
578
671
|
})
|
|
579
672
|
await vi.advanceTimersByTimeAsync(0)
|
|
580
673
|
|
|
581
674
|
await vi.advanceTimersByTimeAsync(2000)
|
|
582
|
-
expect(onDone).toHaveBeenCalledOnce()
|
|
583
675
|
expect(getClarification).not.toHaveBeenCalled()
|
|
676
|
+
const sendFeedback = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send-feedback')!
|
|
677
|
+
expect(sendFeedback).toBeTruthy()
|
|
678
|
+
sendFeedback.click()
|
|
679
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
584
680
|
|
|
585
681
|
card.destroy()
|
|
586
682
|
shadow.destroy()
|
|
587
683
|
})
|
|
588
684
|
|
|
589
|
-
it('
|
|
685
|
+
it('shows the summary card when polling exceeds the timeout with no reply', async () => {
|
|
590
686
|
const getClarification = vi.fn().mockResolvedValue({
|
|
591
687
|
status: 'pending',
|
|
592
688
|
messages: [],
|
|
593
689
|
done: false,
|
|
594
690
|
} satisfies ClarifyResponse)
|
|
595
691
|
|
|
596
|
-
const { shadow, card,
|
|
692
|
+
const { shadow, card, onFinalize } = setupCard({ getClarification })
|
|
597
693
|
await vi.waitFor(() => {
|
|
598
694
|
expect(card).toBeTruthy()
|
|
599
695
|
})
|
|
600
696
|
await vi.advanceTimersByTimeAsync(0)
|
|
601
697
|
|
|
602
|
-
// Poll past the 45s deadline; the card should give up and
|
|
698
|
+
// Poll past the 45s deadline; the card should give up and surface the
|
|
699
|
+
// summary so the user can still confirm the send.
|
|
603
700
|
await vi.advanceTimersByTimeAsync(48000)
|
|
604
|
-
|
|
701
|
+
const sendFeedback = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send-feedback')!
|
|
702
|
+
expect(sendFeedback).toBeTruthy()
|
|
703
|
+
sendFeedback.click()
|
|
704
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
605
705
|
|
|
606
706
|
card.destroy()
|
|
607
707
|
shadow.destroy()
|