fix(sessions): run the assigned recovery pass in the all-profiles view

`?all_profiles=1` passed `project_assigned_limit=False`, on the premise that
its `visible_session_limit=None` first pass already returns every conversation.
It does not: `_load_cli_sessions_uncached` maps `visible_session_limit is None`
to CLI_VISIBLE_SESSION_LIMIT for the interactive pass, so that view truncates
by recency exactly like the single-profile one. Only cron/webhook/kanban limits
reach the reader as `limit=` directly, where None does mean unbounded.

Net effect of the old value: in the "All profiles" sidebar a project-assigned
CLI session older than the newest 20 interactive conversations was missing from
/api/sessions while its project chip still claimed it — the #6659 bug itself,
in the one view that shows every profile at once. Recovery pass 2 (the
unassigned refill) still ran there, so the two passes disagreed as well.

Pass PROJECT_ASSIGNED_CLI_LIMIT instead of None so the per-project bound and
the PROJECT_ASSIGNED_CLI_SCAN_CEILING guard apply per profile, rather than
issuing an unbounded assigned scan for every profile on the box.
This commit is contained in:
Rodrigo Gomes da Silva committed 2026-09-24 11:03:46 -03:00
1 parent 7c984f7ab6
commit bc1ee9d400
2 files changed
+52 -4

No files matched your search

+9 -4
View File
@@ -8905,12 +8905,17 @@ def get_cli_sessions(
merged: list[dict] = []
for idx, (ctx_home, ctx_db_path, ctx_profile) in enumerate(contexts):
load_kwargs = {
# NOTE: visible_session_limit=None is NOT "unbounded" for the
# interactive pass — it resolves to CLI_VISIBLE_SESSION_LIMIT
# above, so this view truncates assigned conversations by
# recency exactly like the single-profile one and needs the
# same recovery passes. project_assigned_limit therefore keeps
# its default per-project bound here. Only the three limits
# below are handed straight to the reader as ``limit=``, where
# None really does mean unbounded.
'source_filter': source_filter,
'visible_session_limit': None,
# An unbounded first pass already returns every assigned and
# unassigned conversation, so the bounded recovery passes
# have nothing to recover — skip their queries.
'project_assigned_limit': False,
'project_assigned_limit': PROJECT_ASSIGNED_CLI_LIMIT,
'cron_project_limit': None,
'webhook_project_limit': None,
'kanban_project_limit': None,