@@ -42,29 +42,34 @@ export async function pollLCAStatus(
42
42
const startTime = Date . now ( ) ;
43
43
44
44
// Send initial notification that polling is starting
45
- await context . sendNotification ( {
46
- method : "notifications/progress" ,
47
- params : {
48
- progressToken : context . _meta ?. progressToken ?? `lca-${ testCaseId } ` ,
49
- message : `Generating Low Code Automation...` ,
50
- progress : 0 ,
51
- total : 100 ,
52
- } ,
53
- } ) ;
45
+ const notificationInterval = Math . min ( initialWaitMs , pollIntervalMs ) ;
46
+ const notificationStartTime = Date . now ( ) ;
47
+
48
+ const notificationIntervalId = setInterval ( async ( ) => {
49
+ const elapsedTime = Date . now ( ) - notificationStartTime ;
50
+ const progressPercentage = Math . min (
51
+ 90 ,
52
+ Math . floor ( ( elapsedTime / maxWaitTimeMs ) * 90 )
53
+ ) ;
54
+
55
+ await context . sendNotification ( {
56
+ method : "notifications/progress" ,
57
+ params : {
58
+ progressToken : context . _meta ?. progressToken ?? `lca-${ testCaseId } ` ,
59
+ message : `Generating Low Code Automation Test..` ,
60
+ progress : progressPercentage ,
61
+ total : 100 ,
62
+ } ,
63
+ } ) ;
64
+
65
+ if ( elapsedTime >= initialWaitMs ) {
66
+ clearInterval ( notificationIntervalId ) ;
67
+ }
68
+ } , notificationInterval ) ;
54
69
55
70
// Wait for initial period before starting to poll
56
71
await new Promise ( ( resolve ) => setTimeout ( resolve , initialWaitMs ) ) ;
57
-
58
- // Send notification that active polling has started
59
- await context . sendNotification ( {
60
- method : "notifications/progress" ,
61
- params : {
62
- progressToken : context . _meta ?. progressToken ?? `lca-${ testCaseId } ` ,
63
- message : `Half of the Low Code Automation is done, Wait for some more time...` ,
64
- progress : 10 ,
65
- total : 100 ,
66
- } ,
67
- } ) ;
72
+ clearInterval ( notificationIntervalId ) ;
68
73
69
74
return new Promise ( ( resolve ) => {
70
75
// Set up timeout to handle max wait time
@@ -133,12 +138,16 @@ export async function pollLCAStatus(
133
138
Math . floor ( ( elapsedTime / maxWaitTimeMs ) * 90 ) + 10 ,
134
139
) ;
135
140
141
+ // Cycle through different numbers of dots (2, 3, 4, 5, then back to 2)
142
+ const dotCount = ( ( Math . floor ( elapsedTime / pollIntervalMs ) % 4 ) + 2 ) ;
143
+ const dots = '.' . repeat ( dotCount ) ;
144
+
136
145
await context . sendNotification ( {
137
146
method : "notifications/progress" ,
138
147
params : {
139
148
progressToken :
140
149
context . _meta ?. progressToken ?? `lca-${ testCaseId } ` ,
141
- message : `Low Code Automation build is still in progress... ` ,
150
+ message : `Generating Low Code Automation Test ${ dots } ` ,
142
151
progress : progressPercentage ,
143
152
total : 100 ,
144
153
} ,
0 commit comments