-
Notifications
You must be signed in to change notification settings - Fork 2.6k
fix: improve code index error handling and add text-embedding-v4 support #7357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2266,21 +2266,108 @@ export const webviewMessageHandler = async ( | |
| } | ||
| if (manager.isFeatureEnabled && manager.isFeatureConfigured) { | ||
| if (!manager.isInitialized) { | ||
| await manager.initialize(provider.contextProxy) | ||
| try { | ||
| await manager.initialize(provider.contextProxy) | ||
| } catch (initError) { | ||
| // Initialization failed - send detailed error to user | ||
| const errorMessage = initError instanceof Error ? initError.message : String(initError) | ||
| provider.log(`Code index initialization failed: ${errorMessage}`) | ||
|
|
||
| // Send error status to webview with user-friendly message | ||
| provider.postMessageToWebview({ | ||
| type: "indexingStatusUpdate", | ||
| values: { | ||
| systemStatus: "Error", | ||
| message: errorMessage, | ||
| processedItems: 0, | ||
| totalItems: 0, | ||
| currentItemUnit: "items", | ||
| }, | ||
| }) | ||
|
|
||
| // Show error notification to user | ||
| vscode.window.showErrorMessage( | ||
| t("embeddings:validation.initializationFailed", { error: errorMessage }) || | ||
| `Code indexing initialization failed: ${errorMessage}`, | ||
| ) | ||
| return | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I notice there's duplicate error handling logic between the initialization (lines 2269-2294) and re-initialization (lines 2302-2329) blocks. Could we extract this into a helper function to reduce duplication? Something like: failed: Code indexing initialization failed: |
||
| } | ||
|
|
||
| // startIndexing now handles error recovery internally | ||
| manager.startIndexing() | ||
|
|
||
| // If startIndexing recovered from error, we need to reinitialize | ||
| if (!manager.isInitialized) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is immediate re-initialization after failure intentional? Consider adding a delay or maximum retry count to prevent rapid repeated failures that could impact performance. |
||
| await manager.initialize(provider.contextProxy) | ||
| // Try starting again after initialization | ||
| manager.startIndexing() | ||
| try { | ||
| await manager.initialize(provider.contextProxy) | ||
| // Try starting again after initialization | ||
| manager.startIndexing() | ||
| } catch (reinitError) { | ||
| // Re-initialization failed - send detailed error to user | ||
| const errorMessage = | ||
| reinitError instanceof Error ? reinitError.message : String(reinitError) | ||
| provider.log(`Code index re-initialization failed: ${errorMessage}`) | ||
|
|
||
| // Send error status to webview | ||
| provider.postMessageToWebview({ | ||
| type: "indexingStatusUpdate", | ||
| values: { | ||
| systemStatus: "Error", | ||
| message: errorMessage, | ||
| processedItems: 0, | ||
| totalItems: 0, | ||
| currentItemUnit: "items", | ||
| }, | ||
| }) | ||
|
|
||
| // Show error notification to user | ||
| vscode.window.showErrorMessage( | ||
| t("embeddings:validation.initializationFailed", { error: errorMessage }) || | ||
| `Code indexing initialization failed: ${errorMessage}`, | ||
| ) | ||
| } | ||
| } | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider adding test coverage for these new error handling scenarios. Would be good to have tests for:
This would help ensure the error handling continues to work as expected. |
||
| } else { | ||
| // Feature is not enabled or not configured | ||
| const message = !manager.isFeatureEnabled | ||
| ? t("embeddings:validation.featureDisabled") || "Code indexing is disabled" | ||
| : t("embeddings:validation.notConfigured") || "Code indexing is not properly configured" | ||
|
|
||
| provider.postMessageToWebview({ | ||
| type: "indexingStatusUpdate", | ||
| values: { | ||
| systemStatus: "Error", | ||
| message: message, | ||
| processedItems: 0, | ||
| totalItems: 0, | ||
| currentItemUnit: "items", | ||
| }, | ||
| }) | ||
|
|
||
| vscode.window.showErrorMessage(message) | ||
| } | ||
| } catch (error) { | ||
| provider.log(`Error starting indexing: ${error instanceof Error ? error.message : String(error)}`) | ||
| const errorMessage = error instanceof Error ? error.message : String(error) | ||
| provider.log(`Error starting indexing: ${errorMessage}`) | ||
|
|
||
| // Send error status to webview | ||
| provider.postMessageToWebview({ | ||
| type: "indexingStatusUpdate", | ||
| values: { | ||
| systemStatus: "Error", | ||
| message: errorMessage, | ||
| processedItems: 0, | ||
| totalItems: 0, | ||
| currentItemUnit: "items", | ||
| }, | ||
| }) | ||
|
|
||
| // Show error notification to user | ||
| vscode.window.showErrorMessage( | ||
| t("embeddings:validation.startIndexingFailed", { error: errorMessage }) || | ||
| `Failed to start indexing: ${errorMessage}`, | ||
| ) | ||
| } | ||
| break | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,6 +40,7 @@ export const EMBEDDING_MODEL_PROFILES: EmbeddingModelProfiles = { | |
| "text-embedding-3-small": { dimension: 1536, scoreThreshold: 0.4 }, | ||
| "text-embedding-3-large": { dimension: 3072, scoreThreshold: 0.4 }, | ||
| "text-embedding-ada-002": { dimension: 1536, scoreThreshold: 0.4 }, | ||
| "text-embedding-v4": { dimension: 1536, scoreThreshold: 0.4 }, // Added support for text-embedding-v4 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment could be more descriptive. Consider: |
||
| "nomic-embed-code": { | ||
| dimension: 3584, | ||
| scoreThreshold: 0.15, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using inline fallback English strings in translation calls. The t() calls (e.g. for 'initializationFailed' and 'startIndexingFailed') already have definitions in the i18n JSON; remove the || fallback portions.
This comment was generated because it violated a code review rule: irule_C0ez7Rji6ANcGkkX.