handleSearchSessions runs a full-text search across saved sessions and prints the matching sessions with context snippets. It reuses the existing JSON session store — no separate index.
(query string)
| 247 | // prints the matching sessions with context snippets. It reuses the existing |
| 248 | // JSON session store — no separate index. |
| 249 | func (cli *ChatCLI) handleSearchSessions(query string) { |
| 250 | hits, err := cli.sessionManager.SearchSessions(query, 3) |
| 251 | if err != nil { |
| 252 | fmt.Println(i18n.T("session.search.error", err)) |
| 253 | return |
| 254 | } |
| 255 | if len(hits) == 0 { |
| 256 | fmt.Println(colorize(" "+i18n.T("session.search.none", query), ColorGray)) |
| 257 | return |
| 258 | } |
| 259 | |
| 260 | fmt.Println() |
| 261 | fmt.Println(colorize(" "+i18n.T("session.search.header", query), ColorCyan+ColorBold)) |
| 262 | fmt.Println(colorize(" ─────────────────────────────────────────", ColorGray)) |
| 263 | for _, h := range hits { |
| 264 | fmt.Printf(" %s %s\n", |
| 265 | colorize(h.Session, ColorYellow), |
| 266 | colorize(i18n.T("session.search.match_count", h.Matches), ColorGray)) |
| 267 | for _, snip := range h.Snippets { |
| 268 | fmt.Printf(" %s\n", colorize(snip, ColorGray)) |
| 269 | } |
| 270 | } |
| 271 | fmt.Println() |
| 272 | } |
| 273 | |
| 274 | func (cli *ChatCLI) handleListSessions(ctx context.Context) { |
| 275 | if cli.isRemote { |
no test coverage detected