Skip to content

fix(dj): return DJ vibe and now playing when listening history is sparse - #926

Merged
LargeModGames merged 2 commits into
LargeModGames:mainfrom
mvanhorn:fix/830-sparse-history-keeps-vibe
Oct 23, 2026
Merged

LargeModGames merged 2 commits into
LargeModGames:mainfrom
mvanhorn:fix/830-sparse-history-keeps-vibe

Conversation

@mvanhorn

@mvanhorn mvanhorn commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On a profile with little listening history, the listening-history answer is a single sentence that says to ask what the listener feels like. A vibe stored just before that call, the track that is playing, and the structured fields are all missing, so the stored vibe looks like it was dropped. history_outcome writes the current track and the stored vibe onto the brief, then returns immediately when the brief is sparse.

That return is ToolOutcome::ok_localized around the history_sparse sentence and carries no structured payload, so the filled-in track and vibe never reach the caller.

history_outcome now ends in history_result. That helper builds one JSON object with period, total_plays, top_artists, top_tracks, top_albums, recent, now_playing, and vibe, and returns it through ToolOutcome::data_localized. A sparse brief still leads with history_sparse, and appends brief_now and brief_vibe when those values are set; a fuller brief still uses display_block. The changelog records this, and new tests call history_result with hand-built briefs for the vibe, the current track, shared keys, the five-play threshold, and a full brief.

Fixes #830

Testing

Ran cargo test --no-default-features --features telemetry,tui locally on macOS for the spotatui history_outcome change; it passed.
cargo test --no-default-features --features telemetry,tui finished with every test passing.
cargo test -q -p spotatui stopped in the portaudio-sys build script before any tests ran.
Ran cargo test --no-default-features --features telemetry,tui in a Linux container (rust:1) for the spotatui history_outcome change; 1758 tests passed.

Additional notes


💬 Questions or want to chat with other contributors? Join the spotatui Discord.

AI was used for assistance.

Summary by CodeRabbit

  • Bug Fixes
    • Listening-history responses with fewer than five qualifying plays now include the configured DJ vibe and current track when available. They retain the prompt asking what the listener feels like and include the standard structured history details. Responses with five or more qualifying plays continue to use the existing localized display format.

history_outcome now ends in history_result. That helper builds one JSON
object with period, total_plays, top_artists, top_tracks, top_albums,
recent, now_playing, and vibe, and returns it through
ToolOutcome::data_localized. A sparse brief still leads with
history_sparse, and appends brief_now and brief_vibe when those values
are set; a fuller brief still uses display_block. The changelog records
this, and new tests call history_result with hand-built briefs for the
vibe, the current track, shared keys, the five-play threshold, and a
full brief.

Fixes LargeModGames#830
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
📥 Commits

Reviewing files that changed from the base of the PR and between 04ff4cd and a1b1203.

📒 Files selected for processing: 1
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes: 1
  • CHANGELOG.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📝 Walkthrough

Sparse listening-history responses now include the configured vibe and current track when available. They retain the ask-the-user text and structured history fields. Full-history formatting remains unchanged.

Changes: Listening History Response

Layer / File(s) Summary
Build and validate history responses
src/infra/dj/tools.rs, CHANGELOG.md
history_outcome uses a shared helper for sparse and full summaries. Sparse text retains the ask-the-user message and includes available current-track and vibe details. Tests cover structured fields, optional context, the five-play threshold, and full-history formatting. The changelog records the sparse-history behavior.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to a1b12

No actionable merge-blocking risk is identified in the supplied change context; proceed with normal validation.

Pre-merge checks: Passed 4
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title uses the conventional-commit prefix "fix" with the scope "dj" and a concise imperative-style subject. It matches the main change: sparse listening-history responses now return the stored DJ …
Linked Issues check Passed Issue #830 requires three things: keep the ask-the-user sentence for sparse history, add the stored vibe and current track when set, and use the same structured keys for sparse and full history.

The …
Out of Scope Changes check Passed The changes address issue #830 only. The tools.rs diff changes history_outcome and adds history_result and its tests, and every change serves the sparse or structured payload requirement. The changelo…
Full details: Title check

Explanation

The title uses the conventional-commit prefix "fix" with the scope "dj" and a concise imperative-style subject. It matches the main change: sparse listening-history responses now return the stored DJ vibe and the current track, as described in the PR objectives and the tools.rs summary.

Full details: Linked Issues check

Explanation

Issue #830 requires three things: keep the ask-the-user sentence for sparse history, add the stored vibe and current track when set, and use the same structured keys for sparse and full history.

The whole-PR diff of src/infra/dj/tools.rs shows these changes:

  • history_outcome now ends with history_result(&summary, period). The early return is removed.
  • history_result builds one structured JSON object with period, total_plays, top_artists, top_tracks, top_albums, recent, now_playing, and vibe. It returns this object for both sparse and full briefs through ToolOutcome::data_localized.
  • For a sparse brief, the text starts with history_sparse. It appends brief_now(now) only when now_playing is Some, and brief_vibe(vibe) only when vibe is Some.
  • For a full brief, the text still comes from display_block.
  • The five-play threshold in is_sparse is not changed.

New tests call history_result with hand-built TasteBrief values, as the issue asks. They cover the vibe, the current track, the shared key set, the threshold at 4 and 5 plays, and full-history output. None of them calls history_outcome or reads listens.jsonl.

The diff reviewed here does not show the wording of the brief_now and brief_vibe strings. The tests assert the phrases "Currently playing:" and "The listener asked for". Those assertions depend on the localized strings, which were not inspected. The PR reports a passing test run, which supports that the assertions hold.

Full details: Out of Scope Changes check

Explanation

The changes address issue #830 only. The tools.rs diff changes history_outcome and adds history_result and its tests, and every change serves the sparse or structured payload requirement. The changelog entry, which is +2 lines, records the same behavior. No unrelated product behavior, threshold, or prompt text is changed. The full-history branch keeps its existing display_block output, which the issue asks to preserve.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
✨ Simplify code
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.52941% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/infra/dj/tools.rs 98.5% 2 Missing ⚠️

📢 Thoughts on this report? Let us know!

@LargeModGames
LargeModGames merged commit 95a123b into LargeModGames:main Oct 23, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_listening_history drops the DJ vibe and now playing when history is sparse

2 participants