Fixed @ file content not being added or sent to server (#962)

This commit is contained in:
Seth Troisi
2025-06-12 16:08:27 -07:00
committed by GitHub
parent 61d0cc39fd
commit b7daa7c702
2 changed files with 33 additions and 68 deletions

View File

@@ -366,38 +366,22 @@ export async function handleAtCommand({
confirmationDetails: undefined,
};
if (
result.llmContent &&
typeof result.llmContent === 'string' &&
result.llmContent.trim() !== ''
) {
if (Array.isArray(result.llmContent)) {
const fileContentRegex = /^--- (.*?) ---\n\n([\s\S]*?)\n\n$/;
processedQueryParts.push({
text: '\n--- Content from referenced files ---',
});
const fileContentRegex =
/\n--- (.*?) ---\n([\s\S]*?)(?=\n--- .*? ---\n|$)/g;
let match;
const foundContentForSpecs = new Set<string>();
while ((match = fileContentRegex.exec(result.llmContent)) !== null) {
const filePathSpecInContent = match[1]; // This is a resolved pathSpec
const fileActualContent = match[2].trim();
if (pathSpecsToRead.includes(filePathSpecInContent)) {
// Ensure we only add content for paths we requested
processedQueryParts.push({
text: `\nContent from @${filePathSpecInContent}:\n`,
});
processedQueryParts.push({ text: fileActualContent });
foundContentForSpecs.add(filePathSpecInContent);
}
}
// Check if any requested pathSpecs didn't yield content in the parsed block, could indicate an issue.
for (const requestedSpec of pathSpecsToRead) {
if (!foundContentForSpecs.has(requestedSpec)) {
onDebugMessage(
`Content for @${requestedSpec} was expected but not found in read_many_files output.`,
);
// Optionally add a note about missing content for this spec
// processedQueryParts.push({ text: `\nContent for @${requestedSpec} not found or empty.\n` });
for (const part of result.llmContent) {
if (typeof part === 'string') {
const match = fileContentRegex.exec(part);
if (match) {
const filePathSpecInContent = match[1]; // This is a resolved pathSpec
const fileActualContent = match[2].trim();
processedQueryParts.push({
text: `\nContent from @${filePathSpecInContent}:\n`,
});
processedQueryParts.push({ text: fileActualContent });
}
}
}
processedQueryParts.push({ text: '\n--- End of content ---' });