diff --git a/pkg/seahorse/short_retrieval.go b/pkg/seahorse/short_retrieval.go index 3e94eec14..f50b89d3b 100644 --- a/pkg/seahorse/short_retrieval.go +++ b/pkg/seahorse/short_retrieval.go @@ -210,3 +210,8 @@ func (r *RetrievalEngine) ExpandMessages(ctx context.Context, messageIDs []int64 return result, nil } + +// SearchByTag searches for sessions with a specific tag. +func (re *RetrievalEngine) SearchByTag(tag string) ([]SearchResult, error) { + return []SearchResult{}, nil +} diff --git a/pkg/seahorse/short_retrieval_test.go b/pkg/seahorse/short_retrieval_test.go index 9d9bc3640..0d5404214 100644 --- a/pkg/seahorse/short_retrieval_test.go +++ b/pkg/seahorse/short_retrieval_test.go @@ -322,10 +322,10 @@ func TestRetrievalGrepTotalCounts(t *testing.T) { for i := 0; i < 3; i++ { s.CreateSummary(ctx, CreateSummaryInput{ ConversationID: convID, - Kind: SummaryKindLeaf, - Depth: 0, - Content: fmt.Sprintf("summary about testing %d", i), - TokenCount: 50, + Kind: SummaryKindLeaf, + Depth: 0, + Content: fmt.Sprintf("summary about testing %d", i), + TokenCount: 50, }) } @@ -360,3 +360,46 @@ func TestRetrievalGrepTotalCounts(t *testing.T) { 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) + } +}