Skip to content

[Fix] Default TUI to latest active sessions#48

Merged
samzong merged 1 commit into
mainfrom
fix/tui-latest-active-sort
Jun 11, 2026
Merged

[Fix] Default TUI to latest active sessions#48
samzong merged 1 commit into
mainfrom
fix/tui-latest-active-sort

Conversation

@samzong

@samzong samzong commented Jun 11, 2026

Copy link
Copy Markdown
Owner

What's changed?

  • Default the TUI sort control to Newest on startup and after clearing filters.
  • Sort Newest results by latest activity using updated_at with started_at as the fallback.
  • Order recent sessions by latest activity in the store query and add regression coverage for the TUI and store behavior.

Why

  • Opening Recall should surface the session that was most recently active without requiring Ctrl+F, switching to Sort, and pressing n.

Signed-off-by: samzong <samzong.lu@gmail.com>
@samzong samzong merged commit 9331bb7 into main Jun 11, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread src/db/store.rs
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}"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@samzong samzong deleted the fix/tui-latest-active-sort branch June 16, 2026 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant