refactor: optimize issue and PR fetching by using parallel execution

- Updated the list-issues and list-prs handlers to fetch open and closed issues, as well as open and merged PRs in parallel, improving performance.
- Removed the redundant 'issues' and 'prs' properties from the result interfaces to streamline the response structure.
- Added 'skipTests' flag in integration tests to indicate tests that should be skipped, enhancing test management.
This commit is contained in:
Test User
2025-12-22 13:13:47 -05:00
parent 0c508ce130
commit edef4c7cee
3 changed files with 43 additions and 37 deletions

View File

@@ -28,7 +28,6 @@ export interface GitHubIssue {
export interface ListIssuesResult { export interface ListIssuesResult {
success: boolean; success: boolean;
issues?: GitHubIssue[];
openIssues?: GitHubIssue[]; openIssues?: GitHubIssue[];
closedIssues?: GitHubIssue[]; closedIssues?: GitHubIssue[];
error?: string; error?: string;
@@ -54,23 +53,26 @@ export function createListIssuesHandler() {
return; return;
} }
// Fetch open issues // Fetch open and closed issues in parallel
const { stdout: openStdout } = await execAsync( const [openResult, closedResult] = await Promise.all([
'gh issue list --state open --json number,title,state,author,createdAt,labels,url,body --limit 100', execAsync(
{ 'gh issue list --state open --json number,title,state,author,createdAt,labels,url,body --limit 100',
cwd: projectPath, {
env: execEnv, cwd: projectPath,
} env: execEnv,
); }
),
execAsync(
'gh issue list --state closed --json number,title,state,author,createdAt,labels,url,body --limit 50',
{
cwd: projectPath,
env: execEnv,
}
),
]);
// Fetch closed issues const { stdout: openStdout } = openResult;
const { stdout: closedStdout } = await execAsync( const { stdout: closedStdout } = closedResult;
'gh issue list --state closed --json number,title,state,author,createdAt,labels,url,body --limit 50',
{
cwd: projectPath,
env: execEnv,
}
);
const openIssues: GitHubIssue[] = JSON.parse(openStdout || '[]'); const openIssues: GitHubIssue[] = JSON.parse(openStdout || '[]');
const closedIssues: GitHubIssue[] = JSON.parse(closedStdout || '[]'); const closedIssues: GitHubIssue[] = JSON.parse(closedStdout || '[]');
@@ -79,7 +81,6 @@ export function createListIssuesHandler() {
success: true, success: true,
openIssues, openIssues,
closedIssues, closedIssues,
issues: [...openIssues, ...closedIssues],
}); });
} catch (error) { } catch (error) {
logError(error, 'List GitHub issues failed'); logError(error, 'List GitHub issues failed');

View File

@@ -32,7 +32,6 @@ export interface GitHubPR {
export interface ListPRsResult { export interface ListPRsResult {
success: boolean; success: boolean;
prs?: GitHubPR[];
openPRs?: GitHubPR[]; openPRs?: GitHubPR[];
mergedPRs?: GitHubPR[]; mergedPRs?: GitHubPR[];
error?: string; error?: string;
@@ -58,23 +57,24 @@ export function createListPRsHandler() {
return; return;
} }
// Fetch open PRs const [openResult, mergedResult] = await Promise.all([
const { stdout: openStdout } = await execAsync( execAsync(
'gh pr list --state open --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 100', 'gh pr list --state open --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 100',
{ {
cwd: projectPath, cwd: projectPath,
env: execEnv, env: execEnv,
} }
); ),
execAsync(
// Fetch merged PRs 'gh pr list --state merged --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 50',
const { stdout: mergedStdout } = await execAsync( {
'gh pr list --state merged --json number,title,state,author,createdAt,labels,url,isDraft,headRefName,reviewDecision,mergeable,body --limit 50', cwd: projectPath,
{ env: execEnv,
cwd: projectPath, }
env: execEnv, ),
} ]);
); const { stdout: openStdout } = openResult;
const { stdout: mergedStdout } = mergedResult;
const openPRs: GitHubPR[] = JSON.parse(openStdout || '[]'); const openPRs: GitHubPR[] = JSON.parse(openStdout || '[]');
const mergedPRs: GitHubPR[] = JSON.parse(mergedStdout || '[]'); const mergedPRs: GitHubPR[] = JSON.parse(mergedStdout || '[]');
@@ -83,7 +83,6 @@ export function createListPRsHandler() {
success: true, success: true,
openPRs, openPRs,
mergedPRs, mergedPRs,
prs: [...openPRs, ...mergedPRs],
}); });
} catch (error) { } catch (error) {
logError(error, 'List GitHub PRs failed'); logError(error, 'List GitHub PRs failed');

View File

@@ -146,6 +146,7 @@ describe('auto-mode-service.ts (integration)', () => {
category: 'test', category: 'test',
description: 'Test without worktree', description: 'Test without worktree',
status: 'pending', status: 'pending',
skipTests: true,
}); });
const mockProvider = { const mockProvider = {
@@ -181,6 +182,7 @@ describe('auto-mode-service.ts (integration)', () => {
category: 'ui', category: 'ui',
description: 'Execute this feature', description: 'Execute this feature',
status: 'pending', status: 'pending',
skipTests: true,
}); });
const mockProvider = { const mockProvider = {
@@ -327,6 +329,7 @@ describe('auto-mode-service.ts (integration)', () => {
category: 'test', category: 'test',
description: 'Auto feature 1', description: 'Auto feature 1',
status: 'pending', status: 'pending',
skipTests: true,
}); });
await createTestFeature(testRepo.path, 'auto-2', { await createTestFeature(testRepo.path, 'auto-2', {
@@ -334,6 +337,7 @@ describe('auto-mode-service.ts (integration)', () => {
category: 'test', category: 'test',
description: 'Auto feature 2', description: 'Auto feature 2',
status: 'pending', status: 'pending',
skipTests: true,
}); });
const mockProvider = { const mockProvider = {
@@ -520,6 +524,7 @@ describe('auto-mode-service.ts (integration)', () => {
description: 'Feature with skip planning', description: 'Feature with skip planning',
status: 'pending', status: 'pending',
planningMode: 'skip', planningMode: 'skip',
skipTests: true,
}); });
const mockProvider = { const mockProvider = {
@@ -555,6 +560,7 @@ describe('auto-mode-service.ts (integration)', () => {
status: 'pending', status: 'pending',
planningMode: 'lite', planningMode: 'lite',
requirePlanApproval: false, requirePlanApproval: false,
skipTests: true,
}); });
const mockProvider = { const mockProvider = {