@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 37 lines 1.19 KB
Raw
1 import type { ScopedThreadRef } from "@t3tools/contracts";
2
3 import ChatMarkdown from "~/components/ChatMarkdown";
4 import { resolvePathLinkTarget } from "@t3tools/shared/fileLinks";
5 import { maskMarkdownFrontmatter } from "@t3tools/shared/markdownFrontmatter";
6
7 export function FileMarkdownPreview(props: {
8 readonly cwd: string;
9 readonly relativePath: string;
10 readonly text: string;
11 readonly threadRef: ScopedThreadRef;
12 readonly workspaceMutationId: string | null;
13 readonly onTaskListChange?:
14 | ((input: { readonly markerOffset: number; readonly checked: boolean }) => void)
15 | undefined;
16 }) {
17 const lastSeparator = Math.max(
18 props.relativePath.lastIndexOf("/"),
19 props.relativePath.lastIndexOf("\\"),
20 );
21 const imageBaseDir =
22 lastSeparator >= 0
23 ? resolvePathLinkTarget(props.relativePath.slice(0, lastSeparator), props.cwd)
24 : props.cwd;
25
26 return (
27 <ChatMarkdown
28 text={maskMarkdownFrontmatter(props.text)}
29 cwd={props.cwd}
30 imageBaseDir={imageBaseDir}
31 threadRef={props.threadRef}
32 workspaceMutationId={props.workspaceMutationId}
33 className="mx-auto max-w-4xl px-6 py-5"
34 onTaskListChange={props.onTaskListChange}
35 />
36 );
37 }