fix: support CLI sessions in /api/list file browser - #204
Conversation
Add optional HTTPS support controlled by two env vars: HERMES_WEBUI_TLS_CERT=/path/to/cert.pem HERMES_WEBUI_TLS_KEY=/path/to/key.pem - Wraps server socket with ssl.SSLContext (min TLSv1.2) - Dynamic scheme detection for startup messages (http:// vs https://) - Graceful fallback to HTTP if cert loading fails — server never crashes due to bad TLS config, just prints a warning and continues - Auth cookie Secure flag already set when HTTPS is detected via getpeercert - 6 end-to-end tests: config flags, HTTPS handshake, HTTP still works, fallback on bad paths Addresses nesquena#191 (HTTPS support issue).
…branch
The update checker in api/updates.py always compared HEAD against
origin/master (or origin/main), which produced false 'N updates
available' alerts when the user is on a feature branch and master has
moved forward with unrelated commits.
Now uses git rev-parse --abbrev-ref @{upstream} to get the current
branch's tracking branch for both the behind-count check and the
apply-update pull command. Falls back to the default branch if no
upstream is set (brand-new local branch with no tracking config).
Fixes nesquena#200.
_handle_list_dir() only checked WebUI in-memory sessions, returning 'Session not found' for CLI sessions imported from the agent's state.db. Now falls back to get_cli_sessions() to find the workspace path for CLI sessions that aren't loaded in WebUI memory. Fixes: workspace pane showing empty for CLI sessions.
|
Thanks for this fix — the root cause is correct and the approach matches the existing pattern in the codebase. What's happening
Fix assessmentThe fallback to A few things that look good:
One thing to verify: if a CLI session has no Closes #203. Ready for maintainer review. |
Full Review: PR #204 — workspace file browser for CLI sessionsThanks @iRonin! Real bug, correct fix pattern. Security AuditClean. The fallback path uses Code ReviewThe fix matches the existing fallback pattern used in The Stacked Branch IssueThis PR includes changes from both PR #199 (TLS) and PR #201 (update checker) — it was branched from #201 which was branched from #199. The diff shows 277 additions but only ~17 are the actual CLI sessions fix in Files that don't belong to this PR:
Recommended merge order: #199 first, then rebase #201, then rebase #204. Each PR should only contain its own changes. Test Results512 passed, 0 failed, 41 skipped. No regressions. VerdictThe CLI sessions fix itself is approved — correct and safe. But please rebase this onto master after PRs #199 and #201 are merged to isolate the actual 17-line change. As-is, merging this would silently ship TLS support and the update checker fix without proper individual review. |
…ession fallback Two changes on top of the CLI session fallback from PR #204: 1. Guard against empty/None workspace in the CLI session fallback path: cli_meta.get('workspace', '') could return an empty string for sessions created before workspace tracking was added (or with workspace=None). Path('') resolves to CWD which is silently wrong. Now returns 400 instead. 2. Add 7 unit tests in test_cli_session_filebrowser.py: - CLI fallback is called when WebUI session not found (KeyError path) - WebUI sessions go through direct path (no CLI fallback) - Session not found in CLI sessions returns 404 - CLI session with missing workspace key returns 400 (not KeyError crash) - CLI session with empty workspace returns 400 (not CWD traversal) - CLI session with None workspace returns 400 (not TypeError) - Missing session_id returns error immediately
|
Rebased onto current master (post #196, #197, #198, #199, #201 merges). The fix is correct and the approach matches the existing fallback pattern used in Added tests covering:
566 tests passing. Ready to merge. |
1. _handle_chat_start: Import CLI sessions on-the-fly when sending a message to a CLI session from the WebUI. Previously returned 404 because only WebUI in-memory sessions were checked. 2. Mobile workspace panel: Added closeMobileFiles() function and wired it into closeMobileSidebar() so tapping the overlay dismisses both the sidebar AND the workspace panel. Fixes nesquena#204 (CLI session chat), fixes mobile workspace panel close.
* feat: optional HTTPS/TLS support via cert and key env vars Add optional HTTPS support controlled by two env vars: HERMES_WEBUI_TLS_CERT=/path/to/cert.pem HERMES_WEBUI_TLS_KEY=/path/to/key.pem - Wraps server socket with ssl.SSLContext (min TLSv1.2) - Dynamic scheme detection for startup messages (http:// vs https://) - Graceful fallback to HTTP if cert loading fails — server never crashes due to bad TLS config, just prints a warning and continues - Auth cookie Secure flag already set when HTTPS is detected via getpeercert - 6 end-to-end tests: config flags, HTTPS handshake, HTTP still works, fallback on bad paths Addresses nesquena#191 (HTTPS support issue). * fix: use current branch upstream for update checks, not repo default branch The update checker in api/updates.py always compared HEAD against origin/master (or origin/main), which produced false 'N updates available' alerts when the user is on a feature branch and master has moved forward with unrelated commits. Now uses git rev-parse --abbrev-ref @{upstream} to get the current branch's tracking branch for both the behind-count check and the apply-update pull command. Falls back to the default branch if no upstream is set (brand-new local branch with no tracking config). Fixes nesquena#200. * fix: support CLI sessions in /api/list file browser _handle_list_dir() only checked WebUI in-memory sessions, returning 'Session not found' for CLI sessions imported from the agent's state.db. Now falls back to get_cli_sessions() to find the workspace path for CLI sessions that aren't loaded in WebUI memory. Fixes: workspace pane showing empty for CLI sessions.
* feat: optional HTTPS/TLS support via cert and key env vars Add optional HTTPS support controlled by two env vars: HERMES_WEBUI_TLS_CERT=/path/to/cert.pem HERMES_WEBUI_TLS_KEY=/path/to/key.pem - Wraps server socket with ssl.SSLContext (min TLSv1.2) - Dynamic scheme detection for startup messages (http:// vs https://) - Graceful fallback to HTTP if cert loading fails — server never crashes due to bad TLS config, just prints a warning and continues - Auth cookie Secure flag already set when HTTPS is detected via getpeercert - 6 end-to-end tests: config flags, HTTPS handshake, HTTP still works, fallback on bad paths Addresses nesquena#191 (HTTPS support issue). * fix: use current branch upstream for update checks, not repo default branch The update checker in api/updates.py always compared HEAD against origin/master (or origin/main), which produced false 'N updates available' alerts when the user is on a feature branch and master has moved forward with unrelated commits. Now uses git rev-parse --abbrev-ref @{upstream} to get the current branch's tracking branch for both the behind-count check and the apply-update pull command. Falls back to the default branch if no upstream is set (brand-new local branch with no tracking config). Fixes nesquena#200. * fix: support CLI sessions in /api/list file browser _handle_list_dir() only checked WebUI in-memory sessions, returning 'Session not found' for CLI sessions imported from the agent's state.db. Now falls back to get_cli_sessions() to find the workspace path for CLI sessions that aren't loaded in WebUI memory. Fixes: workspace pane showing empty for CLI sessions.
Problem
When a CLI session is selected in the Web UI, the workspace file browser is empty. The
/api/listendpoint returns 404 because it only checks WebUI in-memory sessions, not CLI sessions imported fromstate.db.Fix
_handle_list_dir()now falls back toget_cli_sessions()to find the workspace path for CLI sessions that aren't loaded in WebUI memory. This matches the existing pattern used in/api/sessionGET and/api/sessionslist endpoints.Impact
Closes the bug where workspace pane showed no files for CLI sessions.