diff --git a/packages/server/src/services/file-change-plugin.ts b/packages/server/src/services/file-change-plugin.ts index 556c8d6..f4edbab 100644 --- a/packages/server/src/services/file-change-plugin.ts +++ b/packages/server/src/services/file-change-plugin.ts @@ -51,34 +51,31 @@ export class FileChangePlugin { const globalState = await getState(); - const summarizeFiles = globalState.settings.disableSummarizationProjectIds.includes(project.id); - if (summarizeFiles) { - // 5) Re-run summarization for this single file - await this.summaryService.summarizeFiles( - project.id, - [updatedFile], - { - settings: { - language: 'en', - theme: 'light', - codeThemeLight: 'atomOneLight', - codeThemeDark: 'atomOneDark', - ollamaGlobalUrl: 'http://localhost:11434', - lmStudioGlobalUrl: 'http://localhost:8000', - summarizationIgnorePatterns: [], - summarizationAllowPatterns: [], - disableSummarizationProjectIds: [], - }, - counter: 0, - projectTabs: {}, - projectActiveTabId: null, - chatTabs: {}, - chatActiveTabId: null, - } - ); - } + // 5) Re-run summarization for this single file + await this.summaryService.summarizeFiles( + project.id, + [updatedFile], + { + settings: { + language: 'en', + theme: 'light', + codeThemeLight: 'atomOneLight', + codeThemeDark: 'atomOneDark', + ollamaGlobalUrl: 'http://localhost:11434', + lmStudioGlobalUrl: 'http://localhost:8000', + summarizationIgnorePatterns: [], + summarizationAllowPatterns: [], + disableSummarizationProjectIds: [], + }, + counter: 0, + projectTabs: {}, + projectActiveTabId: null, + chatTabs: {}, + chatActiveTabId: null, + } + ); } catch (err) { console.error('[FileChangePlugin] Error handling file change:', err); } diff --git a/packages/server/src/services/file-summary-service.ts b/packages/server/src/services/file-summary-service.ts index 317b332..66f9309 100644 --- a/packages/server/src/services/file-summary-service.ts +++ b/packages/server/src/services/file-summary-service.ts @@ -5,6 +5,7 @@ import { ProjectFile as ProjectFileType, GlobalState } from 'shared' import { matchesAnyPattern } from 'shared/src/utils/pattern-matcher' import { promptsMap } from '@/prompts/prompts-map' import { UnifiedProviderService } from './model-providers/providers/unified-provider-service' +import { getState } from '@/websocket/websocket-config' function chunkArray(arr: T[], size: number): T[][] { const chunks: T[][] = [] @@ -15,22 +16,24 @@ function chunkArray(arr: T[], size: number): T[][] { } const shouldSummarizeFile = async (projectId: string, filePath: string): Promise => { - const settings = await getSettings() - + const state = await getState() + const settings = state.settings + + if (settings.disableSummarizationProjectIds.includes(projectId)) { return false } - const matchesIgnorePattern = settings.summarizationIgnorePatterns.some(pattern => + const matchesIgnorePattern = settings.summarizationIgnorePatterns.some(pattern => new RegExp(pattern).test(filePath) ) - + if (matchesIgnorePattern) { return false } const hasAllowPatterns = settings.summarizationAllowPatterns.length > 0 - const matchesAllowPattern = settings.summarizationAllowPatterns.some(pattern => + const matchesAllowPattern = settings.summarizationAllowPatterns.some(pattern => new RegExp(pattern).test(filePath) ) @@ -168,9 +171,10 @@ export class FileSummaryService { */ private async summarizeFile(file: ProjectFileType) { if (!await shouldSummarizeFile(file.projectId, file.path)) { + console.log(`[FileSummaryService] Skipping summarization for file: ${file.name}`) return } - + try { const fileContent = file.content || '' if (!fileContent.trim()) {