feat: consolidate StepContainer
This commit is contained in:
parent
906fbd82e0
commit
58d9eb7a7e
27 changed files with 132 additions and 34 deletions
|
|
@ -1,18 +1,18 @@
|
|||
import FileIcon from "../FileIcon";
|
||||
import {
|
||||
ChevronDownIcon,
|
||||
ChevronRightIcon,
|
||||
XMarkIcon,
|
||||
} from "@heroicons/react/24/outline";
|
||||
import { useState } from "react";
|
||||
import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview";
|
||||
import { getMarkdownLanguageTagForFile } from "core/util";
|
||||
import styled from "styled-components";
|
||||
import { CodeToEdit } from "core";
|
||||
import { getMarkdownLanguageTagForFile } from "core/util";
|
||||
import {
|
||||
getLastNUriRelativePathParts,
|
||||
getUriPathBasename,
|
||||
} from "core/util/uri";
|
||||
import { useState } from "react";
|
||||
import styled from "styled-components";
|
||||
import FileIcon from "../FileIcon";
|
||||
import StyledMarkdownPreview from "../StepContainer/StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
|
||||
export interface CodeToEditListItemProps {
|
||||
code: CodeToEdit;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ import {
|
|||
vscQuickInputBackground,
|
||||
} from "..";
|
||||
import { getFontSize } from "../../util";
|
||||
import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview";
|
||||
import StyledMarkdownPreview from "./StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
|
||||
interface ReasoningProps {
|
||||
item: ChatHistoryItem;
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ import { useAppSelector } from "../../redux/hooks";
|
|||
import { selectUIConfig } from "../../redux/slices/configSlice";
|
||||
import { deleteMessage } from "../../redux/slices/sessionSlice";
|
||||
import { getFontSize } from "../../util";
|
||||
import StyledMarkdownPreview from "../markdown/StyledMarkdownPreview";
|
||||
import Reasoning from "./Reasoning";
|
||||
import ResponseActions from "./ResponseActions";
|
||||
import StyledMarkdownPreview from "./StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
import ThinkingIndicator from "./ThinkingIndicator";
|
||||
|
||||
interface StepContainerProps {
|
||||
|
|
@ -43,9 +43,6 @@ export default function StepContainer(props: StepContainerProps) {
|
|||
historyItemAfterThis?.message.role === "thinking";
|
||||
const hideActions = hideActionSpace || (isStreaming && props.isLast);
|
||||
|
||||
// const isStepAheadOfCurCheckpoint =
|
||||
// isInEditMode && Math.floor(props.index / 2) > curCheckpointIndex;
|
||||
|
||||
useEffect(() => {
|
||||
if (!isStreaming) {
|
||||
const content = renderChatMessage(props.item.message).trim();
|
||||
|
|
@ -83,9 +80,7 @@ export default function StepContainer(props: StepContainerProps) {
|
|||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
// className={isStepAheadOfCurCheckpoint ? "opacity-25" : "relative"}
|
||||
>
|
||||
<div>
|
||||
<ContentDiv>
|
||||
{uiConfig?.displayRawMarkdown ? (
|
||||
<pre
|
||||
|
|
|
|||
|
|
@ -0,0 +1,107 @@
|
|||
import { CheckIcon, PlayIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { ApplyState } from "core";
|
||||
import { useEffect, useState } from "react";
|
||||
import { lightGray, vscForeground } from "../..";
|
||||
import { getMetaKeyLabel } from "../../../util";
|
||||
import Spinner from "../../gui/Spinner";
|
||||
import { ToolbarButtonWithTooltip } from "./ToolbarButtonWithTooltip";
|
||||
|
||||
interface ApplyActionsProps {
|
||||
disableManualApply?: boolean;
|
||||
applyState?: ApplyState;
|
||||
onClickAccept: () => void;
|
||||
onClickReject: () => void;
|
||||
onClickApply: () => void;
|
||||
}
|
||||
|
||||
export default function ApplyActions(props: ApplyActionsProps) {
|
||||
const [hasRejected, setHasRejected] = useState(false);
|
||||
const [showApplied, setShowApplied] = useState(false);
|
||||
const isClosed = props.applyState?.status === "closed";
|
||||
const isSuccessful = !hasRejected && props.applyState?.numDiffs === 0;
|
||||
|
||||
useEffect(() => {
|
||||
if (isClosed && isSuccessful) {
|
||||
setShowApplied(true);
|
||||
const timer = setTimeout(() => {
|
||||
setShowApplied(false);
|
||||
}, 3_000);
|
||||
return () => clearTimeout(timer);
|
||||
}
|
||||
}, [isClosed, isSuccessful]);
|
||||
|
||||
function onClickReject() {
|
||||
props.onClickReject();
|
||||
setHasRejected(true);
|
||||
}
|
||||
|
||||
const applyButton = (text: string) => (
|
||||
<button
|
||||
className={`flex items-center border-none bg-transparent pl-0 text-xs text-[${vscForeground}] cursor-pointer outline-none hover:brightness-125`}
|
||||
onClick={props.onClickApply}
|
||||
style={{ color: lightGray }}
|
||||
>
|
||||
<div className="flex items-center gap-1 text-gray-400">
|
||||
<PlayIcon className="h-3.5 w-3.5" />
|
||||
<span className="xs:inline hidden">{text}</span>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
|
||||
switch (props.applyState ? props.applyState.status : null) {
|
||||
case "streaming":
|
||||
return (
|
||||
<div className="flex items-center rounded bg-zinc-700 pl-2 pr-1">
|
||||
<span className="inline-flex w-min items-center gap-2 text-center text-xs text-gray-400">
|
||||
Applying
|
||||
<Spinner />
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
case "done":
|
||||
return (
|
||||
<div className="flex items-center rounded bg-zinc-700 px-1.5 sm:gap-1">
|
||||
<span className="max-xs:hidden text-center text-xs text-gray-400">
|
||||
{`${props.applyState?.numDiffs === 1 ? "1 diff" : `${props.applyState?.numDiffs} diffs`}`}
|
||||
<span className="max-md:hidden">{` remaining`}</span>
|
||||
</span>
|
||||
|
||||
<div className="flex">
|
||||
<ToolbarButtonWithTooltip
|
||||
onClick={onClickReject}
|
||||
tooltipContent={`Reject all (${getMetaKeyLabel()}⇧⌫)`}
|
||||
>
|
||||
<XMarkIcon className="h-3.5 w-3.5 text-red-600 hover:brightness-125" />
|
||||
</ToolbarButtonWithTooltip>
|
||||
|
||||
<ToolbarButtonWithTooltip
|
||||
onClick={props.onClickAccept}
|
||||
tooltipContent={`Accept all (${getMetaKeyLabel()}⇧⏎)`}
|
||||
>
|
||||
<CheckIcon className="h-3.5 w-3.5 text-green-600 hover:brightness-125" />
|
||||
</ToolbarButtonWithTooltip>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
case "closed":
|
||||
if (!hasRejected && props.applyState?.numDiffs === 0) {
|
||||
if (showApplied) {
|
||||
return (
|
||||
<span className="flex items-center rounded bg-zinc-700 text-slate-400 max-sm:px-0.5 sm:pl-2">
|
||||
<span className="max-sm:hidden">Applied</span>
|
||||
<CheckIcon className="h-3.5 w-3.5 hover:brightness-125 sm:px-1" />
|
||||
</span>
|
||||
);
|
||||
}
|
||||
if (props.disableManualApply) {
|
||||
return null;
|
||||
}
|
||||
return applyButton("Reapply");
|
||||
}
|
||||
default:
|
||||
if (props.disableManualApply) {
|
||||
return null;
|
||||
}
|
||||
return applyButton("Apply");
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ import {
|
|||
selectIsInEditMode,
|
||||
} from "../../../redux/slices/sessionSlice";
|
||||
import { getFontSize } from "../../../util";
|
||||
import { isTerminalCodeBlock } from "../utils";
|
||||
import { isTerminalCodeBlock } from "../StyledMarkdownPreview/utils";
|
||||
import ApplyActions from "./ApplyActions";
|
||||
import CopyButton from "./CopyButton";
|
||||
import { FileInfo } from "./FileInfo";
|
||||
|
|
@ -12,19 +12,19 @@ import {
|
|||
vscBackground,
|
||||
vscEditorBackground,
|
||||
vscForeground,
|
||||
} from "..";
|
||||
import useUpdatingRef from "../../hooks/useUpdatingRef";
|
||||
import { useAppSelector } from "../../redux/hooks";
|
||||
import { selectUIConfig } from "../../redux/slices/configSlice";
|
||||
import { getContextItemsFromHistory } from "../../redux/thunks/updateFileSymbols";
|
||||
import { getFontSize } from "../../util";
|
||||
import { ToolTip } from "../gui/Tooltip";
|
||||
import FilenameLink from "./FilenameLink";
|
||||
} from "../..";
|
||||
import useUpdatingRef from "../../../hooks/useUpdatingRef";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
import { selectUIConfig } from "../../../redux/slices/configSlice";
|
||||
import { getContextItemsFromHistory } from "../../../redux/thunks/updateFileSymbols";
|
||||
import { getFontSize } from "../../../util";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
import FilenameLink from "../FilenameLink";
|
||||
import StepContainerPreToolbar from "../StepContainerPreToolbar";
|
||||
import SymbolLink from "../SymbolLink";
|
||||
import { SyntaxHighlightedPre } from "../SyntaxHighlightedPre";
|
||||
import "./katex.css";
|
||||
import "./markdown.css";
|
||||
import StepContainerPreToolbar from "./StepContainerPreToolbar";
|
||||
import SymbolLink from "./SymbolLink";
|
||||
import { SyntaxHighlightedPre } from "./SyntaxHighlightedPre";
|
||||
import { isSymbolNotRif, matchCodeToSymbolOrFile } from "./utils";
|
||||
import { fixDoubleDollarNewLineLatex } from "./utils/fixDoubleDollarLatex";
|
||||
import { patchNestedMarkdown } from "./utils/patchNestedMarkdown";
|
||||
|
|
@ -23,10 +23,6 @@ const commonTerminalCommands = [
|
|||
"bundle",
|
||||
];
|
||||
|
||||
export function getTerminalCommand(text: string): string {
|
||||
return text.startsWith("$ ") ? text.slice(2) : text;
|
||||
}
|
||||
|
||||
export function isTerminalCodeBlock(
|
||||
language: string | undefined | null,
|
||||
text: string,
|
||||
|
|
@ -6,7 +6,7 @@ import { useContext, useMemo } from "react";
|
|||
import { vscBadgeBackground } from "../../../..";
|
||||
import { IdeMessengerContext } from "../../../../../context/IdeMessenger";
|
||||
import FileIcon from "../../../../FileIcon";
|
||||
import StyledMarkdownPreview from "../../../../markdown/StyledMarkdownPreview";
|
||||
import StyledMarkdownPreview from "../../../../StepContainer/StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
import { ExpandableToolbarPreview } from "../../components/ExpandableToolbarPreview";
|
||||
import { NodeViewWrapper } from "../../components/NodeViewWrapper";
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { useEffect, useState } from "react";
|
|||
import styled from "styled-components";
|
||||
import { defaultBorderRadius, lightGray, vscBackground } from "../..";
|
||||
import { getFontSize } from "../../../util";
|
||||
import StyledMarkdownPreview from "../../markdown/StyledMarkdownPreview";
|
||||
import StyledMarkdownPreview from "../../StepContainer/StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
|
||||
const SpoilerButton = styled.div`
|
||||
background-color: ${vscBackground};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { getMarkdownLanguageTagForFile } from "core/util";
|
||||
import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview";
|
||||
import StyledMarkdownPreview from "../../../components/StepContainer/StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
|
||||
interface CreateFileToolCallProps {
|
||||
relativeFilepath: string;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { getMarkdownLanguageTagForFile } from "core/util";
|
||||
import { useMemo } from "react";
|
||||
import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview";
|
||||
import AcceptRejectAllButtons from "../../../components/StepContainer/AcceptRejectAllButtons";
|
||||
import StyledMarkdownPreview from "../../../components/StepContainer/StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
import { useAppSelector } from "../../../redux/hooks";
|
||||
|
||||
type EditToolCallProps = {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { ToolCallState } from "core";
|
||||
import StyledMarkdownPreview from "../../../components/markdown/StyledMarkdownPreview";
|
||||
import StyledMarkdownPreview from "../../../components/StepContainer/StyledMarkdownPreview/StyledMarkdownPreview";
|
||||
|
||||
interface RunTerminalCommandToolCallProps {
|
||||
command: string;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue