Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions packages/github/src/__tests__/emit-auxiliary-files.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,48 @@ describe('emitGitHubAuxiliaryFiles', () => {
);
assert.equal(client.files.get(githubByStateAliasPath('acme', 'widgets', 'issues', 'open', 7)), canonicalBytes);
assert.equal(client.files.get(githubByEditedAliasPath('acme', 'widgets', 'issues', '2026-05-12', 7)), canonicalBytes);
const issueRows = JSON.parse(client.files.get(indexPath) ?? '[]') as Array<Record<string, unknown>>;
assert.deepEqual(issueRows, [
Comment thread
kjgbot marked this conversation as resolved.
{
id: '7',
title: 'Bug report',
updated: '2026-05-12T00:00:00Z',
number: 7,
state: 'open',
labels: ['P0 Critical'],
assigneeKeys: ['octocat'],
creatorKey: 'monalisa',
priority: 'P0 Critical',
},
]);

// No writes leaked into the pulls index for this repo.
assert.ok(!writtenPaths.includes(githubRepoPullsIndexPath('acme', 'widgets')));
});

it('retains an explicit empty label array in issue index rows', async () => {
const client = createClient();
await emitGitHubAuxiliaryFiles(client, {
workspaceId: 'ws-1',
issues: [
{
owner: 'acme',
repo: 'widgets',
number: 8,
title: 'Unlabeled issue',
state: 'open',
labels: [],
updated_at: '2026-05-13T00:00:00Z',
},
],
});

const rows = JSON.parse(client.files.get(githubRepoIssuesIndexPath('acme', 'widgets')) ?? '[]') as Array<
Record<string, unknown>
>;
assert.deepEqual(rows[0]?.labels, []);
});

it('uses the newest lifecycle timestamp for PR by-edited aliases', async () => {
const client = createClient();

Expand Down
10 changes: 10 additions & 0 deletions packages/github/src/emit-auxiliary-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -780,6 +780,7 @@ function buildRecordIndexRow(
updated: readLifecycleEditedAt(record) ?? readUpdatedAt(record),
number: Number(number),
state: state ?? '',
labels: readGitHubLabelNames(record),
...withOptionalArray('assigneeKeys', readGitHubAssigneeKeys(record)),
...withOptionalString('creatorKey', readGitHubCreatorKey(record)),
...withOptionalString('priority', readPriority(record)),
Expand Down Expand Up @@ -974,6 +975,15 @@ function readGitHubAssigneeKeys(record: Record<string, unknown>): string[] {
return uniqueStrings(assignees.map((entry) => readUserKey(entry)).filter((entry): entry is string => Boolean(entry)));
}

function readGitHubLabelNames(record: Record<string, unknown>): string[] {
const labels = Array.isArray(record.labels) ? record.labels : [];
return uniqueStrings(
labels
.map((label) => readNonEmptyString(label) ?? readNonEmptyString(isRecord(label) ? label.name : undefined))
.filter((label): label is string => Boolean(label)),
);
}

function readGitHubCreatorKey(record: Record<string, unknown>): string | undefined {
return readUserKey(record.user) ?? readNonEmptyString(record.user);
}
Expand Down
Loading