Skip to content

Commit b59b766

Browse files
feat: add JSON syntax highlighting to Raw Message JSON modal (#183)
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 6e08f22 commit b59b766

2 files changed

Lines changed: 19 additions & 10 deletions

File tree

frontend/src/components/conversation/MessageActions.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import React from "react";
2+
import { useTranslation } from "react-i18next";
23
import { Button } from "../ui/button";
34
import {
45
Dialog,
@@ -9,6 +10,7 @@ import {
910
} from "../ui/dialog";
1011
import { Info } from "lucide-react";
1112
import { type ToolCall } from "../../utils/toolCallParser";
13+
import { CodeMirrorViewer } from "../common/CodeMirrorViewer";
1214

1315
interface Message {
1416
id: string;
@@ -24,6 +26,8 @@ interface MessageActionsProps {
2426
}
2527

2628
export const MessageActions: React.FC<MessageActionsProps> = ({ message }) => {
29+
const { t } = useTranslation();
30+
2731
return (
2832
<div className="mt-2 flex justify-start">
2933
<Dialog>
@@ -34,17 +38,19 @@ export const MessageActions: React.FC<MessageActionsProps> = ({ message }) => {
3438
className="h-6 px-2 text-xs text-muted-foreground hover:text-foreground"
3539
>
3640
<Info className="h-3 w-3 mr-1" />
37-
Raw JSON
41+
{t("dashboard.rawJsonButton")}
3842
</Button>
3943
</DialogTrigger>
4044
<DialogContent className="max-w-2xl max-h-[80vh] overflow-y-auto">
4145
<DialogHeader>
42-
<DialogTitle>Message Raw JSON</DialogTitle>
46+
<DialogTitle>{t("dashboard.rawJsonTitle")}</DialogTitle>
4347
</DialogHeader>
44-
<div className="bg-gray-50 dark:bg-gray-900 p-4 rounded-lg">
45-
<pre className="text-xs whitespace-pre-wrap break-all font-mono">
46-
{JSON.stringify(message, null, 2)}
47-
</pre>
48+
<div className="rounded-lg overflow-hidden border border-border">
49+
<CodeMirrorViewer
50+
code={JSON.stringify(message, null, 2)}
51+
language="json"
52+
readOnly={true}
53+
/>
4854
</div>
4955
</DialogContent>
5056
</Dialog>

frontend/src/pages/HomeDashboard.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
} from "../components/ui/card";
2626
import { Info, UserRound, FolderKanban } from "lucide-react";
2727
import { ModelContextProtocol } from "../components/common/ModelContextProtocol";
28+
import { CodeMirrorViewer } from "../components/common/CodeMirrorViewer";
2829
import { getBackendText } from "../utils/backendText";
2930
import { useBackend } from "../contexts/BackendContext";
3031
import { GeminiMessagePart } from "../types";
@@ -192,10 +193,12 @@ ${part.thinking}`;
192193
{t("dashboard.rawJsonTitle")}
193194
</DialogTitle>
194195
</DialogHeader>
195-
<div className="bg-gray-50 dark:bg-gray-900 p-4 rounded-lg">
196-
<pre className="text-xs whitespace-pre-wrap break-all font-mono">
197-
{JSON.stringify(message, null, 2)}
198-
</pre>
196+
<div className="rounded-lg overflow-hidden border border-border">
197+
<CodeMirrorViewer
198+
code={JSON.stringify(message, null, 2)}
199+
language="json"
200+
readOnly={true}
201+
/>
199202
</div>
200203
</DialogContent>
201204
</Dialog>

0 commit comments

Comments
 (0)