💄 small inline ctx ui improvements

This commit is contained in:
Nate Sesti 2023-12-25 01:28:27 -05:00
parent 55fed41099
commit c66abb697b
6 changed files with 81 additions and 28 deletions

View file

@ -90,7 +90,10 @@ function StepContainer(props: StepContainerProps) {
isUserInput={isUserInput}
fontSize={getFontSize()}
>
<StyledMarkdownPreview source={props.item.message.content} />
<StyledMarkdownPreview
source={props.item.message.content}
showCodeBorder={true}
/>
</ContentDiv>
{(isHovered || typeof feedback !== "undefined") && !active && (
<div

View file

@ -47,12 +47,14 @@ interface InputToolbarProps {
usingCodebase?: boolean;
onAddContextItem?: () => void;
onClick?: () => void;
hidden?: boolean;
}
function InputToolbar(props: InputToolbarProps) {
return (
<StyledDiv hidden={props.hidden}>
<StyledDiv hidden={props.hidden} onClick={props.onClick} id="input-toolbar">
<span
style={{
color: lightGray,

View file

@ -1,4 +1,5 @@
import {
ArrowRightIcon,
ArrowUpOnSquareIcon,
AtSymbolIcon,
BeakerIcon,
@ -217,9 +218,16 @@ const MentionList = forwardRef((props: MentionListProps, ref) => {
textAlign: "right",
opacity: index !== selectedIndex ? 0 : 1,
}}
className="whitespace-nowrap overflow-hidden overflow-ellipsis ml-2"
className="whitespace-nowrap overflow-hidden overflow-ellipsis ml-2 flex items-center"
>
{item.description}
{item.id === "file" && (
<ArrowRightIcon
className="ml-2"
width="1.2em"
height="1.2em"
/>
)}
</span>
</span>
</ItemDiv>

View file

@ -290,14 +290,17 @@ function TipTapEditor(props: TipTapEditorProps) {
}, [editor, props.isMainInput, historyLength, ignoreHighlightedCode]);
return (
<InputBoxDiv>
<InputBoxDiv className="cursor-text">
<EditorContent
editor={editor}
onFocus={() => {
setInputFocused(true);
}}
onBlur={() => {
setInputFocused(false);
// hack to stop from cancelling press of "Enter"
setTimeout(() => {
setInputFocused(false);
}, 100);
}}
/>
<InputToolbar
@ -308,9 +311,12 @@ function TipTapEditor(props: TipTapEditorProps) {
editor.commands.insertContent("@");
}
}}
onEnter={async () => {
onEnter={() => {
props.onEnter(editor.getJSON());
}}
onClick={() => {
editor.commands.focus("end");
}}
/>
</InputBoxDiv>
);

View file

@ -22,6 +22,7 @@ import {
defaultBorderRadius,
lightGray,
vscBackground,
vscForeground,
} from "../components";
import FTCDialog from "../components/dialogs/FTCDialog";
import ErrorStepContainer from "../components/gui/ErrorStepContainer";
@ -45,6 +46,7 @@ import {
} from "../redux/slices/uiStateSlice";
import { RootStore } from "../redux/store";
import { getMetaKeyLabel, isMetaEquivalentKeyPressed } from "../util";
import { isJetBrains } from "../util/ide";
const TopGuiDiv = styled.div`
overflow-y: scroll;
@ -93,6 +95,26 @@ const StepsDiv = styled.div`
}
`;
const NewSessionButton = styled.div`
width: fit-content;
margin-right: auto;
margin-left: 8px;
margin-top: 4px;
font-size: 12px;
border-radius: ${defaultBorderRadius};
padding: 2px 8px;
color: ${lightGray};
&:hover {
background-color: ${lightGray}33;
color: ${vscForeground};
}
cursor: pointer;
`;
function fallbackRender({ error, resetErrorBoundary }) {
// Call resetErrorBoundary() to reset the error boundary and retry the render.
@ -462,6 +484,21 @@ function GUI(props: GUIProps) {
></ContinueInputBox>
)}
</div>
{active ? (
<>
<br />
<br />
</>
) : state.history.length > 0 ? (
<NewSessionButton
onClick={() => {
saveSession();
}}
className="mr-auto"
>
New Session ({getMetaKeyLabel()} {isJetBrains() ? "J" : "M"})
</NewSessionButton>
) : null}
</TopGuiDiv>
{active && (
<StopButton

View file

@ -1,6 +1,7 @@
import { createSlice } from "@reduxjs/toolkit";
import { JSONContent } from "@tiptap/react";
import {
ChatHistory,
ChatMessage,
ContextItemId,
ContextItemWithId,
@ -38,16 +39,18 @@ const TEST_CONTEXT_ITEMS: ContextItemWithId[] = [
},
];
const TEST_TIMELINE = [
const TEST_TIMELINE: ChatHistory = [
{
description: "Hi, please write bubble sort in python",
name: "User Input",
params: { context_items: TEST_CONTEXT_ITEMS },
hide: false,
depth: 0,
message: {
role: "user",
content: "Hi, please write bubble sort in python",
},
contextItems: [],
},
{
description: `\`\`\`python
message: {
role: "assistant",
content: `\`\`\`python
def bubble_sort(arr):
n = len(arr)
for i in range(n):
@ -56,23 +59,17 @@ def bubble_sort(arr):
arr[j], arr[j + 1] = arr[j + 1], arr[j]
return arr
\`\`\``,
name: "Bubble Sort in Python",
params: {},
hide: false,
depth: 0,
},
contextItems: [],
},
{
description: "Now write it in Rust",
name: "User Input",
params: {},
message: { role: "user", content: "Now write it in Rust" },
contextItems: [],
},
{
description: "Hello! This is a test...\n\n1, 2, 3, testing...",
name: "Testing",
hide: false,
},
{
description: `Sure, here's bubble sort written in rust: \n\`\`\`rust
message: {
role: "assistant",
content: `Sure, here's bubble sort written in rust: \n\`\`\`rust
fn bubble_sort<T: Ord>(values: &mut[T]) {
let len = values.len();
for i in 0..len {
@ -84,8 +81,8 @@ fn bubble_sort<T: Ord>(values: &mut[T]) {
}
}
\`\`\`\nIs there anything else I can answer?`,
name: "Rust Bubble Sort",
depth: 0,
},
contextItems: [],
},
];