Skip to content

Commit ba069a4

Browse files
Fixes integration connection sources not making it through
1 parent 9d3a860 commit ba069a4

File tree

5 files changed

+12
-10
lines changed

5 files changed

+12
-10
lines changed

src/commands/patches.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ export class OpenCloudPatchCommand extends Command {
344344
return;
345345
}
346346

347-
const session = await integration.getSession();
347+
const session = await integration.getSession('cloud-patches');
348348
if (session == null) {
349349
void window.showErrorMessage(`Cannot open ${type}; provider not connected.`);
350350
return;

src/plus/drafts/draftsService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ export class DraftService implements Disposable {
766766
}
767767
if (integration == null) return undefined;
768768

769-
const session = await integration.getSession();
769+
const session = await integration.getSession('code-suggest');
770770
if (session == null) return undefined;
771771

772772
return {

src/plus/integrations/integration.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,15 @@ export abstract class IntegrationBase<
129129
}
130130

131131
protected _session: ProviderAuthenticationSession | null | undefined;
132-
getSession() {
132+
getSession(source: Sources) {
133133
if (this._session === undefined) {
134-
return this.ensureSession({ createIfNeeded: false });
134+
return this.ensureSession({ createIfNeeded: false, source: source });
135135
}
136136
return this._session ?? undefined;
137137
}
138138

139139
@log()
140-
async connect(source?: Sources): Promise<boolean> {
140+
async connect(source: Sources): Promise<boolean> {
141141
try {
142142
return Boolean(await this.ensureSession({ createIfNeeded: true, source: source }));
143143
} catch (ex) {
@@ -290,7 +290,7 @@ export abstract class IntegrationBase<
290290
@gate()
291291
@debug({ exit: true })
292292
async isConnected(): Promise<boolean> {
293-
return (await this.getSession()) != null;
293+
return (await this.getSession('integrations')) != null;
294294
}
295295

296296
@gate()

src/plus/integrations/providers/github.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { AuthenticationSession, CancellationToken } from 'vscode';
2+
import type { Sources } from '../../../constants';
23
import type { Container } from '../../../container';
34
import type { Account, UnidentifiedAuthor } from '../../../git/models/author';
45
import type { DefaultBranch } from '../../../git/models/defaultBranch';
@@ -302,7 +303,7 @@ export class GitHubEnterpriseIntegration extends GitHubIntegrationBase<SelfHoste
302303
}
303304

304305
@log()
305-
override async connect(): Promise<boolean> {
306+
override async connect(source: Sources): Promise<boolean> {
306307
if (
307308
!(await ensurePaidPlan(this.container, `Rich integration with ${this.name} is a Pro feature.`, {
308309
source: 'integrations',
@@ -312,6 +313,6 @@ export class GitHubEnterpriseIntegration extends GitHubIntegrationBase<SelfHoste
312313
return false;
313314
}
314315

315-
return super.connect();
316+
return super.connect(source);
316317
}
317318
}

src/plus/integrations/providers/gitlab.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { AuthenticationSession, CancellationToken } from 'vscode';
22
import { window } from 'vscode';
3+
import type { Sources } from '../../../constants';
34
import type { Container } from '../../../container';
45
import type { Account } from '../../../git/models/author';
56
import type { DefaultBranch } from '../../../git/models/defaultBranch';
@@ -349,7 +350,7 @@ export class GitLabSelfHostedIntegration extends GitLabIntegrationBase<SelfHoste
349350
}
350351

351352
@log()
352-
override async connect(): Promise<boolean> {
353+
override async connect(source: Sources): Promise<boolean> {
353354
if (
354355
!(await ensurePaidPlan(this.container, `Rich integration with ${this.name} is a Pro feature.`, {
355356
source: 'integrations',
@@ -359,6 +360,6 @@ export class GitLabSelfHostedIntegration extends GitLabIntegrationBase<SelfHoste
359360
return false;
360361
}
361362

362-
return super.connect();
363+
return super.connect(source);
363364
}
364365
}

0 commit comments

Comments
 (0)