Conversation
The log-trace dialog showed request/response bodies as a raw `<pre>` string, which is hard to read for large JSON payloads. Replace the `<pre>` in `BodyBlock` with a new read-only `JsonView` component built on CodeMirror, giving syntax highlighting, code folding, line numbers, and Cmd/Ctrl-F search. The viewer is read-only but stays focusable so search and text selection work. Its theme follows the app's light/dark preference and blends into the surrounding muted panel. Non-JSON bodies (SSE streams, bodies truncated to invalid JSON) fall back to a plain-text mode that keeps search/scroll/wrap. Each body block gets a copy-to-clipboard button reusing the existing clipboard + toast helpers. All three call sites (client request, upstream request, upstream response) are covered by the single BodyBlock change. Adds @uiw/react-codemirror, @codemirror/lang-json and @uiw/codemirror-theme-github as dev dependencies (renderer-only, bundled by Vite). New i18n keys: toast.bodyCopied and logs.detail.copyBody. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The log-trace dialog rendered request/response bodies as a raw
<pre>string, which is unpleasant to read for large JSON payloads. This swaps
that for a proper read-only CodeMirror viewer.
Changes
src/renderer/src/components/json-view.tsx— a read-only CodeMirrorviewer with syntax highlighting, code folding, line numbers, and
Cmd/Ctrl-Fsearch. It's read-only but stays focusable, so search andtext selection work. Background is transparent to blend into the
surrounding
bg-muted/40panel; font size matchestext-xs; themefollows the app's light/dark preference (
next-themes+ GitHub theme).log-trace-dialog.tsx—BodyBlocknow usesJsonView.prettyBodybecame
formatBody, parsing once to return both the pretty text and anisJsonflag. Non-JSON bodies (SSE streams, bodies truncated to invalidJSON) fall back to a plain-text mode that keeps search/scroll/wrap. Each
body block gains a copy-to-clipboard button (reusing
copyText+ sonnertoast). All three call sites — client request, upstream request, upstream
response — are covered by this single change.
toast.bodyCopiedandlogs.detail.copyBodyto bothen.tsandzh.ts.@uiw/react-codemirror,@codemirror/lang-json,and
@uiw/codemirror-theme-githubtodevDependencies(renderer-only,bundled by Vite, matching the existing convention).
Notes for reviewers
table, or any editing capability — display only.
style-srcalready allows'unsafe-inline'forCodeMirror's injected
<style>, andscript-src 'self'needs no eval.focusable read-only editor so search works). Easy to hide via the theme's
caretsetting if we'd rather not show it.Verification
pnpm typecheckandpnpm lintboth pass. There is no JS/TS test runnerin this repo, so that is the full verification per project convention.