diff --git a/admin_server.py b/admin_server.py index 2ead5fe..a40774d 100644 --- a/admin_server.py +++ b/admin_server.py @@ -2841,11 +2841,14 @@ async def admin_msfs_sync_task(task_id: str): @app.post("/api/admin/msfs-sync/launch-app") async def admin_msfs_sync_launch(): - """Launch the MS Field Service app on the connected phone.""" + """Launch MS Field Service app, navigate to Check for Updates via UI nav. + + Taps globe icon in top-right, waits 15s, taps Check for Updates button, + then waits for the phone's offline DB to stabilize. + """ try: - async with httpx.AsyncClient(timeout=15) as client: - resp = await client.post(f"{EXTRACTION_SYNC_BASE}/api/sync/start") - # The start endpoint already launches the app + async with httpx.AsyncClient(timeout=30) as client: + resp = await client.post(f"{EXTRACTION_SYNC_BASE}/api/sync/check-for-updates") return resp.json() except httpx.RequestError as e: raise HTTPException(502, f"Extraction server unreachable: {e}") diff --git a/assets.db.stale b/assets.db.stale new file mode 100644 index 0000000..e43e681 Binary files /dev/null and b/assets.db.stale differ diff --git a/assets.db.stale2 b/assets.db.stale2 new file mode 100644 index 0000000..c799593 Binary files /dev/null and b/assets.db.stale2 differ diff --git a/static/index.html b/static/index.html index cf55bab..9d21bc1 100644 --- a/static/index.html +++ b/static/index.html @@ -5679,8 +5679,61 @@ async function pollMsfsTask() { async function launchMsfsApp() { try { - await api('/api/admin/msfs-sync/launch-app', { method: 'POST' }); - showToast('📱 Sync started — Field Service app launched on phone, wait for it to complete'); + const result = await api('/api/admin/msfs-sync/launch-app', { method: 'POST' }); + showToast('📱 App launched — navigating to Check for Updates...'); + + const taskId = result.task_id; + if (!taskId) { + showToast('⚠️ No task_id returned — check extraction server', true); + return; + } + + syncTaskId = taskId; + document.getElementById('msfsLaunchBtn').disabled = true; + document.getElementById('msfsProgressCard').style.display = ''; + document.getElementById('msfsProgressResult').style.display = 'none'; + document.getElementById('msfsProgressMsg').textContent = 'Launching app...'; + document.getElementById('msfsCancelBtn').style.display = ''; + + syncPollInterval = setInterval(async () => { + try { + const task = await api(`/api/admin/msfs-sync/task/${taskId}`); + document.getElementById('msfsProgressMsg').textContent = task.message || 'Working...'; + + if (task.status === 'completed') { + clearInterval(syncPollInterval); + syncPollInterval = null; + document.getElementById('msfsLaunchBtn').disabled = false; + document.getElementById('msfsCancelBtn').style.display = 'none'; + document.getElementById('msfsProgressResult').style.display = ''; + document.getElementById('msfsProgressResult').innerHTML = + `