-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(app): Run timer stays at 00:00:00 if you reconnect in the middle of a delay #7841
Changes from 10 commits
e013dc5
da725bd
a7118b4
fe6561d
2ecf85b
1c9db9a
e50b7f1
95dc94d
43af7b1
3d59ea7
073967c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,18 @@ export type SessionState = { | |
remoteTimeCompensation: number | null, | ||
startTime: ?number, | ||
runTime: number, | ||
/** | ||
* The total number of seconds that this protocol has spent paused, across all steps executed so far. | ||
* todo: hacky in that it is managed locally. Not part of the start-time fix, | ||
* but partially fixes issue of pausing without pausing the timer. Keep? | ||
*/ | ||
pausedDuration: number, | ||
/** | ||
* When paused it is the time at which protocol execution pause was started. When not paused it is null. | ||
* todo: hacky in that it is managed locally. Not part of the start-time fix, | ||
* but partially fixes issue of pausing without pausing the timer. Keep? | ||
*/ | ||
pausedTime: number | null, | ||
apiLevel: [number, number] | null, | ||
capabilities: Array<string>, | ||
} | ||
|
@@ -104,6 +116,8 @@ const INITIAL_STATE: SessionState = { | |
remoteTimeCompensation: null, | ||
startTime: null, | ||
runTime: 0, | ||
pausedTime: null, | ||
pausedDuration: 0, | ||
apiLevel: null, | ||
} | ||
|
||
|
@@ -222,6 +236,7 @@ function handleSessionUpdate( | |
function handleSessionInProgress(state: SessionState): SessionState { | ||
return { | ||
...state, | ||
pausedDuration: 0, | ||
runTime: 0, | ||
startTime: null, | ||
remoteTimeCompensation: null, | ||
|
@@ -262,7 +277,11 @@ function handleInvalidFile( | |
} | ||
|
||
function handleRun(state: SessionState, action: any): SessionState { | ||
return { ...state, runTime: 0, runRequest: { inProgress: true, error: null } } | ||
return { | ||
...state, | ||
runTime: Date.now(), | ||
runRequest: { inProgress: true, error: null }, | ||
} | ||
} | ||
|
||
function handleRunResponse(state: SessionState, action: any): SessionState { | ||
|
@@ -280,7 +299,12 @@ function handleTickRunTime(state: SessionState, action: any): SessionState { | |
} | ||
|
||
function handlePause(state: SessionState, action: any): SessionState { | ||
return { ...state, pauseRequest: { inProgress: true, error: null } } | ||
return { | ||
...state, | ||
pausedTime: Date.now(), | ||
pauseRequest: { inProgress: true, error: null }, | ||
runTime: Date.now(), | ||
} | ||
} | ||
|
||
function handlePauseResponse(state: SessionState, action: any): SessionState { | ||
|
@@ -294,7 +318,14 @@ function handlePauseResponse(state: SessionState, action: any): SessionState { | |
} | ||
|
||
function handleResume(state: SessionState, action: any): SessionState { | ||
return { ...state, resumeRequest: { inProgress: true, error: null } } | ||
const pausedDuration = state.pausedTime ? Date.now() - state.pausedTime : 0 | ||
return { | ||
...state, | ||
pausedDuration: state.pausedDuration + pausedDuration, | ||
pausedTime: null, | ||
resumeRequest: { inProgress: true, error: null }, | ||
runTime: Date.now(), | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So if you:
Then the run timer will jump up by 15 minutes between steps 3 and 4, since the app will no longer have any knowledge of If this is right, I don't think we should attempt to pause the timer during pauses at all. The timer being predictable and consistent is more important than it excluding pause time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, that's exactly right. Okay, then if we do want support for it then we would have to go deeper and make the robot-server or lower track pauses. But sounds like we should the hacky fix out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh dear, I've lost the ability to type proper sentences. Okay, I'll pull it out. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I may have been mistaken about what you were saying. It's a little confusing. The pause I am addressing is not the delay in the protocol. It's 100% the I am not doing anything with delays scripted into protocols. Does that change anything? The motivation for doing it was that we are conditioned to see things pause when we pause them. Maybe I spent too much time in the media industry. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I think you can disregard that—I think I'm just confusing myself. 🤐 |
||
} | ||
|
||
function handleResumeResponse(state: SessionState, action: any): SessionState { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think calls to anything non-idempotent should be strictly avoided in Redux reducers. Which makes it very embarrassing to realize that
handleTickRunTime
below has been sitting there for 4 years with a call toDate.now()
that I definitely wrote...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, don't be too hard on yourself. It's probably one of my edits :)