Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
fix(embeddings): translate error messages before sending to UI
- Import t() function from i18n module
- Wrap error messages with t() translation function in _initializeEmbedder()
- Ensures proper localization of error messages in the UI
- Falls back to original message if no translation exists
* fix: handle null/empty custom modes files to prevent 'Cannot read properties of null' error
- Fix SimpleInstaller to ensure existingData is always an object after yaml.parse
- Fix CustomModesManager.parseYamlSafely to return empty object instead of null
- Ensure customModes array is always initialized in both install and remove operations
- Add tests for empty/null file handling scenarios
- Update existing tests to match correct behavior
* fix: handle null/undefined settings in updateModesInFile and loadModesFromFile
- Ensure settings object exists before accessing customModes property
- Initialize customModes as empty array if undefined
- Prevent 'Cannot read properties of null' error during mode import
- Add proper validation in loadModesFromFile before schema check
Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
* fix: add embedder validation to prevent misleading status indicators (#4398)
* fix: address PR feedback and fix critical issues
- Fixed settings-save flow to save before validation
- Fixed Error constructor usage in scanner.ts
- Fixed segment identification in file-watcher.ts
- Added missing translation keys for embedder validation errors
* fix: add missing Ollama translation keys
- Added missing ollama.title, description, and settings keys
- Fixed translation check failure in CI/CD pipeline
- Synchronized all 17 non-English locale files
* feat: add proactive embedder validation on provider switch
- Validate embedder connection when switching providers
- Prevent misleading 'Indexed' status when embedder is unavailable
- Show immediate error feedback for invalid configurations
- Add comprehensive test coverage for validation flow
This ensures users get immediate feedback when configuring embedders,
preventing confusion when providers like Ollama are not accessible.
* fix: improve error handling and validation in code indexing process
* refactor: extract common embedder validation and error handling logic
- Created shared/validation-helpers.ts with centralized error handling utilities
- Refactored OpenAI, OpenAI-Compatible, and Ollama embedders to use shared helpers
- Eliminated duplicate error handling code across embedders
- Improved maintainability and consistency of error handling
- Fixed test compatibility in manager.spec.ts
- All 2721 tests passing
* refactor: simplify validation helpers by removing unnecessary wrapper functions
- Removed getErrorMessageForConnectionError and inlined logic into handleValidationError
- Removed isRateLimitError, logRateLimitRetry, and logEmbeddingError wrapper functions
- Updated openai.ts and openai-compatible.ts to inline rate limit checking and logging
- Reduced code complexity while maintaining all functionality
- All 311 tests continue to pass
* fix: add missing invalidResponse i18n key and fix French translation
- Added missing 'invalidResponse' key to all locale files
- Fixed French translation: changed 'and accessible' to 'et accessible'
- Ensures proper error messages are displayed when embedder returns invalid responses
* fix: restore removed score settings in webviewMessageHandler
- Restored codebaseIndexSearchMaxResults and codebaseIndexSearchMinScore settings that were unintentionally removed
- Keep embedder validation related changes
* fix: revert unintended changes to file-watcher and scanner
- Reverted point ID generation back to using line numbers instead of segmentHash
- Restored { cause: deleteError } parameter in scanner error handling
- These changes were unrelated to the embedder validation feature
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
- Add early return in listFiles() when limit is 0 to avoid unnecessary file scanning
- Update getEnvironmentDetails() to show appropriate message when workspace files context is disabled
- Add test coverage for maxWorkspaceFiles=0 scenario
- Clean up test files to remove unnecessary mocking complexity
This optimization improves performance when users set maxWorkspaceFiles to 0, completely bypassing file system operations.
* feat: add configurable max search results for codebase indexing (#5149)
- Add codebaseIndexSearchMaxResults to configuration schema with validation (10-1000)
- Update Qdrant client to accept maxResults parameter in search method
- Add UI slider in Experimental Settings to configure max search results
- Rename constants to DEFAULT_MAX_SEARCH_RESULTS and DEFAULT_SEARCH_MIN_SCORE for clarity
- Add translations for new setting across all 17 supported languages
- Add comprehensive test coverage for config manager, Qdrant client, and UI components
fix: settings persistence for codebase index configuration
- Add new updateCodebaseIndexConfig message type to properly merge config updates
- Update SettingsView to send entire codebaseIndexConfig object instead of just enabled flag
- Add backend handler to merge configuration updates instead of overwriting
- Add tests for the new message handler functionality
This ensures the max search results setting persists correctly when saved.
* fix: correct property name in updateCodebaseIndexConfig message
The frontend was sending 'config' but the backend expects 'codebaseIndexConfig'.
This mismatch was preventing the max search results setting from persisting.
* feat: refactor codebase index constants and update search result defaults
* feat(chat): add advanced settings for maximum search results configuration
* refactor: remove updateCodebaseIndexConfig and integrate max search results into saveCodeIndexSettingsAtomic
- Removed updateCodebaseIndexConfig message type and handler as per PR feedback
- Added codebaseIndexSearchMaxResults to codeIndexSettings type in WebviewMessage.ts
- Updated saveCodeIndexSettingsAtomic to save codebaseIndexSearchMaxResults
- Fixed SettingsView.tsx to use codebaseIndexEnabled message instead of updateCodebaseIndexConfig
* Delete webview-ui/src/components/settings/__tests__/ExperimentalSettings.spec.tsx
* refactor: remove updateCodebaseIndexConfig tests to streamline codebase indexing logic
* revert this
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
Co-authored-by: Daniel <57051444+daniel-lxs@users.noreply.github.com>
* fix: resolve Go duplicate references in tree-sitter queries (#5367)
- Replace broad statement captures with function-scoped queries
- Eliminates overlapping captures that caused duplicate references
- Improves search quality and indexing performance for Go projects
- Add test to validate no duplicate line ranges are captured
- Maintains backward compatibility with existing functionality
Fixes#5367
* fix: resolve Go codebase indexing with language-specific thresholds
- Update Go tree-sitter queries to capture full declarations instead of just identifiers
- Implement language-specific character thresholds (50 chars for Go vs 100 default)
- Fix inspectGo.spec.ts test to match new query behavior
- Add comprehensive test coverage for Go indexing fix
This ensures Go files are properly indexed for semantic search while preventing
duplicate references. All tests now pass.
* fix: implement universal 50-character threshold for code indexing
- Changed MIN_BLOCK_CHARS from 100 to 50 in parser.ts
- Updated tests to expect single-block captures for small Go files
- Removed language-specific threshold logic
- Fixes Go files not being indexed due to high character threshold
Fixes#5367
* test: replace Go-specific test with generic MIN_BLOCK_CHARS test
- Remove go-indexing-fix.spec.ts as requested in PR feedback
- Add generic test in parser.spec.ts to verify 50-character threshold
- Test ensures content under 50 chars is filtered, 50+ chars is indexed
- Applies to all languages, not just Go
* fix: update markdown tests for MIN_BLOCK_CHARS change from 100 to 50
* feat: add markdown support to codebase indexing (#4660)
* fix: implement chunking for large markdown sections and fix Qdrant deduplication issue (#4660)
- Modified parseMarkdownContent to chunk large sections (>1150 chars)
- Added support for chunking header-less markdown files
- Fixed _chunkTextByLines to handle oversized lines properly
- Added defensive check for parseMarkdown returning undefined
- Fixed Qdrant ID generation to use segmentHash instead of file:line
- This was the root cause: chunks were being deduplicated
- Each chunk now gets a unique ID even from the same line
- Added comprehensive tests for all edge cases
- Ensures all markdown content is properly indexed in Qdrant
* fix: remove redundant supported-extensions test file
As identified in PR review, the supported-extensions.spec.ts file only tests
the contents of an array, which is already implicitly covered by the functional
tests in parser.spec.ts. Removing this reduces maintenance overhead without
sacrificing test quality.
* test: address PR review feedback
- Remove redundant test 'should handle large markdown documentation folders efficiently'
that only verified the scanner could iterate over mocked files
- Add test to verify unique point IDs are generated for each block from the same file,
ensuring the segmentHash-based ID generation prevents collisions
* fix: add segmentHash to vector point payload and refactor tests
- Add segmentHash to payload in scanner.ts to fix vector point ID generation
- Split parser.spec.ts tests into focused unit tests (mocked dependencies)
- Move integration tests to new markdownIntegration.spec.ts file
- Each test suite now has clear, distinct responsibilities
- Fixes issue #4660: vector point ID collisions for large Markdown files
* refactor: move redundant tests
* feat: enhance markdown processing with consistent chunking logic and segment hashing
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* Fix code index secret persistence with async VSCode storage
- Add async secret methods to CodeIndexConfigManager
- Implement direct VSCode secret storage access bypassing ContextProxy cache
- Update loadConfiguration to use async secret loading
- Modify webview message handler to use new async secret storage
- Add public secret methods to CodeIndexManager
- Enhance debugging throughout secret flow
This fixes the issue where API keys were saved but not loaded immediately
into services due to ContextProxy cache synchronization issues.
* Fix code index secret persistence and test failures
- Add async secret handling to CodeIndexConfigManager with new methods:
- getSecretAsync(), storeSecretAsync() for individual secrets
- loadSecretsAsync(), storeSecretsAsync() for batch operations
- Update doesConfigChangeRequireRestart() to check OpenAI Compatible modelDimension changes
- Fix all failing tests by using setupSecretMocks() helper consistently
- Update manager.spec.ts to properly mock _recreateServices to avoid real service creation
This ensures API keys and other secrets are properly loaded from VSCode's async secret storage
and that configuration changes requiring service restart are correctly detected.
* feat: improve code index settings secret handling in UI
- Show placeholder dots (••••••••••••••••) in password fields when secrets are already set
- Only send modified secret fields to prevent overwriting existing secrets with empty values
- Track which fields have been modified by the user
- Add requestCodeIndexSecretStatus message handler to check if secrets exist
- Fix console.log to handle empty string keys without errors
- Ensure changing one setting doesn't clear other unmodified secrets
* refactor: disconnect code index from unified settings system
- Rename handleExternalSettingsChange to handleSettingsChange for clarity
- Remove handleSettingsChange call from ClineProvider (not related to code index)
- Remove codebaseIndexConfig from general settings save in SettingsView
- Delete unused codebaseIndexConfig message handler
- Remove codebaseIndexConfig from WebviewMessage type definition
- Code index settings are now fully independent with their own dedicated UI
* feat: separate code index enable/disable from indexing settings
- Move 'Enable codebase indexing' toggle to global settings in Experimental section
- Keep indexing-specific settings (API keys, URLs, models) in dedicated Code Index Settings component
- Add codebaseIndexEnabled handler to webview message handler
- Update translations with new settings title and disabled message
- Ensure code index service properly responds to enable/disable changes
- Maintain backward compatibility with existing codebaseIndexConfig structure
* refactor: remove ContextProxy.getVSCodeContext() and pass ExtensionContext directly
- Updated CodeIndexConfigManager to accept vscode.ExtensionContext in constructor
- Modified CodeIndexManager to pass context directly to CodeIndexConfigManager
- Updated webviewMessageHandler to use provider.context.secrets directly
- Removed getVSCodeContext() method from ContextProxy
- Updated all related tests to reflect these changes
- Fixed CodeIndexSettings webview tests after UI changes
* refactor: streamline secret handling by removing async methods and utilizing ContextProxy directly
* feat: translations and popover component
* refactor: simplify test mocks and improve checkbox handling in CodeIndexSettings tests
* refactor: remove debug logging from CodeIndexConfigManager, CodeIndexManager, CodeIndexServiceFactory, and QdrantVectorStore
* fix: merge missing translation keys from main after rebase
- Add advancedConfigLabel, searchMinScoreLabel, searchMinScoreDescription, searchMinScoreResetTooltip keys
- Update startIndexingButton and clearIndexDataButton labels to match main
- Preserve all CodeIndexPopover translations added in this PR
* Revert "fix: merge missing translation keys from main after rebase"
This reverts commit beb1de4924ac1475731fcd06d994ddb96eb1e5fd.
* fix: add missing translation keys from main branch after rebase
- Added codeIndex.advancedConfigLabel
- Added codeIndex.searchMinScoreLabel
- Added codeIndex.searchMinScoreDescription
- Added codeIndex.searchMinScoreResetTooltip
These keys exist on main but were missing from non-English locales after rebase.
* fix: remove clickIndicatorMessage, fix toggle message type, and clean up translation key inconsistencies
* refactor: streamline settings management in CodeIndexPopover and improve secret handling
* refactor: remove debug logging from configuration checks in CodeIndexConfigManager and webviewMessageHandler
* fix: translations
* refactor: remove CodeIndexSettings component and associated tests
* fix: handle YAML parsing edge cases in CustomModesManager
- Add BOM (Byte Order Mark) stripping for UTF-8 and UTF-16
- Normalize invisible characters including non-breaking spaces
- Replace fancy quotes and dashes with standard characters
- Remove zero-width characters that can cause parsing issues
- Add comprehensive test coverage for all edge cases
This fixes the YAML parsing limitations documented in PR #237 by
implementing proper preprocessing before parsing YAML content.
* fix: address PR review comments
- Fix BOM handling to correctly handle UTF-16 (all BOMs appear as \uFEFF when decoded)
- Optimize cleanInvisibleCharacters with single regex pass for better performance
- Prevent duplicate error messages by marking errors as already handled
- Refactor test file to use mockFsReadFile helper function to reduce duplication
- Fix YAML indentation in tests (use spaces instead of tabs)
- Add ESLint disable comment for character class warning (regex is correct)
* fix: prevent YAML line breaks by setting lineWidth to 0
- Added lineWidth: 0 option to all yaml.stringify() calls
- Prevents automatic line wrapping at 80 characters
- Improves readability of YAML output for long strings
- Applied to CustomModesManager, SimpleInstaller, and migrateSettings
* fix: add defaultStringType option to yaml.stringify calls
- Added defaultStringType: 'PLAIN' to minimize formatting changes
- This helps preserve plain scalars when possible
- Works alongside lineWidth: 0 to prevent automatic line wrapping
* refactor: extract problematic characters regex as a named constant
- Move regex pattern to PROBLEMATIC_CHARS_REGEX static constant
- Add comprehensive documentation for each character range
- Improves maintainability and makes the pattern reusable
* test: add comprehensive edge case tests for YAML parsing
- Add test for mixed line endings (CRLF vs LF)
- Add test for multiple BOMs in sequence
- Add test for deeply nested structures with problematic characters
- Ensures robustness across different real-world scenarios
* feat(i18n): add error messages for custom modes in multiple languages
* fix: update tests to expect i18n keys instead of hardcoded strings
- Update CustomModesManager tests to expect translation keys
- Fix YAML edge case tests to match new i18n error messages
- All tests now pass with the i18n integration
* refactor: use strip-bom package and fix error handling
- Replace custom stripBOM method with existing strip-bom package
- Fix duplicate error handling in parseYamlSafely by returning empty object instead of re-throwing
- Addresses review comments from PR #5099
---------
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
* Store the organization id in credentials
* Better organization logic
* Fix tests
* Update cloud settings defaults
* Fix organization_id handling in Clerk API calls
Address review feedback by properly handling 3 cases for organization_id:
1. Have an org id: send organization_id=THE_ORG_ID
2. Have a personal account: send organization_id= (empty string)
3. Don't know if you have an org id (old credentials): don't send organization_id param at all
Changes:
- Updated clerkCreateSessionToken() to check credentials.organizationId !== undefined
- Updated fetchUserInfo() to handle all 3 cases consistently
- Added fallback logic for old credentials without organization context
- Improved logging for better debugging of organization context
* DRY up organization loading code in AuthService
Extract common organization membership processing logic into reusable helper methods:
- findOrganizationMembership(): Find specific org membership by ID
- findPrimaryOrganizationMembership(): Get first/primary org membership
- setUserOrganizationInfo(): Set organization info on user object
This eliminates duplication between the two clerkGetOrganizationMemberships()
call sites that were doing very similar organization data processing.