GetSessionSummaries retrieves lightweight session metadata for listing (excludes sub-sessions). This is much faster than GetSessions as it doesn't load message content.
(ctx context.Context)
| 852 | // GetSessionSummaries retrieves lightweight session metadata for listing (excludes sub-sessions). |
| 853 | // This is much faster than GetSessions as it doesn't load message content. |
| 854 | func (s *SQLiteSessionStore) GetSessionSummaries(ctx context.Context) ([]Summary, error) { |
| 855 | rows, err := s.db.QueryContext(ctx, |
| 856 | `SELECT s.id, s.title, s.created_at, s.starred, |
| 857 | (SELECT COUNT(*) FROM session_items si WHERE si.session_id = s.id AND si.item_type = 'message') |
| 858 | FROM sessions s |
| 859 | WHERE s.parent_id IS NULL OR s.parent_id = '' |
| 860 | ORDER BY s.created_at DESC`) |
| 861 | if err != nil { |
| 862 | return nil, err |
| 863 | } |
| 864 | defer rows.Close() |
| 865 | |
| 866 | var summaries []Summary |
| 867 | for rows.Next() { |
| 868 | var ( |
| 869 | summary Summary |
| 870 | createdAtStr string |
| 871 | ) |
| 872 | if err := rows.Scan(&summary.ID, &summary.Title, &createdAtStr, &summary.Starred, &summary.NumMessages); err != nil { |
| 873 | return nil, err |
| 874 | } |
| 875 | summary.CreatedAt, err = time.Parse(time.RFC3339, createdAtStr) |
| 876 | if err != nil { |
| 877 | return nil, err |
| 878 | } |
| 879 | summaries = append(summaries, summary) |
| 880 | } |
| 881 | |
| 882 | if err := rows.Err(); err != nil { |
| 883 | return nil, err |
| 884 | } |
| 885 | |
| 886 | return summaries, nil |
| 887 | } |
| 888 | |
| 889 | // DeleteSession deletes a session by ID |
| 890 | func (s *SQLiteSessionStore) DeleteSession(ctx context.Context, id string) error { |