Skip to content

API for repository description#7066

Merged
alexr00 merged 10 commits intomainfrom
osortega/repository-description-api
Jun 26, 2025
Merged

API for repository description#7066
alexr00 merged 10 commits intomainfrom
osortega/repository-description-api

Conversation

@osortega
Copy link
Copy Markdown
Contributor

Adding an API for fetching repository description

rebornix
rebornix previously approved these changes Jun 24, 2025
DonJayamanne
DonJayamanne previously approved these changes Jun 24, 2025
Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

This is something other users have actually asked for too, so it's cool that we'll have it. What are planning to use if for?

Comment thread src/api/api.d.ts
Comment thread src/extension.ts Outdated
Comment thread src/api/api1.ts Outdated
DonJayamanne
DonJayamanne previously approved these changes Jun 24, 2025
@osortega osortega requested a review from alexr00 June 25, 2025 06:55
Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

I still don't think this is the right approach to give chat info about the active PR. This is a bad pattern:

  • PR extension exposes active PR API
  • Copilot extension calls PR extension's API
  • Copilot extension adds this context to chat.
    This means that every time we have an extension that wants to contribut context, the Copilot extension needs to know about it.

Instead, we should have VS Code extension API:

export interface ChatContextProvider {
    // Returns a short string context. Shortness will be enforced.
    provideContext(): Promise<string>
}

registerChatContextProvider(provider: ChatContextProvider);

Comment thread src/api/api.d.ts Outdated
Comment thread src/api/api1.ts Outdated
}

async getRepositoryDescription(uri: vscode.Uri) {
const repo = this.getGitProvider(uri)?.repositories.find(r => r.rootUri.fsPath === uri.fsPath);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Instead of checking for equality with the rootUri, we should find the git repo where the uri is a subpath of the git repo's uri. This could be multiple repos.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We have a method that does this already for folder managers, I think you can just use that.

getManagerForFile(uri: vscode.Uri): FolderRepositoryManager | undefined {
if (uri.scheme === 'untitled') {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ahhh thanks for this pointer! Makes it so much easier

Comment thread src/api/api1.ts Outdated

if (folderManagerForRepo && folderManagerForRepo.gitHubRepositories.length > 0) {
const repositoryMetadata = await folderManagerForRepo.gitHubRepositories[0].getMetadata();
const pullRequest = folderManagerForPR?.activePullRequest ?? PullRequestOverviewPanel.currentPanel?.getCurrentItem();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's keep this just to the currently checked out PR, not the PR in the webview. When users have asked for this feature in the past they really just want to know about the currently checked out PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good idea, removed the logic that gets it through the panel

Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

Just to emphasize that the Copilot extension should not know about the PR extension: I want to delete the PR title and description stuff from the Copilot extension and move it into the PR extension and will do so in a future debt week.

alexr00
alexr00 previously approved these changes Jun 26, 2025
Copy link
Copy Markdown
Member

@alexr00 alexr00 left a comment

Choose a reason for hiding this comment

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

I'm about to make a pre-release, and I know you've been waiting for this to get in. I pushed some very minor chnages in the interest of getting this into the pre-release sooner. Thank you for addressing my comments!

@alexr00 alexr00 enabled auto-merge (squash) June 26, 2025 09:26
@alexr00 alexr00 merged commit 92971a8 into main Jun 26, 2025
3 checks passed
@alexr00 alexr00 deleted the osortega/repository-description-api branch June 26, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants