Skip to content

Commit 3023103

Browse files
Merge pull request #7722 from sagemathinc/api-exec-await
api/exec await + latex
2 parents dd24268 + cd51323 commit 3023103

File tree

26 files changed

+705
-373
lines changed

26 files changed

+705
-373
lines changed

src/packages/backend/execute-code.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,12 @@ function doSpawn(
477477
finish();
478478
});
479479

480+
// Doc: https://nodejs.org/api/child_process.html#event-exit – read it!
481+
// TODO: This is not 100% correct, because in case the process is killed (signal TERM),
482+
// the $code is "null" and a second argument gives the signal (as a string). Hence, after a kill,
483+
// this code below changes the exit code to 0. This could be a special case, though.
484+
// It cannot be null, though, because the "finish" callback assumes that stdout, err and exit are set.
485+
// The local $killed var is only true, if the process has been killed by the timeout – not by another kill.
480486
child.on("exit", (code) => {
481487
exit_code = code ?? 0;
482488
finish();

src/packages/frontend/editors/stopwatch/time.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { Icon } from "@cocalc/frontend/components/icon";
21
import { CSSProperties } from "react";
32

3+
import { Icon } from "@cocalc/frontend/components/icon";
4+
45
function zpad(n: number): string {
56
let s = `${n}`;
67
if (s.length === 1) {

src/packages/frontend/frame-editors/_style.sass

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
> button.btn
1111
margin-bottom: 20px
1212

13-
1413
// latex editor, build panel
1514
.cocalc-latex-build-content
1615

1716
.ant-tabs-tab
18-
margin: 0 !important
19-
padding: 0 !important
17+
margin: 0 !important
18+
padding: 0 !important
2019
> div
2120
width: 100%
2221
padding: 5px 10px
@@ -26,6 +25,9 @@
2625
.ant-tabs-content-holder
2726
display: flex
2827

28+
.ant-tabs-content
29+
overflow-y: auto
30+
2931
.ant-tabs-tabpane
30-
display : flex
31-
flex-direction : column
32+
display: flex
33+
flex-direction: column

src/packages/frontend/frame-editors/code-editor/actions.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ import {
5959
ext2syntax,
6060
syntax2tool,
6161
} from "@cocalc/util/code-formatter";
62+
import {
63+
TIMEOUT_CALLING_PROJECT,
64+
TIMEOUT_CALLING_PROJECT_MSG,
65+
} from "@cocalc/util/consts/project";
6266
import {
6367
aux_file,
6468
filename_extension,
@@ -67,6 +71,7 @@ import {
6771
uuid,
6872
} from "@cocalc/util/misc";
6973
import { reuseInFlight } from "@cocalc/util/reuse-in-flight";
74+
import { set_account_table } from "../../account/util";
7075
import { default_opts } from "../codemirror/cm-options";
7176
import { print_code } from "../frame-tree/print-code";
7277
import * as tree_ops from "../frame-tree/tree-ops";
@@ -99,7 +104,6 @@ import * as cm_doc_cache from "./doc";
99104
import { SHELLS } from "./editor";
100105
import { test_line } from "./simulate_typing";
101106
import { misspelled_words } from "./spell-check";
102-
import { set_account_table } from "../../account/util";
103107

104108
interface gutterMarkerParams {
105109
line: number;
@@ -1853,13 +1857,12 @@ export class Actions<
18531857
public set_error(
18541858
error?: object | string,
18551859
style?: ErrorStyles,
1856-
id?: string,
1860+
_id?: string, // id - not currently used, but would be for frame-specific error.
18571861
): void {
1858-
id = id; // id - not currently used, but would be for frame-specific error.
18591862
if (error === undefined) {
18601863
this.setState({ error });
18611864
} else {
1862-
if (typeof error == "object") {
1865+
if (typeof error === "object") {
18631866
const e = (error as any).message;
18641867
if (e === undefined) {
18651868
let e = JSON.stringify(error);
@@ -1870,6 +1873,9 @@ export class Actions<
18701873
if (typeof e != "string") throw Error("bug"); // make typescript happy
18711874
error = e;
18721875
}
1876+
if (error === TIMEOUT_CALLING_PROJECT) {
1877+
error = TIMEOUT_CALLING_PROJECT_MSG;
1878+
}
18731879
this.setState({ error });
18741880
}
18751881

src/packages/frontend/frame-editors/frame-tree/commands/generic-commands.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,14 @@ addCommands({
469469
title: "Force rebuild entire project.",
470470
icon: "play",
471471
},
472-
472+
stop_build: {
473+
group: "build",
474+
// TODO does not react to changes
475+
// disabled: ({ props }) => props.editor_actions.is_running !== true,
476+
label: "Stop",
477+
title: "Stop all running jobs.",
478+
icon: "stop",
479+
},
473480
clean: {
474481
group: "build",
475482
label: "Delete Aux Files",

src/packages/frontend/frame-editors/frame-tree/title-bar.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ interface FrameActions extends Actions {
7676
clean?: (id: string) => void;
7777
word_count?: (time: number, force: boolean) => void;
7878
close_and_halt?: (id: string) => void;
79+
stop_build?: (id: string) => void;
7980
}
8081

8182
interface EditorActions extends Actions {

0 commit comments

Comments
 (0)