feat: support workspace variable interpolation in Provider Custom Headers #11166
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.
Summary
This PR attempts to address Issue #11165 by adding support for VS Code variable interpolation in Provider Custom Headers.
Changes
New Features
interpolateHeadersfunction tosrc/utils/config.tsthat supports:${workspaceFolder}- Full path to the workspace root${workspaceFolderBasename}- Just the folder name (e.g.,my-repo-name)${env:VAR_NAME}- Environment variablesIntegration Points
buildApiHandler(src/api/index.ts) so all providers benefit automaticallygetOpenAiModelsfunction to interpolate headers when fetching modelsTests
interpolateHeadersfunction covering:Usage Example
After this change, users can configure a custom header like:
And when working in a project at
/home/user/projects/my-awesome-app, the actual header sent would be:Related Issues
Closes #11165
Feedback
Feedback and guidance are welcome!
Important
Add support for VS Code variable interpolation in provider custom headers via
interpolateHeadersfunction.interpolateHeadersfunction inconfig.tsto support${workspaceFolder},${workspaceFolderBasename}, and${env:VAR_NAME}in headers.interpolateHeadersinbuildApiHandlerinindex.tsandgetOpenAiModelsinopenai.tsfor automatic header interpolation.interpolateHeadersinconfig.spec.tscovering variable interpolation, environment variables, mixed variables, and edge cases.This description was created by
for f9abbd1. You can customize this summary. It will automatically update as commits are pushed.