Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add<SyntaxHighlighter /> for AI BridgeToken Usages Metadata#21318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
jakehwll wants to merge2 commits intojakehwll/ai-bridge-request-logs-prompt-collapse
base:jakehwll/ai-bridge-request-logs-prompt-collapse
Choose a base branch
Loading
fromjakehwll/ai-bridge-request-logs-token-usage-formatting
Draft
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
feat: implement<Codeblock /> component
  • Loading branch information
@jakehwll
jakehwll committedDec 18, 2025
commitd90a6caf00d12bcfba83a23e1583b164f1f33cfd
49 changes: 49 additions & 0 deletionssite/src/components/Codeblock/Codeblock.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
import type React from "react";
import { useEffect, useState } from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import {
darcula,
dracula,
} from "react-syntax-highlighter/dist/cjs/styles/prism";

export const Codeblock = ({
children,
...props
}: React.ComponentProps<typeof SyntaxHighlighter>) => {
const [isDark, setIsDark] = useState(() => {
if (typeof document === "undefined") {
return true;
}
return document.documentElement.classList.contains("dark");
});

useEffect(() => {
if (typeof document === "undefined") {
return;
}
const root = document.documentElement;
const update = () => setIsDark(root.classList.contains("dark"));
update();

const mo = new MutationObserver(update);
mo.observe(root, { attributes: true, attributeFilter: ["class"] });
return () => {
mo.disconnect();
};
}, []);

return (
<SyntaxHighlighter
language="json"
style={isDark ? dracula : darcula}
customStyle={{
padding: 0,
border: "none",
background: "transparent",
}}
{...props}
>
{children}
</SyntaxHighlighter>
);
};
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -4,6 +4,7 @@ import type {
} from "api/typesGenerated";
import { Avatar } from "components/Avatar/Avatar";
import { Badge } from "components/Badge/Badge";
import { Codeblock } from "components/Codeblock/Codeblock";
import { TableCell, TableRow } from "components/Table/Table";
import {
Tooltip,
Expand All@@ -19,8 +20,6 @@ import {
ChevronUpIcon,
} from "lucide-react";
import { type FC, useLayoutEffect, useRef, useState } from "react";
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { dracula } from "react-syntax-highlighter/dist/cjs/styles/prism";
import { cn } from "utils/cn";
import { humanDuration } from "utils/time";
import { AIBridgeProviderIcon } from "../AIBridgeProviderIcon";
Expand DownExpand Up@@ -180,7 +179,6 @@ export const RequestLogsRow: FC<RequestLogsRowProps> = ({ interception }) => {
const [isOpen, setIsOpen] = useState(false);

const [firstPrompt] = interception.user_prompts;

const inputTokens = interception.token_usages.reduce(
(acc, tokenUsage) => acc + tokenUsage.input_tokens,
0,
Expand DownExpand Up@@ -479,16 +477,9 @@ export const RequestLogsRow: FC<RequestLogsRowProps> = ({ interception }) => {
<div className="flex flex-col gap-2 w-[800px]">
<div>Token Usage Metadata</div>
<div className="bg-surface-secondary rounded-md p-4">
<SyntaxHighlighter
language="json"
style={dracula}
customStyle={{
padding: 0,
background: "transparent",
}}
>
<Codeblock>
{JSON.stringify(tokenUsagesMetadata, null, 2)}
</SyntaxHighlighter>
</Codeblock>
</div>
</div>
)}
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp