Skip to content

Commit 6aa5e4f

Browse files
committed
ai popover: some trivial stylistic changes in prep for supporting sage-chat
1 parent 94bbec9 commit 6aa5e4f

File tree

3 files changed

+33
-21
lines changed

3 files changed

+33
-21
lines changed

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3020,17 +3020,14 @@ export class Actions<
30203020
return new Set(["selection"]);
30213021
}
30223022

3023-
async languageModel(frameId: string, options: Options, input: string) {
3023+
languageModel = async (frameId: string, options: Options, input: string) => {
30243024
await languageModelCreateChat({
30253025
actions: this as Actions<CodeEditorState>,
30263026
frameId,
30273027
options,
30283028
input,
30293029
});
3030-
}
3031-
3032-
// TODO: get rid of this. it's used somehow in the title-bar.tsx, without typing
3033-
chatgpt = this.languageModel;
3030+
};
30343031

30353032
tour(_id: string, _refs: any): TourProps["steps"] {
30363033
return [];

src/packages/frontend/frame-editors/llm/context.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ const MISSING =
2121

2222
export default function Context({ value, info }) {
2323
if (!value?.trim()) {
24-
return (
25-
<b style={{ fontSize: FONT_SIZE }}>
26-
No context from your file will be included.
27-
</b>
28-
);
24+
return <b>No context from your file will be included.</b>;
2925
}
3026
if (info === "md" || info === "markdown") {
3127
return (

src/packages/frontend/frame-editors/llm/title-bar-button.tsx

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ import {
3737
IconName,
3838
LLMNameLink,
3939
Paragraph,
40-
RawPrompt,
4140
Text,
4241
Title,
4342
VisibleMDLG,
4443
} from "@cocalc/frontend/components";
44+
import StaticMarkdown from "@cocalc/frontend/editors/slate/static-markdown";
4545
import AIAvatar from "@cocalc/frontend/components/ai-avatar";
4646
import { labels } from "@cocalc/frontend/i18n";
4747
import { LLMCostEstimation } from "@cocalc/frontend/misc/llm-cost-estimation";
@@ -337,7 +337,9 @@ export default function LanguageModelTitleBarButton({
337337
const doIt = async () => {
338338
setShowPreview(false);
339339
const options = getQueryLLMOptions();
340-
if (options == null) return;
340+
if (options == null) {
341+
return;
342+
}
341343
await queryLLM(options);
342344
setShowDialog(false);
343345
setError("");
@@ -410,7 +412,9 @@ export default function LanguageModelTitleBarButton({
410412
icon: <Icon name={icon} />,
411413
label: (
412414
<>
413-
<Text strong>{label}:</Text>{" "}
415+
<Text strong style={{ marginRight: "5px" }}>
416+
{label}:
417+
</Text>{" "}
414418
<Text type="secondary">{description}</Text>
415419
</>
416420
),
@@ -442,7 +446,9 @@ export default function LanguageModelTitleBarButton({
442446
}
443447

444448
function renderShowOptions() {
445-
if (!showOptions) return;
449+
if (!showOptions || path.endsWith(".sage-chat")) {
450+
return;
451+
}
446452

447453
return (
448454
<Paragraph
@@ -504,6 +510,14 @@ export default function LanguageModelTitleBarButton({
504510
return (
505511
<Paragraph style={{ textAlign: "center" }} ref={submitRef}>
506512
<Space size="middle">
513+
<Button
514+
size="large"
515+
onClick={() => {
516+
setShowDialog(false);
517+
}}
518+
>
519+
Cancel
520+
</Button>
507521
<Popover
508522
trigger={["click"]}
509523
title={
@@ -517,7 +531,7 @@ export default function LanguageModelTitleBarButton({
517531
>
518532
<Icon name="times" />
519533
</Button>
520-
Exactly this will be sent to the language model.
534+
This will be sent to the language model
521535
</div>
522536
}
523537
open={showPreview && visible && showDialog}
@@ -528,8 +542,8 @@ export default function LanguageModelTitleBarButton({
528542
}}
529543
content={() => (
530544
<Space direction="vertical" style={{ maxWidth: "50vw" }}>
531-
<RawPrompt
532-
input={message}
545+
<StaticMarkdown
546+
value={message}
533547
style={{
534548
maxHeight: "30vh",
535549
overflow: "auto",
@@ -598,10 +612,12 @@ export default function LanguageModelTitleBarButton({
598612
</Paragraph>
599613
{renderOptions()}
600614
{renderShowOptions()}
601-
<Paragraph type="secondary">
602-
{description} The output will appear in side-chat, so your file isn't
603-
directly modified.
604-
</Paragraph>
615+
{!path.endsWith(".sage-chat") && (
616+
<Paragraph type="secondary">
617+
{description} The output will appear in the side chat, so your file
618+
isn't directly modified.
619+
</Paragraph>
620+
)}
605621
{renderSubmit()}
606622
{error ? (
607623
<Alert type="error" message={error} />
@@ -614,6 +630,9 @@ export default function LanguageModelTitleBarButton({
614630

615631
return (
616632
<Popover
633+
placement={
634+
"right" /* Otherwise this thing gets stuck on the left side of the screen, which is very disconcerting*/
635+
}
617636
title={renderTitle()}
618637
open={visible && showDialog}
619638
content={renderContent}

0 commit comments

Comments
 (0)