[Fix] Default TUI to latest active sessions#48
Conversation
Signed-off-by: samzong <samzong.lu@gmail.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 20a9b6f70d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| apply_scope_filters(&mut sql, &mut params, &mut param_idx, sources, time_range, directory); | ||
| sql.push_str(&format!(" ORDER BY started_at DESC LIMIT ?{param_idx}")); | ||
| sql.push_str(&format!( | ||
| " ORDER BY COALESCE(updated_at, started_at) DESC, started_at DESC, source ASC, source_id ASC LIMIT ?{param_idx}" |
There was a problem hiding this comment.
Add an index for latest-activity ordering
For installs with large session tables, this new ORDER BY COALESCE(updated_at, started_at) ... LIMIT no longer matches the existing idx_sessions_started_at index, so SQLite has to scan and sort all matching sessions before returning the first page. This path is used by load_recent on TUI startup and after clearing/searching with an empty query, so large imported histories can regress startup/filter latency; please add a migration for an expression/generated-column index matching the latest-activity sort or otherwise keep the query indexable.
Useful? React with 👍 / 👎.
What's changed?
Neweston startup and after clearing filters.Newestresults by latest activity usingupdated_atwithstarted_atas the fallback.Why
n.