From 2c24a6f15bad3c5db39f13e958d0dbb814141abb Mon Sep 17 00:00:00 2001 From: Robert Horvath Date: Fri, 16 Oct 2026 13:14:17 +0900 Subject: [PATCH] Follow the new simulation when opening its run log --- app/static/app.js | 4 +++- tests/app_editor_clarity.cjs | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/app/static/app.js b/app/static/app.js index 96bc98bf..3b69bd97 100644 --- a/app/static/app.js +++ b/app/static/app.js @@ -7361,10 +7361,12 @@ async function startSelectedWorkflow() { headers: { "Content-Type": "application/json" }, body: JSON.stringify({simulation_id: state.selectedSimulationId, vehicle_key: activeVehicleKey()}), }); + state.status = await api("/api/status"); state.selectedJobId = job.id; + document.getElementById("job-log").textContent = ""; + document.getElementById("job-log").scrollTop = 0; document.getElementById("run-log-menu").open = true; state.simModalOpen = true; - state.status = await api("/api/status"); renderStandard(); } catch (error) { document.getElementById("run-log-menu").open = true; diff --git a/tests/app_editor_clarity.cjs b/tests/app_editor_clarity.cjs index 22a37175..23c93fbb 100644 --- a/tests/app_editor_clarity.cjs +++ b/tests/app_editor_clarity.cjs @@ -973,6 +973,22 @@ for (const [value, scale, display, edited, expected] of [ api=async()=>({log:'updated output'}); elements['job-log'].scrollHeight=1000; elements['job-log'].scrollTop=100; await loadJobLog();assert.equal(elements['job-log'].scrollTop,100,'reading position survives refresh'); + selectedWorkflow=()=>({id:'lap-qss',actions:[]}); + canRunStandardWorkflow=()=>true; + saveSimulationEdits=async()=>{}; + activeVehicleKey=()=>'vehicle'; + state.dirtySimConfig=false; + state.status={jobs:[{id:'old',label:'Old run',status:'succeeded',argv:[]}]}; + state.selectedJobId='old'; + const newJob={id:'new-run',label:'QSS lap',status:'running',argv:[]}; + api=async path=>path==='/api/status' ? {jobs:[newJob,...state.status.jobs]} : newJob; + Object.defineProperty(elements['run-log-menu'],'open',{ + get:()=>true,set:()=>renderRunLog(),configurable:true, + }); + renderStandard=()=>renderRunLog(); + await startSelectedWorkflow(); + assert.equal(state.selectedJobId,'new-run','opening the log follows the new job'); + assert.equal(elements['job-log'].scrollTop,0,'new run resets the old reading position'); const saves=[]; state.simulationWorkspace={simulations:[{id:'sim',name:'Original'}]}; simulationRequest=async(action,values)=>saves.push({action,...values});