Recall walks the index and returns up to `limit` session records whose summary or tags match the query. Match is a case-insensitive substring scan, ordered most-recent first — enough for sub-thousand-session histories. Swap in a Bleve index or vector store when you outgrow it.
(_ context.Context, query string, limit int)
| 112 | // scan, ordered most-recent first — enough for sub-thousand-session |
| 113 | // histories. Swap in a Bleve index or vector store when you outgrow it. |
| 114 | func (s *SessionFiles) Recall(_ context.Context, query string, limit int) ([]Entry, error) { |
| 115 | if limit <= 0 { |
| 116 | limit = 5 |
| 117 | } |
| 118 | q := strings.ToLower(strings.TrimSpace(query)) |
| 119 | s.mu.Lock() |
| 120 | candidates := append([]SessionRecord(nil), s.index...) |
| 121 | s.mu.Unlock() |
| 122 | sort.Slice(candidates, func(i, j int) bool { |
| 123 | return candidates[i].Date.After(candidates[j].Date) |
| 124 | }) |
| 125 | var out []Entry |
| 126 | for _, r := range candidates { |
| 127 | if q != "" && !matches(r, q) { |
| 128 | continue |
| 129 | } |
| 130 | out = append(out, recordToEntry(r)) |
| 131 | if len(out) >= limit { |
| 132 | break |
| 133 | } |
| 134 | } |
| 135 | return out, nil |
| 136 | } |
| 137 | |
| 138 | func matches(r SessionRecord, q string) bool { |
| 139 | if strings.Contains(strings.ToLower(r.Summary), q) { |