Skip to content

Commit 2f6ce1f

Browse files
committed
fix: stream completion
1 parent 1cd2157 commit 2f6ce1f

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/lib/stream.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export type BrowserState = Readonly<{
88
sessionId: string;
99

1010
liveUrl: string | null;
11-
1211
steps: ReadonlyArray<TaskStepView>;
12+
doneOutput: string | null;
1313
}> | null;
1414

1515
type BrowserAction = {
@@ -24,12 +24,14 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
2424

2525
if (state == null) {
2626
const liveUrl = action.status.sessionLiveUrl ?? null;
27+
const doneOutput = action.status.doneOutput ?? null;
2728

2829
const state: BrowserState = {
2930
taskId: action.status.id,
3031
sessionId: action.status.sessionId,
3132
liveUrl: liveUrl,
3233
steps: action.status.steps,
34+
doneOutput: doneOutput,
3335
};
3436

3537
return [state, action.status];
@@ -38,6 +40,7 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
3840
// UPDATE
3941

4042
const liveUrl = action.status.sessionLiveUrl ?? null;
43+
const doneOutput = action.status.doneOutput ?? null;
4144
const steps: TaskStepView[] = [...state.steps];
4245

4346
if (action.status.steps != null) {
@@ -48,11 +51,20 @@ export function reducer(state: BrowserState, action: BrowserAction): [BrowserSta
4851
}
4952
}
5053

51-
const newState: BrowserState = { ...state, liveUrl, steps };
54+
const newState: BrowserState = {
55+
...state,
56+
liveUrl,
57+
steps,
58+
doneOutput,
59+
};
5260

5361
// CHANGES
5462

55-
if ((state.liveUrl == null && liveUrl != null) || state.steps.length !== steps.length) {
63+
if (
64+
(state.liveUrl == null && liveUrl != null) ||
65+
state.steps.length !== steps.length ||
66+
state.doneOutput != doneOutput
67+
) {
5668
const update: ReducerEvent = {
5769
...action.status,
5870
steps: steps,

0 commit comments

Comments
 (0)