1313# GNU Affero General Public License for more details.
1414
1515# Modified by OpenC3, Inc.
16- # All changes Copyright 2024 , OpenC3, Inc.
16+ # All changes Copyright 2025 , OpenC3, Inc.
1717# All Rights Reserved
1818#
1919# This file may also be used under the terms of a commercial license
185185 v-model =" stateTimer"
186186 label =" Script State"
187187 data-test =" state"
188- class =" shrink ml-2 script-state"
188+ : class =" [' shrink', ' ml-2', ' script-state', stateColorClass] "
189189 style =" max-width : 120px "
190190 density =" compact"
191191 variant =" outlined"
@@ -842,8 +842,30 @@ export default {
842842 if (this .state === ' waiting' || this .state === ' paused' ) {
843843 return ` ${ this .state } ${ this .waitingTime } s`
844844 }
845+ // Map completed_errors to completed for display
846+ // it will be colored via the stateColorClass
847+ if (this .state === ' completed_errors' ) {
848+ return ' completed'
849+ }
845850 return this .state
846851 },
852+ stateColorClass : function () {
853+ // All possible states: spawning, init, running, paused, waiting, breakpoint,
854+ // error, crashed, stopped, completed, completed_errors, killed
855+ if (
856+ this .state === ' error' ||
857+ this .state === ' crashed' ||
858+ this .state === ' killed'
859+ ) {
860+ return ' script-state-red'
861+ } else if (this .state === ' completed_errors' ) {
862+ return ' script-state-orange'
863+ } else if (this .state === ' completed' ) {
864+ return ' script-state-green'
865+ } else {
866+ return ' '
867+ }
868+ },
847869 // This is the list of files shown in the select dropdown
848870 fileList : function () {
849871 // this.files is the list of all files seen while running
@@ -1468,6 +1490,7 @@ export default {
14681490 .then ((response ) => {
14691491 if (response .data ) {
14701492 let state = response .data .state
1493+ // Check for all the completed states, see is_complete in script_status_model
14711494 if (
14721495 state !== ' completed' &&
14731496 state !== ' completed_errors' &&
@@ -1744,7 +1767,6 @@ export default {
17441767 })
17451768 },
17461769 async scriptComplete () {
1747- this .fatal = false
17481770 this .scriptId = null // No current scriptId
17491771 sessionStorage .removeItem (' script_runner__script_id' )
17501772 this .currentFilename = null // No current file running
@@ -1755,8 +1777,6 @@ export default {
17551777 this .subscription = null
17561778 }
17571779 this .receivedEvents .length = 0 // Clear any unprocessed events
1758- // Ensure stopped, if the script has an error we don't get the server stopped message
1759- this .state = ' stopped'
17601780
17611781 await this .reloadFile () // Make sure the right file is shown
17621782 // We may have changed the contents (if there were sub-scripts)
@@ -1847,15 +1867,7 @@ export default {
18471867 }
18481868 },
18491869 stop () {
1850- // We previously encountered a fatal error so remove the marker
1851- // and cleanup by calling scriptComplete() because the script
1852- // is already stopped in the backend
1853- if (this .fatal ) {
1854- this .removeAllMarkers ()
1855- this .scriptComplete ()
1856- } else {
1857- Api .post (` /script-api/running-script/${ this .scriptId } /stop` )
1858- }
1870+ Api .post (` /script-api/running-script/${ this .scriptId } /stop` )
18591871 },
18601872 step () {
18611873 Api .post (` /script-api/running-script/${ this .scriptId } /step` )
@@ -1914,6 +1926,8 @@ export default {
19141926 this .state = data .state
19151927 const markers = this .editor .session .getMarkers ()
19161928 switch (this .state ) {
1929+ // Handle all the script states, see script_status_model for details
1930+ // spawning, init, running, paused, waiting, breakpoint, error, crashed, stopped, completed, completed_errors, killed
19171931 case ' running' :
19181932 this .handleWaiting ()
19191933 this .startOrGoDisabled = false
@@ -1930,23 +1944,17 @@ export default {
19301944 this .editor .gotoLine (data .line_no )
19311945 this .files [data .filename ].lineNo = data .line_no
19321946 break
1933- case ' crashed' :
1934- this .fatal = true
1935- // Deliberate fall through (no break)
19361947 case ' error' :
19371948 this .pauseOrRetryButton = RETRY
19381949 // Deliberate fall through (no break)
1939- case ' breakpoint ' :
1940- case ' waiting ' :
1950+ case ' spawning ' : // wait for script to be spawned
1951+ case ' init ' : // wait for script to initialize
19411952 case ' paused' :
1953+ case ' waiting' :
1954+ case ' breakpoint' :
19421955 this .handleWaiting ()
1943- if (this .state == ' fatal' ) {
1944- this .startOrGoDisabled = true
1945- this .pauseOrRetryDisabled = true
1946- } else {
1947- this .startOrGoDisabled = false
1948- this .pauseOrRetryDisabled = false
1949- }
1956+ this .startOrGoDisabled = false
1957+ this .pauseOrRetryDisabled = false
19501958 this .stopDisabled = false
19511959 let existing = Object .keys (markers).filter (
19521960 (key ) => markers[key].clazz === ` ${ this .state } Marker` ,
@@ -1966,6 +1974,15 @@ export default {
19661974 }
19671975 }
19681976 break
1977+ case ' completed' :
1978+ case ' completed_errors' :
1979+ case ' stopped' :
1980+ case ' crashed' :
1981+ case ' killed' :
1982+ this .removeAllMarkers ()
1983+ this .scriptComplete ()
1984+ break
1985+
19691986 default :
19701987 break
19711988 }
@@ -2016,11 +2033,8 @@ export default {
20162033 this .results .show = true
20172034 break
20182035 case ' complete' :
2019- // Don't complete on fatal because we just sit there on the fatal line
2020- if (! this .fatal ) {
2021- this .removeAllMarkers ()
2022- this .scriptComplete ()
2023- }
2036+ this .removeAllMarkers ()
2037+ this .scriptComplete ()
20242038 break
20252039 case ' step' :
20262040 this .showDebug = true
@@ -2323,7 +2337,7 @@ export default {
23232337 {
23242338 okText: ' Continue' ,
23252339 cancelText: ' Cancel' ,
2326- }
2340+ },
23272341 )
23282342 }
23292343 return true
@@ -2954,6 +2968,20 @@ hr {
29542968.script - state : deep (input ) {
29552969 text- transform: capitalize;
29562970}
2971+
2972+ /* Taken from the various status-symbol-color-fill classes
2973+ on https://www.astrouxds.com/design-tokens/component/ */
2974+ .script - state- red : deep (input ) {
2975+ color: #ff3838 ! important;
2976+ }
2977+
2978+ .script - state- orange : deep (input ) {
2979+ color: #ffb302 ! important;
2980+ }
2981+
2982+ .script - state- green : deep (input ) {
2983+ color: #56f000 ! important;
2984+ }
29572985< / style>
29582986< style>
29592987.splitpanes -- horizontal > .splitpanes__splitter {
@@ -2998,12 +3026,6 @@ hr {
29983026 z- index: 20 ;
29993027}
30003028
3001- .fatalMarker {
3002- position: absolute;
3003- background: rgba (255 , 0 , 0 , 0.5 );
3004- z- index: 20 ;
3005- }
3006-
30073029.saving {
30083030 z- index: 20 ;
30093031 opacity: 0.35 ;
0 commit comments