@@ -3,7 +3,11 @@ import * as z from 'zod';
33
44import { ThunkAction } from '../../actions' ;
55import { jsonPost , routes } from '../../api' ;
6- import { executeRequestPayloadSelector , executeViaWebsocketSelector } from '../../selectors' ;
6+ import {
7+ currentExecutionSequenceNumberSelector ,
8+ executeRequestPayloadSelector ,
9+ executeViaWebsocketSelector ,
10+ } from '../../selectors' ;
711import { Channel , Edition , Mode } from '../../types' ;
812import {
913 WsPayloadAction ,
@@ -13,6 +17,7 @@ import {
1317
1418const initialState : State = {
1519 requestsInProgress : 0 ,
20+ allowLongRun : false ,
1621} ;
1722
1823interface State {
@@ -21,6 +26,9 @@ interface State {
2126 stdout ?: string ;
2227 stderr ?: string ;
2328 error ?: string ;
29+ residentSetSizeBytes ?: number ;
30+ totalTimeSecs ?: number ;
31+ allowLongRun : boolean ;
2432}
2533
2634type wsExecuteRequestPayload = {
@@ -48,6 +56,14 @@ const { action: wsExecuteStderr, schema: wsExecuteStderrSchema } = createWebsock
4856 z . string ( ) ,
4957) ;
5058
59+ const { action : wsExecuteStatus , schema : wsExecuteStatusSchema } = createWebsocketResponse (
60+ 'output/execute/wsExecuteStatus' ,
61+ z . object ( {
62+ totalTimeSecs : z . number ( ) ,
63+ residentSetSizeBytes : z . number ( ) ,
64+ } ) ,
65+ ) ;
66+
5167const { action : wsExecuteEnd , schema : wsExecuteEndSchema } = createWebsocketResponse (
5268 'output/execute/wsExecuteEnd' ,
5369 z . object ( {
@@ -134,6 +150,9 @@ const slice = createSlice({
134150
135151 prepare : prepareWithCurrentSequenceNumber ,
136152 } ,
153+ allowLongRun : ( state ) => {
154+ state . allowLongRun = true ;
155+ } ,
137156 } ,
138157 extraReducers : ( builder ) => {
139158 builder
@@ -163,6 +182,10 @@ const slice = createSlice({
163182 state . stdout = '' ;
164183 state . stderr = '' ;
165184 delete state . error ;
185+
186+ delete state . residentSetSizeBytes ;
187+ delete state . totalTimeSecs ;
188+ state . allowLongRun = false ;
166189 } ) ,
167190 )
168191 . addCase (
@@ -177,6 +200,12 @@ const slice = createSlice({
177200 state . stderr += payload ;
178201 } ) ,
179202 )
203+ . addCase (
204+ wsExecuteStatus ,
205+ sequenceNumberMatches ( ( state , payload ) => {
206+ Object . assign ( state , payload ) ;
207+ } ) ,
208+ )
180209 . addCase (
181210 wsExecuteEnd ,
182211 sequenceNumberMatches ( ( state , payload ) => {
@@ -191,7 +220,7 @@ const slice = createSlice({
191220 } ,
192221} ) ;
193222
194- export const { wsExecuteRequest } = slice . actions ;
223+ export const { wsExecuteRequest, allowLongRun , wsExecuteKill } = slice . actions ;
195224
196225export const performCommonExecute =
197226 ( crateType : string , tests : boolean ) : ThunkAction =>
@@ -211,7 +240,7 @@ const dispatchWhenSequenceNumber =
211240 < A extends UnknownAction > ( cb : ( sequenceNumber : number ) => A ) : ThunkAction =>
212241 ( dispatch , getState ) => {
213242 const state = getState ( ) ;
214- const { sequenceNumber } = state . output . execute ;
243+ const sequenceNumber = currentExecutionSequenceNumberSelector ( state ) ;
215244 if ( sequenceNumber ) {
216245 const action = cb ( sequenceNumber ) ;
217246 dispatch ( action ) ;
@@ -233,6 +262,14 @@ export const wsExecuteKillCurrent = (): ThunkAction =>
233262 slice . actions . wsExecuteKill ( undefined , sequenceNumber ) ,
234263 ) ;
235264
236- export { wsExecuteBeginSchema , wsExecuteStdoutSchema , wsExecuteStderrSchema , wsExecuteEndSchema } ;
265+ export {
266+ wsExecuteBeginSchema ,
267+ wsExecuteStdoutSchema ,
268+ wsExecuteStderrSchema ,
269+ wsExecuteStatusSchema ,
270+ wsExecuteEndSchema ,
271+ } ;
272+
273+ export { wsExecuteStatus , wsExecuteEnd } ;
237274
238275export default slice . reducer ;
0 commit comments