Update CodeBlockToolbar.tsx

This commit is contained in:
Test 2024-11-06 13:46:50 -08:00
parent 2e5b5794e9
commit ef2f20fac5

View file

@ -131,7 +131,6 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
const defaultModel = useSelector(defaultModelSelector);
const isTerminal = isTerminalCodeBlock(props.language, props.text);
const [isCopied, setIsCopied] = useState(false);
const [isApplying, setIsApplying] = useState(false);
const streamIdRef = useRef<string | null>(null);
if (streamIdRef.current === null) {
@ -149,10 +148,11 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
useWebviewListener(
"applyCodeFromChat",
async () => {
await ideMessenger.request("applyToCurrentFile", {
await ideMessenger.request("applyToFile", {
curSelectedModelTitle: defaultModel.title,
text: props.text,
streamId: streamIdRef.current,
filepath: props.filepath,
});
dispatch(incrementNextCodeBlockToApplyIndex({}));
},
@ -172,8 +172,6 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
}
async function onClickApply() {
if (isApplying) return;
if (isTerminal) {
await ideMessenger.ide.runCommand(getTerminalCommand(props.text));
return;
@ -232,7 +230,6 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
{!isJetBrains() && isTerminal && (
<ButtonWithTooltip
text="Run in terminal"
disabled={isApplying}
style={{ backgroundColor: vscEditorBackground }}
onClick={onClickApply}
>
@ -240,15 +237,11 @@ function CodeBlockToolBar(props: CodeBlockToolBarProps) {
</ButtonWithTooltip>
)}
<ButtonWithTooltip
text={isApplying ? "Applying..." : "Apply"}
text="Apply"
style={{ backgroundColor: vscEditorBackground }}
onClick={onClickApply}
>
{isApplying ? (
<CheckIcon className="h-4 w-4 text-green-400" />
) : (
<PlayIcon className="h-4 w-4 text-gray-400" />
)}
<PlayIcon className="h-4 w-4 text-gray-400" />
</ButtonWithTooltip>
<ButtonWithTooltip
text="Insert at cursor"