diff --git a/app/src/pages/RunSummary/index.tsx b/app/src/pages/RunSummary/index.tsx index 4b8e9dba257..3f8a9099737 100644 --- a/app/src/pages/RunSummary/index.tsx +++ b/app/src/pages/RunSummary/index.tsx @@ -3,7 +3,6 @@ import { useSelector } from 'react-redux' import { useParams, useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import styled, { css } from 'styled-components' -import { useQueryClient } from 'react-query' import { ALIGN_CENTER, @@ -144,6 +143,10 @@ export function RunSummary(): JSX.Element { const [showRunAgainSpinner, setShowRunAgainSpinner] = React.useState( false ) + const [showReturnToSpinner, setShowReturnToSpinner] = React.useState( + false + ) + const robotSerialNumber = localRobot?.health?.robot_serial ?? localRobot?.serverHealth?.serialNumber ?? @@ -195,15 +198,6 @@ export function RunSummary(): JSX.Element { } }, [isRunCurrent, enteredER]) - // TODO(jh, 08-02-24): Revisit useCurrentRunRoute and top level redirects. - const queryClient = useQueryClient() - const returnToDash = (): void => { - // Eagerly clear the query caches to prevent top level redirecting back to this page. - queryClient.setQueryData([host, 'runs', 'details'], () => undefined) - queryClient.setQueryData([host, 'runs', runId, 'details'], () => undefined) - navigate('/') - } - const returnToQuickTransfer = (): void => { if (!isRunCurrent) { deleteRun(runId) @@ -239,6 +233,7 @@ export function RunSummary(): JSX.Element { } const handleReturnToDash = (aPipetteWithTip: PipetteWithTip | null): void => { + setShowReturnToSpinner(true) if (isRunCurrent && aPipetteWithTip != null) { void handleTipsAttachedModal({ setTipStatusResolved: setTipStatusResolvedAndRoute(handleReturnToDash), @@ -251,7 +246,7 @@ export function RunSummary(): JSX.Element { onSkipAndHome: () => { closeCurrentRun({ onSuccess: () => { - returnToDash() + navigate('/') }, }) }, @@ -259,8 +254,11 @@ export function RunSummary(): JSX.Element { } else if (isQuickTransfer) { returnToQuickTransfer() } else { - closeCurrentRun() - returnToDash() + closeCurrentRun({ + onSuccess: () => { + navigate('/') + }, + }) } } @@ -297,7 +295,22 @@ export function RunSummary(): JSX.Element { setShowSplash(false) } - const RUN_AGAIN_SPINNER_TEXT = ( + const buildReturnToCopy = (): string => + isQuickTransfer ? t('return_to_quick_transfer') : t('return_to_dashboard') + + const buildReturnToWithSpinnerText = (): JSX.Element => ( + + {buildReturnToCopy()} + + + ) + const buildRunAgainWithSpinnerText = (): JSX.Element => ( {t('run_again')} @@ -517,6 +533,22 @@ const DURATION_TEXT_STYLE = css` font-weight: ${TYPOGRAPHY.fontWeightRegular}; ` +const RETURN_TO_CLICKED_STYLE = css` + background-color: ${COLORS.blue40}; + &:focus { + background-color: ${COLORS.blue40}; + } + &:hover { + background-color: ${COLORS.blue40}; + } + &:focus-visible { + background-color: ${COLORS.blue40}; + } + &:active { + background-color: ${COLORS.blue40}; + } +` + const RUN_AGAIN_CLICKED_STYLE = css` background-color: ${COLORS.blue60}; &:focus { diff --git a/robot-server/robot_server/runs/run_data_manager.py b/robot-server/robot_server/runs/run_data_manager.py index 7996d5c5237..64cdb5fafb5 100644 --- a/robot-server/robot_server/runs/run_data_manager.py +++ b/robot-server/robot_server/runs/run_data_manager.py @@ -359,6 +359,8 @@ async def update(self, run_id: str, current: Optional[bool]) -> Union[Run, BadRu parameters = self._run_orchestrator_store.get_run_time_parameters() run_resource = self._run_store.get(run_id=run_id) + await self._runs_publisher.publish_runs_advise_refetch_async(run_id) + return _build_run( run_resource=run_resource, state_summary=state_summary, diff --git a/robot-server/robot_server/service/notifications/publishers/runs_publisher.py b/robot-server/robot_server/service/notifications/publishers/runs_publisher.py index 9de9e2c7c51..bac6269f942 100644 --- a/robot-server/robot_server/service/notifications/publishers/runs_publisher.py +++ b/robot-server/robot_server/service/notifications/publishers/runs_publisher.py @@ -75,13 +75,22 @@ async def start_publishing_for_run( ) self._engine_state_slice = _EngineStateSlice() - await self._publish_runs_advise_refetch_async(run_id=run_id) + await self.publish_runs_advise_refetch_async(run_id=run_id) async def clean_up_run(self, run_id: str) -> None: """Publish final refetch and unsubscribe flags for the given run.""" - await self._publish_runs_advise_refetch_async(run_id=run_id) + await self.publish_runs_advise_refetch_async(run_id=run_id) await self._publish_runs_advise_unsubscribe_async(run_id=run_id) + async def publish_runs_advise_refetch_async(self, run_id: str) -> None: + """Publish a refetch flag for relevant runs topics.""" + await self._client.publish_advise_refetch_async(topic=topics.RUNS) + + if self._run_hooks is not None: + await self._client.publish_advise_refetch_async( + topic=topics.TopicName(f"{topics.RUNS}/{run_id}") + ) + async def _publish_command_links(self) -> None: """Publish an update to the run's command links. @@ -92,15 +101,6 @@ async def _publish_command_links(self) -> None: topic=topics.RUNS_COMMANDS_LINKS ) - async def _publish_runs_advise_refetch_async(self, run_id: str) -> None: - """Publish a refetch flag for relevant runs topics.""" - await self._client.publish_advise_refetch_async(topic=topics.RUNS) - - if self._run_hooks is not None: - await self._client.publish_advise_refetch_async( - topic=topics.TopicName(f"{topics.RUNS}/{run_id}") - ) - async def _publish_runs_advise_unsubscribe_async(self, run_id: str) -> None: """Publish an unsubscribe flag for relevant runs topics.""" if self._run_hooks is not None: @@ -161,7 +161,7 @@ async def _handle_engine_status_change(self) -> None: and self._engine_state_slice.state_summary_status != new_state_summary.status ): - await self._publish_runs_advise_refetch_async( + await self.publish_runs_advise_refetch_async( run_id=self._run_hooks.run_id ) self._engine_state_slice.state_summary_status = new_state_summary.status diff --git a/robot-server/tests/runs/test_run_data_manager.py b/robot-server/tests/runs/test_run_data_manager.py index ff1f70da399..d067e51828e 100644 --- a/robot-server/tests/runs/test_run_data_manager.py +++ b/robot-server/tests/runs/test_run_data_manager.py @@ -664,6 +664,10 @@ async def test_update_current( await mock_runs_publisher.publish_pre_serialized_commands_notification(run_id), times=1, ) + decoy.verify( + await mock_runs_publisher.publish_runs_advise_refetch_async(run_id), + times=1, + ) assert result == Run( current=False, id=run_resource.run_id,