diff --git a/app/src/components/code/styles.tsx b/app/src/components/code/styles.tsx
index 3ecac50b9a..c8c3293326 100644
--- a/app/src/components/code/styles.tsx
+++ b/app/src/components/code/styles.tsx
@@ -1,9 +1,6 @@
import { css } from "@emotion/react";
export const readOnlyCodeMirrorCSS = css`
- .cm-content {
- padding: var(--ac-global-dimension-static-size-200) 0;
- }
.cm-editor,
.cm-gutters {
background-color: transparent;
diff --git a/app/src/components/markdown/MarkdownBlock.tsx b/app/src/components/markdown/MarkdownBlock.tsx
index 0e59d5e666..7611faa6ee 100644
--- a/app/src/components/markdown/MarkdownBlock.tsx
+++ b/app/src/components/markdown/MarkdownBlock.tsx
@@ -3,6 +3,8 @@ import Markdown from "react-markdown";
import remarkGfm from "remark-gfm";
import { css } from "@emotion/react";
+import { PrettyText } from "../utility";
+
import { useMarkdownMode } from "./MarkdownDisplayContext";
import { MarkdownDisplayMode } from "./types";
@@ -26,15 +28,7 @@ export function MarkdownBlock({
{children}
) : (
-
- {children}
-
+ {children}
);
}
diff --git a/app/src/components/utility/PrettyText.tsx b/app/src/components/utility/PrettyText.tsx
new file mode 100644
index 0000000000..eef53f1f8a
--- /dev/null
+++ b/app/src/components/utility/PrettyText.tsx
@@ -0,0 +1,27 @@
+import React from "react";
+import { css } from "@emotion/react";
+
+import { JSONBlock } from "@phoenix/components/code";
+import { usePrettyText } from "@phoenix/hooks/usePrettyText";
+import { assertUnreachable } from "@phoenix/typeUtils";
+
+export function PrettyText({ children }: { children: string }) {
+ const { text, textType } = usePrettyText(children);
+ if (textType === "string") {
+ return (
+
+ {text}
+
+ );
+ }
+ if (textType === "json") {
+ return ;
+ }
+ assertUnreachable(textType);
+}
diff --git a/app/src/components/utility/index.tsx b/app/src/components/utility/index.tsx
new file mode 100644
index 0000000000..02c9b66b07
--- /dev/null
+++ b/app/src/components/utility/index.tsx
@@ -0,0 +1 @@
+export * from "./PrettyText";
diff --git a/app/src/hooks/usePrettyText.ts b/app/src/hooks/usePrettyText.ts
new file mode 100644
index 0000000000..c62db43f9d
--- /dev/null
+++ b/app/src/hooks/usePrettyText.ts
@@ -0,0 +1,21 @@
+import { useMemo } from "react";
+
+type TextType = "string" | "json";
+/**
+ * A hook that takes in text, detects if it is a JSON string, and formats it
+ * @param text
+ * @returns formatted text
+ */
+export function usePrettyText(text: string): {
+ text: string;
+ textType: TextType;
+} {
+ return useMemo(() => {
+ try {
+ const parsed = JSON.parse(text);
+ return { text: JSON.stringify(parsed, null, 2), textType: "json" };
+ } catch (e) {
+ return { text, textType: "string" };
+ }
+ }, [text]);
+}
diff --git a/app/src/pages/playground/PlaygroundOutput.tsx b/app/src/pages/playground/PlaygroundOutput.tsx
index 968eff7c41..61034ba041 100644
--- a/app/src/pages/playground/PlaygroundOutput.tsx
+++ b/app/src/pages/playground/PlaygroundOutput.tsx
@@ -7,14 +7,13 @@ import {
requestSubscription,
} from "relay-runtime";
-import { Card, Flex, View } from "@arizeai/components";
+import { Card, View } from "@arizeai/components";
import { Loading } from "@phoenix/components";
import {
ConnectedMarkdownBlock,
ConnectedMarkdownModeRadioGroup,
MarkdownDisplayProvider,
- useMarkdownMode,
} from "@phoenix/components/markdown";
import { useNotifyError } from "@phoenix/contexts";
import { useCredentialsContext } from "@phoenix/contexts/CredentialsContext";
@@ -84,7 +83,6 @@ function PlaygroundOutputMessage({
}) {
const { role, content, toolCalls } = message;
const styles = useChatMessageStyles(role);
- const { mode: markdownMode } = useMarkdownMode();
return (
}
>
{content != null && !Array.isArray(content) && (
-
- {markdownMode === "text" ? (
- content
- ) : (
-
- {content}
-
- )}
-
+ {content}
)}
{toolCalls && toolCalls.length > 0
? toolCalls.map((toolCall) => {
diff --git a/app/src/pages/trace/SpanDetails.tsx b/app/src/pages/trace/SpanDetails.tsx
index ff2132ae76..6c4cc1afde 100644
--- a/app/src/pages/trace/SpanDetails.tsx
+++ b/app/src/pages/trace/SpanDetails.tsx
@@ -310,7 +310,6 @@ export function SpanDetails({
{...defaultCardProps}
titleExtra={attributesContextualHelp}
extra={}
- bodyStyle={{ padding: 0 }}
>
{span.attributes}
@@ -1587,7 +1586,6 @@ function SpanIO({ span }: { span: Span }) {
title="All Attributes"
titleExtra={attributesContextualHelp}
{...defaultCardProps}
- bodyStyle={{ padding: 0 }}
extra={}
>
{span.attributes}
@@ -1598,9 +1596,6 @@ function SpanIO({ span }: { span: Span }) {
}
const codeMirrorCSS = css`
- .cm-content {
- padding: var(--ac-global-dimension-static-size-200) 0;
- }
.cm-editor,
.cm-gutters {
background-color: transparent;