code block setup
This commit is contained in:
parent
23b6dac06d
commit
5a8d59ff01
9 changed files with 58 additions and 111 deletions
|
|
@ -61,4 +61,5 @@ export type ToWebviewFromIdeProtocol = ToWebviewFromIdeOrCoreProtocol & {
|
|||
setupLocalModel: [undefined, void];
|
||||
incrementFtc: [undefined, void];
|
||||
openOnboarding: [undefined, void];
|
||||
applyCodeFromChat: [undefined, void];
|
||||
};
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@
|
|||
}
|
||||
},
|
||||
"commands": [
|
||||
{
|
||||
"command": "continue.applyCodeFromChat",
|
||||
"category": "Continue",
|
||||
"title": "Apply code from chat",
|
||||
"group": "Continue"
|
||||
},
|
||||
{
|
||||
"command": "continue.acceptDiff",
|
||||
"category": "Continue",
|
||||
|
|
@ -340,6 +346,12 @@
|
|||
"mac": "cmd+k cmd+a",
|
||||
"key": "ctrl+k ctrl+a",
|
||||
"when": "!terminalFocus"
|
||||
},
|
||||
{
|
||||
"command": "continue.applyCodeFromChat",
|
||||
"mac": "alt+l",
|
||||
"key": "alt+l",
|
||||
"when": "continue.continueGUIView.visible"
|
||||
}
|
||||
],
|
||||
"submenus": [
|
||||
|
|
|
|||
|
|
@ -460,6 +460,9 @@ const commandsMap: (
|
|||
"continue.viewHistory": () => {
|
||||
sidebar.webviewProtocol?.request("viewHistory", undefined);
|
||||
},
|
||||
"continue.applyCodeFromChat": () => {
|
||||
sidebar.webviewProtocol.request("applyCodeFromChat", undefined);
|
||||
},
|
||||
"continue.toggleFullScreen": () => {
|
||||
// Check if full screen is already open by checking open tabs
|
||||
const fullScreenTab = getFullScreenTab();
|
||||
|
|
|
|||
|
|
@ -13,11 +13,7 @@ import { IdeMessengerContext } from "../context/IdeMessenger";
|
|||
import { useWebviewListener } from "../hooks/useWebviewListener";
|
||||
import { isNewUserOnboarding } from "../pages/onboarding/utils";
|
||||
import { defaultModelSelector } from "../redux/selectors/modelSelectors";
|
||||
import {
|
||||
setBottomMessage,
|
||||
setBottomMessageCloseTimeout,
|
||||
setShowDialog,
|
||||
} from "../redux/slices/uiStateSlice";
|
||||
import { setShowDialog } from "../redux/slices/uiStateSlice";
|
||||
import { RootState } from "../redux/store";
|
||||
import { getFontSize, isMetaEquivalentKeyPressed } from "../util";
|
||||
import { FREE_TRIAL_LIMIT_REQUESTS } from "../util/freeTrial";
|
||||
|
|
@ -122,14 +118,6 @@ const Layout = () => {
|
|||
);
|
||||
|
||||
const defaultModel = useSelector(defaultModelSelector);
|
||||
|
||||
const bottomMessage = useSelector(
|
||||
(state: RootState) => state.uiState.bottomMessage,
|
||||
);
|
||||
const displayBottomMessageOnBottom = useSelector(
|
||||
(state: RootState) => state.uiState.displayBottomMessageOnBottom,
|
||||
);
|
||||
|
||||
const timeline = useSelector((state: RootState) => state.state.history);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -280,21 +268,6 @@ const Layout = () => {
|
|||
</Footer>
|
||||
)}
|
||||
</GridDiv>
|
||||
|
||||
<BottomMessageDiv
|
||||
displayOnBottom={displayBottomMessageOnBottom}
|
||||
onMouseEnter={() => {
|
||||
dispatch(setBottomMessageCloseTimeout(undefined));
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
if (!e.buttons) {
|
||||
dispatch(setBottomMessage(undefined));
|
||||
}
|
||||
}}
|
||||
hidden={!bottomMessage}
|
||||
>
|
||||
{bottomMessage}
|
||||
</BottomMessageDiv>
|
||||
</div>
|
||||
<div
|
||||
style={{ fontSize: `${getFontSize() - 4}px` }}
|
||||
|
|
|
|||
|
|
@ -1,47 +0,0 @@
|
|||
import { ContextItemWithId } from "core";
|
||||
import { useDispatch } from "react-redux";
|
||||
import { Button, Input } from "..";
|
||||
import {
|
||||
setDialogMessage,
|
||||
setShowDialog,
|
||||
} from "../../redux/slices/uiStateSlice";
|
||||
|
||||
function AddContextGroupDialog({
|
||||
selectedContextItems,
|
||||
}: {
|
||||
selectedContextItems: ContextItemWithId[];
|
||||
}) {
|
||||
const dispatch = useDispatch();
|
||||
|
||||
let inputElement: HTMLInputElement | null = null;
|
||||
|
||||
const handleCreate = () => {
|
||||
dispatch(setDialogMessage(undefined));
|
||||
dispatch(setShowDialog(false));
|
||||
const title = inputElement ? inputElement.value : "My Context Group";
|
||||
// TODO
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="p-4">
|
||||
<Input
|
||||
defaultValue="My Context Group"
|
||||
type="text"
|
||||
ref={(input) => {
|
||||
inputElement = input;
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
handleCreate();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
<br />
|
||||
<Button className="ml-auto" onClick={handleCreate}>
|
||||
Create
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default AddContextGroupDialog;
|
||||
|
|
@ -4,9 +4,11 @@ import {
|
|||
PlayIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useContext, useState } from "react";
|
||||
import { useSelector } from "react-redux";
|
||||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, vscEditorBackground } from "..";
|
||||
import { IdeMessengerContext } from "../../context/IdeMessenger";
|
||||
import { RootState } from "../../redux/store";
|
||||
import { isJetBrains } from "../../util";
|
||||
import ButtonWithTooltip from "../ButtonWithTooltip";
|
||||
import { CopyButton } from "./CopyButton";
|
||||
|
|
@ -74,6 +76,21 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
|
|||
const ideMessenger = useContext(IdeMessengerContext);
|
||||
const [applying, setApplying] = useState(false);
|
||||
|
||||
const nextCodeBlockToApplyIndex = useSelector(
|
||||
(state: RootState) => state.uiState.nextCodeBlockToApplyIndex,
|
||||
);
|
||||
|
||||
// Handle apply keyboard shortcut
|
||||
// useWebviewListener(
|
||||
// "applyCodeFromChat",
|
||||
// async () => {
|
||||
// await ideMessenger.request("applyToCurrentFile", {
|
||||
// text: "",
|
||||
// });
|
||||
// },
|
||||
// [nextCodeBlockToApplyIndex],
|
||||
// );
|
||||
|
||||
return (
|
||||
<TopDiv>
|
||||
<SecondDiv bottom={props.bottom || false}>
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ function PreWithToolbar(props: { children: any; language: string | null }) {
|
|||
const toolbarBottom = uiConfig?.codeBlockToolbarPosition == "bottom";
|
||||
|
||||
const [hovering, setHovering] = useState(false);
|
||||
|
||||
const [copyValue, setCopyValue] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
|
|
@ -12,12 +12,11 @@ import {
|
|||
vscForeground,
|
||||
} from "..";
|
||||
import { getFontSize } from "../../util";
|
||||
import "./katex.css";
|
||||
import LinkableCode from "./LinkableCode";
|
||||
import "./markdown.css";
|
||||
import PreWithToolbar from "./PreWithToolbar";
|
||||
import { SyntaxHighlightedPre } from "./SyntaxHighlightedPre";
|
||||
import { common } from "lowlight";
|
||||
import "./katex.css";
|
||||
import "./markdown.css";
|
||||
|
||||
const StyledMarkdown = styled.div<{
|
||||
fontSize?: number;
|
||||
|
|
@ -58,9 +57,19 @@ const StyledMarkdown = styled.div<{
|
|||
}
|
||||
|
||||
background-color: ${vscBackground};
|
||||
font-family: var(--vscode-font-family), system-ui, -apple-system,
|
||||
BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell,
|
||||
"Open Sans", "Helvetica Neue", sans-serif;
|
||||
font-family:
|
||||
var(--vscode-font-family),
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
Roboto,
|
||||
Oxygen,
|
||||
Ubuntu,
|
||||
Cantarell,
|
||||
"Open Sans",
|
||||
"Helvetica Neue",
|
||||
sans-serif;
|
||||
font-size: ${(props) => props.fontSize || getFontSize()}px;
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
|
|
|
|||
|
|
@ -1,39 +1,20 @@
|
|||
import { PayloadAction, createSlice } from "@reduxjs/toolkit";
|
||||
type UiState = {
|
||||
bottomMessage: JSX.Element | undefined;
|
||||
bottomMessageCloseTimeout: NodeJS.Timeout | undefined;
|
||||
displayBottomMessageOnBottom: boolean;
|
||||
showDialog: boolean;
|
||||
dialogMessage: string | JSX.Element | undefined;
|
||||
dialogEntryOn: boolean;
|
||||
nextCodeBlockToApplyIndex: number;
|
||||
};
|
||||
|
||||
export const uiStateSlice = createSlice({
|
||||
name: "uiState",
|
||||
initialState: {
|
||||
bottomMessage: undefined,
|
||||
bottomMessageCloseTimeout: undefined,
|
||||
showDialog: false,
|
||||
dialogMessage: "",
|
||||
dialogEntryOn: false,
|
||||
displayBottomMessageOnBottom: true,
|
||||
nextCodeBlockToApplyIndex: -1,
|
||||
} as UiState,
|
||||
reducers: {
|
||||
setBottomMessage: (
|
||||
state,
|
||||
action: PayloadAction<UiState["bottomMessage"]>,
|
||||
) => {
|
||||
state.bottomMessage = action.payload;
|
||||
},
|
||||
setBottomMessageCloseTimeout: (
|
||||
state,
|
||||
action: PayloadAction<UiState["bottomMessageCloseTimeout"]>,
|
||||
) => {
|
||||
if (state.bottomMessageCloseTimeout) {
|
||||
clearTimeout(state.bottomMessageCloseTimeout);
|
||||
}
|
||||
state.bottomMessageCloseTimeout = action.payload;
|
||||
},
|
||||
setDialogMessage: (
|
||||
state,
|
||||
action: PayloadAction<UiState["dialogMessage"]>,
|
||||
|
|
@ -49,21 +30,20 @@ export const uiStateSlice = createSlice({
|
|||
setShowDialog: (state, action: PayloadAction<UiState["showDialog"]>) => {
|
||||
state.showDialog = action.payload;
|
||||
},
|
||||
setDisplayBottomMessageOnBottom: (
|
||||
state,
|
||||
action: PayloadAction<UiState["displayBottomMessageOnBottom"]>,
|
||||
) => {
|
||||
state.displayBottomMessageOnBottom = action.payload;
|
||||
resetNextCodeBlockToApplyIndex: (state) => {
|
||||
state.nextCodeBlockToApplyIndex = -1;
|
||||
},
|
||||
incrementNextCodeBlockToApplyIndex: (state, action) => {
|
||||
state.nextCodeBlockToApplyIndex++;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const {
|
||||
setBottomMessage,
|
||||
setBottomMessageCloseTimeout,
|
||||
setDialogMessage,
|
||||
setDialogEntryOn,
|
||||
setShowDialog,
|
||||
setDisplayBottomMessageOnBottom,
|
||||
resetNextCodeBlockToApplyIndex,
|
||||
incrementNextCodeBlockToApplyIndex,
|
||||
} = uiStateSlice.actions;
|
||||
export default uiStateSlice.reducer;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue