1
1
import type { TaskView , TaskStepView } from '../resources/tasks' ;
2
- import { ExhaustiveSwitchCheck } from './types' ;
2
+ import { type DeepMutable , ExhaustiveSwitchCheck } from './types' ;
3
3
4
4
export type ReducerEvent = TaskView | null ;
5
5
@@ -39,10 +39,10 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
39
39
40
40
// UPDATE
41
41
42
- const liveUrl = action . status . sessionLiveUrl ?? null ;
43
- const doneOutput = action . status . doneOutput ?? null ;
44
- const steps : TaskStepView [ ] = [ ...state . steps ] ;
42
+ const liveUrl = action . status . sessionLiveUrl ?? state . liveUrl ;
43
+ const doneOutput = action . status . doneOutput ?? state . doneOutput ;
45
44
45
+ const steps : TaskStepView [ ] = [ ...state . steps ] ;
46
46
if ( action . status . steps != null ) {
47
47
const newSteps = action . status . steps . slice ( state . steps . length ) ;
48
48
@@ -51,7 +51,7 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
51
51
}
52
52
}
53
53
54
- const newState : BrowserState = {
54
+ const newState : DeepMutable < BrowserState > = {
55
55
...state ,
56
56
liveUrl,
57
57
steps,
@@ -67,9 +67,9 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
67
67
) {
68
68
const update : ReducerEvent = {
69
69
...action . status ,
70
- steps : steps ,
71
- sessionLiveUrl : liveUrl ,
72
- doneOutput : doneOutput ,
70
+ steps : newState . steps ,
71
+ sessionLiveUrl : newState . liveUrl ,
72
+ doneOutput : newState . doneOutput ,
73
73
} ;
74
74
75
75
return [ newState , update ] ;
0 commit comments