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
Let me start by exploring the repository structure to understand what we're working with.
Assistant
Let me explore the repository structure more to understand the codebase.
Assistant
I see there's a test file
test_1079_cron_session_project.pythat seems directly related to this issue. Let me look at it.Assistant
Let me look at the relevant code in models.py to understand how sessions, projects, and cron sessions work.
Assistant
Now let me understand how sessions are listed and filtered by project. Let me look at the session discoverability module since it has "sidebar filters intentionally hide empty drafts, cron/background".
Assistant
Let me find the
all_sessionsfunction and how project filtering works.Assistant
Let me look at how sessions are filtered by project in the routes.
Assistant
Let me look at how project filtering is applied - searching for where project_id is used to filter sessions.
Assistant
Now let me look at how the frontend filters sessions by project.
Assistant
Let me look at how the frontend fetches sessions and how the project filter interacts with the server.
Assistant
Let me look at the conftest and how tests set up the server, and the search endpoint.
Assistant
Let me look at the
_handle_sessions_searchfunction and the MCP server session listing.Assistant
Let me look at the MCP server's session listing.
Assistant
Let me look at the
is_cli_session_row_visibleand related functions in agent_sessions.Assistant
Let me look at the cron-related code at lines 2160-2320 of models.py.
Assistant
Let me look at how the cron session is created (around line 12166).
Assistant
Let me look at the
all_sessionsfunction's sort_filter stage and how_hide_from_default_sidebaris applied.Assistant
Let me search for "retrieval mode" or related terms in the codebase and docs.
Assistant
Let me look at how the client identifies CLI/cron sessions.
Assistant
Let me look at the docs/CONTRACTS.md for session visibility contracts.
Assistant
Let me look at the conftest to understand how tests are run.
Assistant
Let me look at how tests create sessions and check the test_server fixture.
Assistant
Let me run the existing related test to verify the environment works.
Assistant
Let me look at the background.py and how cron sessions get into state.db.
Assistant
Let me look at how state.db sessions are read and the schema.
Assistant
So I see another key issue! In
_load_cli_sessions_uncached, it calls:for row in read_importable_agent_session_rows( db_path, limit=CLI_VISIBLE_SESSION_LIMIT, log=logger, exclude_sources=None, ):Wait, it passes
exclude_sources=None. So cron sessions ARE included inget_cli_sessions(). Good. So cron sessions are read from state.db and given a project_id.But then in
/api/sessions, they're filtered out by_cron_hide.Also, let me look at
_project_agent_session_rowsto see if cron sessions are projected.Assistant
Let me look at the git log to understand recent changes and the context.
Assistant
Let me search the tests for how cron sessions are set up in state.db.
Assistant
Let me look at test_issue2628_cli_sessions_perf.py which seems to set up state.db.
Assistant
Let me look at how other tests insert into state.db against the running server.
Assistant
Let me find how to enable show_cli_sessions via the API and check settings endpoints.
Assistant
Let me check the test state dir and profile structure, and how the server resolves the active hermes home.
Assistant
Now let me write a reproduction test to confirm the current behavior.
Assistant
Let me fix the repro test's projects parsing and also investigate "background" sessions.
Assistant
Let me look at how
/backgroundand/btwcreate sessions and their source. Let me search for the source of background/btw sessions.Assistant
Let me search for all callers of
read_importable_agent_session_rows.Assistant
Let me look at the
_sessionSourceFilterdefault andNO_PROJECT_FILTER.Assistant
Let me look at the
withMessagesfilter before the source filter.Assistant
Let me check
_looks_like_default_cli_titleand_count_user_turns.Assistant
I've confirmed the bug. Now let me look at the exact
_hide_from_default_sidebarand implement the server-side fix.Assistant
Let me implement the server-side fix in
_hide_from_default_sidebar.Assistant
Now let me update
_is_intentionally_background_sidebar_sessionto reuse the shared helper for consistency.Assistant
Let me find other places with the cron detection pattern for consistency.
Assistant
Now let me update the client. Let me add the helper near
_isCliSessionand modify the project filter.Assistant
Now let me modify the project filter in the client.
Assistant
Let me update the repro test to fix the projects parsing and verify the server-side fix.
Assistant
The server-side fix works. Now let me verify the JavaScript syntax is valid.
Assistant
Node isn't available. Let me try installing it differently or use a Python-based JS parser. Actually, let me just install nodejs properly.
Assistant
esprima's parseScript may not handle modern syntax. Let me check line 977 and try parseModule.
Assistant
The error is a pre-existing ES2019 feature (
catch {}) that esprima 4.0.1 can't parse, unrelated to my change. Let me verify my specific added blocks parse correctly in isolation.Assistant
Both added blocks parse fine. The
catch {}error is pre-existing. Now let me run the existing related tests to make sure nothing broke.Assistant
Let me run a broader set of session/sidebar/project tests.
Assistant
The
test_issue2551failure is due tonodenot being installed (FileNotFoundError: 'node'), unrelated to my change. Let me confirm it's pre-existing by stashing my changes.Assistant
Let me check the search/filterSessions frontend behavior to ensure consistency.
Assistant
Let me check all usages of
_hide_from_default_sidebarand_cron_hideto ensure consistency.Assistant
Let me run the sidebar visibility test and related tests.
Assistant
The
test_issue2066failure is also due tonodenot being available. Let me check which tests require node so I can run the rest of the session/sidebar suite cleanly.Assistant
Let me try to install Node.js so I can run the JS-based tests that may be relevant.
Assistant
Node is now available and the full
sessions.jspasses syntax check. Let me run the relevant JS-based tests.Assistant
All pass with node available. Let me run a broader set of session/sidebar/project/cli/cron tests.
Assistant
Let me look at how the JS-based tests work to potentially test the client-side project filter.
Assistant
Let me refactor the client project filter into a testable helper function for clarity and testability.
Assistant
Let me write a temporary Node script to verify the client-side filter logic for all the required scenarios.
Assistant
All client-side scenarios pass. Now let me verify the imported cron session path. Let me find the session import/open endpoint.
Assistant
Let me look at the full import flow for CLI sessions to extend my test.
Assistant
Let me extend my repro test to verify the imported cron session appears under its project.
Assistant
All tests pass. Now let me run a broader regression suite to ensure no breakage. Let me run the full session/sidebar/project/cli/cron test set.
Assistant
A test broke due to a literal-string assertion. Let me examine it.
Assistant
This test pins the literal
profileFiltered.filter(s=>!s.project_id). My refactor broke it unnecessarily. Let me use a more minimal approach that preserves the existing structure — only the default (All) branch needs to hide cron sessions, since the Unassigned and specific-project branches already handle cron correctly via project_id. Let me revert the helper extraction.Assistant
Let me re-run the unassigned filter test and update my node verification for the inline structure.
Assistant
Now let me re-verify the inline filter behavior with a node test replicating the new structure.
Assistant
The one "failure" is for a no-project cron session in the Unassigned view — but the server-side fix guarantees cron sessions always carry a project_id (empty/unassigned cron sessions are hidden server-side by
_hide_from_default_sidebar), so that case never reaches the client. For all server-returned data the inline filter is correct and preserves the existing test contract. Let me re-run the broad regression suite to confirm.Assistant
All pass. Let me review my final diff.
Assistant
The diff is clean. Now, per the repo's contribution guidelines, let me add a CHANGELOG entry for this user-visible behavior change. Let me look at the CHANGELOG format.
Assistant
Let me add a CHANGELOG entry under the
[Unreleased]section.Assistant
Let me run the full test suite to catch any other regressions.
Assistant
Several failures appeared. The most relevant is
test_gateway_sync.py::test_cron_sessions_hidden_from_sidebar_by_default. Let me examine it.Assistant
Let me examine
_insert_gateway_sessionto understand whether the failing cron test inserts messages.Assistant
Let me run the gateway_sync cron tests in isolation to see exactly which fail and why.
Assistant
The
test_cron_sessions_hidden_from_sidebar_by_defaultfailure is expected — it directly conflicts with the issue's new requirement (non-empty project-assigned cron sessions must be surfaced by the server for client-side project scoping). The other failures look unrelated. Let me verify they're pre-existing by stashing my changes.Assistant
Confirmed — the 18 unrelated failures are pre-existing environment issues (they fail without my changes too). The only product test affected by my change is
test_cron_sessions_hidden_from_sidebar_by_default, which directly conflicts with the issue's new requirement. Let me check for any other tests asserting cron sessions are hidden from/api/sessions.Assistant
Let me run the cron-specific test files to confirm only the one outdated test fails.
Assistant
Let me check the
_ensure_state_dbschema to understand my repro test's full-suite failure (a test-isolation issue, not a fix problem).Assistant
My repro test's full-suite failure is just a schema conflict with the gateway_sync test's
state.db(nosession_sourcecolumn), not a fix problem. Let me make the repro test schema-robust and re-run the full suite to confirm only the one outdated test fails.Assistant
The many gateway_sync failures are caused by my temp repro test leaking cron sessions into the shared
state.db(test-isolation issue with my temp test, not the fix). Let me remove the repro test and re-run gateway_sync to confirm only the one outdated test fails.Assistant
Only the one outdated test fails now. Let me do a final review of my complete diff.
Assistant
The diff is clean and the temp test is removed. Let me do a final broad regression run of the session/sidebar/project/cli/cron suite.
Assistant
Only the one outdated test fails (it directly conflicts with the issue's new requirement). Let me run the complete test suite once more to confirm the final state (temp test removed).
Assistant
Final state: 19 failed, 6575 passed. Of the 19 failures:
- 18 are pre-existing environment failures (bootstrap, ctl, workspace, permission, streaming_markdown) — confirmed they fail identically without my changes.
- 1 is
test_cron_sessions_hidden_from_sidebar_by_default, which directly conflicts with the issue's new requirement (non-empty project-assigned cron sessions must be surfaced by the server so the client can show them under their project). This test asserts the server hides them entirely, which the issue supersedes.
Let me confirm there are no leftover temp files.
Assistant
The implementation is complete and clean. Let me do a final review of the key server-side change to ensure correctness.
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.