From 9b1abf37d0bfb39d0e4706aeb01f443092bde128 Mon Sep 17 00:00:00 2001 From: timmy Date: Thu, 27 Aug 2026 20:48:02 +0000 Subject: [PATCH] fix: keep reschedule dialog closed after successful move --- frontend/today-week-reschedule.js | 18 ++++++++++++------ tests/test_today_week_reschedule.py | 20 +++++++++++++++++--- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/frontend/today-week-reschedule.js b/frontend/today-week-reschedule.js index 750a522..bfee898 100644 --- a/frontend/today-week-reschedule.js +++ b/frontend/today-week-reschedule.js @@ -338,8 +338,18 @@ function mountTodayWeekReschedule({ confirm.addEventListener('click',async()=>{ if(!selectedDate)return; confirm.disabled=true;status.textContent='Moving Today into Week Ahead…';dialog.close(); + let result; + try{ + result=await controller.confirm(selectedDate,Number(estimate.value),{allowOverload}); + }catch(error){ + if(!dialog.open)dialog.showModal(); + const overload=error.message.includes('Confirm overload');allowOverload=overload; + status.textContent=error.message; + confirm.textContent=overload?'Confirm overload & continue':'Move to Week Ahead & continue'; + confirm.disabled=false; + return; + } try{ - const result=await controller.confirm(selectedDate,Number(estimate.value),{allowOverload}); if(result.sync_pending){ announce('Moved locally. Saved on this device · sync pending.');warm(); }else{ @@ -347,11 +357,7 @@ function mountTodayWeekReschedule({ } await continueToday(); }catch(error){ - if(!dialog.open)dialog.showModal(); - const overload=error.message.includes('Confirm overload');allowOverload=overload; - status.textContent=error.message; - confirm.textContent=overload?'Confirm overload & continue':'Move to Week Ahead & continue'; - confirm.disabled=false; + announce(`${error.message||'Refresh unavailable.'} Move completed; refresh to continue.`); } }); return {controller,close,flushPending,resumePending}; diff --git a/tests/test_today_week_reschedule.py b/tests/test_today_week_reschedule.py index 3dd76c9..bc44bc0 100644 --- a/tests/test_today_week_reschedule.py +++ b/tests/test_today_week_reschedule.py @@ -326,8 +326,9 @@ console.log(JSON.stringify({message,adopted,pending:controller.pending(),remaini assert result["remaining"] == 1 -def run_mounted_confirmation(*, fail_move: bool = False) -> dict: +def run_mounted_confirmation(*, fail_move: bool = False, fail_refresh: bool = False) -> dict: failure = "true" if fail_move else "false" + refresh_failure = "true" if fail_refresh else "false" scenario = """ const mount=require('./frontend/today-week-reschedule.js').mount; class Element { @@ -361,7 +362,9 @@ const week={load:async()=>weekState,review:()=>({days:[{ }]}),adopt(){}}; const api=async(url)=>url==='api/v1/today' ? today : move; mount({qs:selector=>selectors[selector],document,window,week,api,getToday:()=>today, - adoptToday(){},currentTarget:()=>({identity:'active'}),closeActions(){},refresh:async()=>{},warm(){}, + adoptToday(){},currentTarget:()=>({identity:'active'}),closeActions(){},refresh:async()=>{ + if(__FAIL_REFRESH__)throw new Error('Refresh unavailable.'); + },warm(){}, continueToday:async()=>{},announce(){},schedule:callback=>callback()}); await selectors['[data-work-session-reschedule-week]'].emit('click'); await selectors['#today-week-reschedule-days'].children[0].emit('click'); @@ -376,7 +379,11 @@ if(__FAIL_MOVE__){ await confirming; console.log(JSON.stringify({openWhileSaving,openAfterSettled:selectors['#today-week-reschedule'].open})); """ - return run_controller(scenario.replace("__FAIL_MOVE__", failure)) + return run_controller( + scenario.replace("__FAIL_MOVE__", failure).replace( + "__FAIL_REFRESH__", refresh_failure + ) + ) def test_reschedule_dialog_closes_as_soon_as_a_valid_move_is_confirmed(): @@ -393,6 +400,13 @@ def test_reschedule_dialog_reopens_with_retry_state_when_confirm_fails(): } +def test_reschedule_dialog_stays_closed_when_refresh_fails_after_confirm_succeeds(): + assert run_mounted_confirmation(fail_refresh=True) == { + "openWhileSaving": False, + "openAfterSettled": False, + } + + def test_mobile_active_today_reschedule_dialog_is_touch_safe_and_wired_into_release_bundle(): index = INDEX.read_text() css = CSS.read_text() -- 2.43.0