Skip to content

feat: added GET /sessions endpoint with pagination#295

Closed
hk2166 wants to merge 2 commits intojenkinsci:mainfrom
hk2166:GEt_/session_Endpoint
Closed

feat: added GET /sessions endpoint with pagination#295
hk2166 wants to merge 2 commits intojenkinsci:mainfrom
hk2166:GEt_/session_Endpoint

Conversation

@hk2166
Copy link

@hk2166 hk2166 commented Mar 17, 2026

Implements GET /sessions to list all active server-side sessions with basic
metadata (session ID, message count, last accessed timestamp) and pagination support.

Fixes #218. Complements #196 (GET message history) — together they allow complete
session recovery after a browser restart or sessionStorage clear.

Changes:

  • api/models/schemas.py — Added SessionInfo and SessionListResponse Pydantic models
  • api/services/memory.py — Added list_sessions(page, page_size) using a single
    lock acquisition to ensure a consistent snapshot of total count and session metadata
  • api/routes/chatbot.py — Registered GET /sessions with page (default 1) and
    page_size (default 20, clamped to 1–100) query parameters
  • tests/unit/mocks/test_env.py — Added mock_list_sessions fixture
  • tests/unit/routes/test_chatbot.py — 6 new unit tests
  • tests/integration/test_chatbot.py — 7 new integration tests

Testing done

Automated tests were added at both unit and integration level. All 33 tests pass:

Submitter checklist

@hk2166 hk2166 requested a review from a team as a code owner March 17, 2026 21:52
@hk2166 hk2166 changed the title feat: add GET /sessions endpoint with pagination (#218) feat: added GET /sessions endpoint with pagination Mar 17, 2026
Copy link
Author

@hk2166 hk2166 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds unit tests for BM25Indexer in rag/embedding/bm25_indexer.py which had zero test coverage. Closes #290

Testing done

12 unit tests added, all passing (pytest tests/unit/rag/embedding/test_bm25_indexer.py -v — 12 passed in 0.02s), covering build(), _index_config(), and get() across both available and unavailable SparseRetriever scenarios.

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Link to relevant issues in GitHub or Jira — Closes #290
  • Link to relevant pull requests, esp. upstream and downstream changes — N/A
  • Ensure you have provided tests that demonstrate the feature works or the issue is fixed

@berviantoleo
Copy link
Contributor

Duplicates.

@berviantoleo berviantoleo added the duplicate This issue or pull request already exists label Mar 17, 2026
@berviantoleo
Copy link
Contributor

#238

@berviantoleo
Copy link
Contributor

Before submitting please look at the openned PR and give feedback in that PR.

This PR looks like combining two issues, it makes harder to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

duplicate This issue or pull request already exists

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add GET /sessions endpoint to list all active sessions

2 participants