Skip to content

Commit 8fd0a5c

Browse files
Copilotalexr00
andauthored
Fix issue closed state colors to match GitHub.com behavior with state reason support (#7629)
* Initial plan * Fix issue colors: use purple for closed issues instead of red Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Use the existing purple color * Initial plan to implement state reason for closed issues Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Add stateReason support to distinguish closed issues by completion status Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Fix TypeScript error and linting issues with stateReason parameter Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com> * Propagate state reason --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
1 parent ec56f20 commit 8fd0a5c

12 files changed

Lines changed: 36 additions & 13 deletions

File tree

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3436,8 +3436,8 @@
34363436
{
34373437
"id": "issues.closed",
34383438
"defaults": {
3439-
"dark": "#cb2431",
3440-
"light": "#cb2431",
3439+
"dark": "pullRequests.merged",
3440+
"light": "pullRequests.merged",
34413441
"highContrast": "editor.foreground",
34423442
"highContrastLight": "editor.foreground"
34433443
},
@@ -3476,8 +3476,8 @@
34763476
{
34773477
"id": "pullRequests.closed",
34783478
"defaults": {
3479-
"dark": "issues.closed",
3480-
"light": "issues.closed",
3479+
"dark": "#cb2431",
3480+
"light": "#cb2431",
34813481
"highContrast": "editor.background",
34823482
"highContrastLight": "editor.background"
34833483
},

src/github/graphql.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ export interface Issue {
638638
number: number;
639639
url: string;
640640
state: 'OPEN' | 'CLOSED' | 'MERGED'; // TODO: don't allow merged in an issue
641+
stateReason?: 'REOPENED' | 'NOT_PLANNED' | 'COMPLETED' | 'DUPLICATE';
641642
body: string;
642643
bodyHTML: string;
643644
title: string;

src/github/interface.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,15 @@ export interface Reaction {
189189
reactors: readonly string[];
190190
}
191191

192+
export type StateReason = 'REOPENED' | 'NOT_PLANNED' | 'COMPLETED' | 'DUPLICATE';
193+
192194
export interface Issue {
193195
id: number;
194196
graphNodeId: string;
195197
url: string;
196198
number: number;
197199
state: string;
200+
stateReason?: StateReason;
198201
body: string;
199202
bodyHTML?: string;
200203
title: string;

src/github/issueModel.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import {
2323
TimelineEventsResponse,
2424
UpdateIssueResponse,
2525
} from './graphql';
26-
import { GithubItemStateEnum, IAccount, IIssueEditData, IMilestone, IProject, IProjectItem, Issue } from './interface';
26+
import { GithubItemStateEnum, IAccount, IIssueEditData, IMilestone, IProject, IProjectItem, Issue, StateReason } from './interface';
2727
import { convertRESTIssueToRawPullRequest, eventTime, parseCombinedTimelineEvents, parseGraphQlIssueComment, parseMilestone, parseSelectRestTimelineEvents, restPaginate } from './utils';
2828

2929
export interface IssueChangeEvent {
@@ -52,6 +52,7 @@ export class IssueModel<TItem extends Issue = Issue> extends Disposable {
5252
public titleHTML: string;
5353
public html_url: string;
5454
public state: GithubItemStateEnum = GithubItemStateEnum.Open;
55+
public stateReason?: StateReason;
5556
public author: IAccount;
5657
public assignees?: IAccount[];
5758
public createdAt: string;
@@ -175,6 +176,10 @@ export class IssueModel<TItem extends Issue = Issue> extends Disposable {
175176
changes.state = true;
176177
this.state = newState;
177178
}
179+
if ((this.stateReason !== issue.stateReason) && issue.stateReason) {
180+
changes.state = true;
181+
this.stateReason = issue.stateReason;
182+
}
178183
if (issue.assignees && (issue.assignees.length !== (this.assignees?.length ?? 0) || issue.assignees.some(assignee => this.assignees?.every(a => a.id !== assignee.id)))) {
179184
changes.assignees = true;
180185
this.assignees = issue.assignees;

src/github/issueOverview.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ export class IssueOverviewPanel<TItem extends IssueModel = IssueModel> extends W
220220
labels: labels,
221221
author: issue.author,
222222
state: issue.state,
223+
stateReason: issue.stateReason,
223224
events: timelineEvents,
224225
continueOnGitHub: this.continueOnGitHub(),
225226
canEdit,

src/github/markdownUtils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ function getIconMarkdown(issue: IssueModel) {
3838
return `<span style="color:#22863a;">$(issues)</span>`;
3939
}
4040
case GithubItemStateEnum.Closed: {
41-
return `<span style="color:#cb2431;">$(issue-closed)</span>`;
41+
// Use grey for issues closed as "not planned", purple for "completed"
42+
const color = issue.stateReason !== 'COMPLETED' ? '#6a737d' : '#8957e5';
43+
return `<span style="color:${color};">$(issue-closed)</span>`;
4244
}
4345
}
4446
}

src/github/queries.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fragment IssueBase on Issue {
6464
number
6565
url
6666
state
67+
stateReason
6768
body
6869
bodyHTML
6970
title

src/github/queriesExtra.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ fragment IssueBase on Issue {
6464
number
6565
url
6666
state
67+
stateReason
6768
body
6869
bodyHTML
6970
title

src/github/queriesLimited.gql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fragment IssueBase on Issue {
5454
number
5555
url
5656
state
57+
stateReason
5758
body
5859
bodyHTML
5960
title

src/github/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,7 @@ export async function parseGraphQLIssue(issue: GraphQL.Issue, githubRepository:
942942
url: issue.url,
943943
number: issue.number,
944944
state: issue.state,
945+
stateReason: issue.stateReason,
945946
body: issue.body,
946947
bodyHTML: await transformHtmlUrlsToExtensionUrls(issue.bodyHTML, githubRepository),
947948
title: issue.title,

0 commit comments

Comments
 (0)