Skip to content

Enhances remote provider connection flow #4411

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion src/commands/remoteProviders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { CommandContext } from './commandContext';
import { isCommandContextViewNodeHasRemote } from './commandContext.utils';

export interface ConnectRemoteProviderCommandArgs {
remote: string;
remote?: string;
Copy link
Contributor

@axosoft-ramint axosoft-ramint Jul 31, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does feel a bit weird that we could call "ConnectRemoteProvider" as a command without a remote supplied, but that's probably just semantics at this point.

LGTM will verify once it's in, thanks for updating it!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axosoft-ramint

It does feel a bit weird that we could call "ConnectRemoteProvider" as a command without a remote supplied

Yes. It's called "connect provider" but connects an integration. The question is what if I have 2 remotes: one for GitHub and another one for Azure and both are disconnected. But at some point on the previous version with ConnectCloudIntegrationsCommand it should have been defined somehow too.

In ConnectRemoteProviderCommand it can be called without a defined remote and there is a code substitute a value for remote:

image

With old ConnectCloudIntegrationsCommand we already had a provider and took an integration-id from it:
image

But how that provider has been picked? I'm going to check out the origin of the provider value there and maybe it will be possible to take a remote for it in that place. Or, maybe the ConnectRemoteProviderCommand could accept provider argument when remote is unknown, because having provider is enough for getting its integration.

repoPath: string;
}

Expand Down
15 changes: 7 additions & 8 deletions src/webviews/apps/shared/components/repo-button-group.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { css, html, nothing } from 'lit';
import { customElement, property } from 'lit/decorators.js';
import { ifDefined } from 'lit/directives/if-defined.js';
import { when } from 'lit/directives/when.js';
import type { ConnectCloudIntegrationsCommandArgs } from '../../../../commands/cloudIntegrations';
import type { ConnectRemoteProviderCommandArgs } from '../../../../commands/remoteProviders';
import type { Source } from '../../../../constants.telemetry';
import type { RepositoryShape } from '../../../../git/models/repositoryShape';
import { createCommandLink } from '../../../../system/commands';
Expand Down Expand Up @@ -198,9 +198,9 @@ export class GlRepoButtonGroup extends GlElement {
return html`
<code-icon style="margin-top: -3px" icon="plug" aria-hidden="true"></code-icon>
<a
href=${createCommandLink<ConnectCloudIntegrationsCommandArgs>(
'gitlens.plus.cloudIntegrations.connect',
{ integrationIds: [provider.integration!.id], source: this.source },
href=${createCommandLink<ConnectRemoteProviderCommandArgs>(
'gitlens.connectRemoteProvider',
{ repoPath: repo.path },
)}
>
Connect to ${repo.provider!.name}
Expand All @@ -227,10 +227,9 @@ export class GlRepoButtonGroup extends GlElement {
<gl-button
part="connect-icon"
appearance="toolbar"
href=${createCommandLink<ConnectCloudIntegrationsCommandArgs>(
'gitlens.plus.cloudIntegrations.connect',
{ integrationIds: [provider.integration.id], source: this.source },
)}
href=${createCommandLink<ConnectRemoteProviderCommandArgs>('gitlens.connectRemoteProvider', {
repoPath: repo.path,
})}
>
<code-icon icon="plug" style="color: var(--titlebar-fg)"></code-icon>
<span slot="tooltip">
Expand Down
6 changes: 6 additions & 0 deletions src/webviews/home/homeWebview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import type { SubscriptionChangeEvent } from '../../plus/gk/subscriptionService'
import { isAiAllAccessPromotionActive } from '../../plus/gk/utils/-webview/promo.utils';
import { isSubscriptionTrialOrPaidFromState } from '../../plus/gk/utils/subscription.utils';
import type { ConfiguredIntegrationsChangeEvent } from '../../plus/integrations/authentication/configuredIntegrationService';
import type { ConnectionStateChangeEvent } from '../../plus/integrations/integrationService';
import { providersMetadata } from '../../plus/integrations/providers/models';
import type { LaunchpadCategorizedResult } from '../../plus/launchpad/launchpadProvider';
import { getLaunchpadItemGroups } from '../../plus/launchpad/launchpadProvider';
Expand Down Expand Up @@ -175,6 +176,7 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
this.container.subscription.onDidChange(this.onSubscriptionChanged, this),
onDidChangeContext(this.onContextChanged, this),
this.container.integrations.onDidChange(this.onIntegrationsChanged, this),
this.container.integrations.onDidChangeConnectionState(this.onIntegrationConnectionStateChanged, this),
this.container.walkthrough?.onDidChangeProgress(this.onWalkthroughProgressChanged, this) ?? emptyDisposable,
configuration.onDidChange(this.onDidChangeConfig, this),
this.container.launchpad.onDidChange(this.onLaunchpadChanged, this),
Expand Down Expand Up @@ -243,6 +245,10 @@ export class HomeWebviewProvider implements WebviewProvider<State, State, HomeWe
void this.notifyDidChangeIntegrations();
}

private onIntegrationConnectionStateChanged(_e: ConnectionStateChangeEvent) {
void this.notifyDidChangeIntegrations();
}

private async onChooseRepository() {
const currentRepo = this.getSelectedRepository();
// Ensure that the current repository is always last
Expand Down