Allow manual context management (#376)

This commit is contained in:
Will Chen
2025-06-10 13:52:20 -07:00
committed by GitHub
parent e7941bc6f7
commit 534cbad909
55 changed files with 3296 additions and 114 deletions

View File

@@ -0,0 +1,25 @@
import { AppChatContext, AppChatContextSchema } from "@/lib/schemas";
import log from "electron-log";
const logger = log.scope("context_paths_utils");
export function validateChatContext(chatContext: unknown): AppChatContext {
if (!chatContext) {
return {
contextPaths: [],
smartContextAutoIncludes: [],
};
}
try {
// Validate that the contextPaths data matches the expected schema
return AppChatContextSchema.parse(chatContext);
} catch (error) {
logger.warn("Invalid contextPaths data:", error);
// Return empty array as fallback if validation fails
return {
contextPaths: [],
smartContextAutoIncludes: [],
};
}
}