Support turbo edits (pro) (#166)

This commit is contained in:
Will Chen
2025-05-14 23:35:50 -07:00
committed by GitHub
parent d545babb63
commit 35b459d82d
12 changed files with 400 additions and 26 deletions

View File

@@ -215,17 +215,16 @@ export function registerChatStreamHandlers() {
} else {
// Normal AI processing for non-test prompts
const settings = readSettings();
const { modelClient, backupModelClients } = await getModelClient(
settings.selectedModel,
settings,
);
// Extract codebase information if app is associated with the chat
let codebaseInfo = "";
let files: { path: string; content: string }[] = [];
if (updatedChat.app) {
const appPath = getDyadAppPath(updatedChat.app.path);
try {
codebaseInfo = await extractCodebase(appPath);
const out = await extractCodebase(appPath);
codebaseInfo = out.formattedOutput;
files = out.files;
logger.log(`Extracted codebase information from ${appPath}`);
} catch (error) {
logger.error("Error extracting codebase:", error);
@@ -237,6 +236,11 @@ export function registerChatStreamHandlers() {
"estimated tokens",
codebaseInfo.length / 4,
);
const { modelClient, backupModelClients } = await getModelClient(
settings.selectedModel,
settings,
files,
);
// Prepare message history for the AI
const messageHistory = updatedChat.messages.map((message) => ({

View File

@@ -140,7 +140,7 @@ export function registerDebugHandlers() {
// Extract codebase
const appPath = getDyadAppPath(app.path);
const codebase = await extractCodebase(appPath);
const codebase = (await extractCodebase(appPath)).formattedOutput;
return {
debugInfo,

View File

@@ -92,7 +92,8 @@ async function getCodebaseTokenCount(
// Calculate and cache the token count
logger.log(`Calculating codebase token count for chatId: ${chatId}`);
const codebase = await extractCodebase(getDyadAppPath(appPath));
const codebase = (await extractCodebase(getDyadAppPath(appPath)))
.formattedOutput;
const tokenCount = estimateTokens(codebase);
// Store in cache

View File

@@ -68,7 +68,7 @@ export function registerTokenCountHandlers() {
if (chat.app) {
const appPath = getDyadAppPath(chat.app.path);
codebaseInfo = await extractCodebase(appPath);
codebaseInfo = (await extractCodebase(appPath)).formattedOutput;
codebaseTokens = estimateTokens(codebaseInfo);
logger.log(
`Extracted codebase information from ${appPath}, tokens: ${codebaseTokens}`,