Merge pull request 'feat: Stabilize Today-to-Week dialog closure in packaged browser CI' (#1484) from timmy/1483-stabilize-today-to-week-dialog-closure-in-packag into main
All checks were successful
CI / lint (push) Successful in 3m50s
CI / build-release (push) Successful in 7s
CI / browser-journey (push) Successful in 7m38s
CI / release-candidate (push) Successful in 7s

This commit is contained in:
timmy 2026-08-27 21:15:15 +00:00
commit 5af34508b4
2 changed files with 29 additions and 9 deletions

View File

@ -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};

View File

@ -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()