merge main
This commit is contained in:
parent
890c9b3e7b
commit
4a41aa17ac
6 changed files with 48 additions and 72 deletions
|
|
@ -68,7 +68,7 @@ class ApplyToFileHandler(
|
|||
) {
|
||||
val payload = ApplyState(
|
||||
streamId = params.streamId,
|
||||
status = status,
|
||||
status = status.status,
|
||||
numDiffs = numDiffs,
|
||||
filepath = params.filepath,
|
||||
fileContent = params.text,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ import com.intellij.openapi.application.ApplicationManager
|
|||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.editor.SelectionModel
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager
|
||||
import com.intellij.openapi.project.DumbAware
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
package com.github.continuedev.continueintellijextension.editor
|
||||
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.github.continuedev.continueintellijextension.ApplyState
|
||||
import com.github.continuedev.continueintellijextension.ApplyStateStatus
|
||||
import com.github.continuedev.continueintellijextension.StreamDiffLinesPayload
|
||||
import com.github.continuedev.continueintellijextension.UpdateApplyStatePayload
|
||||
import com.github.continuedev.continueintellijextension.services.ContinuePluginService
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.command.undo.UndoManager
|
||||
|
|
@ -56,7 +56,7 @@ class DiffStreamHandler(
|
|||
}
|
||||
|
||||
// Define a single payload and use it for sending
|
||||
val payload = UpdateApplyStatePayload(
|
||||
val payload = ApplyState(
|
||||
streamId = streamId,
|
||||
status = status.status,
|
||||
numDiffs = diffBlocks.size,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.github.continuedev.continueintellijextension
|
||||
|
||||
import com.github.continuedev.continueintellijextension.editor.RangeInFileWithContents
|
||||
import com.google.gson.JsonElement
|
||||
|
||||
enum class ToastType(val value: String) {
|
||||
|
|
@ -214,25 +215,16 @@ data class AcceptRejectDiff(val accepted: Boolean, val stepIndex: Int)
|
|||
|
||||
data class DeleteAtIndex(val index: Int)
|
||||
|
||||
enum class ApplyStateStatus {
|
||||
NOT_STARTED, // Apply state created but not necessarily streaming
|
||||
STREAMING, // Changes are being applied to the file
|
||||
DONE, // All changes have been applied, awaiting user to accept/reject
|
||||
CLOSED; // All changes have been applied. Note that for new files, we immediately set the status to "closed"
|
||||
|
||||
companion object {
|
||||
fun toString(status: ApplyStateStatus): String = when (status) {
|
||||
NOT_STARTED -> "not-started"
|
||||
STREAMING -> "streaming"
|
||||
DONE -> "done"
|
||||
CLOSED -> "closed"
|
||||
}
|
||||
}
|
||||
enum class ApplyStateStatus(val status: String) {
|
||||
NOT_STARTED("not-started"),
|
||||
STREAMING("streaming"),
|
||||
DONE("done"),
|
||||
CLOSED("closed");
|
||||
}
|
||||
|
||||
data class ApplyState(
|
||||
val streamId: String,
|
||||
val status: ApplyStateStatus? = null,
|
||||
val status: String,
|
||||
val numDiffs: Int? = null,
|
||||
val filepath: String? = null,
|
||||
val fileContent: String? = null,
|
||||
|
|
@ -245,3 +237,17 @@ data class HighlightedCodePayload(
|
|||
val shouldRun: Boolean? = null
|
||||
)
|
||||
|
||||
data class StreamDiffLinesPayload(
|
||||
val prefix: String,
|
||||
val highlighted: String,
|
||||
val suffix: String,
|
||||
val input: String,
|
||||
val language: String?,
|
||||
val modelTitle: String?,
|
||||
val includeRulesInSystemMessage: Boolean
|
||||
)
|
||||
|
||||
data class AcceptOrRejectDiffPayload(
|
||||
val filepath: String,
|
||||
val streamId: String? = null
|
||||
)
|
||||
4
extensions/vscode/package-lock.json
generated
4
extensions/vscode/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "1.1.34",
|
||||
"version": "1.1.35",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "1.1.34",
|
||||
"version": "1.1.35",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@continuedev/config-types": "^1.0.14",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { CheckIcon, PlayIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
||||
import { ApplyState } from "core";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getMetaKeyLabel } from "../../../util";
|
||||
import Spinner from "../../gui/Spinner";
|
||||
import { ToolTip } from "../../gui/Tooltip";
|
||||
|
|
@ -16,47 +15,10 @@ interface ApplyActionsProps {
|
|||
}
|
||||
|
||||
export 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) => (
|
||||
<HoverItem
|
||||
data-tooltip-id="codeblock-apply-code-button-tooltip"
|
||||
className="!p-0"
|
||||
>
|
||||
<button
|
||||
data-testid="codeblock-toolbar-apply"
|
||||
className="text-lightgray text-[${vscForeground}] flex cursor-pointer items-center border-none bg-transparent pl-0 text-xs outline-none hover:brightness-125"
|
||||
onClick={props.onClickApply}
|
||||
>
|
||||
<div className="text-lightgray flex items-center gap-1">
|
||||
<PlayIcon className="h-3.5 w-3.5" />
|
||||
<span className="xs:inline hidden">{text}</span>
|
||||
</div>
|
||||
</button>
|
||||
<ToolTip id="codeblock-apply-code-button-tooltip" place="top">
|
||||
{text} Code
|
||||
</ToolTip>
|
||||
</HoverItem>
|
||||
);
|
||||
|
||||
switch (props.applyState ? props.applyState.status : null) {
|
||||
case "streaming":
|
||||
return (
|
||||
|
|
@ -94,21 +56,30 @@ export function ApplyActions(props: ApplyActionsProps) {
|
|||
</div>
|
||||
);
|
||||
case "closed":
|
||||
if (isSuccessful) {
|
||||
if (showApplied || props.disableManualApply) {
|
||||
return (
|
||||
<span className="flex select-none 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>
|
||||
);
|
||||
}
|
||||
return applyButton("Reapply");
|
||||
}
|
||||
default:
|
||||
if (props.disableManualApply) {
|
||||
return null;
|
||||
}
|
||||
return applyButton("Apply");
|
||||
|
||||
return (
|
||||
<HoverItem
|
||||
data-tooltip-id="codeblock-apply-code-button-tooltip"
|
||||
className="!p-0"
|
||||
>
|
||||
<button
|
||||
data-testid="codeblock-toolbar-apply"
|
||||
className="text-lightgray text-[${vscForeground}] flex cursor-pointer items-center border-none bg-transparent pl-0 text-xs outline-none hover:brightness-125"
|
||||
onClick={props.onClickApply}
|
||||
>
|
||||
<div className="text-lightgray flex items-center gap-1">
|
||||
<PlayIcon className="h-3.5 w-3.5" />
|
||||
<span className="xs:inline hidden">Apply</span>
|
||||
</div>
|
||||
</button>
|
||||
<ToolTip id="codeblock-apply-code-button-tooltip" place="top">
|
||||
Apply Code
|
||||
</ToolTip>
|
||||
</HoverItem>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue