setIsExpanded(!isExpanded)}
+ role="button"
+ aria-expanded={isExpanded}
+ tabIndex={0}
+ onKeyDown={(e) => {
+ if (e.key === "Enter" || e.key === " ") {
+ e.preventDefault();
+ setIsExpanded(!isExpanded);
+ }
+ }}
+ >
+ {/* Top-left label badge */}
+
+
+ Codebase Context
+
+
+ {/* File count when collapsed */}
+ {files.length > 0 && (
+
+
+ Using {files.length} file{files.length !== 1 ? "s" : ""}
+
+
+ )}
+
+ {/* Indicator icon */}
+
+ {isExpanded ? : }
+
+
+ {/* Main content with smooth transition */}
+
+ {/* File list when expanded */}
+ {files.length > 0 && (
+
+
+ {files.map((file, index) => {
+ const filePath = file.trim();
+ const fileName = filePath.split("/").pop() || filePath;
+ const pathPart =
+ filePath.substring(0, filePath.length - fileName.length) ||
+ "";
+
+ return (
+
+
+ {pathPart && (
+
+ {pathPart}
+
+ )}
+
+ );
+ })}
+
+
+ )}
+
+
+ );
+};
diff --git a/src/components/chat/DyadMarkdownParser.tsx b/src/components/chat/DyadMarkdownParser.tsx
index a1e08d8..ea22f3d 100644
--- a/src/components/chat/DyadMarkdownParser.tsx
+++ b/src/components/chat/DyadMarkdownParser.tsx
@@ -8,6 +8,7 @@ import { DyadAddDependency } from "./DyadAddDependency";
import { DyadExecuteSql } from "./DyadExecuteSql";
import { DyadAddIntegration } from "./DyadAddIntegration";
import { DyadEdit } from "./DyadEdit";
+import { DyadCodebaseContext } from "./DyadCodebaseContext";
import { CodeHighlight } from "./CodeHighlight";
import { useAtomValue } from "jotai";
import { isStreamingAtom } from "@/atoms/chatAtoms";
@@ -117,6 +118,7 @@ function preprocessUnclosedTags(content: string): {
"dyad-output",
"dyad-chat-summary",
"dyad-edit",
+ "dyad-codebase-context",
];
let processedContent = content;
@@ -180,6 +182,7 @@ function parseCustomTags(content: string): ContentPiece[] {
"dyad-output",
"dyad-chat-summary",
"dyad-edit",
+ "dyad-codebase-context",
];
const tagPattern = new RegExp(
@@ -362,6 +365,20 @@ function renderCustomTag(
);
+ case "dyad-codebase-context":
+ return (
+