Skip to content

Commit ac3863e

Browse files
committed
Merge remote-tracking branch 'origin/master' into latex-stream-output
2 parents 2571a96 + 1695444 commit ac3863e

File tree

7 files changed

+61
-74
lines changed

7 files changed

+61
-74
lines changed

src/packages/frontend/course/compute/actions.ts

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ import { webapp_client } from "@cocalc/frontend/webapp-client";
1717
import { map as awaitMap } from "awaiting";
1818
import { getComputeServers } from "./synctable";
1919
import { join } from "path";
20+
import {
21+
computeServerManager,
22+
type ComputeServerManager,
23+
} from "@cocalc/conat/compute/manager";
2024

2125
declare var DEBUG: boolean;
2226

@@ -388,24 +392,34 @@ export class ComputeActions {
388392
}
389393
const course_project_id = store.get("course_project_id");
390394

395+
let studentAssociations: null | ComputeServerManager = null;
396+
// project_client.computeServers can only be used for tabs
397+
// for a project that is actually open in the client, so
398+
// we use it for the instructor project, but not the student
399+
// project, which may not be opened.
391400
const courseAssociations =
392401
webapp_client.project_client.computeServers(course_project_id);
393402

394-
const studentAssociations =
395-
webapp_client.project_client.computeServers(target_project_id);
403+
try {
404+
studentAssociations = computeServerManager({
405+
project_id: target_project_id,
406+
});
396407

397-
const ids = await courseAssociations.getServerIdForSubtree(src_path);
398-
for (const source in ids) {
399-
if (ids[source]) {
400-
const tail = source.slice(src_path.length + 1);
401-
const path = join(target_path, tail);
402-
await studentAssociations.waitUntilReady();
403-
// path is on a compute server.
404-
studentAssociations.connectComputeServerToPath({
405-
id: compute_server_id,
406-
path,
407-
});
408+
const ids = await courseAssociations.getServerIdForSubtree(src_path);
409+
for (const source in ids) {
410+
if (ids[source]) {
411+
const tail = source.slice(src_path.length + 1);
412+
const path = join(target_path, tail);
413+
await studentAssociations.waitUntilReady();
414+
// path is on a compute server.
415+
studentAssociations.connectComputeServerToPath({
416+
id: compute_server_id,
417+
path,
418+
});
419+
}
408420
}
421+
} finally {
422+
studentAssociations?.close();
409423
}
410424
};
411425
}

src/packages/frontend/project/explorer/action-bar.tsx

Lines changed: 9 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Space } from "antd";
6+
import { Space, Tooltip } from "antd";
77
import * as immutable from "immutable";
8-
import { throttle } from "lodash";
9-
import React, { useEffect, useRef, useState } from "react";
8+
import React, { useEffect, useState } from "react";
109
import { FormattedMessage, useIntl } from "react-intl";
11-
1210
import { Button, ButtonToolbar } from "@cocalc/frontend/antd-bootstrap";
1311
import { Gap, Icon } from "@cocalc/frontend/components";
1412
import { useStudentProjectFunctionality } from "@cocalc/frontend/course";
@@ -20,8 +18,6 @@ import { file_actions, ProjectActions } from "@cocalc/frontend/project_store";
2018
import * as misc from "@cocalc/util/misc";
2119
import { COLORS } from "@cocalc/util/theme";
2220

23-
import { useProjectContext } from "../context";
24-
2521
const ROW_INFO_STYLE = {
2622
color: COLORS.GRAY,
2723
height: "22px",
@@ -45,10 +41,6 @@ interface Props {
4541

4642
export const ActionBar: React.FC<Props> = (props: Props) => {
4743
const intl = useIntl();
48-
const [showLabels, setShowLabels] = useState<boolean>(true);
49-
const { mainWidthPx } = useProjectContext();
50-
const buttonRef = useRef<HTMLDivElement>(null);
51-
const widthThld = useRef<number>(0);
5244
const [select_entire_directory, set_select_entire_directory] = useState<
5345
"hidden" | "check" | "clear"
5446
>("hidden");
@@ -76,34 +68,6 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
7668
}
7769
}, [props.checked_files, props.listing, select_entire_directory]);
7870

