From 16e98c1ced66843f36492f038bd3529a29887a77 Mon Sep 17 00:00:00 2001 From: kubrickcode Date: Sun, 5 Oct 2025 09:19:39 +0000 Subject: [PATCH 1/2] add rebuild command --- .vscode/settings.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.vscode/settings.json b/.vscode/settings.json index 3919393..0b6aff0 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -55,6 +55,12 @@ "shortcut": "c", "command": "export IS_SANDBOX=1 && claude --dangerously-skip-permissions", "useVsCodeApi": false + }, + { + "name": "Rebuild", + "color": "orange", + "command": "just rebuild", + "useVsCodeApi": false } ], "quickCommandButtons.refreshButton": { From a515d2c16069c9a6a74fe16d2ac07d2bb676e356 Mon Sep 17 00:00:00 2001 From: kubrickcode Date: Sun, 5 Oct 2025 09:22:53 +0000 Subject: [PATCH 2/2] Replace hardcoded project statuses with dynamic detection Remove fixed status union types (\"Backlog\", \"Ready\", \"In progress\", etc.) and implement dynamic status handling that works with any GitHub Project V2 status field values. Add hash-based color assignment using a predefined palette to ensure consistent badge styling across different project configurations. fix #3 --- public/styles.css | 20 -------------------- src/background.ts | 13 +++---------- src/content.ts | 38 +++++++++++++++++++++++++------------- 3 files changed, 28 insertions(+), 43 deletions(-) diff --git a/public/styles.css b/public/styles.css index a3a915d..21deb30 100644 --- a/public/styles.css +++ b/public/styles.css @@ -9,23 +9,3 @@ color: white; vertical-align: middle; } - -.status-backlog { - background-color: #6e7781; -} - -.status-ready { - background-color: #0969da; -} - -.status-in-progress { - background-color: #bf8700; -} - -.status-in-review { - background-color: #8250df; -} - -.status-done { - background-color: #1a7f37; -} diff --git a/src/background.ts b/src/background.ts index b1ae2f4..004866c 100644 --- a/src/background.ts +++ b/src/background.ts @@ -3,16 +3,9 @@ pat: string; }; - type ProjectStatus = - | "Backlog" - | "Ready" - | "In progress" - | "In review" - | "Done"; - type IssueStatus = { number: number; - status: ProjectStatus | null; + status: string | null; }; type GraphQLResponse = { @@ -96,7 +89,7 @@ }; const buildIssueStatusMap = (issues: IssueNode[]) => { - const issueStatusMap = new Map(); + const issueStatusMap = new Map(); issues.forEach((issue) => { if (!issue.number || !issue.projectItems.nodes.length) return; @@ -107,7 +100,7 @@ ); if (statusField?.name) { - issueStatusMap.set(issue.number, statusField.name as ProjectStatus); + issueStatusMap.set(issue.number, statusField.name); } }); diff --git a/src/content.ts b/src/content.ts index 520adb0..b4dd39b 100644 --- a/src/content.ts +++ b/src/content.ts @@ -1,20 +1,34 @@ (() => { - type ProjectStatus = - | "Backlog" - | "Ready" - | "In progress" - | "In review" - | "Done"; - type IssueStatus = { number: number; - status: ProjectStatus | null; + status: string | null; }; const GITHUB_ISSUES_URL_PATTERN = /https:\/\/github\.com\/[^/]+\/[^/]+\/issues/; const BADGE_CLASS = "project-status-badge"; + const STATUS_COLORS = [ + "#0969da", // blue + "#1a7f37", // green + "#bf8700", // yellow + "#8250df", // purple + "#cf222e", // red + "#fb8500", // orange + "#0550ae", // dark blue + "#116329", // dark green + "#6e7781", // gray + ]; + + const getStatusColor = (status: string): string => { + let hash = 0; + for (let i = 0; i < status.length; i++) { + hash = (hash << 5) - hash + status.charCodeAt(i); + hash = hash & hash; + } + return STATUS_COLORS[Math.abs(hash) % STATUS_COLORS.length]; + }; + const getIssueNumbers = (): number[] => { const issueElements = document.querySelectorAll( '[data-testid="issue-pr-title-link"]' @@ -43,7 +57,7 @@ return numbers; }; - const addStatusBadge = (issueNumber: number, status: ProjectStatus) => { + const addStatusBadge = (issueNumber: number, status: string) => { const issueLinks = document.querySelectorAll( '[data-testid="issue-pr-title-link"]' ); @@ -68,11 +82,9 @@ } const badge = document.createElement("span"); - badge.className = `${BADGE_CLASS} status-${status - .toLowerCase() - .replace(/\s+/g, "-")}`; + badge.className = BADGE_CLASS; badge.textContent = status; - badge.style.marginLeft = "8px"; + badge.style.backgroundColor = getStatusColor(status); parent.appendChild(badge); console.log(