Skip to content

Unit-test coverage for the Ask session resolver #10

@jstuart0

Description

@jstuart0

Goal

The resolver at `src/server/services/ask/resolver.ts` powers how `/ask` picks candidate sessions for the LLM's context. There's a minimal test file (`resolver.test.ts`) but coverage is thin — edge cases around token weighting, stopwords, and the breadth-hint fallback aren't exercised.

Scope

Add tests for:

  1. Stopword filtering — "is the api session healthy?" should drop "is", "the", "session", "healthy" and score against "api".
  2. Multi-keyword match — "the sourcebridge oauth session" should rank a session whose cwd contains both "sourcebridge" and "oauth" above one that only matches one.
  3. Stable ordering on ties — two sessions with identical scores should order by `lastActivityAt` desc.
  4. `fetchSessionsById` respects order — passing `["b", "a"]` returns in that order (not alphabetic).
  5. Archived sessions excluded — a session with `status: "archived"` shouldn't leak into the resolver pool.

Where to look

  • `src/server/services/ask/resolver.ts` — the resolver.
  • `src/server/services/ask/resolver.test.ts` — existing tests to extend.
  • `src/server/services/ai/__test_db.ts` — test DB helper.

Acceptance criteria

  • 5+ new tests, all green.
  • Total test count up by at least 5.
  • Tests use the shared `__test_db.ts` helper, not a private sqlite instance.

Great issue if you want to learn the AI/Ask codebase without writing production code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    askAsk assistant: global chat, resolver, streamingdocumentationImprovements or additions to documentationgood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions