Skip to content

Commit c85f74a

Browse files
committed
Merge remote-tracking branch 'origin/master' into sso-exclusive-all
2 parents 681f6b9 + c2c9744 commit c85f74a

File tree

16 files changed

+107
-28
lines changed

16 files changed

+107
-28
lines changed
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { set, get, del } from "@cocalc/frontend/misc/local-storage-typed";
2+
import { isEqual } from "lodash";
3+
4+
export function getFoldedLines(cm): number[] {
5+
if (cm?.foldCode == null) {
6+
// not enabled
7+
return [];
8+
}
9+
return cm
10+
.getAllMarks()
11+
.filter((mark) => mark.__isFold)
12+
.map((mark) => mark.find().from.line);
13+
}
14+
15+
export function setFoldedLines(cm, lines: number[]) {
16+
if (cm?.foldCode == null) {
17+
// not enabled
18+
return;
19+
}
20+
lines.reverse();
21+
for (const n of lines) {
22+
cm.foldCode(n);
23+
}
24+
}
25+
26+
function toKey(key: string): string {
27+
return `cmfold-${key}`;
28+
}
29+
30+
export function initFold(cm, key: string) {
31+
const k = toKey(key);
32+
const lines = get<number[]>(k);
33+
if (lines != null) {
34+
try {
35+
setFoldedLines(cm, lines);
36+
} catch (err) {
37+
console.warn(`error setting cold folding for ${key}: `, err);
38+
del(k);
39+
}
40+
}
41+
}
42+
43+
export function saveFold(cm, key: string) {
44+
const k = toKey(key);
45+
const lines = get<number[]>(k);
46+
const lines2 = getFoldedLines(cm);
47+
if (lines2.length == 0) {
48+
if (lines != null) {
49+
del(k);
50+
}
51+
return;
52+
}
53+
if (!isEqual(lines, lines2)) {
54+
set<number[]>(k, lines2);
55+
}
56+
}

src/packages/frontend/components/link-retry.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ interface Props {
2424
onClick?: () => void;
2525
autoStart?: boolean;
2626
maxTime?: number;
27-
tooltip?: string;
27+
tooltip?: React.ReactNode;
2828
}
2929

3030
const LinkRetry: React.FC<Props> = ({

src/packages/frontend/frame-editors/code-editor/codemirror-editor.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import { GutterMarkers } from "./codemirror-gutter-markers";
3636
import { Actions } from "./actions";
3737
import { EditorState } from "../frame-tree/types";
3838
import { Path } from "../frame-tree/path";
39+
import { initFold, saveFold } from "@cocalc/frontend/codemirror/util";
3940

4041
const STYLE = {
4142
width: "100%",
@@ -290,6 +291,16 @@ export const CodemirrorEditor: React.FC<Props> = React.memo((props) => {
290291
}
291292
cmRef.current.setOption("readOnly", props.read_only);
292293
cm_refresh();
294+
295+
const foldKey = `${props.path}\\${props.id}`;
296+
const saveFoldState = () => {
297+
if (cmRef.current != null) {
298+
saveFold(cmRef.current,foldKey);
299+
}
300+
};
301+
cmRef.current.on("fold" as any, saveFoldState);
302+
cmRef.current.on("unfold" as any, saveFoldState);
303+
initFold(cmRef.current, foldKey);
293304
}
294305

295306
function init_new_codemirror(): void {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,8 @@ export const FrameTree: React.FC<FrameTreeProps> = React.memo(
290290
let name_leaf = name;
291291
let actions_leaf = actions;
292292
if (
293-
spec.name === "TimeTravel" &&
293+
typeof spec.name != "string" &&
294+
spec.name?.id === "labels.timetravel" &&
294295
!(actions instanceof TimeTravelActions)
295296
) {
296297
if (path_leaf.slice(path_leaf.length - 12) != ".time-travel") {

src/packages/frontend/i18n/bin/common.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/compile.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/download.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/extract.sh

100644100755
File mode changed.

src/packages/frontend/i18n/bin/upload.sh

100644100755
File mode changed.

src/packages/frontend/i18n/common.ts

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ export const labels = defineMessages({
157157
description: "The button to engage with the AI Assistant dialog",
158158
},
159159
timetravel: {
160+
// DO NOT CHANGE THIS labels.timetravel ID!!!! It is explcitly used in frontend/frame-editors/frame-tree/frame-tree.tsx
161+
// This caused a massive bug when i18n was first merged.
160162
id: "labels.timetravel",
161163
defaultMessage: "TimeTravel",
162164
description:

src/packages/frontend/i18n/extracted.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@
560560
"defaultMessage": "Describe the problem of that cell in order to get a bugfixed version."
561561
},
562562
"jupyter.llm.dell-tool.actions.bugfix.label": {
563-
"defaultMessage": "Explain"
563+
"defaultMessage": "Fix Bugs"
564564
},
565565
"jupyter.llm.dell-tool.actions.document.descr": {
566566
"defaultMessage": "Add documentation"

src/packages/frontend/jupyter/codemirror-editor.tsx

+18-8
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import { Complete, Actions as CompleteActions } from "./complete";
2828
import { Cursors } from "./cursors";
2929
import { Position } from "./insert-cell/types";
3030
import { is_whitespace } from "@cocalc/util/misc";
31+
import { initFold, saveFold } from "@cocalc/frontend/codemirror/util";
3132

3233
// We cache a little info about each Codemirror editor we make here,
3334
// so we can restore it when we make the same one again. Due to
@@ -147,12 +148,17 @@ export const CodeMirrorEditor: React.FC<CodeMirrorEditorProps> = ({
147148

148149
useEffect(() => {
149150
if (frameActions.current?.frame_id != null) {
150-
key.current = `${frameActions.current.frame_id}${id}`;
151+
key.current = `${(actions as any)?.path}${
152+
frameActions.current.frame_id
153+
}${id}`;
151154
}
152155
init_codemirror(options, value);
153156

154157
return () => {
155158
if (cm.current != null) {
159+
if (key.current != null) {
160+
saveFold(cm.current, key.current);
161+
}
156162
cm_save();
157163
cm_destroy();
158164
}
@@ -638,13 +644,6 @@ export const CodeMirrorEditor: React.FC<CodeMirrorEditorProps> = ({
638644
options0.extraKeys["Ctrl-Enter"] = () => {};
639645
options0.extraKeys["Alt-Enter"] = () => {};
640646
options0.extraKeys["Cmd-Enter"] = () => {};
641-
/*
642-
Disabled for now since fold state isn't preserved.
643-
if (options0.foldGutter) {
644-
options0.extraKeys["Ctrl-Q"] = cm => cm.foldCodeSelectionAware();
645-
options0.gutters = ["CodeMirror-linenumbers", "CodeMirror-foldgutter"];
646-
}
647-
*/
648647
} else {
649648
options0.readOnly = true;
650649
}
@@ -762,6 +761,17 @@ export const CodeMirrorEditor: React.FC<CodeMirrorEditorProps> = ({
762761
if (is_focused) {
763762
focus_cm();
764763
}
764+
765+
if (key.current != null) {
766+
initFold(cm.current, key.current);
767+
const save = () => {
768+
if (cm.current != null && key.current != null) {
769+
saveFold(cm.current, key.current);
770+
}
771+
};
772+
cm.current.on("fold", save);
773+
cm.current.on("unfold", save);
774+
}
765775
}
766776

767777
function focus_cm(): void {

src/packages/frontend/jupyter/llm/cell-tool.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ const ACTIONS: { [mode in Mode]: LLMTool } = {
158158
icon: "clean-outlined",
159159
label: defineMessage({
160160
id: "jupyter.llm.dell-tool.actions.bugfix.label",
161-
defaultMessage: "Explain",
161+
defaultMessage: "Fix Bugs",
162162
}),
163163
descr: defineMessage({
164164
id: "jupyter.llm.dell-tool.actions.bugfix.descr",

src/packages/frontend/project/named-server-panel.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { useAvailableFeatures } from "./use-available-features";
2828

2929
interface Server {
3030
longName: string;
31-
description: string;
31+
description: React.ReactNode;
3232
usesBasePath: boolean;
3333
icon: IconName;
3434
}
@@ -66,8 +66,12 @@ code completion, snippets, code refactoring, and embedded Git.`,
6666
},
6767
pluto: {
6868
longName: "Julia Pluto.jl",
69-
description:
70-
"Reactive notebooks for Julia. NOTE: This can take a long time to start, so be patient.",
69+
description: (
70+
<>
71+
Reactive notebooks for Julia.{" "}
72+
<b>NOTE: Pluto may take a long time to start, so be patient.</b>
73+
</>
74+
),
7175
usesBasePath: false,
7276
icon: "julia",
7377
},

src/packages/server/accounts/account-creation-actions.ts

+7-12
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ const log = getLogger("server:accounts:creation-actions");
1313
export default async function accountCreationActions(
1414
email_address: string,
1515
account_id: string,
16-
tags?: string[]
16+
tags?: string[],
1717
): Promise<void> {
1818
log.debug({ account_id, email_address, tags });
1919
const pool = getPool();
2020
const { rows } = await pool.query(
2121
"SELECT action FROM account_creation_actions WHERE email_address=$1 AND expire > NOW()",
22-
[email_address]
22+
[email_address],
2323
);
2424
let numProjects = 0;
2525
for (const { action } of rows) {
@@ -32,17 +32,12 @@ export default async function accountCreationActions(
3232
}
3333
}
3434
log.debug("added user to", numProjects, "projects");
35-
if (numProjects == 0 && tags != null && tags.length > 0) {
36-
// didn't get added to any projects, but there are some explicit tags.
35+
if (numProjects == 0) {
36+
// didn't get added to any projects
3737
// You're a new user with no known "reason"
3838
// to use CoCalc, except that you found the page and signed up. You are
39-
// VERY likely to create a project next, or you wouldn't be here. The only
40-
// exception I can think of is accounting people (e.g., in the store) making
41-
// an enterprise purchase, and that is probably 0.01% of users, and likely
42-
// that sign in flow won't have tags set anyways, so won't end up here.
43-
// Also directly creating accounts via the api wouldn't have tags set.
44-
// So we create an account for you now to increase your chance of success,
45-
// since you tagged some things.
39+
// VERY likely to create a project next, or you wouldn't be here.
40+
// So we create a project for you now to increase your chance of success.
4641
// NOTE -- wrapped in closure, since do NOT block on this:
4742
(async () => {
4843
try {
@@ -70,6 +65,6 @@ export async function creationActionsDone(account_id: string): Promise<void> {
7065
const pool = getPool();
7166
await pool.query(
7267
"UPDATE accounts SET creation_actions_done=true WHERE account_id=$1::UUID",
73-
[account_id]
68+
[account_id],
7469
);
7570
}

src/packages/util/smc-version.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
/* autogenerated by the update_version script */
2-
exports.version=1721605026;
2+
exports.version=1724777878;

0 commit comments

Comments
 (0)