makethisbetter 1.5.4 → 1.7.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 +50 -25
- package/dist/makethisbetter.cjs.map +1 -1
- package/dist/makethisbetter.esm.js +1132 -590
- package/dist/makethisbetter.esm.js.map +1 -1
- package/dist/makethisbetter.js +49 -24
- 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 +18 -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 +1 -1
- 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 +132 -40
- package/src/popup/clarify.ts +154 -42
- 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 +476 -65
- package/src/widget/controller.ts +222 -40
- 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/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,14 +155,14 @@ 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()
|
|
@@ -227,13 +227,13 @@ describe('ClarifyCard', () => {
|
|
|
227
227
|
done: false,
|
|
228
228
|
} satisfies ClarifyResponse)
|
|
229
229
|
.mockResolvedValueOnce({
|
|
230
|
-
status: '
|
|
230
|
+
status: 'completed',
|
|
231
231
|
messages: [
|
|
232
232
|
{ role: 'assistant', content: 'Tell me more' },
|
|
233
233
|
{ role: 'user', content: 'Button does nothing' },
|
|
234
234
|
{ role: 'assistant', content: 'Got it' },
|
|
235
235
|
],
|
|
236
|
-
done:
|
|
236
|
+
done: true,
|
|
237
237
|
} satisfies ClarifyResponse)
|
|
238
238
|
|
|
239
239
|
const { shadow, card } = setupCard({ startClarification })
|
|
@@ -252,7 +252,41 @@ describe('ClarifyCard', () => {
|
|
|
252
252
|
await vi.waitFor(() => {
|
|
253
253
|
expect(startClarification).toHaveBeenCalledTimes(2)
|
|
254
254
|
})
|
|
255
|
-
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)
|
|
256
290
|
|
|
257
291
|
card.destroy()
|
|
258
292
|
shadow.destroy()
|
|
@@ -285,7 +319,7 @@ describe('ClarifyCard', () => {
|
|
|
285
319
|
await vi.waitFor(() => {
|
|
286
320
|
expect(startClarification).toHaveBeenCalledTimes(2)
|
|
287
321
|
})
|
|
288
|
-
expect(startClarification).toHaveBeenCalledWith('
|
|
322
|
+
expect(startClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', 'Help me')
|
|
289
323
|
|
|
290
324
|
card.destroy()
|
|
291
325
|
shadow.destroy()
|
|
@@ -339,7 +373,7 @@ describe('ClarifyCard', () => {
|
|
|
339
373
|
await vi.advanceTimersByTimeAsync(0)
|
|
340
374
|
|
|
341
375
|
await vi.advanceTimersByTimeAsync(2000)
|
|
342
|
-
expect(getClarification).toHaveBeenCalledWith('
|
|
376
|
+
expect(getClarification).toHaveBeenCalledWith('submission_123', 'submission-secret')
|
|
343
377
|
|
|
344
378
|
await vi.advanceTimersByTimeAsync(2000)
|
|
345
379
|
expect(getClarification).toHaveBeenCalledTimes(2)
|
|
@@ -348,22 +382,26 @@ describe('ClarifyCard', () => {
|
|
|
348
382
|
shadow.destroy()
|
|
349
383
|
})
|
|
350
384
|
|
|
351
|
-
it('
|
|
385
|
+
it('shows a summary card and calls onFinalize on Send feedback when done=true from start', async () => {
|
|
352
386
|
const startClarification = vi.fn().mockResolvedValue({
|
|
353
387
|
status: 'complete',
|
|
354
388
|
messages: [{ role: 'assistant', content: 'All clear, thanks!' }],
|
|
355
389
|
done: true,
|
|
356
390
|
} satisfies ClarifyResponse)
|
|
357
391
|
|
|
358
|
-
const { shadow, card,
|
|
392
|
+
const { shadow, card, onFinalize } = setupCard({ startClarification })
|
|
359
393
|
await vi.waitFor(() => {
|
|
360
394
|
expect(startClarification).toHaveBeenCalled()
|
|
361
395
|
})
|
|
362
396
|
await vi.advanceTimersByTimeAsync(0)
|
|
363
397
|
|
|
364
|
-
expect(
|
|
365
|
-
|
|
366
|
-
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()
|
|
367
405
|
|
|
368
406
|
card.destroy()
|
|
369
407
|
shadow.destroy()
|
|
@@ -376,7 +414,7 @@ describe('ClarifyCard', () => {
|
|
|
376
414
|
done: true,
|
|
377
415
|
} satisfies ClarifyResponse)
|
|
378
416
|
|
|
379
|
-
const { shadow, card,
|
|
417
|
+
const { shadow, card, onFinalize } = setupCard({ getClarification })
|
|
380
418
|
await vi.waitFor(() => {
|
|
381
419
|
expect(card).toBeTruthy()
|
|
382
420
|
})
|
|
@@ -389,13 +427,16 @@ describe('ClarifyCard', () => {
|
|
|
389
427
|
await vi.advanceTimersByTimeAsync(0)
|
|
390
428
|
|
|
391
429
|
await vi.advanceTimersByTimeAsync(2000)
|
|
392
|
-
|
|
430
|
+
const sendFeedback = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send-feedback')!
|
|
431
|
+
expect(sendFeedback).toBeTruthy()
|
|
432
|
+
sendFeedback.click()
|
|
433
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
393
434
|
|
|
394
435
|
card.destroy()
|
|
395
436
|
shadow.destroy()
|
|
396
437
|
})
|
|
397
438
|
|
|
398
|
-
it('
|
|
439
|
+
it('replaces the input with a summary send-feedback button after done', async () => {
|
|
399
440
|
const startClarification = vi.fn().mockResolvedValue({
|
|
400
441
|
status: 'complete',
|
|
401
442
|
messages: [{ role: 'assistant', content: 'Resolved' }],
|
|
@@ -408,25 +449,69 @@ describe('ClarifyCard', () => {
|
|
|
408
449
|
})
|
|
409
450
|
await vi.advanceTimersByTimeAsync(0)
|
|
410
451
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
expect(input
|
|
414
|
-
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')
|
|
415
499
|
|
|
416
500
|
card.destroy()
|
|
417
501
|
shadow.destroy()
|
|
418
502
|
})
|
|
419
503
|
|
|
420
|
-
it('
|
|
504
|
+
it('shows summary without finalizing on startClarification error', async () => {
|
|
421
505
|
const startClarification = vi.fn().mockRejectedValue(new Error('Network error'))
|
|
422
506
|
|
|
423
|
-
const { shadow, card,
|
|
507
|
+
const { shadow, card, onFinalize } = setupCard({ startClarification })
|
|
424
508
|
await vi.waitFor(() => {
|
|
425
509
|
expect(startClarification).toHaveBeenCalled()
|
|
426
510
|
})
|
|
427
511
|
await vi.advanceTimersByTimeAsync(0)
|
|
428
512
|
|
|
429
|
-
expect(
|
|
513
|
+
expect(shadow.root.querySelector('.mtb-clarify-summary')).toBeTruthy()
|
|
514
|
+
expect(onFinalize).not.toHaveBeenCalled()
|
|
430
515
|
|
|
431
516
|
card.destroy()
|
|
432
517
|
shadow.destroy()
|
|
@@ -480,7 +565,7 @@ describe('ClarifyCard', () => {
|
|
|
480
565
|
await vi.waitFor(() => {
|
|
481
566
|
expect(startClarification).toHaveBeenCalledTimes(2)
|
|
482
567
|
})
|
|
483
|
-
expect(startClarification).toHaveBeenCalledWith('
|
|
568
|
+
expect(startClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', '导出坏了')
|
|
484
569
|
|
|
485
570
|
card.destroy()
|
|
486
571
|
shadow.destroy()
|
|
@@ -550,7 +635,7 @@ describe('ClarifyCard', () => {
|
|
|
550
635
|
|
|
551
636
|
it('renders streamed deltas live and completes on the stream result', async () => {
|
|
552
637
|
const streamClarification = vi.fn().mockImplementation(
|
|
553
|
-
async (_id: string,
|
|
638
|
+
async (_id: string, _token: string, onDelta: (t: string) => void) => {
|
|
554
639
|
onDelta('What ')
|
|
555
640
|
onDelta('broke?')
|
|
556
641
|
return {
|
|
@@ -562,7 +647,7 @@ describe('ClarifyCard', () => {
|
|
|
562
647
|
|
|
563
648
|
const { shadow, card } = setupCard({ streamClarification } as never)
|
|
564
649
|
await vi.waitFor(() => {
|
|
565
|
-
expect(streamClarification).toHaveBeenCalledWith('
|
|
650
|
+
expect(streamClarification).toHaveBeenCalledWith('submission_123', 'submission-secret', expect.any(Function))
|
|
566
651
|
})
|
|
567
652
|
await vi.advanceTimersByTimeAsync(0)
|
|
568
653
|
|
|
@@ -580,36 +665,43 @@ describe('ClarifyCard', () => {
|
|
|
580
665
|
})
|
|
581
666
|
const getClarification = vi.fn()
|
|
582
667
|
|
|
583
|
-
const { shadow, card,
|
|
668
|
+
const { shadow, card, onFinalize } = setupCard({ streamClarification, getClarification } as never)
|
|
584
669
|
await vi.waitFor(() => {
|
|
585
670
|
expect(streamClarification).toHaveBeenCalled()
|
|
586
671
|
})
|
|
587
672
|
await vi.advanceTimersByTimeAsync(0)
|
|
588
673
|
|
|
589
674
|
await vi.advanceTimersByTimeAsync(2000)
|
|
590
|
-
expect(onDone).toHaveBeenCalledOnce()
|
|
591
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()
|
|
592
680
|
|
|
593
681
|
card.destroy()
|
|
594
682
|
shadow.destroy()
|
|
595
683
|
})
|
|
596
684
|
|
|
597
|
-
it('
|
|
685
|
+
it('shows the summary card when polling exceeds the timeout with no reply', async () => {
|
|
598
686
|
const getClarification = vi.fn().mockResolvedValue({
|
|
599
687
|
status: 'pending',
|
|
600
688
|
messages: [],
|
|
601
689
|
done: false,
|
|
602
690
|
} satisfies ClarifyResponse)
|
|
603
691
|
|
|
604
|
-
const { shadow, card,
|
|
692
|
+
const { shadow, card, onFinalize } = setupCard({ getClarification })
|
|
605
693
|
await vi.waitFor(() => {
|
|
606
694
|
expect(card).toBeTruthy()
|
|
607
695
|
})
|
|
608
696
|
await vi.advanceTimersByTimeAsync(0)
|
|
609
697
|
|
|
610
|
-
// 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.
|
|
611
700
|
await vi.advanceTimersByTimeAsync(48000)
|
|
612
|
-
|
|
701
|
+
const sendFeedback = shadow.root.querySelector<HTMLButtonElement>('.mtb-clarify-send-feedback')!
|
|
702
|
+
expect(sendFeedback).toBeTruthy()
|
|
703
|
+
sendFeedback.click()
|
|
704
|
+
expect(onFinalize).toHaveBeenCalledOnce()
|
|
613
705
|
|
|
614
706
|
card.destroy()
|
|
615
707
|
shadow.destroy()
|