feat(embedding): improve robustness with pre-flight checks and URL nprmalization#103
Open
capyBearista wants to merge 1 commit intotickernelz:mainfrom
Open
feat(embedding): improve robustness with pre-flight checks and URL nprmalization#103capyBearista wants to merge 1 commit intotickernelz:mainfrom
capyBearista wants to merge 1 commit intotickernelz:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR hardens embedding initialization and configuration in the plugin by adding local-model preflight/failure handling, surfacing startup feedback to users, and normalizing configured API base URLs before embedding requests are made.
Changes:
- Added local embedding preflight/import failure tracking in
EmbeddingService, plus clearer fallback errors when no API-based embeddings are configured. - Added startup toasts in the plugin entrypoint to warn about unavailable local embeddings and report initialization failures.
- Normalized embedding API URLs to a consistent base form and stripped trailing slashes from memory API URLs in config parsing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/services/embedding.ts |
Adds local embedding preflight logic, failure state tracking, and updated warmup/embed fallback behavior. |
src/index.ts |
Adds embedding-service-aware startup notifications for warning and error cases. |
src/config.ts |
Adds embedding URL normalization helpers and strips trailing slashes from memory API URLs during config build. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+38
to
+45
| if (!embeddingService.localEmbeddingsAvailable && !CONFIG.embeddingApiUrl) { | ||
| if (ctx.client?.tui) { | ||
| ctx.client.tui | ||
| .showToast({ | ||
| body: { | ||
| title: "Memory System", | ||
| message: | ||
| "Local embedding model unavailable. Configure embeddingApiUrl and embeddingApiKey in opencode-mem.jsonc to use API-based embeddings.", |
Comment on lines
+510
to
+512
| embeddingApiUrl: fileConfig.embeddingApiUrl | ||
| ? normalizeEmbeddingUrl(fileConfig.embeddingApiUrl) | ||
| : undefined, |
Comment on lines
+112
to
+114
| log("Local embedding model unavailable (native dependency check failed)", {}); | ||
| this.isWarmedUp = true; | ||
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request improves the robustness and user experience of the embedding system by handling cases where the local embedding model is unavailable, providing clearer configuration and error messaging, and normalizing embedding API URLs. The changes ensure that users are properly notified if local embeddings cannot be loaded and are guided to configure API-based embeddings as a fallback.
Embedding system robustness and user feedback:
src/services/embedding.ts,src/index.ts) [1] [2] [3] [4]@huggingface/transformerslibrary can be imported before attempting to use local embeddings, improving reliability in diverse environments. (src/services/embedding.ts)Configuration improvements:
embeddingApiUrlby automatically appending/v1if missing and stripping any trailing/embeddings, ensuring consistent API usage and reducing configuration errors. (src/config.ts) [1] [2] [3]memoryApiUrlfor consistency. (src/config.ts)Code organization:
embeddingServicein the main plugin entry point to support the new initialization and error handling logic. (src/index.ts)^ Copilot summary