feat: move apply accept/reject into lump

This commit is contained in:
Patrick Erichsen 2025-05-22 17:41:11 -07:00
parent 7c72c4af87
commit 071ecb91eb
5 changed files with 69 additions and 31 deletions

View file

@ -34,10 +34,6 @@ export default function AcceptRejectAllButtons({
}
}
if (!pendingApplyStates.length) {
return null;
}
const rejectShortcut = `${getMetaKeyLabel()}⇧⌫`;
const acceptShortcut = `${getMetaKeyLabel()}⇧⏎`;

View file

@ -14,7 +14,7 @@ export function EditOutcomeToolbar() {
const ideMessenger = useContext(IdeMessengerContext);
return (
<div className="text-description-muted gap- flex items-center justify-between py-0.5 text-xs">
<div className="text-description-muted flex items-center justify-between py-0.5 text-xs">
<div className="bg-badge rounded px-1.5">
<span>{`${editApplyState.numDiffs} diff${editApplyState.numDiffs !== 1 ? "s" : ""}`}</span>
</div>

View file

@ -10,6 +10,7 @@ import { isJetBrains } from "../../../../util";
import { BlockSettingsTopToolbar } from "./BlockSettingsTopToolbar";
import { EditOutcomeToolbar } from "./EditOutcomeToolbar";
import { EditToolbar } from "./EditToolbar";
import { PendingApplyStatesToolbar } from "./PendingApplyStatesToolbar";
import { PendingToolCallToolbar } from "./PendingToolCallToolbar";
import { StreamingToolbar } from "./StreamingToolbar";
import { TtsActiveToolbar } from "./TtsActiveToolbar";
@ -24,6 +25,9 @@ export function LumpToolbar() {
const editApplyState = useAppSelector(
(state) => state.editModeState.applyState,
);
const pendingApplyStates = useAppSelector(
(state) => state.session.codeBlockApplyStates.states,
).filter((state) => state.status === "done");
const handleKeyDown = (event: KeyboardEvent) => {
if (toolCallState?.status === "generated") {
@ -49,6 +53,14 @@ export function LumpToolbar() {
};
}, [toolCallState]);
if (isInEdit) {
if (editApplyState.status === "done") {
return <EditOutcomeToolbar />;
}
return <EditToolbar />;
}
if (ttsActive) {
return <TtsActiveToolbar />;
}
@ -61,12 +73,10 @@ export function LumpToolbar() {
return <PendingToolCallToolbar />;
}
if (isInEdit) {
if (editApplyState.status === "done") {
return <EditOutcomeToolbar />;
}
return <EditToolbar />;
if (pendingApplyStates.length > 0) {
return (
<PendingApplyStatesToolbar pendingApplyStates={pendingApplyStates} />
);
}
return <BlockSettingsTopToolbar />;

View file

@ -0,0 +1,44 @@
import { ApplyState } from "core";
import { getUriPathBasename } from "core/util/uri";
import AcceptRejectDiffButtons from "../../../AcceptRejectDiffButtons";
import FileIcon from "../../../FileIcon";
interface PendingApplyStatesToolbarProps {
pendingApplyStates: ApplyState[];
}
export function PendingApplyStatesToolbar({
pendingApplyStates,
}: PendingApplyStatesToolbarProps) {
// Group apply states by filepath
const applyStatesByFilepath = pendingApplyStates.reduce(
(acc, state) => {
const filepath = state.filepath || ""; // Use empty string as fallback
if (!acc[filepath]) {
acc[filepath] = [];
}
acc[filepath].push(state);
return acc;
},
{} as Record<string, ApplyState[]>,
);
return (
<div className="flex flex-col gap-2">
{Object.entries(applyStatesByFilepath).map(([filepath, states]) => (
<div key={filepath} className="flex justify-between gap-3">
{filepath && (
<span className="bg-badge flex items-center gap-1 rounded px-0.5">
<FileIcon filename={filepath} height="18px" width="18px" />
{getUriPathBasename(filepath)}
</span>
)}
<AcceptRejectDiffButtons
applyStates={states}
onAcceptOrReject={async () => {}}
/>
</div>
))}
</div>
);
}

View file

@ -54,7 +54,6 @@ import {
incrementFreeTrialCount,
} from "../../util/freeTrial";
import AcceptRejectDiffButtons from "../../components/AcceptRejectDiffButtons";
import { getLocalStorage, setLocalStorage } from "../../util/localStorage";
import { EmptyChatBody } from "./EmptyChatBody";
import { ExploreDialogWatcher } from "./ExploreDialogWatcher";
@ -119,9 +118,6 @@ export function Chat() {
const toolCallState = useAppSelector(selectCurrentToolCall);
const mode = useAppSelector((store) => store.session.mode);
const isInEdit = useAppSelector((store) => store.session.isInEdit);
const applyStates = useAppSelector(
(state) => state.session.codeBlockApplyStates.states,
);
const lastSessionId = useAppSelector((state) => state.session.lastSessionId);
const hasDismissedExploreDialog = useAppSelector(
@ -382,22 +378,14 @@ export function Chat() {
))}
</StepsDiv>
<div className={"relative"}>
<>
{!isStreaming && !isInEdit && (
<AcceptRejectDiffButtons
applyStates={applyStates}
onAcceptOrReject={async () => {}}
/>
)}
<ContinueInputBox
isMainInput
isLastUserInput={false}
onEnter={(editorState, modifiers, editor) =>
sendInput(editorState, modifiers, undefined, editor)
}
inputId={MAIN_EDITOR_INPUT_ID}
/>
</>
<ContinueInputBox
isMainInput
isLastUserInput={false}
onEnter={(editorState, modifiers, editor) =>
sendInput(editorState, modifiers, undefined, editor)
}
inputId={MAIN_EDITOR_INPUT_ID}
/>
<div
style={{