Skip to content

Commit 0514824

Browse files
committed
Add code editor to the MCP dialog
1 parent a174751 commit 0514824

File tree

5 files changed

+285
-12
lines changed

5 files changed

+285
-12
lines changed

package-lock.json

Lines changed: 232 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,14 @@
118118
"zip-webpack-plugin": "^4.0.2"
119119
},
120120
"dependencies": {
121+
"@codemirror/lang-json": "^6.0.2",
121122
"@floating-ui/react": "^0.25.1",
122123
"@formkit/auto-animate": "^0.8.2",
123124
"@microsoft/fetch-event-source": "^2.0.1",
124125
"@react-oauth/google": "^0.12.1",
125126
"@reduxjs/toolkit": "^2.5.0",
126127
"@tanstack/react-table": "^8.7.8",
128+
"@uiw/react-codemirror": "^4.23.14",
127129
"@xyflow/react": "^12.6.4",
128130
"allotment": "^1.19.0",
129131
"axios": "^1.8.4",

src/components/Agentic/IncidentTemplate/MCPServerDialog/ServerStep/index.tsx

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import { type ChangeEvent } from "react";
1+
import { json } from "@codemirror/lang-json";
2+
import { oneDark } from "@codemirror/theme-one-dark";
3+
import { EditorView } from "@codemirror/view";
4+
import CodeMirror from "@uiw/react-codemirror";
5+
import { useTheme } from "styled-components";
26
import { sendUserActionTrackingEvent } from "../../../../../utils/actions/sendUserActionTrackingEvent";
7+
import { getCodeFontFamilyRulesValue } from "../../../../common/App/styles";
38
import { NewButton } from "../../../../common/v3/NewButton";
49
import { trackingEvents } from "../../../tracking";
510
import { Footer } from "../Footer";
@@ -25,9 +30,21 @@ export const ServerStep = ({
2530
isLoading,
2631
error
2732
}: ServerStepProps) => {
28-
const handleTextAreaChange = (e: ChangeEvent<HTMLTextAreaElement>) => {
29-
onConnectionSettingsChange(e.target.value);
30-
};
33+
const theme = useTheme();
34+
35+
const codeMirrorTheme = EditorView.theme({
36+
"&": {
37+
padding: "24px",
38+
borderRadius: "8px",
39+
fontFamily: getCodeFontFamilyRulesValue(theme.codeFont),
40+
fontSize: "14px",
41+
fontWeight: "500",
42+
backgroundColor: "#000 !important"
43+
},
44+
".cm-scroller": {
45+
overflow: "auto"
46+
}
47+
});
3148

3249
const handleConnectButtonClick = () => {
3350
sendUserActionTrackingEvent(
@@ -41,10 +58,26 @@ export const ServerStep = ({
4158

4259
return (
4360
<s.Container>
44-
<s.TextArea
61+
<CodeMirror
4562
value={connectionSettings}
63+
onChange={onConnectionSettingsChange}
64+
extensions={[codeMirrorTheme, EditorView.lineWrapping, json()]}
4665
placeholder={placeholderText}
47-
onChange={handleTextAreaChange}
66+
theme={oneDark}
67+
height={"343px"}
68+
basicSetup={{
69+
lineNumbers: false,
70+
foldGutter: false,
71+
allowMultipleSelections: false,
72+
rectangularSelection: false,
73+
highlightActiveLine: false,
74+
highlightSelectionMatches: false,
75+
closeBracketsKeymap: false,
76+
searchKeymap: false,
77+
foldKeymap: false,
78+
completionKeymap: false,
79+
lintKeymap: false
80+
}}
4881
/>
4982
<Footer
5083
isLoading={isLoading}

src/components/Agentic/Sidebar/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const Sidebar = () => {
145145
<s.IncidentsList>
146146
{incidents.map((incident) => (
147147
<s.IncidentItem
148-
key={incident.name}
148+
key={incident.id}
149149
$isSelected={incident.id === incidentId}
150150
$isActive={isIncidentActive(incident)}
151151
onClick={handleIncidentListItemClick(incident.id)}

0 commit comments

Comments
 (0)