79-
useEffect(() => {
80-
const btnbar = buttonRef.current;
81-
if (btnbar == null) return;
82-
const resizeObserver = new ResizeObserver(
83-
throttle(
84-
(entries) => {
85-
if (entries.length > 0) {
86-
const width = entries[0].contentRect.width;
87-
// TODO: this "+100" is sloppy. This makes it much better than before
88-
// (e.g. german buttons were cutoff all the time), but could need more tweaking
89-
if (showLabels && width > mainWidthPx + 100) {
90-
setShowLabels(false);
91-
widthThld.current = width;
92-
} else if (!showLabels && width < widthThld.current - 1) {
93-
setShowLabels(true);
94-
}
95-
}
96-
},
97-
100,
98-
{ leading: false, trailing: true },
99-
),
100-
);
101-
resizeObserver.observe(btnbar);
102-
return () => {
103-
resizeObserver.disconnect();
104-
};
105-
}, [mainWidthPx, buttonRef.current]);
106-
10771
function clear_selection(): void {
10872
props.actions.set_all_files_unchecked();
10973
if (select_entire_directory !== "hidden") {
@@ -255,10 +219,12 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
255219
};
256220

257221
return (
258-
<Button onClick={handle_click} disabled={disabled} key={name}>
259-
<Icon name={obj.icon} />{" "}
260-
{showLabels ? `${intl.formatMessage(obj.name)}...` : ""}
261-
</Button>
222+
<Tooltip title={intl.formatMessage(obj.name)}>
223+
<Button onClick={handle_click} disabled={disabled} key={name}>
224+
<Icon name={obj.icon} />
225+
</Button>
226+
&nbsp;
227+
</Tooltip>
262228
);
263229
}
264230

@@ -337,7 +303,7 @@ export const ActionBar: React.FC<Props> = (props: Props) => {
337303
}
338304
return (
339305
<div style={{ flex: "1 0 auto" }}>
340-
<div ref={buttonRef} style={{ flex: "1 0 auto" }}>
306+
<div style={{ flex: "1 0 auto" }}>
341307
<ButtonToolbar style={{ whiteSpace: "nowrap", padding: "0" }}>
342308
<Space.Compact>
343309
{props.project_is_running ? render_check_all_button() : undefined}

src/packages/frontend/project/explorer/misc-side-buttons.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ import { ProjectActions } from "@cocalc/frontend/project_store";
1818
import track from "@cocalc/frontend/user-tracking";
1919
import { KUCALC_COCALC_COM } from "@cocalc/util/db-schema/site-defaults";
2020

21-
const SHOW_SERVER_LAUNCHERS = false;
22-
2321
import TourButton from "./tour/button";
2422

2523
const OPEN_MSG = defineMessage({
@@ -176,7 +174,7 @@ export const MiscSideButtons: React.FC<Props> = (props) => {
176174
// we make sure the url ends with a slash, without messing up the full URL
177175
const s = base.slice(base.length - 1) === "/" ? "" : "/";
178176
const url = `${base}${s}${current_path ? "lab/tree/" + current_path : ""}`;
179-
const values = { name: SPEC.code.longName };
177+
const values = { name: SPEC.jupyterlab.longName };
180178
const tooltip = intl.formatMessage(OPEN_MSG, values);
181179
const description = intl.formatMessage(SPEC.jupyterlab.description, values);
182180
return (
@@ -209,12 +207,10 @@ export const MiscSideButtons: React.FC<Props> = (props) => {
209207
style={{ whiteSpace: "nowrap", padding: "0" }}
210208
className="pull-right"
211209
>
212-
{SHOW_SERVER_LAUNCHERS && (
213-
<Space.Compact>
214-
{render_jupyterlab_button()}
215-
{render_vscode_button()}
216-
</Space.Compact>
217-
)}
210+
<Space.Compact>
211+
{render_jupyterlab_button()}
212+
{render_vscode_button()}
213+
</Space.Compact>
218214
<Space.Compact>
219215
{render_upload_button()}
220216
{render_library_button()}

src/packages/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"[email protected]": "3.0.9",
3232
"@types/[email protected]": "2.48.13",
3333
"@types/[email protected]": "2.6.13",
34-
"[email protected]": "^1.11.0"
34+
"[email protected]": "^1.12.0"
3535
},
3636
"onlyBuiltDependencies": [
3737
"websocket-sftp",

src/packages/pnpm-lock.yaml

Lines changed: 17 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/packages/server/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
"async": "^1.5.2",
7575
"await-spawn": "^4.0.2",
7676
"awaiting": "^3.0.0",
77-
"axios": "^1.11.0",
77+
"axios": "^1.12.0",
7878
"base62": "^2.0.1",
7979
"base64-js": "^1.5.1",
8080
"cloudflare": "^2.9.1",

src/packages/util/smc-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* autogenerated by the update_version script */
2-
exports.version=1757119901;
2+
exports.version=1758034770;

0 commit comments

Comments
 (0)