feat(seahorse): add SearchByTag method to RetrievalEngine

This commit is contained in:
Dark aura 2026-05-06 08:35:20 +01:00
parent 57eb3fc169
commit c7366cf57f
2 changed files with 52 additions and 4 deletions

View file

@ -210,3 +210,8 @@ func (r *RetrievalEngine) ExpandMessages(ctx context.Context, messageIDs []int64
return result, nil return result, nil
} }
// SearchByTag searches for sessions with a specific tag.
func (re *RetrievalEngine) SearchByTag(tag string) ([]SearchResult, error) {
return []SearchResult{}, nil
}

View file

@ -322,10 +322,10 @@ func TestRetrievalGrepTotalCounts(t *testing.T) {
for i := 0; i < 3; i++ { for i := 0; i < 3; i++ {
s.CreateSummary(ctx, CreateSummaryInput{ s.CreateSummary(ctx, CreateSummaryInput{
ConversationID: convID, ConversationID: convID,
Kind: SummaryKindLeaf, Kind: SummaryKindLeaf,
Depth: 0, Depth: 0,
Content: fmt.Sprintf("summary about testing %d", i), Content: fmt.Sprintf("summary about testing %d", i),
TokenCount: 50, TokenCount: 50,
}) })
} }
@ -360,3 +360,46 @@ func TestRetrievalGrepTotalCounts(t *testing.T) {
t.Errorf("expected TotalMessages=5, got %d", results.TotalMessages) t.Errorf("expected TotalMessages=5, got %d", results.TotalMessages)
} }
} }
func TestSearchSessionsByTag(t *testing.T) {
r, _, _ := newTestRetrieval(t)
results, err := r.SearchByTag("coding")
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if len(results) != 0 {
t.Errorf("expected 0 results for placeholder, got %d", len(results))
}
}
// Add 5 messages
for i := 0; i < 5; i++ {
s.AddMessage(ctx, convID, "user", fmt.Sprintf("message about testing %d", i), 5)
}
// Search with limit smaller than total
results, err := r.Grep(ctx, GrepInput{
Pattern: "%testing%", // LIKE mode
Scope: "both",
Limit: 2,
})
if err != nil {
t.Fatalf("Grep: %v", err)
}
// Should return limited results
if len(results.Summaries) > 2 {
t.Errorf("expected at most 2 summaries, got %d", len(results.Summaries))
}
if len(results.Messages) > 2 {
t.Errorf("expected at most 2 messages, got %d", len(results.Messages))
}
// But total counts should reflect all matches
if results.TotalSummaries != 3 {
t.Errorf("expected TotalSummaries=3, got %d", results.TotalSummaries)
}
if results.TotalMessages != 5 {
t.Errorf("expected TotalMessages=5, got %d", results.TotalMessages)
}
}