Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix: show GitLab issue label colors in managed-app Issues tab (#7410)

Adam Eivy1ea84392f8d8
diff --git a/server/services/appIssues.js b/server/services/appIssues.js
index bc48f9e408..1c1c90b381 100644
--- a/server/services/appIssues.js
+++ b/server/services/appIssues.js
@@ -45,6 +45,14 @@ const truncateBody = (body) => {
return text.length > BODY_MAX_CHARS ? `${text.slice(0, BODY_MAX_CHARS)}\n\n…(truncated)` : text;
};
+/**
+ * Forge label colors arrive bare (`d73a4a`) or `#`-prefixed (`#d73a4a`);
+ * the UI needs the `#rrggbb` form `chipColors`/`parseColor` accepts.
+ */
+const normalizeLabelColor = (color) => (
+ color ? `#${String(color).replace(/^#/, '')}` : null
+);
+
/**
* Normalize a raw `gh issue list --json` row into the common issue shape.
* GitHub labels carry a hex `color` with no `#`; the UI needs it prefixed.
@@ -62,7 +70,7 @@ function normalizeGithubIssue(issue) {
labels: Array.isArray(issue.labels)
? issue.labels.filter(Boolean).map((l) => ({
name: l.name || '',
- color: l.color ? `#${String(l.color).replace(/^#/, '')}` : null,
+ color: normalizeLabelColor(l.color),
description: l.description || '',
})).filter((l) => l.name)
: [],
@@ -83,8 +91,13 @@ function normalizeGithubIssue(issue) {
* across glab versions, and a silently-dropped label list is worse than an
* unused branch. GitLab counts discussion in `user_notes_count` (system notes
* excluded), which is already the scalar the UI wants.
+ *
+ * String labels carry no color of their own — they are joined against the
+ * name-keyed map built from `glab label list` (see `buildGitlabLabelMap`), so
+ * the tab renders forge colors instead of the neutral fallback. A label absent
+ * from the map keeps `color: null` and renders neutral, exactly as before.
*/
-function normalizeGitlabIssue(issue) {
+function normalizeGitlabIssue(issue, labelMap = null) {
return {
number: issue.iid,
title: issue.title || '',
@@ -92,8 +105,13 @@ function normalizeGitlabIssue(issue) {
url: issue.web_url || '',
labels: Array.isArray(issue.labels)
? issue.labels
- .map((l) => (typeof l === 'string' ? { name: l, color: null, description: '' }
- : { name: l?.name || '', color: l?.color || null, description: l?.description || '' }))
+ .map((l) => {
+ if (typeof l === 'string') {
+ const known = labelMap?.get(l);
+ return known ? { name: l, ...known } : { name: l, color: null, description: '' };
+ }
+ return { name: l?.name || '', color: normalizeLabelColor(l?.color), description: l?.description || '' };
+ })
.filter((l) => l.name)
: [],
assignees: Array.isArray(issue.assignees)
@@ -106,6 +124,22 @@ function normalizeGitlabIssue(issue) {
};
}
+/**
+ * Build the name-keyed `{ color, description }` map `normalizeGitlabIssue`
+ * joins string labels against, from a `glab label list` row list. GitLab
+ * colors use the same `#rrggbb` form GitHub normalizes to, so they go through
+ * the same prefixing. First row wins on duplicate names.
+ */
+function buildGitlabLabelMap(labelRows) {
+ const map = new Map();
+ for (const row of labelRows) {
+ const name = row?.name;
+ if (!name || map.has(name)) continue;
+ map.set(name, { color: normalizeLabelColor(row?.color), description: row?.description || '' });
+ }
+ return map;
+}
+
/**
* Classify an ANSWERED row list. The absent-vs-empty split is the whole point —
* a CLI that answered with zero rows is the definitive `no-open-issues`, never
@@ -170,19 +204,27 @@ async function fetchGithubIssues(repoSpec, apiHost, { repoPath = null, forgeAcco
async function fetchGitlabIssues(repoPath) {
// `glab issue list` defaults to OPEN issues.
const { rows, reason } = await execGlabJson(['issue', 'list', '--per-page', String(GL_PER_PAGE)], repoPath);
- if (rows) return toIssueResult(rows, normalizeGitlabIssue);
- if (reason === 'not-json') {
+ if (!rows) {
+ if (reason === 'not-json') {
+ return {
+ issues: [], reason: 'glab-output-not-json', transient: true,
+ headline: "Reached GitLab, but couldn't read its answer",
+ remedy: 'update `glab` — its JSON output flag moved (check `glab issue list --help`)',
+ };
+ }
return {
- issues: [], reason: 'glab-output-not-json', transient: true,
- headline: "Reached GitLab, but couldn't read its answer",
- remedy: 'update `glab` — its JSON output flag moved (check `glab issue list --help`)',
+ issues: [], reason: 'fetch-failed', transient: true,
+ headline: "Couldn't reach GitLab",
+ remedy: 'check `glab auth status` and that `glab` is installed and can reach the host',
};
}
- return {
- issues: [], reason: 'fetch-failed', transient: true,
- headline: "Couldn't reach GitLab",
- remedy: 'check `glab auth status` and that `glab` is installed and can reach the host',
- };
+ // Best-effort color enrichment, same cwd the issue list resolved its project
+ // from (so enterprise/custom-host repos get it too — no hostname gating).
+ // A failed lookup must never become a whole-tab failure: unknown labels keep
+ // `color: null` and the issue list is returned untouched.
+ const labelLookup = await execGlabJson(['label', 'list', '--per-page', String(GL_PER_PAGE)], repoPath);
+ const labelMap = labelLookup.rows ? buildGitlabLabelMap(labelLookup.rows) : null;
+ return toIssueResult(rows, (issue) => normalizeGitlabIssue(issue, labelMap));
}
/**
diff --git a/server/services/appIssues.test.js b/server/services/appIssues.test.js
index 40066aec2c..6cdba7ffb4 100644
--- a/server/services/appIssues.test.js
+++ b/server/services/appIssues.test.js
@@ -174,22 +174,30 @@ describe('listAppIssues — GitHub', () => {
});
describe('listAppIssues — GitLab', () => {
- it('normalizes iid / description / string labels / username assignees', async () => {
+ it('normalizes iid / description / string labels / username assignees, joined to label-list colors', async () => {
useGitlabOrigin();
- execGlabJson.mockResolvedValue({ reason: 'ok', rows: [{
- iid: 7,
- title: 'Add export',
- description: 'We need CSV',
- web_url: 'https://gitlab.com/group/proj/-/issues/7',
- state: 'opened',
- labels: ['feature', 'p2'],
- assignees: [{ username: 'dana' }],
- author: { username: 'erin' },
- milestone: { title: 'Sprint 3' },
- created_at: '2026-02-01T00:00:00Z',
- updated_at: '2026-02-02T00:00:00Z',
- user_notes_count: 4,
- }] });
+ execGlabJson.mockImplementation(async (args) => {
+ if (args[0] === 'label') {
+ return { reason: 'ok', rows: [
+ { name: 'feature', color: '#5843AD', description: 'New functionality' },
+ { name: 'p2', color: 'D4C5F9', description: '' },
+ ] };
+ }
+ return { reason: 'ok', rows: [{
+ iid: 7,
+ title: 'Add export',
+ description: 'We need CSV',
+ web_url: 'https://gitlab.com/group/proj/-/issues/7',
+ state: 'opened',
+ labels: ['feature', 'p2'],
+ assignees: [{ username: 'dana' }],
+ author: { username: 'erin' },
+ milestone: { title: 'Sprint 3' },
+ created_at: '2026-02-01T00:00:00Z',
+ updated_at: '2026-02-02T00:00:00Z',
+ user_notes_count: 4,
+ }] };
+ });
const result = await listAppIssues(APP);
@@ -204,13 +212,63 @@ describe('listAppIssues — GitLab', () => {
commentCount: 4,
});
expect(result.issues[0].labels).toEqual([
- { name: 'feature', color: null, description: '' },
- { name: 'p2', color: null, description: '' },
+ { name: 'feature', color: '#5843AD', description: 'New functionality' },
+ // Bare-hex label colors get the same `#` prefixing the GitHub path applies.
+ { name: 'p2', color: '#D4C5F9', description: '' },
]);
- // glab resolves the project from its cwd, so the repo path is load-bearing.
+ // glab resolves the project from its cwd, so the repo path is load-bearing
+ // on BOTH calls — issue list and label list alike.
expect(execGlabJson.mock.calls[0][1]).toBe('/repo');
// execGlabJson owns the output flag (lib/glabArgs.js); callers pass none.
expect(execGlabJson.mock.calls[0][0]).toEqual(['issue', 'list', '--per-page', '100']);
+ expect(execGlabJson.mock.calls[1][0]).toEqual(['label', 'list', '--per-page', '100']);
+ expect(execGlabJson.mock.calls[1][1]).toBe('/repo');
+ });
+
+ it('a label absent from label list still renders neutral; the issue list is unaffected', async () => {
+ useGitlabOrigin();
+ execGlabJson.mockImplementation(async (args) => {
+ if (args[0] === 'label') return { reason: 'ok', rows: [{ name: 'feature', color: '#5843AD', description: '' }] };
+ return { reason: 'ok', rows: [{ iid: 7, title: 'Add export', labels: ['feature', 'unlisted'], assignees: [] }] };
+ });
+ const result = await listAppIssues(APP);
+ expect(result).toMatchObject({ reason: 'ok', transient: false });
+ expect(result.issues[0].labels).toEqual([
+ { name: 'feature', color: '#5843AD', description: '' },
+ { name: 'unlisted', color: null, description: '' },
+ ]);
+ });
+
+ it('a failed label list is non-fatal — issues still return with neutral labels', async () => {
+ useGitlabOrigin();
+ execGlabJson.mockImplementation(async (args) => {
+ if (args[0] === 'label') return { rows: null, reason: 'cli-failed' };
+ return { reason: 'ok', rows: [{ iid: 7, title: 'Add export', labels: ['feature'], assignees: [] }] };
+ });
+ const result = await listAppIssues(APP);
+ expect(result).toMatchObject({ reason: 'ok', transient: false });
+ expect(result.issues[0].labels).toEqual([{ name: 'feature', color: null, description: '' }]);
+ });
+
+ it('a non-JSON label list is non-fatal — issues still return with neutral labels', async () => {
+ useGitlabOrigin();
+ execGlabJson.mockImplementation(async (args) => {
+ if (args[0] === 'label') return { rows: null, reason: 'not-json' };
+ return { reason: 'ok', rows: [{ iid: 7, title: 'Add export', labels: ['feature'], assignees: [] }] };
+ });
+ const result = await listAppIssues(APP);
+ expect(result).toMatchObject({ reason: 'ok', transient: false });
+ expect(result.issues[0].labels).toEqual([{ name: 'feature', color: null, description: '' }]);
+ });
+
+ it('tolerates the object label form, normalizing its color the same way', async () => {
+ useGitlabOrigin();
+ execGlabJson.mockImplementation(async (args) => {
+ if (args[0] === 'label') return { reason: 'ok', rows: [] };
+ return { reason: 'ok', rows: [{ iid: 7, title: 'Add export', labels: [{ name: 'bug', color: 'd73a4a', description: 'x' }], assignees: [] }] };
+ });
+ const result = await listAppIssues(APP);
+ expect(result.issues[0].labels).toEqual([{ name: 'bug', color: '#d73a4a', description: 'x' }]);
});
it('an older glab that omits user_notes_count reports 0 comments, never NaN', async () => {
@@ -298,10 +356,18 @@ describe('listAppIssues — non-forge apps', () => {
it('lists issues for a gitlab tracker explicitly pinned on a custom-hostname self-hosted origin', async () => {
getOriginInfo.mockResolvedValue({ isGithub: false, host: 'git.example-corp.com', fullName: 'acme/widget' });
readOriginRemoteUrl.mockResolvedValue('[email protected]:acme/widget.git');
- execGlabJson.mockResolvedValue({ reason: 'ok', rows: [{ iid: 3, title: 'Custom host works', labels: [], assignees: [] }] });
+ execGlabJson.mockImplementation(async (args) => {
+ if (args[0] === 'label') return { reason: 'ok', rows: [{ name: 'bug', color: '#d73a4a', description: '' }] };
+ return { reason: 'ok', rows: [{ iid: 3, title: 'Custom host works', labels: ['bug'], assignees: [] }] };
+ });
const result = await listAppIssues({ ...APP, workTracker: 'gitlab' });
expect(result).toMatchObject({ forge: 'gitlab', tracker: 'gitlab', reason: 'ok' });
expect(execGlabJson.mock.calls[0][1]).toBe('/repo');
+ // The color enrichment runs in the same cwd with no hostname gate, so a
+ // self-hosted repo gets forge colors through the identical path.
+ expect(execGlabJson.mock.calls[1][0]).toEqual(['label', 'list', '--per-page', '100']);
+ expect(execGlabJson.mock.calls[1][1]).toBe('/repo');
+ expect(result.issues[0].labels).toEqual([{ name: 'bug', color: '#d73a4a', description: '' }]);
});
});