@@ -55,7 +55,7 @@ import {
55
55
import { reuseInFlight } from "@cocalc/util/reuse-in-flight" ;
56
56
57
57
import { ExecOutput } from "@cocalc/util/db-schema/projects" ;
58
- import { ExecuteCodeOutputAsync } from "@cocalc/util/types/execute-code" ;
58
+ // import { ExecuteCodeOutputAsync } from "@cocalc/util/types/execute-code";
59
59
import { bibtex } from "./bibtex" ;
60
60
import { clean } from "./clean" ;
61
61
import { KNITR_EXTS } from "./constants" ;
@@ -79,7 +79,7 @@ import {
79
79
BuildLogs ,
80
80
BuildSpecName ,
81
81
IBuildSpecs ,
82
- JobInfos ,
82
+ // JobInfos,
83
83
ScrollIntoViewMap ,
84
84
ScrollIntoViewRecord ,
85
85
} from "./types" ;
@@ -99,7 +99,7 @@ interface LatexEditorState extends CodeEditorState {
99
99
includeError ?: string ;
100
100
build_command_hardcoded ?: boolean ; // if true, an % !TeX cocalc = ... directive sets the command via the document itself
101
101
contents ?: TableOfContentsEntryList ; // table of contents data.
102
- job_infos : JobInfos ;
102
+ // job_infos: JobInfos;
103
103
}
104
104
105
105
export class Actions extends BaseActions < LatexEditorState > {
@@ -675,7 +675,7 @@ export class Actions extends BaseActions<LatexEditorState> {
675
675
await this . build ( ) ; // kicks off a save of all relevant files
676
676
}
677
677
678
- // used by generic framework.
678
+ // used by generic framework – this is bound to the instance, otherwise "this" is undefined
679
679
build = async ( id ?: string , force : boolean = false ) : Promise < void > => {
680
680
this . set_error ( "" ) ;
681
681
this . set_status ( "" ) ;
@@ -685,6 +685,7 @@ export class Actions extends BaseActions<LatexEditorState> {
685
685
cm . focus ( ) ;
686
686
}
687
687
}
688
+ // initiating a build. if one is running & forced, we stop the build
688
689
if ( this . is_building ) {
689
690
if ( force ) {
690
691
await this . stop_build ( ) ;
@@ -723,29 +724,30 @@ export class Actions extends BaseActions<LatexEditorState> {
723
724
// likely "No such process", we just ignore it
724
725
// console.info("LatexEditor/actions/kill:", err);
725
726
} finally {
726
- // even if there was an error, we clean it out
727
- this . set_job_infos ( { [ name ] : null } ) ;
727
+ // we keep the data for debugging, but set its state to completed
728
+ job . status = "completed" ;
729
+ this . set_build_logs ( { [ name ] : job } ) ;
728
730
}
729
731
}
730
732
}
731
733
732
734
// This stops all known jobs with a status "running" and resets the state.
733
735
async stop_build ( _id ?: string ) {
734
- const job_infos = this . store . get ( "job_infos" ) ;
736
+ const job_infos = this . store . get ( "build_logs" ) ; // (" job_infos");
735
737
if ( job_infos ) {
736
738
for ( const [ name , job ] of job_infos ) {
737
739
await this . kill ( name , job . toJS ( ) ) ;
738
740
}
739
741
}
740
742
741
743
// this must run in any case, we want a clean empty map!
742
- this . setState ( { job_infos : Map ( ) } ) ;
744
+ // this.setState({ job_infos: Map() });
743
745
this . set_status ( "" ) ;
744
746
this . is_building = false ;
745
747
}
746
748
747
749
private async run_build ( time : number , force : boolean ) : Promise < void > {
748
- // reset state and build info
750
+ // reset state of build_logs, since it is a fresh start
749
751
this . setState ( { build_logs : Map ( ) } ) ;
750
752
751
753
if ( this . bad_filename ) {
@@ -809,7 +811,7 @@ export class Actions extends BaseActions<LatexEditorState> {
809
811
private async run_knitr ( time : number , force : boolean ) : Promise < void > {
810
812
let output : BuildLog ;
811
813
const status = ( s ) => this . set_status ( `Running Knitr... ${ s } ` ) ;
812
- const set_job_info = ( job ) => this . set_job_infos ( { knitr : job } ) ;
814
+ const set_job_info = ( job ) => this . set_build_logs ( { knitr : job } ) ;
813
815
status ( "" ) ;
814
816
815
817
try {
@@ -900,14 +902,14 @@ export class Actions extends BaseActions<LatexEditorState> {
900
902
}
901
903
this . set_error ( "" ) ;
902
904
this . set_build_logs ( { latex : undefined } ) ;
903
- this . set_job_infos ( { latex : undefined } ) ;
905
+ // this.set_job_infos({ latex: undefined });
904
906
if ( typeof s == "string" ) {
905
907
build_command = s ;
906
908
} else {
907
909
build_command = s . toJS ( ) ;
908
910
}
909
911
const status = ( s ) => this . set_status ( `Running Latex... ${ s } ` ) ;
910
- const set_job_info = ( job ) => this . set_job_infos ( { latex : job } ) ;
912
+ const set_job_info = ( job ) => this . set_build_logs ( { latex : job } ) ;
911
913
912
914
status ( "" ) ;
913
915
try {
@@ -936,6 +938,7 @@ export class Actions extends BaseActions<LatexEditorState> {
936
938
this . parsed_output_log = output . parse = new LatexParser ( output . stdout , {
937
939
ignoreDuplicates : true ,
938
940
} ) . parse ( ) ;
941
+ console . log ( "set_build_logs after complete:" , ( output as any ) ?. status ) ;
939
942
this . set_build_logs ( { latex : output } ) ;
940
943
// TODO: knitr complicates multifile a lot, so we do
941
944
// not support it yet.
@@ -1106,7 +1109,7 @@ export class Actions extends BaseActions<LatexEditorState> {
1106
1109
1107
1110
async run_sagetex ( time : number , force : boolean ) : Promise < void > {
1108
1111
const status = ( s ) => this . set_status ( `Running SageTeX... ${ s } ` ) ;
1109
- const set_job_info = ( job ) => this . set_job_infos ( { sagetex : job } ) ;
1112
+ const set_job_info = ( job ) => this . set_build_logs ( { sagetex : job } ) ;
1110
1113
status ( "" ) ;
1111
1114
// First compute hash of sagetex file.
1112
1115
let hash : string = "" ;
@@ -1176,7 +1179,7 @@ export class Actions extends BaseActions<LatexEditorState> {
1176
1179
async run_pythontex ( time : number , force : boolean ) : Promise < void > {
1177
1180
let output : BuildLog ;
1178
1181
const status = ( s ) => this . set_status ( `Running PythonTeX... ${ s } ` ) ;
1179
- const set_job_info = ( job ) => this . set_job_infos ( { pythontex : job } ) ;
1182
+ const set_job_info = ( job ) => this . set_build_logs ( { pythontex : job } ) ;
1180
1183
status ( "" ) ;
1181
1184
1182
1185
try {
@@ -1341,36 +1344,37 @@ export class Actions extends BaseActions<LatexEditorState> {
1341
1344
} ) ;
1342
1345
}
1343
1346
1344
- set_job_infos ( obj : {
1345
- [ K in keyof IBuildSpecs ] ?: ExecuteCodeOutputAsync ;
1346
- } ) : void {
1347
- let job_infos : JobInfos = this . store . get ( "job_infos" ) ?? Map ( ) ;
1347
+ // set_job_infos(obj: {
1348
+ // [K in keyof IBuildSpecs]?: ExecuteCodeOutputAsync;
1349
+ // }): void {
1350
+ // let job_infos: JobInfos = this.store.get("job_infos") ?? Map();
1351
+ // let k: BuildSpecName;
1352
+ // for (k in obj) {
1353
+ // const v: ExecuteCodeOutputAsync | undefined = obj[k];
1354
+ // if (v) {
1355
+ // job_infos = job_infos.set(
1356
+ // k as any,
1357
+ // fromJS(v) as any as TypedMap<ExecOutput>,
1358
+ // );
1359
+ // } else {
1360
+ // job_infos = job_infos.delete(k);
1361
+ // }
1362
+ // }
1363
+ // this.setState({ job_infos });
1364
+ // }
1365
+
1366
+ private set_build_logs ( obj : { [ K in keyof IBuildSpecs ] ?: BuildLog } ) : void {
1367
+ let build_logs : BuildLogs = this . store . get ( "build_logs" ) ?? Map ( ) ;
1348
1368
let k : BuildSpecName ;
1349
1369
for ( k in obj ) {
1350
- const v : ExecuteCodeOutputAsync | undefined = obj [ k ] ;
1370
+ const v : BuildLog | undefined = obj [ k ] ;
1351
1371
if ( v ) {
1352
- job_infos = job_infos . set (
1353
- k as any ,
1354
- fromJS ( v ) as any as TypedMap < ExecOutput > ,
1355
- ) ;
1372
+ build_logs = build_logs . set ( k , fromJS ( v ) as any as TypedMap < BuildLog > ) ;
1356
1373
} else {
1357
- job_infos = job_infos . delete ( k ) ;
1374
+ build_logs = build_logs . delete ( k ) ;
1358
1375
}
1359
1376
}
1360
- this . setState ( { job_infos } ) ;
1361
- }
1362
-
1363
- set_build_logs ( obj : { [ K in keyof IBuildSpecs ] ?: BuildLog } ) : void {
1364
- let build_logs : BuildLogs = this . store . get ( "build_logs" ) ;
1365
- if ( ! build_logs ) {
1366
- // may have already been closed.
1367
- return ;
1368
- }
1369
- let k : BuildSpecName ;
1370
- for ( k in obj ) {
1371
- const v : BuildLog | undefined = obj [ k ] ;
1372
- build_logs = build_logs . set ( k , fromJS ( v ) as any as TypedMap < BuildLog > ) ;
1373
- }
1377
+ console . log ( "set_job_info.latex" , build_logs ?. get ( "latex" ) ?. get ( "status" ) ) ;
1374
1378
this . setState ( { build_logs } ) ;
1375
1379
}
1376
1380
0 commit comments