@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
tsx 657 lines 24.2 KB
Raw
1 import { msg, T, useGT, useMessages } from "gt-react";
2 import type { MessageResolver } from "~/i18n/messages";
3 import { useNativeFileDrag } from "../../useNativeFileDrag";
4 import { resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
5 import { documentChipKindForFileName } from "~/pierre-icons";
6 import { isSvgAttachment } from "@t3tools/shared/image";
7 import { useRenderedAppearance } from "../../hooks/useTheme";
8 import { PullRequestGlyph } from "../pullRequest/pullRequestIcons";
9 import { ReadOnlySourcePreview } from "../files/AttachmentFilePreview";
10 import { useRightPanelStore } from "~/rightPanelStore";
11 import { COMPOSER_CONTEXT_KINDS } from "@t3tools/contracts";
12 import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
13 import { use, type ReactNode } from "react";
14 import { FileDiff } from "@pierre/diffs/react";
15 import { DiffWorkerPoolProvider } from "../DiffWorkerPoolProvider";
16 import {
17 type ChatFileAttachment,
18 type ChatImageAttachment,
19 isImageAttachment,
20 isVideoAttachment,
21 } from "../../types";
22 import {
23 getRenderablePatch,
24 resolveDiffThemeName,
25 resolveFileDiffPath,
26 } from "../../lib/diffRendering";
27 import { PREFERRED_HIGHLIGHTER } from "../../lib/syntaxHighlighting";
28 import ChatMarkdown from "../ChatMarkdown";
29 import { EnvironmentContextChip } from "../EnvironmentContextChip";
30 import { ThreadContextChip } from "../ThreadContextChip";
31 import { ResponseReplyCard } from "./AssistantCitationChip";
32 import { MessageCircleIcon, MousePointerClickIcon, PaintbrushIcon } from "lucide-react";
33 import type { ComposerContextId, KnownComposerContextRecord } from "@t3tools/contracts";
34 import { buildExpandedImagePreview } from "./ExpandedImagePreview";
35 import { WorkspaceEntryIcon, WorkspaceEntryTooltip } from "./WorkspaceEntryIcon";
36 import { TerminalContextInlineChip } from "./TerminalContextInlineChip";
37 import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
38 import {
39 ContextChipPopover as UserMessageContextPopover,
40 FileChip,
41 ImageChipButton,
42 PULL_REQUEST_CHIP_KINDS,
43 PullRequestChip,
44 UnresolvedChip,
45 } from "../contextChipParts";
46 import {
47 isPullRequestSummaryContext,
48 previewAnnotationTargetText,
49 pullRequestContextDisplayState,
50 pullRequestContextKindLabel,
51 reviewCommentContextLabel,
52 reviewCommentRangeText,
53 reviewCommentSectionText,
54 } from "~/lib/composerContextRecords";
55 import { formatComposerContextReference } from "@t3tools/shared/composerContextReferences";
56 import { ContextChip, ContextChipLabel, type ContextChipKind } from "../ContextChip";
57 import { createContextPresentationRegistry } from "../contextPresentationRegistry";
58 import type { ChatMarkdownContextReference } from "../ChatMarkdown";
59 import {
60 SkillChipPopover,
61 skillInstructionsOpener,
62 skillPopoverDescription,
63 } from "./SkillInlineText";
64 import { formatWorkspaceRelativePath } from "../../filePathDisplay";
65 import {
66 buildReviewCommentRenderablePatch,
67 formatReviewCommentFence,
68 type ReviewCommentContext,
69 } from "../../reviewCommentContext";
70 import { TimelineRowCtx } from "./timelineRowContext";
71 import { userMessageFileLabel } from "./TimelineUserMessageRow.logic";
72
73 function UserMessageMentionChip(props: {
74 record: Extract<KnownComposerContextRecord, { kind: "mention" }>;
75 copyMarkdown: string;
76 }) {
77 const gt = useGT();
78 const ctx = use(TimelineRowCtx);
79 const nativeDrag = useNativeFileDrag(ctx.activeThreadEnvironmentId, () =>
80 resolvePathLinkTarget(props.record.path, ctx.workspaceRoot ?? ""),
81 );
82 return (
83 <Tooltip>
84 <TooltipTrigger
85 render={
86 <ContextChip
87 {...nativeDrag}
88 kind={documentChipKindForFileName(props.record.path) ?? "mention"}
89 render={<button type="button" />}
90 aria-label={gt("Preview {name}", { name: props.record.path })}
91 data-markdown-copy={props.copyMarkdown}
92 onClick={() => {
93 if (ctx.threadRef)
94 useRightPanelStore.getState().openFile(ctx.threadRef, props.record.path);
95 }}
96 >
97 <WorkspaceEntryIcon
98 path={props.record.path}
99 environmentId={ctx.activeThreadEnvironmentId}
100 cwd={ctx.workspaceRoot}
101 theme={ctx.resolvedTheme}
102 />
103 <ContextChipLabel>{props.record.label}</ContextChipLabel>
104 </ContextChip>
105 }
106 />
107 <TooltipPopup>
108 <WorkspaceEntryTooltip
109 path={props.record.path}
110 environmentId={ctx.activeThreadEnvironmentId}
111 cwd={ctx.workspaceRoot}
112 />
113 </TooltipPopup>
114 </Tooltip>
115 );
116 }
117
118 function UserMessageSkillChip(props: {
119 record: Extract<KnownComposerContextRecord, { kind: "skill" }>;
120 copyMarkdown: string;
121 }) {
122 const { skills, threadRef } = use(TimelineRowCtx);
123 const skill = skills.find((candidate) => candidate.name === props.record.name);
124 return (
125 <SkillChipPopover
126 label={props.record.label || props.record.name}
127 description={skill ? skillPopoverDescription(skill) : null}
128 copyMarkdown={props.copyMarkdown}
129 onViewInstructions={skillInstructionsOpener(threadRef, skill)}
130 />
131 );
132 }
133
134 function UserMessagePullRequestContextChip(props: {
135 record: Extract<KnownComposerContextRecord, { kind: "review-comment" }>;
136 copyMarkdown: string;
137 kind: ContextChipKind;
138 }) {
139 const { activeThreadEnvironmentId, openPullRequest } = use(TimelineRowCtx);
140 const messages = useMessages();
141 const metadata = props.record.pullRequest;
142 if (metadata === undefined) return null;
143 return (
144 <PullRequestChip
145 metadata={metadata}
146 environmentId={activeThreadEnvironmentId}
147 label={reviewCommentContextLabel(props.record, messages)}
148 kindLabel={pullRequestContextKindLabel(props.record, messages)}
149 kind={props.kind}
150 copyMarkdown={props.copyMarkdown}
151 onOpen={openPullRequest}
152 />
153 );
154 }
155
156 function UserMessagePreviewAnnotationDetails(props: {
157 record: Extract<KnownComposerContextRecord, { kind: "preview-annotation" }>;
158 image: ChatImageAttachment | null;
159 }) {
160 const ctx = use(TimelineRowCtx);
161 const gt = useGT();
162 const messages = useMessages();
163 const visibleElements = props.record.elements ?? [];
164 const targetText = previewAnnotationTargetText(props.record, messages);
165 return (
166 <div className="max-w-full overflow-hidden rounded-lg border border-border/70 bg-background/70">
167 {props.image?.previewUrl ? (
168 <button
169 type="button"
170 className="block max-h-64 w-full cursor-zoom-in overflow-hidden border-b border-border/70 bg-muted"
171 aria-label={gt("Preview {name}", { name: props.image.name })}
172 onClick={() => {
173 if (!props.image) return;
174 const preview = buildExpandedImagePreview([props.image], props.image.id);
175 if (preview) ctx.onImageExpand(preview);
176 }}
177 >
178 <img
179 src={props.image.previewUrl}
180 alt={gt("Annotated preview crop")}
181 className="max-h-64 w-full object-contain"
182 />
183 </button>
184 ) : (
185 <div className="border-b border-border/70 bg-muted/40 px-3 py-2 text-secondary-label text-xs">
186 <T>Screenshot unavailable</T>
187 </div>
188 )}
189 <div className="min-w-0 px-3 py-2.5">
190 <div className="text-message-foreground text-xs font-medium">
191 {props.record.pageTitle?.trim() || props.record.pageUrl || gt("Preview annotation")}
192 </div>
193 {props.record.comment ? (
194 <div className="mt-1 whitespace-pre-wrap wrap-break-word text-sm">
195 {props.record.comment}
196 </div>
197 ) : null}
198 <div className="mt-1 flex items-center gap-2 text-secondary-label text-3xs">
199 {targetText ? <span className="truncate">{targetText}</span> : null}
200 {(props.record.styleChanges?.length ?? 0) > 0 ? (
201 <span className="inline-flex shrink-0 items-center gap-1">
202 <PaintbrushIcon className="size-3" />
203 {props.record.styleChanges?.length ?? 0}
204 </span>
205 ) : null}
206 </div>
207 {visibleElements.length > 0 ? (
208 <div className="mt-2 space-y-2 border-t border-border/60 pt-2">
209 {visibleElements.map((element) => {
210 const source = element.source;
211 const sourceLabel = source?.fileName
212 ? `${source.fileName}${source.lineNumber === null ? "" : `:${source.lineNumber}`}`
213 : null;
214 return (
215 <div
216 key={`${element.selector}\u0000${element.tagName}\u0000${sourceLabel ?? ""}\u0000${element.htmlPreview}`}
217 className="min-w-0"
218 >
219 <div className="flex min-w-0 items-center gap-2 text-xs">
220 <code className="truncate text-message-foreground">
221 {element.selector || `<${element.tagName}>`}
222 </code>
223 {sourceLabel ? (
224 <span className="ml-auto shrink-0 text-secondary-label">{sourceLabel}</span>
225 ) : null}
226 </div>
227 {element.htmlPreview?.trim() ? (
228 <pre className="mt-1 max-h-24 overflow-auto whitespace-pre-wrap rounded bg-muted/60 px-2 py-1.5 text-3xs leading-relaxed">
229 {element.htmlPreview.trim()}
230 </pre>
231 ) : null}
232 </div>
233 );
234 })}
235 </div>
236 ) : null}
237 </div>
238 </div>
239 );
240 }
241
242 function UserMessageElementDetails({
243 record,
244 }: {
245 record: Extract<KnownComposerContextRecord, { kind: "element" }>;
246 }) {
247 const sourceLabel = record.source?.fileName
248 ? `${record.source.fileName}${record.source.lineNumber === null ? "" : `:${record.source.lineNumber}`}`
249 : null;
250 return (
251 <div className="max-w-full overflow-hidden rounded-lg border border-border/70 bg-background/70">
252 <div className="border-b border-border/70 px-3 py-2.5">
253 <div className="truncate text-message-foreground text-xs font-medium">
254 {record.pageTitle?.trim() || record.pageUrl}
255 </div>
256 <div className="mt-0.5 truncate text-secondary-label text-3xs">{record.pageUrl}</div>
257 </div>
258 <div className="space-y-2 px-3 py-2.5">
259 <div className="flex min-w-0 items-center gap-2 text-xs">
260 <code className="truncate text-message-foreground">
261 {record.selector || `<${record.tagName}>`}
262 </code>
263 {sourceLabel ? (
264 <span className="ml-auto shrink-0 text-secondary-label">{sourceLabel}</span>
265 ) : null}
266 </div>
267 {record.htmlPreview?.trim() ? (
268 <div className="flex h-40 flex-col overflow-hidden rounded border border-border">
269 <ReadOnlySourcePreview name="element.html" text={record.htmlPreview} />
270 </div>
271 ) : null}
272 {record.styles?.trim() ? (
273 <div className="flex h-32 flex-col overflow-hidden rounded border border-border">
274 <ReadOnlySourcePreview name="styles.css" text={record.styles} />
275 </div>
276 ) : null}
277 </div>
278 </div>
279 );
280 }
281
282 interface UserMessageContextRenderContext {
283 environmentId: import("@t3tools/contracts").EnvironmentId;
284 reference: ChatMarkdownContextReference;
285 annotationImage: ChatImageAttachment | null;
286 attachment: ChatImageAttachment | ChatFileAttachment | null;
287 resolvedTheme: "light" | "dark";
288 copyMarkdown: string;
289 onExpandImage: (image: ChatImageAttachment) => void;
290 onExpandVideo: (file: ChatFileAttachment) => void;
291 onOpenFile: (file: ChatFileAttachment) => void;
292 m: MessageResolver;
293 }
294
295 function UnavailableUserMessageContextChip(props: UserMessageContextRenderContext) {
296 return (
297 <UnresolvedChip
298 label={props.reference.label}
299 copyMarkdown={props.copyMarkdown}
300 tooltip={props.m(msg("This context is no longer available."))}
301 />
302 );
303 }
304
305 const userMessageContextPresentationRegistry = createContextPresentationRegistry<
306 KnownComposerContextRecord,
307 UserMessageContextRenderContext,
308 ReactNode
309 >({
310 requiredKinds: COMPOSER_CONTEXT_KINDS,
311 handlers: [
312 {
313 kind: "mention",
314 canRender: (record) => record.kind === "mention",
315 render: (record, context) =>
316 record.kind === "mention" ? (
317 <UserMessageMentionChip record={record} copyMarkdown={context.copyMarkdown} />
318 ) : (
319 <UnavailableUserMessageContextChip {...context} />
320 ),
321 },
322 {
323 kind: "skill",
324 canRender: (record) => record.kind === "skill",
325 render: (record, context) =>
326 record.kind === "skill" ? (
327 <UserMessageSkillChip record={record} copyMarkdown={context.copyMarkdown} />
328 ) : (
329 <UnavailableUserMessageContextChip {...context} />
330 ),
331 },
332 {
333 kind: "thread",
334 canRender: (record) => record.kind === "thread",
335 render: (record, context) =>
336 record.kind === "thread" ? (
337 <ThreadContextChip record={record} copyMarkdown={context.copyMarkdown} />
338 ) : (
339 <UnavailableUserMessageContextChip {...context} />
340 ),
341 },
342 {
343 kind: "response",
344 canRender: (record) => record.kind === "response",
345 render: (record, context) =>
346 record.kind === "response" ? (
347 <ResponseReplyCard
348 record={record}
349 copyMarkdown={context.copyMarkdown}
350 leading={context.reference.leading ?? false}
351 trailing={context.reference.trailing ?? false}
352 />
353 ) : (
354 <UnavailableUserMessageContextChip {...context} />
355 ),
356 },
357 {
358 kind: "environment",
359 canRender: (record) => record.kind === "environment",
360 render: (record, context) =>
361 record.kind === "environment" ? (
362 <EnvironmentContextChip record={record} copyMarkdown={context.copyMarkdown} />
363 ) : (
364 <UnavailableUserMessageContextChip {...context} />
365 ),
366 },
367 {
368 kind: "image",
369 canRender: (record, context) =>
370 record.kind === "image" &&
371 context.attachment !== null &&
372 isImageAttachment(context.attachment),
373 render: (record, context) => {
374 if (
375 record.kind !== "image" ||
376 context.attachment === null ||
377 !isImageAttachment(context.attachment)
378 ) {
379 return <UnavailableUserMessageContextChip {...context} />;
380 }
381 const attachment = context.attachment;
382 return (
383 <ImageChipButton
384 name={record.name}
385 previewUrl={attachment.previewUrl}
386 size={formatAttachmentSize(record.sizeBytes, context.m)}
387 data-markdown-copy={context.copyMarkdown}
388 onClick={() => context.onExpandImage(attachment)}
389 />
390 );
391 },
392 },
393 {
394 kind: "file",
395 canRender: (record, context) =>
396 record.kind === "file" && context.attachment !== null && context.attachment.type === "file",
397 render: (record, context) => {
398 if (
399 record.kind !== "file" ||
400 context.attachment === null ||
401 context.attachment.type !== "file"
402 ) {
403 return <UnavailableUserMessageContextChip {...context} />;
404 }
405 const attachment = context.attachment;
406 const isVideo = isVideoAttachment(attachment);
407 const label = userMessageFileLabel(attachment, context.m);
408 const disabled =
409 attachment.downloadable === false && (!isVideo || attachment.previewUrl === undefined);
410 const size =
411 attachment.downloadable === false
412 ? context.m(msg("Sending…"))
413 : formatAttachmentSize(record.sizeBytes, context.m);
414 return (
415 <FileChip
416 name={label}
417 svgPreview={
418 isSvgAttachment(attachment)
419 ? { environmentId: context.environmentId, attachmentId: attachment.id }
420 : undefined
421 }
422 size={size}
423 isVideo={isVideo}
424 theme={context.resolvedTheme}
425 disabled={disabled}
426 accessibleLabel={
427 isVideo
428 ? context.m(msg("Video attachment, {label}, {size}", { label, size }))
429 : context.m(msg("File attachment, {label}, {size}", { label, size }))
430 }
431 copyMarkdown={context.copyMarkdown}
432 onOpen={() =>
433 isVideo ? context.onExpandVideo(attachment) : context.onOpenFile(attachment)
434 }
435 tooltip={`${label}\n${size}`}
436 />
437 );
438 },
439 },
440 {
441 kind: "terminal",
442 canRender: (record) => record.kind === "terminal",
443 render: (record, context, definition) =>
444 record.kind === "terminal" ? (
445 <span data-markdown-copy={context.copyMarkdown}>
446 <TerminalContextInlineChip
447 label={record.label}
448 terminalLabel={record.terminalLabel}
449 lineStart={record.lineStart}
450 lineEnd={record.lineEnd}
451 text={record.text}
452 detailsMode={definition.capabilities.details}
453 />
454 </span>
455 ) : (
456 <UnavailableUserMessageContextChip {...context} />
457 ),
458 },
459 {
460 kind: "element",
461 canRender: (record) => record.kind === "element",
462 render: (record, context) =>
463 record.kind === "element" ? (
464 <UserMessageContextPopover
465 copyMarkdown={context.copyMarkdown}
466 accessibleLabel={context.m(msg("Browser element, {label}", { label: record.label }))}
467 kind="element"
468 icon={<MousePointerClickIcon />}
469 label={record.label}
470 >
471 <UserMessageElementDetails record={record} />
472 </UserMessageContextPopover>
473 ) : (
474 <UnavailableUserMessageContextChip {...context} />
475 ),
476 },
477 {
478 kind: "review-comment",
479 canRender: (record) => record.kind === "review-comment",
480 render: (record, context) => {
481 if (record.kind !== "review-comment") {
482 return <UnavailableUserMessageContextChip {...context} />;
483 }
484 const isPullRequest = isPullRequestSummaryContext(record);
485 const label = reviewCommentContextLabel(record, context.m);
486 const kindLabel = isPullRequest
487 ? pullRequestContextKindLabel(record, context.m)
488 : context.m(msg("Review comment"));
489 const pullRequestState = pullRequestContextDisplayState(record) ?? "unknown";
490 if (isPullRequest && record.pullRequest !== undefined) {
491 return (
492 <UserMessagePullRequestContextChip
493 record={record}
494 copyMarkdown={context.copyMarkdown}
495 kind={PULL_REQUEST_CHIP_KINDS[pullRequestState]}
496 />
497 );
498 }
499 return (
500 <UserMessageContextPopover
501 copyMarkdown={context.copyMarkdown}
502 accessibleLabel={
503 record.pullRequest
504 ? context.m(
505 msg("{kind}, {label}, {title}", {
506 kind: kindLabel,
507 label,
508 title: record.pullRequest.title,
509 }),
510 )
511 : context.m(msg("{kind}, {label}", { kind: kindLabel, label }))
512 }
513 kind={isPullRequest ? PULL_REQUEST_CHIP_KINDS[pullRequestState] : "review-comment"}
514 icon={isPullRequest ? <PullRequestGlyph.pullRequest /> : <MessageCircleIcon />}
515 label={label}
516 >
517 <UserMessageReviewCommentCard
518 comment={{
519 id: record.contextId,
520 sectionId: record.sectionId,
521 sectionTitle: record.sectionTitle,
522 filePath: record.filePath,
523 startIndex: record.startIndex,
524 endIndex: record.endIndex,
525 rangeLabel: record.rangeLabel,
526 text: record.text,
527 diff: record.diff,
528 ...(record.fenceLanguage !== undefined
529 ? { fenceLanguage: record.fenceLanguage }
530 : {}),
531 ...(record.pullRequest !== undefined ? { pullRequest: record.pullRequest } : {}),
532 }}
533 />
534 </UserMessageContextPopover>
535 );
536 },
537 },
538 {
539 kind: "preview-annotation",
540 canRender: (record) => record.kind === "preview-annotation",
541 render: (record, context) =>
542 record.kind === "preview-annotation" ? (
543 <UserMessageContextPopover
544 copyMarkdown={context.copyMarkdown}
545 accessibleLabel={context.m(msg("Preview annotation, {label}", { label: record.label }))}
546 kind="preview-annotation"
547 icon={<MousePointerClickIcon />}
548 label={record.label}
549 >
550 <UserMessagePreviewAnnotationDetails record={record} image={context.annotationImage} />
551 </UserMessageContextPopover>
552 ) : (
553 <UnavailableUserMessageContextChip {...context} />
554 ),
555 },
556 ],
557 fallback: (_kind, _record, context) => <UnavailableUserMessageContextChip {...context} />,
558 });
559
560 export function UserMessageContextReferenceChip(props: {
561 reference: ChatMarkdownContextReference;
562 record: KnownComposerContextRecord | undefined;
563 annotationImage: ChatImageAttachment | null;
564 attachment: ChatImageAttachment | ChatFileAttachment | null;
565 onExpandImage: (image: ChatImageAttachment) => void;
566 onExpandVideo: (file: ChatFileAttachment) => void;
567 onOpenFile: (file: ChatFileAttachment) => void;
568 }) {
569 const { resolvedTheme, activeThreadEnvironmentId } = use(TimelineRowCtx);
570 const m = useMessages();
571 const copyMarkdown = formatComposerContextReference({
572 kind: props.reference.kind,
573 contextId: props.reference.contextId as ComposerContextId,
574 label: props.reference.label,
575 });
576 return userMessageContextPresentationRegistry.render(props.reference.kind, props.record, {
577 environmentId: activeThreadEnvironmentId,
578 reference: props.reference,
579 annotationImage: props.annotationImage,
580 attachment: props.attachment,
581 resolvedTheme,
582 copyMarkdown,
583 onExpandImage: props.onExpandImage,
584 onExpandVideo: props.onExpandVideo,
585 onOpenFile: props.onOpenFile,
586 m,
587 });
588 }
589
590 function UserMessageReviewCommentCard({ comment }: { comment: ReviewCommentContext }) {
591 const m = useMessages();
592 const renderedAppearance = useRenderedAppearance();
593 const ctx = use(TimelineRowCtx);
594 const fenceLanguage = comment.fenceLanguage ?? "diff";
595 const renderablePatch = getRenderablePatch(
596 buildReviewCommentRenderablePatch(comment),
597 `review-comment:${comment.id}`,
598 undefined,
599 m,
600 );
601
602 return (
603 <div className="space-y-2 rounded-lg border border-border/70 bg-background/70 p-3">
604 <div className="space-y-1">
605 <div className="text-xs font-medium text-foreground">
606 {formatWorkspaceRelativePath(comment.filePath, ctx.workspaceRoot)}
607 </div>
608 <div className="text-2xs text-muted-foreground">
609 {reviewCommentSectionText(comment.sectionTitle, m)} ·{" "}
610 {reviewCommentRangeText(comment.rangeLabel, m)}
611 </div>
612 </div>
613 {comment.text.length > 0 && (
614 <div className="wrap-break-word text-sm">
615 <ChatMarkdown
616 text={comment.text}
617 cwd={ctx.markdownCwd}
618 threadRef={ctx.threadRef ?? undefined}
619 skills={ctx.skills}
620 parseRawHtml={false}
621 lineBreaks
622 />
623 </div>
624 )}
625 {fenceLanguage !== "diff" && comment.diff.trim().length > 0 && (
626 <ChatMarkdown
627 text={formatReviewCommentFence(fenceLanguage, comment.diff)}
628 cwd={ctx.markdownCwd}
629 threadRef={ctx.threadRef ?? undefined}
630 skills={ctx.skills}
631 className="text-foreground"
632 />
633 )}
634 {renderablePatch?.kind === "files" && (
635 <DiffWorkerPoolProvider>
636 {renderablePatch.files.map((fileDiff) => (
637 <FileDiff
638 key={resolveFileDiffPath(fileDiff)}
639 fileDiff={fileDiff}
640 options={{
641 collapsed: false,
642 diffStyle: "unified",
643 theme: resolveDiffThemeName(renderedAppearance),
644 preferredHighlighter: PREFERRED_HIGHLIGHTER,
645 }}
646 />
647 ))}
648 </DiffWorkerPoolProvider>
649 )}
650 {renderablePatch?.kind === "raw" && (
651 <pre className="overflow-x-auto rounded-md bg-muted/40 p-2 text-xs">
652 {renderablePatch.text}
653 </pre>
654 )}
655 </div>
656 );
657 }