diff --git a/package.json b/package.json index 121adffe67..7099b67a8e 100644 --- a/package.json +++ b/package.json @@ -646,6 +646,11 @@ "default": "number", "description": "%githubIssues.createInsertFormat.description%" }, + "githubIssues.assignToMeOnCreate": { + "type": "boolean", + "default": false, + "description": "%githubIssues.assignToMeOnCreate.description%" + }, "githubIssues.issueCompletions.enabled": { "type": "boolean", "default": true, diff --git a/package.nls.json b/package.nls.json index 73c02b7684..15cdde4ac1 100644 --- a/package.nls.json +++ b/package.nls.json @@ -107,6 +107,7 @@ "githubIssues.createIssueTriggers.items": "String that enables the 'Create issue from comment' code action. Should not contain whitespace.", "githubPullRequests.codingAgent.codeLens.description": "Show the 'Delegate to agent' CodeLens actions above TODO comments for delegating to coding agent.", "githubIssues.createInsertFormat.description": "Controls whether an issue number (ex. #1234) or a full url (ex. https://github.com/owner/name/issues/1234) is inserted when the Create Issue code action is run.", + "githubIssues.assignToMeOnCreate.description": "When enabled, automatically assigns new issues created from TODO/FIXME comments to yourself.", "githubIssues.issueCompletions.enabled.description": "Controls whether completion suggestions are shown for issues.", "githubIssues.userCompletions.enabled.description": "Controls whether completion suggestions are shown for users.", "githubIssues.ignoreCompletionTrigger.description": "Languages that the '#' character should not be used to trigger issue completion suggestions.", diff --git a/src/common/settingKeys.ts b/src/common/settingKeys.ts index 1376c4c7bc..8178206b1a 100644 --- a/src/common/settingKeys.ts +++ b/src/common/settingKeys.ts @@ -47,6 +47,7 @@ export const USER_COMPLETIONS = 'userCompletions'; export const ENABLED = 'enabled'; export const IGNORE_USER_COMPLETION_TRIGGER = 'ignoreUserCompletionTrigger'; export const CREATE_INSERT_FORMAT = 'createInsertFormat'; +export const ASSIGN_TO_ME_ON_CREATE = 'assignToMeOnCreate'; export const ISSUE_BRANCH_TITLE = 'issueBranchTitle'; export const USE_BRANCH_FOR_ISSUES = 'useBranchForIssues'; export const WORKING_ISSUE_FORMAT_SCM = 'workingIssueFormatScm'; diff --git a/src/issues/issueFeatureRegistrar.ts b/src/issues/issueFeatureRegistrar.ts index a4f253a57d..d283861468 100644 --- a/src/issues/issueFeatureRegistrar.ts +++ b/src/issues/issueFeatureRegistrar.ts @@ -15,6 +15,7 @@ import { Disposable } from '../common/lifecycle'; import Logger from '../common/logger'; import { ALWAYS_PROMPT_FOR_NEW_ISSUE_REPO, + ASSIGN_TO_ME_ON_CREATE, CREATE_INSERT_FORMAT, ENABLED, ISSUE_COMPLETIONS, @@ -1000,6 +1001,32 @@ export class IssueFeatureRegistrar extends Disposable { if (matches && matches.length === 2 && (await this._stateManager.getUserMap(document.uri)).has(matches[1])) { assignees = [matches[1]]; } + + // Check if we should auto-assign to the current user + const assignToMe = vscode.workspace.getConfiguration(ISSUES_SETTINGS_NAMESPACE).get(ASSIGN_TO_ME_ON_CREATE, false); + if (assignToMe) { + // Get the folder manager to access the current user + const folderManager = this.manager.getManagerForFile(document.uri); + if (folderManager) { + try { + // Get the GitHub repository for the document to ensure we get the correct user + const githubRepository = folderManager.gitHubRepositories[0]; + const currentUser = await folderManager.getCurrentUser(githubRepository); + if (currentUser?.login) { + // Add current user to assignees if not already included + if (!assignees) { + assignees = [currentUser.login]; + } else if (!assignees.includes(currentUser.login)) { + assignees.push(currentUser.login); + } + } + } catch (error) { + // If we can't get the current user, just continue without auto-assignment + Logger.debug('Failed to get current user for auto-assignment', IssueFeatureRegistrar.ID, error); + } + } + } + let title: string | undefined; const body: string | undefined = await this.createTodoIssueBody(newIssue, issueBody);