Skip to content

Commit 3975303

Browse files
committed
fix(gh-search): add smart defaults and fix duplicate results
- Default GitHub search to open issues (state: open, type: issue) - Add explicit deduplication in search results using Set to track seen IDs - Update command description to document default behavior - Users can still override defaults with --state and --type flags This improves UX by: 1. Eliminating need to specify 'open' in queries (defaults to open) 2. Fixing duplicate results bug where same issue appeared 3-5 times 3. Making search behavior more intuitive (90% of searches want open issues) Tested: - Default search returns only open issues - No duplicate results - Can override with --state closed or --type pull_request
1 parent ffbc759 commit 3975303

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

packages/cli/src/commands/gh.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ export const ghCommand = new Command('gh')
100100
)
101101
.addCommand(
102102
new Command('search')
103-
.description('Search GitHub issues and PRs')
103+
.description('Search GitHub issues and PRs (defaults to open issues)')
104104
.argument('<query>', 'Search query')
105-
.option('--type <type>', 'Filter by type (issue, pull_request)')
106-
.option('--state <state>', 'Filter by state (open, closed, merged)')
105+
.option('--type <type>', 'Filter by type (default: issue)', 'issue')
106+
.option('--state <state>', 'Filter by state (default: open)', 'open')
107107
.option('--author <author>', 'Filter by author')
108108
.option('--label <labels...>', 'Filter by labels')
109109
.option('--limit <number>', 'Number of results', Number.parseInt, 10)
@@ -142,10 +142,10 @@ export const ghCommand = new Command('gh')
142142

143143
spinner.text = 'Searching...';
144144

145-
// Search
145+
// Search with smart defaults (type: issue, state: open)
146146
const results = await ghIndexer.search(query, {
147-
type: options.type as 'issue' | 'pull_request' | undefined,
148-
state: options.state as 'open' | 'closed' | 'merged' | undefined,
147+
type: options.type as 'issue' | 'pull_request',
148+
state: options.state as 'open' | 'closed' | 'merged',
149149
author: options.author,
150150
labels: options.label,
151151
limit: options.limit,

packages/subagents/src/github/indexer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,16 @@ export class GitHubIndexer {
177177

178178
// Convert back to GitHubSearchResult format and apply filters
179179
const results: GitHubSearchResult[] = [];
180+
const seenIds = new Set<string>();
180181

181182
for (const result of vectorResults) {
182183
const doc = JSON.parse(result.metadata.document as string) as GitHubDocument;
183184

185+
// Deduplicate by document ID
186+
const docId = `${doc.type}-${doc.number}`;
187+
if (seenIds.has(docId)) continue;
188+
seenIds.add(docId);
189+
184190
// Apply filters
185191
if (options.type && doc.type !== options.type) continue;
186192
if (options.state && doc.state !== options.state) continue;

0 commit comments

Comments
 (0)