@@ -43,6 +43,20 @@ function isLogElementInViewport(el: HTMLElement): boolean {
4343  return  rect .top  >=  0  &&  rect .bottom  <=  window .innerHeight ; //  only check height but not width 
4444} 
4545
46+ type  LocaleStorageOptions  =  {
47+   autoScroll:  boolean ; 
48+   expandRunning:  boolean ; 
49+ }; 
50+ 
51+ function  getLocaleStorageOptions():  LocaleStorageOptions  {
52+   try  { 
53+     const   optsJson =  localStorage .getItem (' actions-view-options'  ); 
54+     if  (optsJson ) return  JSON .parse (optsJson ); 
55+   } catch  {} 
56+   //  if no options in localStorage, or failed to parse, return default options 
57+   return  {autoScroll: true , expandRunning: false }; 
58+ } 
59+ 
4660const   sfc =  {
4761  name: ' RepoActionView'  , 
4862  components: { 
@@ -56,7 +70,17 @@ const sfc = {
5670    locale: Object , 
5771  }, 
5872
73+   watch: { 
74+     optionAlwaysAutoScroll() { 
75+       this .saveLocaleStorageOptions (); 
76+     }, 
77+     optionAlwaysExpandRunning() { 
78+       this .saveLocaleStorageOptions (); 
79+     }, 
80+   }, 
81+ 
5982  data() { 
83+     const   {autoScroll, expandRunning} =  getLocaleStorageOptions (); 
6084    return  { 
6185      //  internal state 
6286      loadingAbortController: null , 
@@ -70,6 +94,8 @@ const sfc = {
7094        ' log-time-stamp'  : false , 
7195        ' log-time-seconds'  : false , 
7296      }, 
97+       optionAlwaysAutoScroll: autoScroll  ??  false , 
98+       optionAlwaysExpandRunning: expandRunning  ??  false , 
7399
74100      //  provided by backend 
75101      run: { 
@@ -147,6 +173,11 @@ const sfc = {
147173  }, 
148174
149175  methods: { 
176+     saveLocaleStorageOptions() { 
177+       const   opts:  LocaleStorageOptions  =  {autoScroll: this .optionAlwaysAutoScroll , expandRunning: this .optionAlwaysExpandRunning }; 
178+       localStorage .setItem (' actions-view-options'  , JSON .stringify (opts )); 
179+     }, 
180+ 
150181    //  get the job step logs container ('.job-step-logs') 
151182    getJobStepLogsContainer(stepIndex :  number ):  HTMLElement  { 
152183      return  this .$refs .logs [stepIndex ]; 
@@ -228,8 +259,10 @@ const sfc = {
228259    }, 
229260
230261    shouldAutoScroll(stepIndex :  number ):  boolean  { 
262+       if  (! this .optionAlwaysAutoScroll ) return  false ; 
231263      const   el =  this .getJobStepLogsContainer (stepIndex ); 
232-       if  (! el .lastChild ) return  false ; 
264+       //  if the logs container is empty, then auto-scroll if the step is expanded 
265+       if  (! el .lastChild ) return  this .currentJobStepsStates [stepIndex ].expanded ; 
233266      return  isLogElementInViewport (el .lastChild ); 
234267    }, 
235268
@@ -280,6 +313,7 @@ const sfc = {
280313      const   abortController =  new  AbortController (); 
281314      this .loadingAbortController  =  abortController ; 
282315      try  { 
316+         const   isFirstLoad =  ! this .run .status ; 
283317        const   job =  await  this .fetchJobData (abortController ); 
284318        if  (this .loadingAbortController  !==  abortController ) return ; 
285319
@@ -289,9 +323,10 @@ const sfc = {
289323
290324        //  sync the currentJobStepsStates to store the job step states 
291325        for  (let  i =  0 ; i  <  this .currentJob .steps .length ; i ++ ) { 
326+           const   expanded =  isFirstLoad  &&  this .optionAlwaysExpandRunning  &&  this .currentJob .steps [i ].status  ===  ' running'  ; 
292327          if  (! this .currentJobStepsStates [i ]) { 
293328            //  initial states for job steps 
294-             this .currentJobStepsStates [i ] =  {cursor: null , expanded:  false }; 
329+             this .currentJobStepsStates [i ] =  {cursor: null , expanded }; 
295330          } 
296331        } 
297332
@@ -426,6 +461,8 @@ export function initRepositoryActionView() {
426461        skipped: el .getAttribute (' data-locale-status-skipped'  ), 
427462        blocked: el .getAttribute (' data-locale-status-blocked'  ), 
428463      }, 
464+       logsAlwaysAutoScroll: el .getAttribute (' data-locale-logs-always-auto-scroll'  ), 
465+       logsAlwaysExpandRunning: el .getAttribute (' data-locale-logs-always-expand-running'  ), 
429466    }, 
430467  }); 
431468  view .mount (el ); 
@@ -528,6 +565,17 @@ export function initRepositoryActionView() {
528565                  <i  class =" icon"  ><SvgIcon  :name =" isFullScreen ? 'octicon-check' : 'gitea-empty-checkbox'"  /></i >
529566                  {{ locale.showFullScreen }}
530567                </a >
568+ 
569+                 <div  class =" divider"  />
570+                 <a  class =" item"   @click =" optionAlwaysAutoScroll = !optionAlwaysAutoScroll"  >
571+                   <i  class =" icon"  ><SvgIcon  :name =" optionAlwaysAutoScroll ? 'octicon-check' : 'gitea-empty-checkbox'"  /></i >
572+                   {{ locale.logsAlwaysAutoScroll }}
573+                 </a >
574+                 <a  class =" item"   @click =" optionAlwaysExpandRunning = !optionAlwaysExpandRunning"  >
575+                   <i  class =" icon"  ><SvgIcon  :name =" optionAlwaysExpandRunning ? 'octicon-check' : 'gitea-empty-checkbox'"  /></i >
576+                   {{ locale.logsAlwaysExpandRunning }}
577+                 </a >
578+ 
531579                <div  class =" divider"  />
532580                <a  :class =" ['item', !currentJob.steps.length ? 'disabled' : '']"   :href =" run.link+'/jobs/'+jobIndex+'/logs'"   target =" _blank"  >
533581                  <i  class =" icon"  ><SvgIcon  name =" octicon-download"  /></i >
0 commit comments