Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions extensions/cursor/src/manager/cursor-inference-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ describe('connection delete lifecycle', () => {

expect(SECRET_STORAGE_MOCK.delete).toHaveBeenCalledWith(`${PROVIDER_ID}:fake-uuid-1:token`);

expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection._type', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection.token', undefined);

expect(disposeMock).toHaveBeenCalledOnce();
});
Expand Down Expand Up @@ -270,8 +270,8 @@ describe('workspace configuration', () => {
const connection = vi.mocked(PROVIDER_MOCK.registerInferenceProviderConnection).mock.calls[0][0];
expect(configuration.getConfiguration).toHaveBeenCalledWith(undefined, connection);

expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:fake-uuid-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection._type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection.token', `${PROVIDER_ID}:fake-uuid-1:token`);
});

test('should set workspace configuration for each restored connection', async () => {
Expand All @@ -287,9 +287,9 @@ describe('workspace configuration', () => {
expect(SECRET_STORAGE_MOCK.store).toHaveBeenCalledWith(`${PROVIDER_ID}:id-1:token`, 'key1');
expect(SECRET_STORAGE_MOCK.store).toHaveBeenCalledWith(`${PROVIDER_ID}:id-2:token`, 'key2');

expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:id-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:id-2:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection._type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection.token', `${PROVIDER_ID}:id-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('cursor.connection.token', `${PROVIDER_ID}:id-2:token`);
});
});

Expand Down
10 changes: 5 additions & 5 deletions extensions/cursor/src/manager/cursor-inference-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,17 +115,17 @@ export class CursorInferenceManager {
await this.secrets.store(secretName, token);

const config = configuration.getConfiguration(undefined, connection);
await config.update('_type', PROVIDER_ID);
await config.update('token', secretName);
await config.update('cursor.connection._type', PROVIDER_ID);
await config.update('cursor.connection.token', secretName);
}

private async clearConnectionConfiguration(connection: InferenceProviderConnection): Promise<void> {
const secretName = this.getSecretName(connection.id);
await this.secrets.delete(secretName);

const config = configuration.getConfiguration('cursor.connection', connection);
await config.update('_type', undefined);
await config.update('token', undefined);
const config = configuration.getConfiguration(undefined, connection);
await config.update('cursor.connection._type', undefined);
await config.update('cursor.connection.token', undefined);
}

private async registerInferenceProviderConnection({ id, token }: { id: string; token: string }): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ describe('connection delete lifecycle', () => {

expect(SECRET_STORAGE_MOCK.delete).toHaveBeenCalledWith(`${PROVIDER_ID}:fake-uuid-1:token`);

expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection._type', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection.token', undefined);

expect(disposeMock).toHaveBeenCalledOnce();
});
Expand Down Expand Up @@ -305,8 +305,8 @@ describe('workspace configuration', () => {
const connection = vi.mocked(PROVIDER_MOCK.registerInferenceProviderConnection).mock.calls[0][0];
expect(configuration.getConfiguration).toHaveBeenCalledWith(undefined, connection);

expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:fake-uuid-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection._type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection.token', `${PROVIDER_ID}:fake-uuid-1:token`);
});

test('should set workspace configuration for each restored connection', async () => {
Expand All @@ -322,9 +322,9 @@ describe('workspace configuration', () => {
expect(SECRET_STORAGE_MOCK.store).toHaveBeenCalledWith(`${PROVIDER_ID}:id-1:token`, 'key1');
expect(SECRET_STORAGE_MOCK.store).toHaveBeenCalledWith(`${PROVIDER_ID}:id-2:token`, 'key2');

expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:id-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:id-2:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection._type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection.token', `${PROVIDER_ID}:id-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('mistral.connection.token', `${PROVIDER_ID}:id-2:token`);
});
});

Expand Down
8 changes: 4 additions & 4 deletions extensions/mistral/src/manager/mistral-inference-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,17 @@ export class MistralInferenceManager {
await this.secrets.store(secretName, token);

const config = configuration.getConfiguration(undefined, connection);
await config.update('_type', PROVIDER_ID);
await config.update('token', secretName);
await config.update('mistral.connection._type', PROVIDER_ID);
await config.update('mistral.connection.token', secretName);
}

private async clearConnectionConfiguration(connection: InferenceProviderConnection): Promise<void> {
const secretName = this.getSecretName(connection.id);
await this.secrets.delete(secretName);

const config = configuration.getConfiguration('mistral.connection', connection);
await config.update('_type', undefined);
await config.update('token', undefined);
await config.update('mistral.connection._type', undefined);
await config.update('mistral.connection.token', undefined);
Comment thread
coderabbitai[bot] marked this conversation as resolved.
}

private async registerInferenceProviderConnection({ id, token }: { id: string; token: string }): Promise<void> {
Expand Down
16 changes: 8 additions & 8 deletions extensions/openai-compatible/src/openAI.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,8 @@ describe('connection delete lifecycle', () => {
expect(SECRET_STORAGE_MOCK.delete).toHaveBeenCalledWith(`${PROVIDER_ID}:fake-uuid-1:token`);

// configuration values should be cleared
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection._type', undefined);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection.token', undefined);

// provider inference connection should be disposed
expect(disposeMock).toHaveBeenCalledOnce();
Expand Down Expand Up @@ -279,11 +279,11 @@ describe('workspace configuration', () => {

// configuration should be scoped to the connection object
const connection = vi.mocked(PROVIDER_MOCK.registerInferenceProviderConnection).mock.calls[0][0];
expect(CONFIGURATION_API_MOCK.getConfiguration).toHaveBeenCalledWith('openai.connection', connection);
expect(CONFIGURATION_API_MOCK.getConfiguration).toHaveBeenCalledWith(undefined, connection);

// _type and token should be set
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:fake-uuid-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection._type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection.token', `${PROVIDER_ID}:fake-uuid-1:token`);
});

test('should set workspace configuration for each restored connection', async () => {
Expand All @@ -301,9 +301,9 @@ describe('workspace configuration', () => {
expect(SECRET_STORAGE_MOCK.store).toHaveBeenCalledWith(`${PROVIDER_ID}:id-2:token`, 'key2');

// configuration should be set for each connection
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('_type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:id-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('token', `${PROVIDER_ID}:id-2:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection._type', PROVIDER_ID);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection.token', `${PROVIDER_ID}:id-1:token`);
expect(CONFIG_UPDATE_MOCK).toHaveBeenCalledWith('openai.connection.token', `${PROVIDER_ID}:id-2:token`);
});
});

Expand Down
12 changes: 6 additions & 6 deletions extensions/openai-compatible/src/openAI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,18 @@ export class OpenAI implements Disposable {
const secretName = this.getSecretName(connection.id);
await this.secrets.store(secretName, token);

const config = this.configurationAPI.getConfiguration('openai.connection', connection);
await config.update('_type', PROVIDER_ID);
await config.update('token', secretName);
const config = this.configurationAPI.getConfiguration(undefined, connection);
await config.update('openai.connection._type', PROVIDER_ID);
await config.update('openai.connection.token', secretName);
}

private async clearConnectionConfiguration(connection: InferenceProviderConnection): Promise<void> {
const secretName = this.getSecretName(connection.id);
await this.secrets.delete(secretName);

const config = this.configurationAPI.getConfiguration('openai.connection', connection);
await config.update('_type', undefined);
await config.update('token', undefined);
const config = this.configurationAPI.getConfiguration(undefined, connection);
await config.update('openai.connection._type', undefined);
await config.update('openai.connection.token', undefined);
}

private async registerInferenceProviderConnection({
Expand Down
Loading
Loading