Skip to content

feat(tui): make session history window configurable#17046

Open
seilk wants to merge 1 commit intoanomalyco:devfrom
seilk:feat/session-history-days
Open

feat(tui): make session history window configurable#17046
seilk wants to merge 1 commit intoanomalyco:devfrom
seilk:feat/session-history-days

Conversation

@seilk
Copy link
Contributor

@seilk seilk commented Mar 11, 2026

Issue for this PR

Related: #16270, #16733, #13877, #16878

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The TUI bootstrap hard-codes a 30-day window when fetching sessions. If
you haven't touched a project in over a month, the /sessions picker
comes up empty — even though the data is right there in the DB and the
CLI returns it fine. This trips up a lot of people (#16270, #16733,
#13877) into thinking their sessions got nuked.

The 30-day cap makes sense as a default — nobody wants to pull thousands
of sessions on every boot. But it shouldn't be a wall you can't move.

This adds session_history_days to the main config:

// opencode.json
{
  "session_history_days": 90  // default: 30, set 0 to disable
}

Since the value lives in server config, the session list request is
chained after the config fetch so the setting is available before the
query fires. No extra round-trip — config was already being fetched in
the same bootstrap batch.

How did you verify your code works?

Tested against a real DB (2,823 sessions, project last active 41 days ago):

Setting Result
default (30) 0 sessions — same behavior as before
60 All 77 root sessions show up
0 All 77 root sessions show up (no time filter)

Typecheck and build both pass.

Note

This only addresses the time window. The child session dilution issue
(missing roots: true) is tracked separately in #16273.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add session_history_days to opencode.json config (default: 30, 0 to
disable). The TUI bootstrap previously hard-coded a 30-day time window
for session list fetching, making projects untouched for >30 days appear
empty in the /sessions picker.

The session list request is now chained after the config fetch so the
setting is available before the query fires.
@seilk seilk marked this pull request as ready for review March 11, 2026 14:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant