diff --git a/openpilot/starpilot/galaxy/server.py b/openpilot/starpilot/galaxy/server.py index a23bd5c597..e3abe64cfd 100644 --- a/openpilot/starpilot/galaxy/server.py +++ b/openpilot/starpilot/galaxy/server.py @@ -1065,13 +1065,19 @@ def make_server(*, port=8082, host='127.0.0.1', monitor=None, owner=None, crashe else: if self.require_session(): self.json(200, result) - elif path == '/api/software/status': + elif path in ('/api/software/status', '/api/update/fast/status'): identity = self.settings_session() if identity is None: if not self.require_session(): return try: - result = software_snapshot(include_history=parse_qs(urlsplit(self.path).query).get('history') != ['0']) + if path == '/api/update/fast/status': + installed = (software_source if software_source is not None else SoftwareStatus()).snapshot()['installed'] + result = {'branch': installed['branch'], 'localCommit': installed['commit'], + 'running': False, 'stage': 'updated', 'updateAvailable': False, + 'message': 'Galaxy has been upgraded. Reload this page, or close and reopen the Galaxy app, to load the new interface.'} + else: + result = software_snapshot(include_history=parse_qs(urlsplit(self.path).query).get('history') != ['0']) except (SoftwareUnavailable, SoftwareOperationError, OSError): self.json(503, {'error': 'Software status is unavailable'}) else: diff --git a/openpilot/starpilot/galaxy/tests/test_software_status.py b/openpilot/starpilot/galaxy/tests/test_software_status.py index b5d1f7c9b7..d98e9c17ca 100644 --- a/openpilot/starpilot/galaxy/tests/test_software_status.py +++ b/openpilot/starpilot/galaxy/tests/test_software_status.py @@ -228,6 +228,27 @@ class SoftwareHTTPTest(unittest.TestCase): self.assertEqual(self.request("/api/software/status", method="POST", body="{}", headers={"Cookie": cookie, "Origin": origin, "Content-Type": "application/json"})[0], 405) + def test_old_galaxy_gets_refresh_guidance_after_upgrade(self): + self.owner.configure("password123", lambda: True) + with mock.patch.object(self.source, "snapshot", wraps=self.source.snapshot) as read: + self.assertEqual(self.request("/api/update/fast/status")[0], 401) + read.assert_not_called() + self.params.put('GitBranch', 'StarPilot', block=True) + self.params.put('GitCommit', 'a' * 40, block=True) + cookie = self.login() + status, body, headers = self.request('/api/update/fast/status', headers={'Cookie': cookie}) + self.assertEqual(status, 200) + self.assertEqual(headers['Cache-Control'], 'no-store') + result = json.loads(body) + self.assertEqual((result['branch'], result['localCommit']), ('StarPilot', 'a' * 40)) + self.assertFalse(result['running']) + self.assertFalse(result['updateAvailable']) + self.assertEqual(result['stage'], 'updated') + self.assertIn('Reload this page', result['message']) + self.assertEqual(self.request('/api/update/fast/status', method='POST', body='{}', + headers={'Cookie': cookie, 'Origin': f'http://127.0.0.1:{self.server.server_port}', + 'Content-Type': 'application/json'})[0], 405) + def test_logout_and_credential_change_during_read_suppress_result(self): self.owner.configure("password123", lambda: True) cookie = self.login()