Recipes

Add a "Previous Track" Button

Play the last track again using the queue history.

Every track that ends naturally is pushed onto queue.history (capped at maxHistory). That history is what powers a "previous" control.

Peek vs. take

queue.previous() returns the most recent history entry without removing it; queue.previous(true) pops it off and persists the change.

peek-previous.ts
const  = await ..();      // peek, history untouched
const  = await ..(true); // pop it off the history

.(?.., ?..);

Play the previous track

Take the last track off the history and play it. Replaying over the current track ends it with the Replaced reason, which Hoshimi handles without pushing it back to history — so you will not loop between the same two tracks.

previous-button.ts
const  = await ..(true);
if () await .({ :  });

List the history

queue.history is a plain array (newest first), so a "recently played" list is just a map.

history-list.ts
const  = ...(() => ..);
.();