Skip to content

Commit bc4bb89

Browse files
Merge pull request #5801 from continuedev/pe/remove-edit-mode
feat: remove edit as a mode
2 parents 781c008 + 3d407ee commit bc4bb89

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+745
-804
lines changed

core/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ export interface PromptLog {
423423
completion: string;
424424
}
425425

426-
export type MessageModes = "chat" | "edit" | "agent";
426+
export type MessageModes = "chat" | "agent";
427427

428428
export type ToolStatus =
429429
| "generating"

gui/src/components/AcceptRejectDiffButtons.tsx

Lines changed: 15 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ApplyState } from "core";
33
import { useContext } from "react";
44
import { IdeMessengerContext } from "../context/IdeMessenger";
55
import { getMetaKeyLabel } from "../util";
6-
import { useFontSize } from "./ui/font";
6+
import { ToolTip } from "./gui/Tooltip";
77

88
export interface AcceptRejectAllButtonsProps {
99
applyStates: ApplyState[];
@@ -21,8 +21,6 @@ export default function AcceptRejectAllButtons({
2121
);
2222
const ideMessenger = useContext(IdeMessengerContext);
2323

24-
const tinyFont = useFontSize(-3);
25-
2624
async function handleAcceptOrReject(status: AcceptOrRejectOutcome) {
2725
for (const { filepath = "", streamId } of pendingApplyStates) {
2826
ideMessenger.post(status, {
@@ -36,54 +34,43 @@ export default function AcceptRejectAllButtons({
3634
}
3735
}
3836

39-
if (!pendingApplyStates.length) {
40-
return null;
41-
}
37+
const rejectShortcut = `${getMetaKeyLabel()}⇧⌫`;
38+
const acceptShortcut = `${getMetaKeyLabel()}⇧⏎`;
4239

4340
return (
4441
<div
45-
className="flex flex-row items-center justify-evenly gap-2 p-1 px-3"
42+
className="flex flex-row items-center justify-evenly gap-3 px-3"
4643
data-testid="accept-reject-all-buttons"
4744
>
4845
<button
49-
className="flex cursor-pointer flex-row flex-wrap justify-center gap-1 border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
46+
className="text-foreground flex cursor-pointer flex-row flex-wrap justify-center gap-1 border-none bg-transparent p-0 text-xs opacity-80 hover:opacity-100 hover:brightness-125"
5047
onClick={() => handleAcceptOrReject("rejectDiff")}
5148
data-testid="edit-reject-button"
49+
data-tooltip-id="reject-shortcut"
50+
data-tooltip-content={`Reject All (${rejectShortcut})`}
5251
>
5352
<div className="flex flex-row items-center gap-1">
54-
<XMarkIcon className="h-4 w-4 text-red-600" />
53+
<XMarkIcon className="text-error h-4 w-4" />
5554
<span>Reject</span>
5655
<span className="xs:inline-block hidden">All</span>
5756
</div>
58-
59-
<span
60-
className="xs:inline-block hidden text-gray-400"
61-
style={{
62-
fontSize: tinyFont,
63-
}}
64-
>
65-
({getMetaKeyLabel()}⇧⌫)
66-
</span>
6757
</button>
58+
<ToolTip id="reject-shortcut" />
59+
6860
<button
69-
className="flex cursor-pointer flex-row flex-wrap justify-center gap-1 border-none bg-transparent px-2 py-1 text-xs text-gray-300 opacity-80 hover:opacity-100 hover:brightness-125"
61+
className="text-foreground flex cursor-pointer flex-row flex-wrap justify-center gap-1 border-none bg-transparent p-0 text-xs opacity-80 hover:opacity-100 hover:brightness-125"
7062
onClick={() => handleAcceptOrReject("acceptDiff")}
7163
data-testid="edit-accept-button"
64+
data-tooltip-id="accept-shortcut"
65+
data-tooltip-content={`Accept All (${acceptShortcut})`}
7266
>
7367
<div className="flex flex-row items-center gap-1">
74-
<CheckIcon className="h-4 w-4 text-green-600" />
68+
<CheckIcon className="text-success h-4 w-4" />
7569
<span>Accept</span>
7670
<span className="xs:inline-block hidden">All</span>
7771
</div>
78-
<span
79-
className="xs:inline-block hidden text-gray-400"
80-
style={{
81-
fontSize: tinyFont,
82-
}}
83-
>
84-
({getMetaKeyLabel()}⇧⏎)
85-
</span>
8672
</button>
73+
<ToolTip id="accept-shortcut" />
8774
</div>
8875
);
8976
}

gui/src/components/History/HistoryTableRow.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { useNavigate } from "react-router-dom";
66
import { Input } from "..";
77
import { IdeMessengerContext } from "../../context/IdeMessenger";
88
import { useAppDispatch, useAppSelector } from "../../redux/hooks";
9-
import { exitEditMode } from "../../redux/thunks/editMode";
9+
import { exitEdit } from "../../redux/thunks/edit";
1010
import {
1111
deleteSession,
1212
getSession,
@@ -69,7 +69,7 @@ export function HistoryTableRow({
6969
data-testid={`history-row-${index}`}
7070
className="hover:bg-vsc-editor-background relative box-border flex cursor-pointer overflow-hidden rounded-lg p-3"
7171
onClick={async () => {
72-
await dispatch(exitEditMode({}));
72+
await dispatch(exitEdit({}));
7373
if (sessionMetadata.sessionId !== currentSessionId) {
7474
await dispatch(
7575
loadSession({

gui/src/components/Layout.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import { IdeMessengerContext } from "../context/IdeMessenger";
77
import { LocalStorageProvider } from "../context/LocalStorage";
88
import { useWebviewListener } from "../hooks/useWebviewListener";
99
import { useAppDispatch, useAppSelector } from "../redux/hooks";
10-
import { setCodeToEdit } from "../redux/slices/editModeState";
10+
import { setCodeToEdit } from "../redux/slices/editState";
1111
import { setShowDialog } from "../redux/slices/uiSlice";
12-
import { enterEditMode, exitEditMode } from "../redux/thunks/editMode";
12+
import { enterEdit, exitEdit } from "../redux/thunks/edit";
1313
import { saveCurrentSession } from "../redux/thunks/session";
1414
import { fontSize, isMetaEquivalentKeyPressed } from "../util";
1515
import { incrementFreeTrialCount } from "../util/freeTrial";
@@ -48,14 +48,14 @@ const Layout = () => {
4848
const dialogMessage = useAppSelector((state) => state.ui.dialogMessage);
4949

5050
const showDialog = useAppSelector((state) => state.ui.showDialog);
51-
const mode = useAppSelector((state) => state.session.mode);
51+
const isInEdit = useAppSelector((store) => store.session.isInEdit);
5252

5353
useWebviewListener(
5454
"newSession",
5555
async () => {
5656
navigate(ROUTES.HOME);
57-
if (mode === "edit") {
58-
await dispatch(exitEditMode({}));
57+
if (isInEdit) {
58+
await dispatch(exitEdit({}));
5959
} else {
6060
await dispatch(
6161
saveCurrentSession({
@@ -65,7 +65,7 @@ const Layout = () => {
6565
);
6666
}
6767
},
68-
[mode],
68+
[isInEdit],
6969
);
7070

7171
useWebviewListener(
@@ -81,9 +81,9 @@ const Layout = () => {
8181
"focusContinueInputWithNewSession",
8282
async () => {
8383
navigate(ROUTES.HOME);
84-
if (mode === "edit") {
84+
if (isInEdit) {
8585
await dispatch(
86-
exitEditMode({
86+
exitEdit({
8787
openNewSession: true,
8888
}),
8989
);
@@ -96,7 +96,7 @@ const Layout = () => {
9696
);
9797
}
9898
},
99-
[location.pathname, mode],
99+
[location.pathname, isInEdit],
100100
location.pathname === ROUTES.HOME,
101101
);
102102

@@ -148,7 +148,7 @@ const Layout = () => {
148148
"focusEdit",
149149
async () => {
150150
await ideMessenger.request("edit/addCurrentSelection", undefined);
151-
await dispatch(enterEditMode({}));
151+
await dispatch(enterEdit({ editorContent: mainEditor?.getJSON() }));
152152
mainEditor?.commands.focus();
153153
},
154154
[ideMessenger, mainEditor],
@@ -169,7 +169,7 @@ const Layout = () => {
169169
useWebviewListener(
170170
"exitEditMode",
171171
async () => {
172-
await dispatch(exitEditMode({}));
172+
await dispatch(exitEdit({}));
173173
},
174174
[],
175175
);
@@ -181,7 +181,7 @@ const Layout = () => {
181181
if (selection) {
182182
// Copy to clipboard
183183
setTimeout(() => {
184-
navigator.clipboard.writeText(selection);
184+
void navigator.clipboard.writeText(selection);
185185
}, 100);
186186
}
187187
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { ChatBubbleLeftIcon, SparklesIcon } from "@heroicons/react/24/outline";
2+
import { MessageModes } from "core";
3+
4+
interface ModeIconProps {
5+
mode: MessageModes;
6+
className?: string;
7+
}
8+
9+
export function ModeIcon({
10+
mode,
11+
className = "xs:h-3 xs:w-3 h-3 w-3",
12+
}: ModeIconProps) {
13+
switch (mode) {
14+
case "agent":
15+
return <SparklesIcon className={className} />;
16+
case "chat":
17+
return <ChatBubbleLeftIcon className={className} />;
18+
}
19+
}

0 commit comments

Comments
 (0)