Skip to content

Commit b4f77d5

Browse files
committed
Merge remote-tracking branch 'origin/master' into conat-optimize1
2 parents c533cf9 + 07002cf commit b4f77d5

File tree

9 files changed

+210
-97
lines changed

9 files changed

+210
-97
lines changed

src/packages/frontend/cspell.json

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"ggplot",
1919
"ipython",
2020
"ipywidgets",
21+
"jsonic",
2122
"katex",
2223
"knitr",
2324
"kucalc",
@@ -60,12 +61,9 @@
6061
"ignoreWords": [
6162
"antd",
6263
"buttonbar",
63-
"buttonbar",
6464
"collab",
6565
"descr",
6666
"flyoutdragbar",
67-
"flyoutdragbar",
68-
"flyouts",
6967
"flyouts",
7068
"immutablejs",
7169
"ipynb",
@@ -79,22 +77,16 @@
7977
"mintime",
8078
"mistralai",
8179
"noconf",
82-
"noconf",
8380
"nprocs",
84-
"nprocs",
85-
"pchildren",
8681
"pchildren",
8782
"pids",
88-
"pids",
8983
"Popconfirm",
9084
"PoweroffOutlined",
9185
"ptree",
92-
"ptree",
9386
"reuseinflight",
9487
"sidechat",
9588
"vertexai",
9689
"vfill",
97-
"xsmall",
9890
"xsmall"
9991
],
10092
"flagWords": [],

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

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
205205
const [close_and_halt_confirm, set_close_and_halt_confirm] =
206206
useState<boolean>(false);
207207

208-
const [showAI, setShowAI] = useState<boolean>(false);
208+
const [showAIDialogs, setShowAIDialogs] = useState<{
209+
main: boolean;
210+
popover: boolean;
211+
}>({ main: false, popover: false });
209212
const [showNewAI, setShowNewAI] = useState<boolean>(false);
210213

211214
const [helpSearch, setHelpSearch] = useState<string>("");
@@ -235,7 +238,8 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
235238
new ManageCommands({
236239
props,
237240
studentProjectFunctionality: student_project_functionality,
238-
setShowAI,
241+
setShowAI: (val: boolean) =>
242+
setShowAIDialogs((prev) => ({ ...prev, main: val })),
239243
setShowNewAI,
240244
helpSearch,
241245
setHelpSearch,
@@ -248,7 +252,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
248252
student_project_functionality,
249253
helpSearch,
250254
setHelpSearch,
251-
setShowAI,
255+
setShowAIDialogs,
252256
setShowNewAI,
253257
read_only,
254258
editorSettings,
@@ -579,7 +583,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
579583
);
580584
}
581585

582-
function renderAssistant(noLabel): Rendered {
586+
function renderAssistant(noLabel, where: "main" | "popover"): Rendered {
583587
if (
584588
!manageCommands.isVisible("chatgpt") ||
585589
!redux.getStore("projects").hasLanguageModelEnabled(props.project_id)
@@ -590,11 +594,13 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
590594
<LanguageModelTitleBarButton
591595
path={props.path}
592596
type={props.type}
593-
showDialog={showAI}
594-
setShowDialog={setShowAI}
597+
showDialog={showAIDialogs[where]}
598+
setShowDialog={(value: boolean) => {
599+
setShowAIDialogs((prev) => ({ ...prev, [where]: value }));
600+
}}
595601
project_id={props.project_id}
596602
buttonRef={getTourRef("chatgpt")}
597-
key={"ai-button"}
603+
key={`ai-button-${where}`}
598604
id={props.id}
599605
actions={props.actions}
600606
buttonSize={button_size()}
@@ -641,7 +647,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
641647
);
642648
}
643649

644-
function renderSaveTimetravelGroup(): Rendered {
650+
function renderSaveTimetravelGroup(where: "main" | "popover"): Rendered {
645651
if (props.type == "chat") {
646652
// these buttons don't make much sense for side chat.
647653
return;
@@ -651,7 +657,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
651657
let x;
652658
if ((x = renderSaveButton(noLabel))) v.push(x);
653659
if ((x = renderTimeTravel(noLabel))) v.push(x);
654-
if ((x = renderAssistant(noLabel))) v.push(x);
660+
if ((x = renderAssistant(noLabel, where))) v.push(x);
655661
if ((x = renderComputeServer(noLabel))) v.push(x);
656662
if (v.length == 1) return v[0];
657663
if (v.length > 0) {
@@ -754,7 +760,11 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
754760
// seems too horrible right now since it is a selector.
755761
}
756762

757-
function renderButtons(style?: CSS, noRefs?): Rendered {
763+
function renderButtons(
764+
style?: CSS,
765+
noRefs?,
766+
where: "main" | "popover" = "main",
767+
): Rendered {
758768
if (!is_active) {
759769
return (
760770
<div style={{ display: "flex", width: "100%" }}>
@@ -784,7 +794,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
784794
}
785795

786796
const v: (React.JSX.Element | undefined | null)[] = [];
787-
v.push(renderSaveTimetravelGroup());
797+
v.push(renderSaveTimetravelGroup(where));
788798
if (props.title != null) {
789799
v.push(renderTitle());
790800
}
@@ -841,7 +851,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
841851
}
842852
return (
843853
<Popover
844-
overlayStyle={{ zIndex: 990 }}
854+
styles={{ root: { zIndex: 990 } }}
845855
open={
846856
props.tab_is_visible && props.is_visible && showMainButtonsPopover
847857
}
@@ -860,7 +870,11 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
860870
marginRight: "3px",
861871
}}
862872
>
863-
{renderButtons({ maxHeight: "50vh", display: "block" }, true)}
873+
{renderButtons(
874+
{ maxHeight: "50vh", display: "block" },
875+
true,
876+
"popover",
877+
)}
864878
</div>
865879
<div>
866880
{renderFrameControls()}

src/packages/frontend/frame-editors/llm/help-me-fix-utils.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface GetHelpOptions {
1818
redux: any;
1919
prioritize?: "start" | "start-end" | "end";
2020
model: string;
21+
isHint?: boolean;
2122
}
2223

2324
export interface CreateMessageOpts {
@@ -35,23 +36,22 @@ export interface CreateMessageOpts {
3536
isHint?: boolean;
3637
}
3738

38-
export async function getHelp(options: GetHelpOptions) {
39-
const {
40-
project_id,
41-
path,
42-
tag,
43-
line = "",
44-
error,
45-
input,
46-
task,
47-
language,
48-
extraFileInfo,
49-
redux,
50-
prioritize,
51-
model,
52-
} = options;
53-
54-
const solutionText = createMessage({
39+
export async function getHelp({
40+
project_id,
41+
path,
42+
tag,
43+
line = "",
44+
error,
45+
input,
46+
task,
47+
language,
48+
extraFileInfo,
49+
redux,
50+
prioritize,
51+
model,
52+
isHint = false,
53+
}: GetHelpOptions) {
54+
const messageText = createMessage({
5555
error,
5656
task,
5757
line,
@@ -60,17 +60,18 @@ export async function getHelp(options: GetHelpOptions) {
6060
extraFileInfo,
6161
model,
6262
prioritize,
63-
open: false,
64-
full: false,
65-
isHint: false,
63+
open: true,
64+
full: true,
65+
isHint,
6666
});
6767

6868
try {
6969
const actions = await getChatActions(redux, project_id, path);
7070
setTimeout(() => actions.scrollToBottom(), 100);
71+
const tagSuffix = isHint ? "hint" : "solution";
7172
await actions.sendChat({
72-
input: solutionText,
73-
tag: `help-me-fix-solution${tag ? `:${tag}` : ""}`,
73+
input: messageText,
74+
tag: `help-me-fix-${tagSuffix}${tag ? `:${tag}` : ""}`,
7475
noNotification: true,
7576
});
7677
} catch (err) {
@@ -139,8 +140,8 @@ export function createMessage({
139140
prioritize === "start"
140141
? "starts"
141142
: prioritize === "end"
142-
? "ends"
143-
: "starts and ends";
143+
? "ends"
144+
: "starts and ends";
144145
message.push(
145146
`My ${
146147
extraFileInfo ?? ""

src/packages/frontend/jupyter/cell-buttonbar-menu.tsx

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { useIntl } from "react-intl";
1111
import { alert_message } from "@cocalc/frontend/alerts";
1212
import { Icon } from "@cocalc/frontend/components";
1313
import { jupyter, labels } from "@cocalc/frontend/i18n";
14+
import { commands } from "./commands";
1415
import {
1516
CODE_BAR_BTN_STYLE,
1617
COPY_CELL_ICON,
@@ -21,6 +22,27 @@ import {
2122
export function CodeBarDropdownMenu({ actions, frameActions, id, cell }) {
2223
const intl = useIntl();
2324

25+
// All jupyter commands
26+
const allCommands = commands({
27+
jupyter_actions: actions,
28+
frame_actions: frameActions,
29+
});
30+
31+
// Extract the cell toolbar command definitions
32+
const toolbarNone = allCommands["cell toolbar none"];
33+
const toolbarAssignment = allCommands["cell toolbar create_assignment"];
34+
const toolbarSlideshow = allCommands["cell toolbar slideshow"];
35+
const toolbarMetadata = allCommands["cell toolbar metadata"];
36+
const toolbarAttachments = allCommands["cell toolbar attachments"];
37+
const toolbarTags = allCommands["cell toolbar tags"];
38+
const toolbarIds = allCommands["cell toolbar ids"];
39+
40+
// Helper to format labels safely
41+
const formatLabel = (cmd) => {
42+
const message = cmd.menu || cmd.m;
43+
return typeof message === "string" ? message : intl.formatMessage(message);
44+
};
45+
2446
function cut_cell(): void {
2547
if (id == null) return;
2648
frameActions.current?.unselect_all_cells();
@@ -113,6 +135,55 @@ export function CodeBarDropdownMenu({ actions, frameActions, id, cell }) {
113135
},
114136
],
115137
},
138+
{
139+
key: "cell-toolbar",
140+
label: intl.formatMessage(jupyter.commands.view_toolbars_menu),
141+
icon: <Icon name="tool" />,
142+
children: [
143+
{
144+
key: "cell-toolbar-none",
145+
label: formatLabel(toolbarNone),
146+
icon: <Icon name={toolbarNone.i} />,
147+
onClick: toolbarNone.f,
148+
},
149+
{
150+
key: "cell-toolbar-create-assignment",
151+
label: formatLabel(toolbarAssignment),
152+
icon: <Icon name={toolbarAssignment.i} />,
153+
onClick: toolbarAssignment.f,
154+
},
155+
{
156+
key: "cell-toolbar-slideshow",
157+
label: formatLabel(toolbarSlideshow),
158+
icon: <Icon name={toolbarSlideshow.i} />,
159+
onClick: toolbarSlideshow.f,
160+
},
161+
{
162+
key: "cell-toolbar-metadata",
163+
label: formatLabel(toolbarMetadata),
164+
icon: <Icon name={toolbarMetadata.i} />,
165+
onClick: toolbarMetadata.f,
166+
},
167+
{
168+
key: "cell-toolbar-attachments",
169+
label: formatLabel(toolbarAttachments),
170+
icon: <Icon name={toolbarAttachments.i} />,
171+
onClick: toolbarAttachments.f,
172+
},
173+
{
174+
key: "cell-toolbar-tags",
175+
label: formatLabel(toolbarTags),
176+
icon: <Icon name={toolbarTags.i} />,
177+
onClick: toolbarTags.f,
178+
},
179+
{
180+
key: "cell-toolbar-ids",
181+
label: formatLabel(toolbarIds),
182+
icon: <Icon name={toolbarIds.i} />,
183+
onClick: toolbarIds.f,
184+
},
185+
],
186+
},
116187
{ key: "divider4", type: "divider" },
117188
{
118189
key: "copy-cell",

src/packages/frontend/project/new/file-type-selector.tsx

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

6-
import { Col, Flex, Modal, Row, Tag } from "antd";
6+
import { Col, Flex, Row, Tag } from "antd";
77
import { Gutter } from "antd/es/grid/row";
88
import type { ReactNode } from "react";
99
import { FormattedMessage, useIntl } from "react-intl";
@@ -372,30 +372,6 @@ export function FileTypeSelector({
372372
function renderSageWS() {
373373
if (!availableFeatures.sage) return;
374374

375-
function handleClick(ext) {
376-
Modal.confirm({
377-
icon: <Icon name="exclamation-circle" />,
378-
title: intl.formatMessage({
379-
id: "project.new.file-type-selector.sagews.modal.title",
380-
defaultMessage: "SageMath Worksheets are Deprecated",
381-
}),
382-
content: intl.formatMessage({
383-
id: "project.new.file-type-selector.sagews.modal.content",
384-
defaultMessage:
385-
"Consider creating a Jupyter Notebook and use a SageMath Kernel (use the 'SageMath Notebook' button). You can also convert existing SageMath Worksheets to Jupyter Notebooks by opening the worksheet and clicking 'Jupyter'.",
386-
}),
387-
okText: intl.formatMessage({
388-
id: "project.new.file-type-selector.sagews.modal.ok",
389-
defaultMessage: "Create SageMath Worksheet Anyways",
390-
}),
391-
onOk: (close) => {
392-
create_file(ext);
393-
close();
394-
},
395-
closable: true,
396-
});
397-
}
398-
399375
return (
400376
<Col sm={sm} md={md}>
401377
<Tip
@@ -405,12 +381,12 @@ export function FileTypeSelector({
405381
tip={intl.formatMessage({
406382
id: "new.file-type-selector.sagews.tooltip",
407383
defaultMessage:
408-
"Create an interactive worksheet for using the SageMath mathematical software, Python, R, and many other systems. Do sophisticated mathematics, draw plots, compute integrals, work with matrices, etc.",
384+
"Create an interactive worksheet for using the SageMath mathematical software, Python, R, and many other systems. Do mathematics, draw plots, compute integrals, work with matrices, etc.",
409385
})}
410386
>
411387
<NewFileButton
412388
name={intl.formatMessage(labels.sagemath_worksheet)}
413-
on_click={handleClick}
389+
on_click={create_file}
414390
ext="sagews"
415391
size={btnSize}
416392
active={btnActive("sagews")}

0 commit comments

Comments
 (0)