@@ -133,60 +133,80 @@ describe('live-user-inputs', () => {
133133 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
134134 setSessionConnected ( 'session-1' , true )
135135
136- const isLive = checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' )
136+ const isLive = checkLiveUserInput ( {
137+ userId : 'user-1' ,
138+ userInputId : 'input-123' ,
139+ clientSessionId : 'session-1' ,
140+ } )
137141 expect ( isLive ) . toBe ( true )
138142 } )
139143
140144 it ( 'should return true for user input with matching prefix' , ( ) => {
141145 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
142146 setSessionConnected ( 'session-1' , true )
143147
144- const isLive = checkLiveUserInput (
145- 'user-1' ,
146- 'input-123-async-agent' ,
147- 'session-1' ,
148- )
148+ const isLive = checkLiveUserInput ( {
149+ userId : 'user-1' ,
150+ userInputId : 'input-123-async-agent' ,
151+ clientSessionId : 'session-1' ,
152+ } )
149153 expect ( isLive ) . toBe ( true )
150154 } )
151155
152156 it ( 'should return false for non-existent user' , ( ) => {
153157 setSessionConnected ( 'session-1' , true )
154158
155- const isLive = checkLiveUserInput (
156- 'user-nonexistent' ,
157- 'input-123' ,
158- 'session-1' ,
159- )
159+ const isLive = checkLiveUserInput ( {
160+ userId : 'user-nonexistent' ,
161+ userInputId : 'input-123' ,
162+ clientSessionId : 'session-1' ,
163+ } )
160164 expect ( isLive ) . toBe ( false )
161165 } )
162166
163167 it ( 'should return false for undefined user' , ( ) => {
164168 setSessionConnected ( 'session-1' , true )
165169
166- const isLive = checkLiveUserInput ( undefined , 'input-123' , 'session-1' )
170+ const isLive = checkLiveUserInput ( {
171+ userId : undefined ,
172+ userInputId : 'input-123' ,
173+ clientSessionId : 'session-1' ,
174+ } )
167175 expect ( isLive ) . toBe ( false )
168176 } )
169177
170178 it ( 'should return false for disconnected session' , ( ) => {
171179 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
172180 setSessionConnected ( 'session-1' , false )
173181
174- const isLive = checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' )
182+ const isLive = checkLiveUserInput ( {
183+ userId : 'user-1' ,
184+ userInputId : 'input-123' ,
185+ clientSessionId : 'session-1' ,
186+ } )
175187 expect ( isLive ) . toBe ( false )
176188 } )
177189
178190 it ( 'should return false for non-matching user input' , ( ) => {
179191 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
180192 setSessionConnected ( 'session-1' , true )
181193
182- const isLive = checkLiveUserInput ( 'user-1' , 'input-456' , 'session-1' )
194+ const isLive = checkLiveUserInput ( {
195+ userId : 'user-1' ,
196+ userInputId : 'input-456' ,
197+ clientSessionId : 'session-1' ,
198+ } )
183199 expect ( isLive ) . toBe ( false )
184200 } )
185201
186202 it ( 'should return true when live user input check is disabled' , ( ) => {
187203 disableLiveUserInputCheck ( )
188204
189- const isLive = checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' )
205+ const isLive = checkLiveUserInput ( {
206+ userId : 'user-1' ,
207+ userInputId : 'input-123' ,
208+ clientSessionId : 'session-1' ,
209+ } )
190210 expect ( isLive ) . toBe ( true )
191211 } )
192212 } )
@@ -196,7 +216,11 @@ describe('live-user-inputs', () => {
196216 setSessionConnected ( 'session-1' , true )
197217 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
198218
199- const isLive = checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' )
219+ const isLive = checkLiveUserInput ( {
220+ userId : 'user-1' ,
221+ userInputId : 'input-123' ,
222+ clientSessionId : 'session-1' ,
223+ } )
200224 expect ( isLive ) . toBe ( true )
201225 } )
202226
@@ -205,11 +229,23 @@ describe('live-user-inputs', () => {
205229 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
206230
207231 // First verify it's connected
208- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( true )
232+ expect (
233+ checkLiveUserInput ( {
234+ userId : 'user-1' ,
235+ userInputId : 'input-123' ,
236+ clientSessionId : 'session-1' ,
237+ } ) ,
238+ ) . toBe ( true )
209239
210240 // Then disconnect
211241 setSessionConnected ( 'session-1' , false )
212- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( false )
242+ expect (
243+ checkLiveUserInput ( {
244+ userId : 'user-1' ,
245+ userInputId : 'input-123' ,
246+ clientSessionId : 'session-1' ,
247+ } ) ,
248+ ) . toBe ( false )
213249 } )
214250
215251 it ( 'should handle multiple sessions independently' , ( ) => {
@@ -218,8 +254,20 @@ describe('live-user-inputs', () => {
218254
219255 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
220256
221- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( true )
222- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-2' ) ) . toBe ( false )
257+ expect (
258+ checkLiveUserInput ( {
259+ userId : 'user-1' ,
260+ userInputId : 'input-123' ,
261+ clientSessionId : 'session-1' ,
262+ } ) ,
263+ ) . toBe ( true )
264+ expect (
265+ checkLiveUserInput ( {
266+ userId : 'user-1' ,
267+ userInputId : 'input-123' ,
268+ clientSessionId : 'session-2' ,
269+ } ) ,
270+ ) . toBe ( false )
223271 } )
224272 } )
225273
@@ -250,14 +298,26 @@ describe('live-user-inputs', () => {
250298 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
251299
252300 // Verify input is live
253- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( true )
301+ expect (
302+ checkLiveUserInput ( {
303+ userId : 'user-1' ,
304+ userInputId : 'input-123' ,
305+ clientSessionId : 'session-1' ,
306+ } ) ,
307+ ) . toBe ( true )
254308 expect ( getLiveUserInputIds ( 'user-1' ) ) . toEqual ( [ 'input-123' ] )
255309
256310 // End user input
257311 cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } )
258312
259313 // Verify input is no longer live
260- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( false )
314+ expect (
315+ checkLiveUserInput ( {
316+ userId : 'user-1' ,
317+ userInputId : 'input-123' ,
318+ clientSessionId : 'session-1' ,
319+ } ) ,
320+ ) . toBe ( false )
261321 expect ( getLiveUserInputIds ( 'user-1' ) ) . toBeUndefined ( )
262322 } )
263323
@@ -267,13 +327,25 @@ describe('live-user-inputs', () => {
267327 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
268328
269329 // Verify input is live
270- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( true )
330+ expect (
331+ checkLiveUserInput ( {
332+ userId : 'user-1' ,
333+ userInputId : 'input-123' ,
334+ clientSessionId : 'session-1' ,
335+ } ) ,
336+ ) . toBe ( true )
271337
272338 // Disconnect session
273339 setSessionConnected ( 'session-1' , false )
274340
275341 // Input should no longer be considered live
276- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( false )
342+ expect (
343+ checkLiveUserInput ( {
344+ userId : 'user-1' ,
345+ userInputId : 'input-123' ,
346+ clientSessionId : 'session-1' ,
347+ } ) ,
348+ ) . toBe ( false )
277349
278350 // But input ID should still exist (for potential reconnection)
279351 expect ( getLiveUserInputIds ( 'user-1' ) ) . toEqual ( [ 'input-123' ] )
@@ -285,15 +357,39 @@ describe('live-user-inputs', () => {
285357 startUserInput ( { userId : 'user-1' , userInputId : 'input-123' } )
286358 startUserInput ( { userId : 'user-1' , userInputId : 'input-456' } )
287359
288- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( true )
289- expect ( checkLiveUserInput ( 'user-1' , 'input-456' , 'session-1' ) ) . toBe ( true )
360+ expect (
361+ checkLiveUserInput ( {
362+ userId : 'user-1' ,
363+ userInputId : 'input-123' ,
364+ clientSessionId : 'session-1' ,
365+ } ) ,
366+ ) . toBe ( true )
367+ expect (
368+ checkLiveUserInput ( {
369+ userId : 'user-1' ,
370+ userInputId : 'input-456' ,
371+ clientSessionId : 'session-1' ,
372+ } ) ,
373+ ) . toBe ( true )
290374 expect ( getLiveUserInputIds ( 'user-1' ) ) . toEqual ( [ 'input-123' , 'input-456' ] )
291375
292376 // Cancel one input
293377 cancelUserInput ( { userId : 'user-1' , userInputId : 'input-123' , logger } )
294378
295- expect ( checkLiveUserInput ( 'user-1' , 'input-123' , 'session-1' ) ) . toBe ( false )
296- expect ( checkLiveUserInput ( 'user-1' , 'input-456' , 'session-1' ) ) . toBe ( true )
379+ expect (
380+ checkLiveUserInput ( {
381+ userId : 'user-1' ,
382+ userInputId : 'input-123' ,
383+ clientSessionId : 'session-1' ,
384+ } ) ,
385+ ) . toBe ( false )
386+ expect (
387+ checkLiveUserInput ( {
388+ userId : 'user-1' ,
389+ userInputId : 'input-456' ,
390+ clientSessionId : 'session-1' ,
391+ } ) ,
392+ ) . toBe ( true )
297393 expect ( getLiveUserInputIds ( 'user-1' ) ) . toEqual ( [ 'input-456' ] )
298394 } )
299395 } )
0 commit comments