ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / src / vs / sessions / contrib / chat / test / browser / responseSelectionSideChatController.test.ts 729 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
import assert from 'assert' ;
import * as dom from '../../../../../base/browser/dom.js' ;
import { Emitter } from '../../../../../base/common/event.js' ;
import { DisposableStore, toDisposable } from '../../../../../base/common/lifecycle.js' ;
import { constObservable } from '../../../../../base/common/observable.js' ;
import { URI } from '../../../../../base/common/uri.js' ;
import { upcastPartial } from '../../../../../base/test/common/mock.js' ;
import { ensureNoDisposablesAreLeakedInTestSuite }
ILogService NullLogService
TestInstantiationService
INotificationHandle INotificationService Severity
TestNotificationService
IChatWidget
IChatResponseViewModel
ResponseSelectionSideChatController
ISessionsPartService
ISessionsService
IChat ISession SessionStatus
ISessionsManagementService
notifications severity Severity message
override message INotificationHandle
notifications severity Severity Warning message
message
override error Error INotificationHandle
notifications severity Severity Error message error error message error
error
disposables
options
createSideChatInSession ISessionsManagementService
sendRequest ISessionsManagementService
getElementFromNode IChatWidget
store disposables
instantiationService store
doc dom
widgetDomNode doc
doc body widgetDomNode
store widgetDomNode
transcriptDomNode doc
widgetDomNode transcriptDomNode
markdown doc
markdown classList
markdown style position
markdown style top
markdown style left
textNode doc
markdown textNode
transcriptDomNode markdown
response requestId
focusResponseItemCalls
onDidScroll store
autoScrollHolds
widget
domNode widgetDomNode
transcriptDomNode
getElementFromNode options getElementFromNode response
lastFocused focusResponseItemCalls lastFocused
onDidScroll onDidScroll event
autoScrollHolds
autoScrollHolds
containerRect Partial DOMRect top left width height
widgetDomNode containerRect DOMRect
transcriptRect Partial DOMRect top left width height
transcriptDomNode transcriptRect DOMRect
targetWindow dom widgetDomNode
originalGetSelection targetWindow targetWindow
mutableWindow targetWindow targetWindow Selection
selectionText
range doc
range textNode
range textNode textNode data length
outsideNode doc
outside doc
outside outsideNode
widgetDomNode outside
outsideRange doc
outsideRange outsideNode
outsideRange outsideNode outsideNode data length
activeRange range
mutableWindow
selectionText
isCollapsed selectionText length
anchorNode activeRange startContainer
focusNode activeRange endContainer
rangeCount
activeRange
store mutableWindow getSelection originalGetSelection
text selectionTop
activeRange range
selectionText text
selectionTop
markdown style top
doc
text
activeRange outsideRange
selectionText text
doc
rect Partial DOMRect transcriptRect rect
markdown
selectionText
selectionTop
selectionTop
markdown style top
onDidScroll
targetWindow highlights size
sideChat resource
chat resource
session
sessionId
resource
status SessionStatus Completed
isArchived
capabilities supportsMultipleChats supportsSideChat
callOrder
notificationService
instantiationService ISessionsManagementService
resource resource chat resource session chat
createSideChatInSession options createSideChatInSession _session _sourceChat turnId selection
callOrder
sideChat
sendRequest options sendRequest _session sentChat sendOptions
callOrder
instantiationService ISessionsService
_session chatUri
callOrder
instantiationService ISessionsPartService
instantiationService INotificationService notificationService
instantiationService ILogService
controller store instantiationService ResponseSelectionSideChatController widget
controller chat
controller setSelection setSelectionOutsideTranscript setTranscriptRect detachSelectedRow scroll autoScrollHolds callOrder doc chat sideChat focusResponseItemCalls notificationService highlightedRanges controller offsetHeight
controller ResponseSelectionSideChatController HTMLElement
controller _input domNode HTMLElement _input domNode
controller ResponseSelectionSideChatController HTMLTextAreaElement
controller _input inputElement HTMLTextAreaElement _input inputElement
controller ResponseSelectionSideChatController
controller _input isBusy _input isBusy
controller ResponseSelectionSideChatController query
textArea controller
textArea value query
textArea bubbles
controller
target HTMLElement key options shiftKey isComposing KeyboardEvent
event key shiftKey options shiftKey bubbles cancelable
Object event key
options isComposing
Object event
target event
event
controller setSelection
assert controller style display
assert controller style display
controller setSelection
assert controller style display
assert controller style display
controller setSelection callOrder sideChat
textArea controller
textArea value
textArea bubbles
controller
resolve resolve
assert callOrder
controller setSelection callOrder
assert controller style display
textArea controller
textArea
assert controller style display
textArea value
textArea bubbles
controller
assert callOrder
controller setSelection
textArea controller
textArea
assert controller style display
textArea
assert controller style display
controller setSelection focusResponseItemCalls
textArea controller
textArea
textArea
assert controller style display
assert focusResponseItemCalls
setSelection focusResponseItemCalls
assert focusResponseItemCalls
controller setSelection setTranscriptRect
top left width height
style controller style
assert style display
assert style top
controller setSelection scroll autoScrollHolds detachSelectedRow
assert controller style display
assert
assert controller style display
assert
controller setSelection scroll
style controller style
initialTop style top
assert style top initialTop
controller setSelection scroll setTranscriptRect inputHeight
top left width height
top controller style top
assert top
controller setSelection scroll setTranscriptRect inputHeight
top left width height
assert controller style display
style controller style
assert style display
assert style top
assert
controller setSelection scroll setTranscriptRect inputHeight
top left width height
top controller style top
assert top
controller setSelection setTranscriptRect
top left width height
left controller style left
assert left
assert left
setSelection autoScrollHolds
assert
assert
assert
setSelectionOutsideTranscript autoScrollHolds
assert
controller setSelection autoScrollHolds
assert controller style display
assert
controller setSelection autoScrollHolds
controller
assert
controller setSelection autoScrollHolds
assert
controller
assert
controller setSelection highlightedRanges
assert
controller
assert
controller
assert controller style display
assert
controller setSelection highlightedRanges
controller
assert
controller
assert
resolveCreate chat IChat
pending resolve resolveCreate resolve
controller setSelection callOrder sideChat
_session _sourceChat turnId selection
callOrder
pending
controller
assert controller
assert controller disabled
assert controller style display
sideChat
resolve resolve
assert callOrder
assert controller
resolveCreate chat IChat
pending resolve resolveCreate resolve
createCalls
controller setSelection sideChat
createCalls
pending
controller
assert createCalls
controller
controller
assert createCalls
sideChat
resolve resolve
resolveCreate chat IChat
pending resolve resolveCreate resolve
controller setSelection sideChat
pending
controller
assert controller style display
controller
assert controller style display
assert controller style display
sideChat
resolve resolve
controller setSelection notificationService
controller
assert controller
resolve resolve
assert controller
assert controller disabled
assert controller value
assert controller style display
assert notificationService notifications length
assert notificationService notifications severity Severity Error
controller setSelection chat
textArea controller
textArea value
textArea bubbles
controller resource chat resource
assert controller style display
assert textArea value
resolveCreate chat IChat
pending resolve resolveCreate resolve
controller setSelection callOrder chat sideChat
_session _sourceChat turnId selection
callOrder
pending
controller
assert controller
controller resource chat resource
assert controller
assert controller disabled
assert controller style display
sideChat
resolve resolve
assert callOrder
assert controller
resolveCreate chat IChat
pending resolve resolveCreate resolve
controller setSelection
pending
controller
assert controller
controller resource
assert controller style display
assert controller
resource
resolve resolve
assert controller style display
resolveCreate chat IChat
pending resolve resolveCreate resolve
controller setSelection focusResponseItemCalls
pending
controller
controller resource
focusCallsAtDismiss focusResponseItemCalls length
resource
resolve resolve
assert controller style display
assert controller value
assert focusResponseItemCalls length focusCallsAtDismiss
rejectCreate err Error
pending _resolve reject rejectCreate reject
controller setSelection notificationService focusResponseItemCalls
pending
controller
controller resource
focusCallsAtDismiss focusResponseItemCalls length
resolve resolve
assert controller style display
assert controller value
assert focusResponseItemCalls length focusCallsAtDismiss
assert notificationService notifications length
controller setSelection callOrder
textArea controller
textArea value
textArea bubbles
event textArea
assert event defaultPrevented
assert callOrder
controller setSelection callOrder
textArea controller
textArea value
textArea bubbles
event textArea shiftKey
assert event defaultPrevented
assert callOrder
assert controller style display
controller setSelection callOrder
textArea controller
textArea value
textArea bubbles
event textArea isComposing
assert event defaultPrevented
assert callOrder
assert controller style display
from
'../../../../../base/test/common/utils.js'
;
import
{
,
}
from
'../../../../../platform/log/common/log.js'
;
import
{
}
from
'../../../../../platform/instantiation/test/common/instantiationServiceMock.js'
;
import
{
,
,
}
from
'../../../../../platform/notification/common/notification.js'
;
import
{
}
from
'../../../../../platform/notification/test/common/testNotificationService.js'
;
import
{
}
from
'../../../../../workbench/contrib/chat/browser/chat.js'
;
import
{
}
from
'../../../../../workbench/contrib/chat/common/model/chatViewModel.js'
;
import
{
}
from
'../../browser/responseSelectionSideChatController.js'
;
import
{
}
from
'../../../../services/sessions/browser/sessionsPartService.js'
;
import
{
}
from
'../../../../services/sessions/browser/sessionsService.js'
;
import
{
,
,
}
from
'../../../../services/sessions/common/session.js'
;
import
{
}
from
'../../../../services/sessions/common/sessionsManagement.js'
;
class
RecordingNotificationService
extends
TestNotificationService
{
readonly
:
{
:
;
:
string
}
[
]
=
[
]
;
warn
(
:
string
)
:
{
this
.
.
push
(
{
:
.
,
}
)
;
return
super
.
warn
(
)
;
}
error
(
:
string
|
)
:
{
this
.
.
push
(
{
:
.
,
:
instanceof
Error
?
.
:
}
)
;
return
super
.
error
(
)
;
}
}
suite
(
'ResponseSelectionSideChatController'
,
(
)
=>
{
const
=
ensureNoDisposablesAreLeakedInTestSuite
(
)
;
function
setup
(
?
:
{
?
:
[
'createSideChatInSession'
]
;
?
:
[
'sendRequest'
]
;
?
:
[
'getElementFromNode'
]
;
}
)
{
const
=
.
add
(
new
DisposableStore
(
)
)
;
const
=
.
add
(
new
TestInstantiationService
(
)
)
;
const
=
.
getActiveDocument
(
)
;
const
=
.
createElement
(
'div'
)
;
.
.
appendChild
(
)
;
.
add
(
toDisposable
(
(
)
=>
.
remove
(
)
)
)
;
const
=
.
createElement
(
'div'
)
;
.
appendChild
(
)
;
const
=
.
createElement
(
'div'
)
;
.
.
add
(
'chat-markdown-part'
)
;
.
.
=
'absolute'
;
.
.
=
'0px'
;
.
.
=
'0px'
;
const
=
.
createTextNode
(
'hello world'
)
;
.
appendChild
(
)
;
.
appendChild
(
)
;
const
=
upcastPartial < IChatResponseViewModel>
(
{
:
'turn-1'
,
setVote
:
(
)
=>
undefined
}
)
;
const
:
boolean
[
]
=
[
]
;
const
=
.
add
(
new
Emitter< void >
(
)
)
;
let
=
0
;
const
=
upcastPartial < IChatWidget>
(
{
:
,
,
:
?.
??
(
(
)
=>
)
,
focusResponseItem
:
(
?
:
boolean
)
=>
{
.
push
(
!
!
)
;
}
,
:
.
,
holdAutoScroll
:
(
)
=>
{
++
;
return
toDisposable
(
(
)
=>
{
--
;
}
)
;
}
,
}
)
;
const
:
<
>
=
{
:
0
,
:
0
,
:
600
,
:
600
}
;
.
getBoundingClientRect
=
(
)
=>
as
;
let
:
<
>
=
{
:
0
,
:
0
,
:
600
,
:
600
}
;
.
getBoundingClientRect
=
(
)
=>
as
;
const
=
.
getWindow
(
)
;
const
=
.
getSelection
.
bind
(
)
;
const
=
as
typeof
&
{
getSelection
:
(
)
=>
|
null
}
;
let
=
''
;
const
=
.
createRange
(
)
;
.
setStart
(
,
0
)
;
.
setEnd
(
,
.
.
)
;
const
=
.
createTextNode
(
'unrelated text'
)
;
const
=
.
createElement
(
'div'
)
;
.
appendChild
(
)
;
.
appendChild
(
)
;
const
=
.
createRange
(
)
;
.
setStart
(
,
0
)
;
.
setEnd
(
,
.
.
)
;
let
=
;
.
getSelection
=
(
)
=>
upcastPartial < Selection>
(
{
toString
:
(
)
=>
,
:
.
===
0
,
:
.
,
:
.
,
:
1
,
getRangeAt
:
(
)
=>
,
}
)
;
.
add
(
toDisposable
(
(
)
=>
{
.
=
;
}
)
)
;
const
setSelection
=
(
:
string
,
?
:
number
)
=>
{
=
;
=
;
if
(
!==
undefined
)
{
.
.
=
` ${ selectionTop} px `
;
}
.
dispatchEvent
(
new
Event
(
'selectionchange'
)
)
;
}
;
const
setSelectionOutsideTranscript
=
(
:
string
)
=>
{
=
;
=
;
.
dispatchEvent
(
new
Event
(
'selectionchange'
)
)
;
}
;
const
setTranscriptRect
=
(
:
<
>
)
=>
{
=
;
}
;
const
detachSelectedRow
=
(
)
=>
{
.
remove
(
)
;
=
''
;
}
;
const
scroll
=
(
?
:
number
)
=>
{
if
(
!==
undefined
)
{
.
.
=
` ${ selectionTop} px `
;
}
.
fire
(
)
;
}
;
const
highlightedRanges
=
(
)
=>
.
CSS
.
?.
get
(
'chat-response-selection'
)
?.
??
0
;
const
=
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/side'
)
}
)
;
const
=
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/source'
)
}
)
;
const
=
upcastPartial < ISession>
(
{
:
'session'
,
:
URI
.
parse
(
'test:///session'
)
,
:
constObservable
(
.
)
,
:
constObservable
(
false
)
,
:
constObservable
(
{
:
true
,
:
true
}
)
,
}
)
;
const
:
string
[
]
=
[
]
;
const
=
new
RecordingNotificationService
(
)
;
.
stub
(
,
upcastPartial < ISessionsManagementService>
(
{
getSessionForChatResource
:
=>
.
toString
(
)
===
.
.
toString
(
)
?
{
,
}
:
undefined
,
:
?.
??
(
async
(
,
,
,
)
=>
{
.
push
(
` create: ${ turnId} : ${ selection?. text} `
)
;
return
;
}
)
,
:
?.
??
(
async
(
,
,
)
=>
{
.
push
(
` send: ${ sentChat. resource. toString ( ) } : ${ sendOptions. query} `
)
;
}
)
,
}
)
)
;
.
stub
(
,
upcastPartial < ISessionsService>
(
{
openChat
:
async
(
,
)
=>
{
.
push
(
` open: ${ chatUri. toString ( ) } `
)
;
}
,
}
)
)
;
.
stub
(
,
upcastPartial < ISessionsPartService>
(
{
getSessionView
:
(
)
=>
undefined
,
}
)
)
;
.
stub
(
,
)
;
.
stub
(
,
new
NullLogService
(
)
)
;
const
=
.
add
(
.
createInstance
(
,
)
)
;
.
setChat
(
)
;
return
{
,
,
,
,
,
,
autoScrollHolds
:
(
)
=>
,
,
,
,
,
,
,
,
inputHeight
:
(
)
=>
inputDomNode
(
)
.
}
;
}
function
inputDomNode
(
:
)
:
{
return
(
as
unknown
as
{
:
{
:
}
}
)
.
.
;
}
function
inputTextArea
(
:
)
:
{
return
(
as
unknown
as
{
:
{
:
}
}
)
.
.
;
}
function
isInputBusy
(
:
)
:
boolean
{
return
(
as
unknown
as
{
:
{
:
boolean
}
}
)
.
.
;
}
function
submitViaClick
(
:
,
:
string
)
:
void
{
const
=
inputTextArea
(
)
;
.
=
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
inputDomNode
(
)
.
querySelector < HTMLElement>
(
'.action-label'
)
!
.
click
(
)
;
}
function
dispatchKey
(
:
,
:
string
,
?
:
{
?
:
boolean
;
?
:
boolean
}
)
:
{
const
=
new
KeyboardEvent
(
'keydown'
,
{
,
:
?.
,
:
true
,
:
true
}
)
;
.
defineProperty
(
,
'keyCode'
,
{
get
:
(
)
=>
===
'Escape'
?
27
:
13
}
)
;
if
(
?.
)
{
.
defineProperty
(
,
'isComposing'
,
{
get
:
(
)
=>
true
}
)
;
}
.
dispatchEvent
(
)
;
return
;
}
test
(
'shows the ask-question input for a valid markdown selection'
,
(
)
=>
{
const
{
,
}
=
setup
(
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
setSelection
(
'hello world'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
}
)
;
test
(
'hides the input again once the selection is cleared'
,
(
)
=>
{
const
{
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
setSelection
(
''
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
}
)
;
test
(
'creates, opens, and sends a side chat anchored to the response on submit'
,
async
(
)
=>
{
const
{
,
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
=
'what does this mean?'
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
inputDomNode
(
)
.
querySelector < HTMLElement>
(
'.action-label'
)
!
.
click
(
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
deepStrictEqual
(
,
[
'create:turn-1:hello world'
,
` open: ${ sideChat. resource. toString ( ) } `
,
` send: ${ sideChat. resource. toString ( ) } :what does this mean? `
,
]
)
;
}
)
;
test
(
'stays visible and keeps the captured selection when the input steals focus and collapses the native selection'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
const
=
inputTextArea
(
)
;
.
focus
(
)
;
setSelection
(
''
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'input must stay visible while focused'
)
;
.
=
'what does this mean?'
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
inputDomNode
(
)
.
querySelector < HTMLElement>
(
'.action-label'
)
!
.
click
(
)
;
.
ok
(
[
0
]
?.
startsWith
(
'create:turn-1:hello world'
)
)
;
}
)
;
test
(
'dismisses once focus genuinely leaves the input and the selection is invalid'
,
(
)
=>
{
const
{
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
focus
(
)
;
setSelection
(
''
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
.
blur
(
)
;
setSelection
(
''
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'input must dismiss once focus truly leaves it'
)
;
}
)
;
test
(
'restores focus to the response item when Escape dismisses the focused input'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
focus
(
)
;
dispatchKey
(
,
'Escape'
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
.
deepStrictEqual
(
,
[
true
]
)
;
}
)
;
test
(
'does not restore focus on dismiss when the input was not focused'
,
(
)
=>
{
const
{
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
setSelection
(
''
)
;
.
deepStrictEqual
(
,
[
]
)
;
}
)
;
test
(
'clamps the overlay vertically when the transcript is shorter than the overlay'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setTranscriptRect
(
{
:
0
,
:
0
,
:
600
,
:
20
}
)
;
setSelection
(
'hello world'
,
10
)
;
const
=
inputDomNode
(
)
.
;
.
notStrictEqual
(
.
,
'none'
)
;
.
strictEqual
(
parseFloat
(
.
)
,
0
)
;
}
)
;
test
(
'dismisses and releases the hold when virtualization detaches the selected row'
,
(
)
=>
{
const
{
,
,
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
,
100
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
1
)
;
detachSelectedRow
(
)
;
scroll
(
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'must not point at nothing'
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
0
,
'the transcript must not stay pinned forever'
)
;
}
)
;
test
(
'follows the selection as the transcript scrolls instead of staying pinned'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
,
100
)
;
const
=
inputDomNode
(
)
.
;
const
=
parseFloat
(
.
)
;
scroll
(
60
)
;
.
strictEqual
(
parseFloat
(
.
)
,
-
40
)
;
}
)
;
test
(
'confines the overlay to the transcript even when the widget extends past it'
,
(
)
=>
{
const
{
,
,
,
,
}
=
setup
(
)
;
setTranscriptRect
(
{
:
0
,
:
0
,
:
600
,
:
300
}
)
;
setSelection
(
'hello world'
,
50
)
;
scroll
(
5000
)
;
const
=
parseFloat
(
inputDomNode
(
)
.
.
)
;
.
ok
(
<=
300
-
inputHeight
(
)
,
` top ${ top} must stay within the 300px transcript, not the 600px widget `
)
;
}
)
;
test
(
'parks at the top of the transcript when the selection scrolls above it'
,
(
)
=>
{
const
{
,
,
,
,
}
=
setup
(
)
;
setTranscriptRect
(
{
:
100
,
:
0
,
:
600
,
:
300
}
)
;
setSelection
(
'hello world'
,
200
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
scroll
(
-
800
)
;
const
=
inputDomNode
(
)
.
;
.
notStrictEqual
(
.
,
'none'
,
'the overlay stays visible at the edge'
)
;
.
strictEqual
(
parseFloat
(
.
)
,
100
,
'parks at the transcript top, not the widget top'
)
;
.
ok
(
inputHeight
(
)
>
0
)
;
}
)
;
test
(
'parks at the bottom of the transcript instead of drifting over the chat input'
,
(
)
=>
{
const
{
,
,
,
,
}
=
setup
(
)
;
setTranscriptRect
(
{
:
0
,
:
0
,
:
600
,
:
300
}
)
;
setSelection
(
'hello world'
,
50
)
;
scroll
(
900
)
;
const
=
parseFloat
(
inputDomNode
(
)
.
.
)
;
.
strictEqual
(
,
300
-
inputHeight
(
)
,
'parks flush with the transcript bottom'
)
;
}
)
;
test
(
'clamps horizontally to the transcript bounds'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setTranscriptRect
(
{
:
0
,
:
40
,
:
120
,
:
300
}
)
;
setSelection
(
'hello world'
)
;
const
=
parseFloat
(
inputDomNode
(
)
.
.
)
;
.
ok
(
>=
40
,
` left ${ left} must not start before the transcript's left edge `
)
;
.
ok
(
<=
160
,
` left ${ left} must not start past the transcript's right edge `
)
;
}
)
;
test
(
'holds transcript auto-scroll while a selection is active and releases it on dismiss'
,
(
)
=>
{
const
{
,
}
=
setup
(
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
0
)
;
setSelection
(
'hello world'
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
1
,
'a selection must pin the transcript'
)
;
setSelection
(
''
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
0
,
'clearing the selection releases the transcript'
)
;
}
)
;
test
(
'does not hold auto-scroll for a selection outside the transcript'
,
(
)
=>
{
const
{
,
}
=
setup
(
{
getElementFromNode
:
(
)
=>
undefined
}
)
;
setSelectionOutsideTranscript
(
'unrelated text'
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
0
)
;
}
)
;
test
(
'holds auto-scroll for a transcript selection that does not resolve to a single response'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
{
getElementFromNode
:
(
)
=>
undefined
}
)
;
setSelection
(
'hello world'
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'no affordance for an unresolvable selection'
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
1
)
;
}
)
;
test
(
'keeps holding auto-scroll while the input has focus and the native selection is collapsed'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
inputTextArea
(
)
.
focus
(
)
;
setSelection
(
''
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
1
)
;
}
)
;
test
(
'releases the auto-scroll hold when disposed'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
1
)
;
.
dispose
(
)
;
.
strictEqual
(
autoScrollHolds
(
)
,
0
)
;
}
)
;
test
(
'paints the captured selection with a custom highlight once the native selection is gone'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
.
strictEqual
(
highlightedRanges
(
)
,
0
,
'the browser still paints the live native selection'
)
;
inputTextArea
(
)
.
focus
(
)
;
setSelection
(
''
)
;
.
strictEqual
(
highlightedRanges
(
)
,
1
)
;
inputTextArea
(
)
.
blur
(
)
;
setSelection
(
''
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
.
strictEqual
(
highlightedRanges
(
)
,
0
,
'dismissing must clear the highlight'
)
;
}
)
;
test
(
'clears the highlight when the controller is disposed'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
inputTextArea
(
)
.
focus
(
)
;
setSelection
(
''
)
;
.
strictEqual
(
highlightedRanges
(
)
,
1
)
;
.
dispose
(
)
;
.
strictEqual
(
highlightedRanges
(
)
,
0
)
;
}
)
;
test
(
'stays visible with a busy state while the request is pending, then clears once it settles'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
=>
{
=
;
}
)
;
const
{
,
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
,
,
,
)
=>
{
.
push
(
` create: ${ turnId} : ${ selection?. text} `
)
;
return
;
}
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
strictEqual
(
isInputBusy
(
)
,
true
,
'input must report busy while the request is pending'
)
;
.
strictEqual
(
inputTextArea
(
)
.
,
true
,
'the textarea must be disabled while pending'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'the overlay must stay visible while pending, not be dismissed eagerly'
)
;
resolveCreate
(
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
deepStrictEqual
(
,
[
'create:turn-1:hello world'
,
` open: ${ sideChat. resource. toString ( ) } `
,
` send: ${ sideChat. resource. toString ( ) } :what does this mean? `
,
]
)
;
.
strictEqual
(
isInputBusy
(
)
,
false
,
'busy clears once the orchestration settles'
)
;
}
)
;
test
(
'prevents duplicate submission (click and Enter) while a request is pending'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
=>
{
=
;
}
)
;
let
=
0
;
const
{
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
)
=>
{
++
;
return
;
}
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
strictEqual
(
,
1
)
;
inputDomNode
(
)
.
querySelector < HTMLElement>
(
'.action-label'
)
!
.
click
(
)
;
dispatchKey
(
inputTextArea
(
)
,
'Enter'
)
;
.
strictEqual
(
,
1
,
'only the first submission must create a side chat'
)
;
resolveCreate
(
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
}
)
;
test
(
'ignores Escape and selection-change dismissal while a request is pending'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
=>
{
=
;
}
)
;
const
{
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
)
=>
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
dispatchKey
(
inputTextArea
(
)
,
'Escape'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'Escape must not dismiss a pending request'
)
;
setSelection
(
''
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'an invalidated selection must not dismiss a pending request'
)
;
resolveCreate
(
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
}
)
;
test
(
'restores the entered question and re-enables the input when the side chat fails to create'
,
async
(
)
=>
{
const
{
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
)
=>
{
throw
new
Error
(
'boom'
)
;
}
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
strictEqual
(
isInputBusy
(
)
,
true
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
strictEqual
(
isInputBusy
(
)
,
false
,
'busy must clear on failure'
)
;
.
strictEqual
(
inputTextArea
(
)
.
,
false
,
'the textarea must be re-enabled on failure'
)
;
.
strictEqual
(
inputTextArea
(
)
.
,
'what does this mean?'
,
'the entered question must be restored on failure'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'the overlay must stay visible so the user can retry'
)
;
.
strictEqual
(
.
.
,
1
)
;
.
strictEqual
(
.
[
0
]
.
,
.
)
;
}
)
;
test
(
'same-chat setChat (e.g. a status/interactivity update) preserves a visible draft'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
=
'a draft in progress'
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
.
setChat
(
upcastPartial < IChat>
(
{
:
.
}
)
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'input must stay visible on a same-resource setChat'
)
;
.
strictEqual
(
.
,
'a draft in progress'
,
'the typed draft must survive a same-resource setChat'
)
;
}
)
;
test
(
'same-chat setChat does not clear a pending busy submission'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
=>
{
=
;
}
)
;
const
{
,
,
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
,
,
,
)
=>
{
.
push
(
` create: ${ turnId} : ${ selection?. text} `
)
;
return
;
}
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
strictEqual
(
isInputBusy
(
)
,
true
)
;
.
setChat
(
upcastPartial < IChat>
(
{
:
.
}
)
)
;
.
strictEqual
(
isInputBusy
(
)
,
true
,
'busy must survive a same-resource setChat'
)
;
.
strictEqual
(
inputTextArea
(
)
.
,
true
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
resolveCreate
(
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
deepStrictEqual
(
,
[
'create:turn-1:hello world'
,
` open: ${ sideChat. resource. toString ( ) } `
,
` send: ${ sideChat. resource. toString ( ) } :what does this mean? `
,
]
)
;
.
strictEqual
(
isInputBusy
(
)
,
false
)
;
}
)
;
test
(
'different-resource setChat force-dismisses even while busy'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
=>
{
=
;
}
)
;
const
{
,
}
=
setup
(
{
createSideChatInSession
:
async
(
)
=>
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
strictEqual
(
isInputBusy
(
)
,
true
)
;
.
setChat
(
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/other'
)
}
)
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'a genuine chat change must dismiss even a busy overlay'
)
;
.
strictEqual
(
isInputBusy
(
)
,
false
)
;
setSelection
(
''
)
;
resolveCreate
(
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/side'
)
}
)
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
)
;
}
)
;
test
(
'a success that settles after a different-resource setChat does not reopen, refocus, or mutate the overlay'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
=>
{
=
;
}
)
;
const
{
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
)
=>
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
setChat
(
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/other'
)
}
)
)
;
setSelection
(
''
)
;
const
=
.
;
resolveCreate
(
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/side'
)
}
)
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'a stale success must not reopen the overlay'
)
;
.
strictEqual
(
inputTextArea
(
)
.
,
''
,
'a stale success must not mutate the (already cleared) input value'
)
;
.
deepStrictEqual
(
.
,
,
'a stale success must not refocus the transcript'
)
;
}
)
;
test
(
'a failure that settles after a different-resource setChat does not reopen, refocus, mutate, or notify'
,
async
(
)
=>
{
let
!
:
(
:
)
=>
void
;
const
=
new
Promise < IChat>
(
(
,
)
=>
{
=
;
}
)
;
const
{
,
,
,
}
=
setup
(
{
createSideChatInSession
:
async
(
)
=>
,
}
)
;
setSelection
(
'hello world'
)
;
submitViaClick
(
,
'what does this mean?'
)
;
.
setChat
(
upcastPartial < IChat>
(
{
:
URI
.
parse
(
'test:///chat/other'
)
}
)
)
;
setSelection
(
''
)
;
const
=
.
;
rejectCreate
(
new
Error
(
'boom'
)
)
;
await
new
Promise
(
=>
setTimeout
(
,
0
)
)
;
.
strictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'a stale failure must not reopen the overlay'
)
;
.
strictEqual
(
inputTextArea
(
)
.
,
''
,
'a stale failure must not restore the failed question into the (already cleared) input'
)
;
.
deepStrictEqual
(
.
,
,
'a stale failure must not refocus the input'
)
;
.
strictEqual
(
.
.
,
0
,
'a stale failure must not surface a retry notification for an abandoned overlay'
)
;
}
)
;
test
(
'plain Enter submits and prevents the default newline'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
=
'what does this mean?'
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
const
=
dispatchKey
(
,
'Enter'
)
;
.
strictEqual
(
.
,
true
,
'plain Enter must prevent the default newline'
)
;
.
ok
(
[
0
]
?.
startsWith
(
'create:turn-1:hello world'
)
,
'plain Enter must submit'
)
;
}
)
;
test
(
'Shift+Enter inserts a newline instead of submitting'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
=
'what does this mean?'
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
const
=
dispatchKey
(
,
'Enter'
,
{
:
true
}
)
;
.
strictEqual
(
.
,
false
,
'Shift+Enter must let the textarea insert a newline'
)
;
.
deepStrictEqual
(
,
[
]
,
'Shift+Enter must not submit'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'Shift+Enter must not dismiss the overlay'
)
;
}
)
;
test
(
'Enter during IME composition does not submit'
,
(
)
=>
{
const
{
,
,
}
=
setup
(
)
;
setSelection
(
'hello world'
)
;
const
=
inputTextArea
(
)
;
.
=
'what does this mean?'
;
.
dispatchEvent
(
new
Event
(
'input'
,
{
:
true
}
)
)
;
const
=
dispatchKey
(
,
'Enter'
,
{
:
true
}
)
;
.
strictEqual
(
.
,
false
,
'Enter during IME composition must not be prevented'
)
;
.
deepStrictEqual
(
,
[
]
,
'Enter during IME composition must not submit'
)
;
.
notStrictEqual
(
inputDomNode
(
)
.
.
,
'none'
,
'Enter during IME composition must not dismiss the overlay'
)
;
}
)
;
}
)
;