Skip to content

Exempt starred sessions from auto-archival (keep-alive)#193

Merged
pufit merged 1 commit into
mainfrom
serxa/starred-sessions-keepalive
Jul 21, 2026
Merged

Exempt starred sessions from auto-archival (keep-alive)#193
pufit merged 1 commit into
mainfrom
serxa/starred-sessions-keepalive

Conversation

@serxa

@serxa serxa commented Jul 21, 2026

Copy link
Copy Markdown
Member

What

Extend the existing per-session star flag so a starred session is never auto-closed.

starred already means "this session is important" — the retention pruner skips starred sessions. This adds the natural second half: a starred session is exempt from all auto-archival (the interactive idle cutoff, the 30-day backstop, and the max_sessions overflow eviction) and is off-budget for max_sessions (neither counted toward the cap nor evicted), until explicitly unstarred/archived/deleted.

Changes

  • db (db/sessions.py)AND starred = 0 in the three cleanup queries (get_stale_interactive_sessions, get_stale_sessions, get_oldest_sessions); count_active_sessions gains an opt-in exclude_starred.
  • sessions (agent/sessions.py)SessionManager.set_starred / toggle_starred; exemption documented on run_cleanup.
  • telegram (channels/telegram.py, router.py) — a per-session ⭐/☆ toggle in /sessions, a ⭐ marker on switch buttons, and /star · /unstar.
  • config + docs/config.md — document the exemption.
  • tests — all three cleanup paths + the Telegram marker/toggle/callback.

The web star button (SessionSidebar) already exists and inherits the new behavior.

max_sessions: starred are off-budget

Starred sessions are not counted toward the cap and never evicted; the cap governs only non-starred sessions. Trade-off: total sessions can grow unbounded via starring — intended (the limit is for ordinary sessions).

History

Re-lands #189, which — after its dependencies #182/#184 merged — was merged into its stacked scaffold base branch rather than main, so the feature never reached main. This is the identical change, cleanly rebased onto current main as a single commit.

Testing

pytest tests/test_sessions.py tests/test_telegram_sessions.py → 82 passed.

🤖 Generated with Claude Code

Extend the existing per-session `starred` flag so a starred session is never
auto-closed. It already survived content pruning; now it is also exempt from
all session auto-archival:

- db (db/sessions.py): skip starred rows in the idle-cutoff, age-backstop, and
  overflow-eviction queries; count_active_sessions gains an opt-in
  exclude_starred so starred sessions are off-budget for max_sessions (neither
  counted toward the cap nor evicted).
- sessions (agent/sessions.py): SessionManager.set_starred / toggle_starred;
  run_cleanup documents the exemption.
- telegram (channels/telegram.py, router.py): a per-session star toggle in the
  /sessions list, a marker on switch buttons, and /star, /unstar commands.
- config + docs/config.md: document the exemption.
- tests: cover all three cleanup paths and the telegram toggle.

The web star button already exists and inherits the new behavior.

Re-lands the change from #189, which merged into its stacked scaffold base
branch rather than main; this is the same feature cleanly rebased onto main.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@pufit
pufit merged commit ca15550 into main Jul 21, 2026
2 checks passed
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.

2 participants