Просмотр исходного кода

Merge branch 'master' into imprv/context-for-editor-assistant

Yuki Takei 9 месяцев назад
Родитель
Сommit
0d7aa03681

+ 0 - 1
apps/app/src/features/openai/client/services/client-engine-integration.tsx

@@ -163,7 +163,6 @@ export function useClientEngineIntegration(config: Partial<ClientEngineConfig> =
         appliedCount: diffResult.appliedCount,
         skippedCount: Math.max(0, diffs.length - diffResult.appliedCount),
         modifiedText: diffResult.content || content,
-        originalText: content,
         processingTime,
       };
 

+ 0 - 145
apps/app/src/features/openai/client/services/editor-assistant/processor.ts

@@ -241,71 +241,6 @@ export class ClientSearchReplaceProcessor {
     }
   }
 
-  /**
-   * Process diffs with direct editor integration
-   */
-  async processWithEditor(
-      editor: EditorAdapter,
-      diffs: LlmEditorAssistantDiff[],
-      options: ProcessingOptions = {},
-  ): Promise<DiffApplicationResult> {
-    const content = editor.getContent();
-
-    if (options.previewMode) {
-      // Preview mode: don't modify editor
-      return this.processMultipleDiffs(content, diffs, options);
-    }
-
-    // Create undo checkpoint before starting
-    editor.createUndoCheckpoint();
-
-    const result = await this.processMultipleDiffs(content, diffs, options);
-
-    if (result.success && result.content) {
-      editor.setContent(result.content);
-    }
-
-    return result;
-  }
-
-  /**
-   * Quick single diff processing for real-time applications
-   */
-  async processSingleDiffQuick(
-      content: string,
-      diff: LlmEditorAssistantDiff,
-  ): Promise<DiffApplicationResult> {
-    try {
-      const result = this.diffEngine.applySingleDiff(content, diff);
-
-      if (result.success && result.updatedLines) {
-        return {
-          success: true,
-          appliedCount: 1,
-          content: result.updatedLines.join('\n'),
-        };
-      }
-      return {
-        success: false,
-        appliedCount: 0,
-        failedParts: result.error ? [result.error] : [],
-      };
-
-    }
-    catch (error) {
-      const processingError = this.errorHandler.createContentError(
-        error as Error,
-        'Quick processing error',
-      );
-
-      return {
-        success: false,
-        appliedCount: 0,
-        failedParts: [processingError],
-      };
-    }
-  }
-
   // -----------------------------------------------------------------------------
   // Private Helper Methods
   // -----------------------------------------------------------------------------
@@ -388,13 +323,6 @@ export class ClientSearchReplaceProcessor {
     return batches;
   }
 
-  /**
-   * Yield control to browser event loop
-   */
-  private async yieldToBrowser(): Promise<void> {
-    return new Promise(resolve => setTimeout(resolve, 0));
-  }
-
   /**
    * Update processing status
    */
@@ -482,77 +410,4 @@ export class ClientSearchReplaceProcessor {
     }
   }
 
-  /**
-   * Validate processor configuration
-   */
-  validateConfig(): { valid: boolean; issues: string[] } {
-    const issues: string[] = [];
-
-    if (this.config.fuzzyThreshold < 0 || this.config.fuzzyThreshold > 1) {
-      issues.push('Fuzzy threshold must be between 0 and 1');
-    }
-
-    if (this.config.bufferLines < 0) {
-      issues.push('Buffer lines must be non-negative');
-    }
-
-    if (this.config.maxDiffBlocks <= 0) {
-      issues.push('Max diff blocks must be positive');
-    }
-
-    return {
-      valid: issues.length === 0,
-      issues,
-    };
-  }
-
-  /**
-   * Get processor performance statistics
-   */
-  getPerformanceStats(): {
-    lastProcessingTime?: number;
-    averageProcessingTime?: number;
-    successRate?: number;
-    } {
-    // This would be enhanced with persistent statistics tracking
-    return {
-      lastProcessingTime: this.currentStatus
-        ? performance.now() - this.currentStatus.startTime
-        : undefined,
-    };
-  }
-
 }
-
-// -----------------------------------------------------------------------------
-// Utility Functions
-// -----------------------------------------------------------------------------
-
-/**
- * Create a processor with browser-optimized defaults
- */
-export function createBrowserOptimizedProcessor(
-    overrides: Partial<ProcessorConfig> = {},
-): ClientSearchReplaceProcessor {
-  const browserConfig: Partial<ProcessorConfig> = {
-    fuzzyThreshold: 0.8,
-    bufferLines: 30, // Smaller buffer for browser performance
-    preserveIndentation: true,
-    stripLineNumbers: true,
-    enableAggressiveMatching: false,
-    maxDiffBlocks: 8, // Conservative limit for browser
-    ...overrides,
-  };
-
-  return new ClientSearchReplaceProcessor(browserConfig);
-}
-
-// -----------------------------------------------------------------------------
-// Export Default Instance
-// -----------------------------------------------------------------------------
-
-/**
- * Default client search/replace processor instance
- * Pre-configured for typical browser usage
- */
-export const defaultClientProcessor = createBrowserOptimizedProcessor();

+ 0 - 83
apps/app/src/features/openai/interfaces/editor-assistant/types.ts

@@ -27,10 +27,7 @@ export interface ProcessorConfig {
 
 export type DiffErrorType =
   | 'SEARCH_NOT_FOUND'
-  | 'SIMILARITY_TOO_LOW'
-  | 'MULTIPLE_MATCHES'
   | 'EMPTY_SEARCH'
-  | 'MARKER_SEQUENCE_ERROR'
   | 'CONTENT_ERROR';
 
 export interface DiffError {
@@ -110,66 +107,6 @@ export interface SearchContext {
   bufferLines?: number;
 }
 
-// -----------------------------------------------------------------------------
-// Validation Types
-// -----------------------------------------------------------------------------
-
-export interface ValidationResult {
-  /** Whether validation passed */
-  success: boolean;
-  /** Error message if validation failed */
-  error?: string;
-  /** Line number where error occurred */
-  line?: number;
-  /** Suggested fixes */
-  suggestions?: string[];
-}
-
-// -----------------------------------------------------------------------------
-// Editor Integration Types
-// -----------------------------------------------------------------------------
-
-export interface EditorAdapter {
-  getContent(): EditorContent;
-  setContent(content: string): void;
-  getValue(): string;
-  setValue(value: string): void;
-  getSelection(): EditorSelection;
-  setSelection(start: number, end: number): void;
-  getSelectedText(): string;
-  getPosition(): EditorPosition;
-  focus(): void;
-  blur(): void;
-  insertText(text: string, position?: EditorPosition): void;
-  replaceText(text: string, start?: number, end?: number): void;
-  onChange(handler: () => void): () => void;
-}
-
-export interface EditorAdapterConfig {
-  preserveSelection?: boolean;
-  autoFocus?: boolean;
-  enableUndo?: boolean;
-}
-
-export interface EditorContent {
-  text: string;
-  lines: string[];
-  lineCount: number;
-  charCount: number;
-}
-
-export interface EditorPosition {
-  line: number;
-  column: number;
-  offset: number;
-}
-
-export interface EditorSelection {
-  start: number;
-  end: number;
-  text: string;
-}
-
 // -----------------------------------------------------------------------------
 // Processing Types
 // -----------------------------------------------------------------------------
@@ -188,25 +125,5 @@ export interface ProcessingResult {
   appliedCount: number;
   skippedCount: number;
   modifiedText: string;
-  originalText: string;
   processingTime: number;
 }
-
-export type ProgressCallback = (progress: {
-  current: number;
-  total: number;
-  message: string;
-  percentage: number;
-}) => void;
-
-// -----------------------------------------------------------------------------
-// Legacy Compatibility
-// -----------------------------------------------------------------------------
-
-/**
- * @deprecated Use the new Search/Replace format instead
- * Kept for backward compatibility during migration
- */
-export interface LegacyReplaceOperation {
-  replace: string;
-}