ISSUE DESCRIPTION Cron sessions do not appear under their assigned project Non-empty…
- User
ISSUE DESCRIPTION
Cron sessions do not appear under their assigned project
Non-empty cron or background sessions assigned to a project must be shown when that project is selected. They remain hidden in default, unassigned, empty, and unrelated-project views. The behavior must be consistent across supported session retrieval modes.
Interface
No new interfaces are introduced.
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted.CHECKLIST
Before submitting your solution, please go over the following checklist and make sure you've done everything:
- If an error was reported in the issue description, I have successfully reproduced it.
- If an error was reported in the issue description, I have confirmed that my fix resolves the error.
- I have thought about edge cases and made sure my fix handles them as well.
- I have run existing tests in the repository that might have been affected by the change I made and confirmed that they pass. I want you to list every bullet from this checklist and write your reasoning for why you think you did it or didn't need to.
Repository has been uploaded and your shell is currently at the repository root. Time to solve the issue!
(Current directory: /hermes-webui, current file: none) bash-$
Assistant
I'll start by exploring the repository structure to understand the codebase.
Assistant
There's a test file
test_1079_cron_session_project.pythat seems directly relevant. Let me examine it.Assistant
Let me look at the
api/models.pyfile, which seems to contain the relevant functions likeget_cli_sessions,is_cron_session,ensure_cron_project, etc.Assistant
Let me look at how sessions are filtered by project. Let me search for the project filtering logic.
Assistant
Let me look at the
_hide_from_default_sidebarfunction andis_cli_session_row_visible.Assistant
Now let me find the
all_sessionsfunction and understand how sessions are retrieved and filtered.Assistant
Let me look at how the client filters sessions by project.
Assistant
Let me look at how the client fetches and caches sessions.
Assistant
Let me look at the search-related session retrieval and check for other relevant tests.
Assistant
Let me look at the search endpoint as another session retrieval mode.
Assistant
The search endpoint uses
all_sessions()which already filters out cron sessions via_hide_from_default_sidebar. So search won't find cron sessions either. But search isn't really project-filtered, so that's a separate concern.Now, let me understand the "session retrieval modes" mentioned in the issue. Let me re-read: "The behavior must be consistent across supported session retrieval modes."
Looking at the code, sessions can come from two main sources in
/api/sessions:- WebUI sessions (
all_sessions()) - CLI sessions (
get_cli_sessions())
Both are subject to
_hide_from_default_sidebarandis_cli_session_row_visible. The cron sessions are CLI sessions (from state.db). They get aproject_idassigned in_load_cli_sessions_uncached. But then in/api/sessions, the deduped_cli is filtered withnot _cron_hide(s)where_cron_hide = _hide_from_default_sidebar. So ALL cron sessions are removed from deduped_cli.So the fix is: non-empty cron/background sessions with a project_id should be kept in the list so the client can show them when their project is selected. But they should still be hidden from the default (All) view.
Now there's a tension: the client filters by project locally. If we keep cron sessions in the list, they'd appear in the "All" view too. So we need to also handle the client side.
Let me check the test
test_cron_session_gets_project_id_in_cli_list- it just checksget_cli_sessions()returns a list. So the actual project assignment is tested indirectly.Let me check the existing test for visibility behavior. Let me look at
test_cron_needs_attention.pyandtest_issue1140_cron_badge_per_job.py.Actually, let me look at what tests might already exist for this behavior, since the issue describes a specific behavior. Let me check the git log to understand recent changes around this.
- WebUI sessions (
Assistant
Let me look at the existing tests that involve
_hide_from_default_sidebarandis_cli_session_row_visible.Assistant
Let me look at how the client identifies cron/background sessions and the
_isCliSessionhelper.Assistant
Let me look at the full render filter logic, especially the
withMessagesfilter.Assistant
Let me look at the cron session creation route around line 12166.
Assistant
Let me look at
is_cli_session_rowfully.Assistant
Let me check the default
_sessionSourceFilterand how the source tabs work.Assistant
Let me look at the project chip UI test and the test for issue 1611 to understand expected behavior.
Assistant
Let me look at the test conftest to understand the test server setup.
Assistant
Let me look at the
test_serverfixture and_posthelper, and how tests interact with the server.Assistant
Let me run the existing test_1079 to see the environment state.
Assistant
So the hermes-agent is not installed. The tests that require agent modules will be skipped. The test_1079 test uses
test_serverfixture and hits the API. Let me check whether the cron session tests would actually run without the agent. Theget_cli_sessionsreads from state.db usingread_importable_agent_session_rowswhich is from the agent. Without the agent, get_cli_sessions returns empty (the import would fail and return []).So to reproduce the bug, I need to create a state.db with cron sessions. But
read_importable_agent_session_rowsis from the agent module. Let me check where it's imported.Assistant
read_importable_agent_session_rowsis called withexclude_sources=Nonein_load_cli_sessions_uncached, so cron sessions ARE included. They're then removed in the/api/sessionsdeduped_cli filter vianot _cron_hide(s). This is the bug. Let me look at_project_agent_session_rowsand_with_normalized_source.Assistant
Let me look at
_project_agent_session_rows.Assistant
Let me check the profile resolution and where state.db should be.
Assistant
Now let me write a reproduction script to confirm the bug.
Assistant
I referenced
is_cli_session_row_visible_helperwhich doesn't exist. Let me fix the script to import the actualis_cli_session_row_visiblefrom api.agent_sessions.Assistant
Let me check what "background" sessions refer to and look at the cron panel to understand how cron sessions are accessed.
Assistant
Let me search the tests for any test checking cron sessions appearing via
/api/sessionsor project filtering.Assistant
Let me check the CHANGELOG and docs for #1079 to understand the intended design.
Assistant
Let me check git status and look for any test that might be the target evaluation test.
Assistant
Let me look at how cron tests set up state.db to understand the testing patterns.
Assistant
Let me look at a test that creates state.db and uses the server.
Assistant
Let me check the default
show_cli_sessionssetting andload_settings.Assistant
Let me look at
_is_cli_session_for_settings.Assistant
Let me check the test that references
_hide_from_default_sidebarsource pattern.Assistant
Let me search for tests that directly test
_hide_from_default_sidebarbehavior.Assistant
Let me check for any tests that assert cron sessions are hidden by these functions.
Assistant
Let me check if any tests assert on the
withMessagesfilter expression in sessions.js.Assistant
test_issue2351_cli_session_source_filter.pychecks exact source patterns for the counts and source filter. Let me view it fully.Assistant
Let me check for any test asserting the exact
withMessagesfilter expression.Assistant
test_session_batch_select.py:148asserts"_isSessionEffectivelyStreaming(s)" in src. That's a substring check, not the full withMessages expression. So adding to the withMessages filter is fine as long as_isSessionEffectivelyStreaming(s)still appears.Let me check test_session_batch_select.py around line 148 to be sure.
Assistant
Now I have a clear plan. Let me view the exact
withMessagesblock to edit precisely.Assistant
Now let me implement the server-side fix. First, modify
_hide_from_default_sidebarinapi/models.py.Assistant
Now let me verify the server-side change with the repro script (simulating the deduped_cli filter).
Assistant
The server-side fix works. Let me test
_hide_from_default_sidebardirectly for edge cases.Assistant
All edge cases work. Now let me add the client-side helper. Let me view the area near
_isCliSession.Assistant
Let me add the
_isBackgroundSidebarSessionhelper after_isCliSession.Assistant
Now let me update the
withMessagesfilter andprojectFilteredlogic. Let me view the current state.Assistant
Let me check if any test asserts the exact
projectFiltered/ unassigned filter expression.Assistant
test_sidebar_unassigned_filter.pyrequires the exact substringprofileFiltered.filter(s=>!s.project_id)(with closing paren). Let me view that test fully to understand all constraints.Assistant
Let me check all usages of
_isCliSessionto understand the impact of potentially reclassifying background sessions.Assistant
Let me check if any test asserts the exact
allMatched.filterarrow-expression form.Assistant
No tests reference the exact
withMessagesarrow form. Let me update thewithMessagesfilter with the background gating, preserving active-session visibility.Assistant
The
projectFilteredlines are unchanged, preserving the substring assertions. Now let me run the existing relevant tests to make sure nothing breaks.Assistant
All pass. Let me run a broader set of relevant tests.
Assistant
There's a directly relevant failure:
test_gateway_sync.py::test_cron_sessions_hidden_from_sidebar_by_default. Let me examine it.Assistant
Let me look at
_insert_gateway_sessionand_insert_agent_session_rowhelpers.Assistant
Several tests fail. Let me determine which are pre-existing vs caused by my change. Let me stash my changes and run the failing tests as a baseline.
Assistant
The baseline confirms most failures are pre-existing (missing
node). Let me restore my changes and confirm which test my change actually breaks.Assistant
I found a clue earlier: line 472 sends
project_idin a request body. Let me examine that context.Assistant
The existing test confirms the server now returns the cron session. Let me verify the project_id is set on it by writing a standalone reproduction that exercises the real handler. Let me check how the routes dispatch is structured.
Assistant
Let me write a standalone script that starts the server subprocess and tests the full
/api/sessionsflow end-to-end, without touching the tests directory.Assistant
Let me write a standalone end-to-end reproduction script that starts the server subprocess.
Assistant
The end-to-end test confirms the server fix works. Now let me verify the client-side filter logic with a node simulation.
Assistant
Node isn't available here (consistent with the baseline failures). Let me consider whether to also reclassify background sessions so they appear in the default (webui) tab. Let me examine how
_isCliSessionis used in the action menu.Assistant
Node isn't available (consistent with baseline). My approach (option A: server returns cron sessions, client filters) aligns with "No new interfaces" and the existing client-side filtering. Let me run the relevant Python-only test files to confirm only the expected behavior-change test fails.
Assistant
Only the expected behavior-change test fails. Let me check for other places that filter cron sessions from the sidebar to ensure consistency across retrieval modes.
Assistant
The fix is centralized in
_hide_from_default_sidebar, used in bothall_sessionspaths and the deduped_cli filter. Let me check the gateway watcher for any independent cron filtering that might affect session retrieval.Assistant
The gateway watcher excludes cron via the default
exclude_sources, but that's a change-detection mechanism (the client refetches/api/sessionswhich is authoritative). Let me check theCLI_VISIBLE_SESSION_LIMITand_cap_recent_cli_sessionsto ensure cron sessions aren't dropped.Assistant
Both caps are 20 (pre-existing). The fix is consistent across the two server retrieval paths. Let me run the full test suite to confirm no regressions beyond the one expected behavior-change test.
Assistant
There's a concerning failure:
test_quote_entity_mangling.py::TestAlStashSourceFix::test_js_syntax_valid— this checks JS syntax validity. Let me investigate whether my JS edit caused it.Assistant
test_js_syntax_validrunsnode --check ui.js— it fails becausenodeisn't installed (pre-existing environment issue, and it checksui.js, not mysessions.js). Let me confirm by comparing the failure lists before and after my change.Assistant
My change introduces exactly ONE new failure — the expected behavior-change test. All 82 other failures are pre-existing (node availability, etc.). Let me verify the key substring assertions still hold after my JS edits.
Assistant
All substring assertions hold. Let me verify the
models.pyline thattest_sidebar_first_turn_visibilitychecks still exists.Assistant
Both
visible_resultlines are intact. Now let me add a CHANGELOG entry per the AGENTS.md guidance. Let me check the CHANGELOG format at the top.Assistant
Now let me clean up the temp scripts and review the final diff.
Assistant
The diff looks correct and complete. Let me run the most directly relevant tests once more to confirm everything passes (except the expected behavior-change test).
Assistant
All pass, including
test_imported_cron_sessions_hidden_from_sidebar_by_default(the imported cron session has no project_id, so it correctly stays hidden — confirming unassigned background sessions remain hidden). The only failing test istest_cron_sessions_hidden_from_sidebar_by_default, which encodes the old behavior this issue is explicitly changing.Let me do a final full diff review.
Assistant
The fix is complete and clean. Let me verify the final state of the key logic once more before submitting.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
claude-sonnet-5Compare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-35B-A3BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →
Qwen/Qwen3.6-27BCompare side by side →