From 55c66877730dd21eb46ac43c7fb42528e599c154 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 18 Jul 2026 07:56:39 +0000 Subject: [PATCH 1/2] Initial plan From e8c48c87d5dd053ffa798f631e39d141f2d57b14 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 18 Jul 2026 07:59:02 +0000 Subject: [PATCH 2/2] fix: keep update entity in progress until refresh completes --- tests/unit_tests/test_update.py | 15 +++++++++++++++ update.py | 8 +++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/unit_tests/test_update.py b/tests/unit_tests/test_update.py index b104c6d..387fc02 100644 --- a/tests/unit_tests/test_update.py +++ b/tests/unit_tests/test_update.py @@ -168,6 +168,21 @@ async def test_install_requests_coordinator_refresh(self): coordinator.async_request_refresh.assert_awaited_once() + async def test_install_keeps_in_progress_true_while_refresh_runs(self): + """in_progress should remain True until coordinator refresh completes.""" + entity, coordinator = _make_update_entity() + coordinator.create = AsyncMock() + + async def _refresh_side_effect(): + self.assertTrue(entity._attr_in_progress) + + coordinator.async_request_refresh = AsyncMock(side_effect=_refresh_side_effect) + + await entity.async_install(None, False) + + coordinator.async_request_refresh.assert_awaited_once() + self.assertFalse(entity._attr_in_progress) + async def test_install_raises_when_coordinator_create_fails(self): """async_install should propagate ServiceValidationError from coordinator.create().""" entity, coordinator = _make_update_entity() diff --git a/update.py b/update.py index 32cd94f..29ad5e6 100644 --- a/update.py +++ b/update.py @@ -133,7 +133,9 @@ async def async_install( try: await self.coordinator.create() finally: - self._attr_in_progress = False - self.async_write_ha_state() # Refresh coordinator so the new container state is reflected quickly. - await self.coordinator.async_request_refresh() + try: + await self.coordinator.async_request_refresh() + finally: + self._attr_in_progress = False + self.async_write_ha_state()