Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

List the preparation queue on the Downloads screen

Leonardo Lobato43c707bee318
diff --git a/cmake/HomebrewUI.cmake b/cmake/HomebrewUI.cmake
index 5c29083..ee64e0f 100644
--- a/cmake/HomebrewUI.cmake
+++ b/cmake/HomebrewUI.cmake
@@ -186,6 +186,7 @@ target_include_directories(playden_hui PUBLIC
add_library(playden_homebrew_model STATIC
"${CMAKE_SOURCE_DIR}/src/homebrew/simulation.cpp"
"${CMAKE_SOURCE_DIR}/src/homebrew/storage_sim.cpp"
+ "${CMAKE_SOURCE_DIR}/src/homebrew/queue_layout.cpp"
"${CMAKE_SOURCE_DIR}/src/homebrew/browse.cpp")
target_compile_features(playden_homebrew_model PUBLIC cxx_std_20)
target_link_libraries(playden_homebrew_model PUBLIC playden_library playden_diagnostic_log playden_steam_cm_codec)
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 5b8c247..5271d1e 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -686,6 +686,11 @@ void Controller::TickRuntime() {
// A quit to Home waits for the running preparation; the queued ones would be cut off.
runtime_->HoldPreparations(model_.state().quit_waiting);
for (const auto id : model_.TakeRuntimePrepareRequests()) RequestPrepare(id);
+ // A game Playden still holds back moves to the front once it is asked for.
+ for (const auto id : model_.TakePrepareNextRequests())
+ if (!runtime_->PrepareNext(id)) prepare_next_pending_ = id;
+ for (const auto& done : model_.TakePreparedDismissals()) runtime_->DismissPrepared(done.game_id, done.finished_at);
+ if (model_.TakePreparedClear()) runtime_->ClearPrepared();
if (model_.TakeRuntimeCleanupRequest()) runtime_->CleanUpRequests();
for (const auto id : model_.TakeKeptDeleteRequests()) runtime_->DeleteKeptBottle(id);
for (const auto id : model_.TakeActivityRequests()) runtime_->CheckActivity(id);
@@ -950,6 +955,31 @@ void Controller::TickRuntime() {
for (const auto id : ready_notices_) model_.NotifyReadyToPlay(id);
ready_notices_.clear();
};
+ {
+ // Queue's Preparation section: the runtime's queue in order, then games Playden holds back before
+ // asking for them (Steam's launch options, saves in transit, a Play waiting to ask).
+ PreparationQueue queue;
+ queue.active = snapshot.preparing_app;
+ queue.waiting = snapshot.queued_prepares;
+ const auto add = [&queue](GameId id) {
+ if (queue.active != id && std::find(queue.waiting.begin(), queue.waiting.end(), id) == queue.waiting.end())
+ queue.waiting.push_back(id);
+ };
+ for (const auto id : prepare_after_details_) add(id);
+ for (const auto id : auto_prepare_) if (game_roots_.count(id)) add(id);
+ for (const auto& [id, pending] : play_after_prepare_) if (!pending.queued) add(id);
+ if (prepare_next_pending_)
+ if (const auto found = std::find(queue.waiting.begin(), queue.waiting.end(), *prepare_next_pending_);
+ found != queue.waiting.end())
+ std::rotate(queue.waiting.begin(), found, found + 1);
+ for (const auto& done : snapshot.prepared)
+ if (game_roots_.count(done.app_id)) queue.completed.push_back({done.app_id, done.finished_at});
+ for (const auto& [id, refusal] : snapshot.refusals)
+ if (game_roots_.count(id) && queue.active != id &&
+ std::find(queue.waiting.begin(), queue.waiting.end(), id) == queue.waiting.end())
+ queue.refused[id] = refusal;
+ model_.UpdatePreparationQueue(std::move(queue));
+ }
if (snapshot.revision == runtime_revision_ && install_revision_ == runtime_install_revision_ &&
cloud_revision_ == runtime_cloud_revision_ && play_notes_revision_ == runtime_notes_revision_) {
announce_ready();
@@ -1064,7 +1094,7 @@ void Controller::TickRuntime() {
if ((launching && busy) || PrepareQueued(snapshot, id)) game.can_prepare = false;
// Queued behind another game's setup, from the runtime's queue or a Play that waits to ask it.
const auto waiting_play = play_after_prepare_.find(id);
- game.queued = snapshot.preparing_app && *snapshot.preparing_app != id &&
+ game.queued = snapshot.preparing_app != id &&
(PrepareQueued(snapshot, id) ||
(waiting_play != play_after_prepare_.end() && !waiting_play->second.queued));
game.can_play = game.ready && !busy && snapshot.preparing_app != id && !cloud_busy_.count(id) &&
@@ -1359,6 +1389,10 @@ void Controller::SubmitPrepare(GameId id, bool announce) {
// After a failed answer, ask Steam again so a later Prepare can use the options.
if (app_details_ && !launch_options_.count(id)) app_details_->Request(id, model_.state().account_generation);
runtime_->Prepare(std::move(request));
+ if (prepare_next_pending_ == id) {
+ runtime_->PrepareNext(id);
+ prepare_next_pending_.reset();
+ }
}
void Controller::Apply(const steam::SteamEvent& event) {
const auto ignore = [&](const char* reason) {
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index 1012c07..5653280 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -129,6 +129,7 @@ class Controller {
// was queued tells a new refusal from an old one.
std::set<GameId> downloading_;
std::vector<GameId> auto_prepare_; // in the order their downloads finished
+ std::optional<GameId> prepare_next_pending_; // Prepare next on a game not in the runtime's queue yet
struct PlayAfterPrepare {
bool queued = false;
bool seen_preparing = false;
diff --git a/src/homebrew/queue_layout.cpp b/src/homebrew/queue_layout.cpp
new file mode 100644
index 0000000..abdd78a
--- /dev/null
+++ b/src/homebrew/queue_layout.cpp
@@ -0,0 +1,244 @@
+// queue_layout.cpp - What the Queue screen shows: downloads and preparations, each section's rows and counts.
+// Copyright (c) 2026 Playden contributors
+// SPDX-License-Identifier: MIT
+#include "homebrew/queue_layout.hpp"
+
+#include <algorithm>
+
+namespace playden::homebrew {
+namespace {
+std::string game_title(const State& state, GameId id) {
+ for (const auto& game : state.games)
+ if (game.id == id && !game.title.empty()) return game.title;
+ return "Steam app " + std::to_string(id);
+}
+
+std::string need_attention(std::size_t count) {
+ return std::to_string(count) + (count == 1 ? " needs attention" : " need attention");
+}
+
+void join(std::string& text, const std::string& part) {
+ if (part.empty()) return;
+ if (!text.empty()) text += " · ";
+ text += part;
+}
+
+bool running(const Job& job) {
+ return job.state == JobState::Downloading || job.state == JobState::Verifying || job.state == JobState::Pausing;
+}
+
+QueueSection downloads(const State& state) {
+ QueueSection section{kQueueDownloads, "Downloads"};
+ std::vector<const Job*> jobs;
+ for (const auto& job : state.jobs)
+ if (job.state != JobState::Cancelled) jobs.push_back(&job);
+ std::stable_sort(jobs.begin(), jobs.end(), [](const Job* left, const Job* right) { return left->queue_order < right->queue_order; });
+ // The card shows the running transfer, or else the first unfinished one in queue order (a failed or
+ // paused download does not jump ahead of the queue).
+ auto card = std::find_if(jobs.begin(), jobs.end(), [](const Job* job) { return running(*job); });
+ if (card == jobs.end())
+ card = std::find_if(jobs.begin(), jobs.end(), [](const Job* job) { return job->state != JobState::Downloaded; });
+ const auto entry = [&state](const Job& job) {
+ QueueEntry item;
+ item.key = "job-" + job.id;
+ item.game_id = job.game_id;
+ item.job = &job;
+ item.title = !job.title.empty() ? job.title : game_title(state, job.game_id);
+ item.note = job.failure;
+ item.completed = job.state == JobState::Downloaded && job.kind == "install";
+ item.finished_at = job.finished_at;
+ return item;
+ };
+ std::vector<const Job*> finished;
+ std::size_t paused = 0, failed = 0;
+ for (const auto* job : jobs) {
+ if (running(*job)) ++section.running;
+ else if (job->state == JobState::Queued) ++section.waiting;
+ else if (job->state == JobState::Paused || job->state == JobState::Interrupted) ++paused;
+ else if (job->state == JobState::Failed) ++failed;
+ if (card != jobs.end() && job == *card) section.active = entry(*job);
+ // A staged Playden update is a Downloaded job that still asks for a restart: it stays with the work.
+ else if (job->state == JobState::Downloaded && job->kind == "install") finished.push_back(job);
+ else section.rows.push_back(entry(*job));
+ }
+ std::stable_sort(finished.begin(), finished.end(), [](const Job* left, const Job* right) {
+ return left->finished_at > right->finished_at;
+ });
+ for (const auto* job : finished) section.rows.push_back(entry(*job));
+ section.attention = paused + failed;
+ section.completed = finished.size();
+ return section;
+}
+
+std::string downloads_words(const QueueSection& section, std::size_t paused, std::size_t failed) {
+ std::string text;
+ if (section.running) join(text, std::to_string(section.running) + " downloading");
+ if (section.waiting) join(text, std::to_string(section.waiting) + " waiting");
+ if (paused) join(text, std::to_string(paused) + " paused");
+ if (failed) join(text, std::to_string(failed) + " failed");
+ return text;
+}
+
+QueueSection preparations(const State& state) {
+ QueueSection section{kQueuePreparation, "Preparation"};
+ const auto& queue = state.preparation_queue;
+ const auto runtime = [&state](GameId id) -> const LiveRuntimeGame* {
+ const auto found = state.runtime_games.find(id);
+ return found == state.runtime_games.end() ? nullptr : &found->second;
+ };
+ std::string active_title;
+ if (queue.active) {
+ QueueEntry item;
+ item.key = "prep-active-" + std::to_string(*queue.active);
+ item.game_id = *queue.active;
+ item.title = active_title = game_title(state, *queue.active);
+ item.status = "Preparing";
+ item.tone = "busy";
+ // The actual step, never a made-up percentage.
+ if (const auto* game = runtime(*queue.active)) item.note = game->detail;
+ section.active = item;
+ section.running = 1;
+ }
+ int position = 0;
+ for (const auto id : queue.waiting) {
+ if (queue.active && id == *queue.active) continue;
+ QueueEntry item;
+ item.key = "prep-" + std::to_string(id);
+ item.game_id = id;
+ item.title = game_title(state, id);
+ item.position = ++position;
+ item.status = position == 1 ? "Up next" : "Queued";
+ item.tone = position == 1 ? "busy" : "quiet";
+ item.note = position == 1 ? (active_title.empty() ? "Starts next" : "Starts after " + active_title)
+ : "Waiting for preparation";
+ section.rows.push_back(std::move(item));
+ ++section.waiting;
+ }
+ // Games whose preparation needs the player: it failed, stopped part way or waits for the PS5.
+ const auto listed = [&](GameId id) {
+ return (queue.active && *queue.active == id) ||
+ std::find(queue.waiting.begin(), queue.waiting.end(), id) != queue.waiting.end();
+ };
+ for (const auto& [id, game] : state.runtime_games) {
+ if (listed(id)) continue;
+ QueueEntry item;
+ item.key = "prep-attn-" + std::to_string(id);
+ item.game_id = id;
+ item.title = game_title(state, id);
+ item.note = game.detail;
+ item.tone = "attention";
+ if (game.status == "Waiting for the PS5") {
+ item.status = "Waiting for the PS5";
+ item.note = "Quit Playden and the PS5 adds it to Home";
+ } else if (game.status == "Registration pending") {
+ item.status = "Registration pending";
+ } else if (game.status == "Needs recovery") {
+ item.status = "Interrupted";
+ } else if (game.status == "Failed") {
+ item.status = "Couldn't prepare";
+ item.tone = "problem";
+ } else if (const auto refused = queue.refused.find(id);
+ refused != queue.refused.end() && !game.ready && !game.prepared && !game.awaiting_registration) {
+ item.status = "Couldn't prepare";
+ item.note = refused->second;
+ item.tone = "problem";
+ } else {
+ continue;
+ }
+ section.rows.push_back(std::move(item));
+ ++section.attention;
+ }
+ for (const auto& done : queue.completed) {
+ QueueEntry item;
+ item.key = "prep-done-" + std::to_string(done.game_id) + "-" + std::to_string(done.finished_at);
+ item.game_id = done.game_id;
+ item.title = game_title(state, done.game_id);
+ item.status = "Ready";
+ item.tone = "good";
+ item.completed = true;
+ item.finished_at = done.finished_at;
+ section.rows.push_back(std::move(item));
+ ++section.completed;
+ }
+ return section;
+}
+
+// The heading's words: what runs and waits when expanded, how many more when collapsed; both keep
+// what needs the player and the completed count.
+void summarize(QueueSection& section, const std::string& expanded_words, const std::string& attention_words,
+ const char* idle) {
+ std::string text;
+ const std::size_t more = section.rows.size() - section.completed; // unfinished, after the card
+ if (section.expanded) {
+ text = expanded_words;
+ if (section.running && !section.waiting && !section.attention) join(text, "Nobody waiting");
+ } else if (section.active) {
+ text = more == 0 ? "No other games queued"
+ : more == 1 ? "1 more game queued" : std::to_string(more) + " more games queued";
+ join(text, attention_words);
+ } else {
+ join(text, attention_words);
+ }
+ if (section.completed) join(text, std::to_string(section.completed) + " completed");
+ if (text.empty()) text = section.unfinished() ? expanded_words : idle;
+ section.summary = text;
+}
+} // namespace
+
+std::string QueueSectionOf(const std::string& key) {
+ if (key == "queue-downloads" || key.rfind("job-", 0) == 0) return kQueueDownloads;
+ if (key == "queue-preparation" || key.rfind("prep-", 0) == 0) return kQueuePreparation;
+ return {};
+}
+
+QueueLayout BuildQueueLayout(const State& state) {
+ QueueLayout layout{downloads(state), preparations(state)};
+ auto& download = layout.downloads;
+ auto& prepare = layout.preparation;
+ // A row (not a card: it shows either way) with focus keeps its section open.
+ std::string open;
+ const auto& focus = state.navigation.modals.empty() ? state.navigation.focus_key
+ : state.navigation.modals.front().opener_focus_key;
+ for (const auto* section : {&download, &prepare})
+ for (const auto& row : section->rows)
+ if (row.key == focus) open = section->id;
+ const auto section = [&](const std::string& id) -> QueueSection& { return id == kQueueDownloads ? download : prepare; };
+ if (open.empty() && !state.queue_expanded.empty() && !section(state.queue_expanded).empty()) open = state.queue_expanded;
+ if (open.empty()) {
+ if (prepare.waiting > 0) open = kQueuePreparation;
+ else if (download.unfinished()) open = kQueueDownloads;
+ else if (prepare.unfinished()) open = kQueuePreparation;
+ else if (!download.empty()) open = kQueueDownloads;
+ else if (!prepare.empty()) open = kQueuePreparation;
+ }
+ download.expanded = !download.empty() && open == kQueueDownloads;
+ prepare.expanded = !prepare.empty() && open == kQueuePreparation;
+
+ std::size_t paused = 0, failed = 0;
+ for (const auto& job : state.jobs) {
+ if (job.state == JobState::Paused || job.state == JobState::Interrupted) ++paused;
+ if (job.state == JobState::Failed) ++failed;
+ }
+ std::string download_attention;
+ if (paused) join(download_attention, std::to_string(paused) + " paused");
+ if (failed) join(download_attention, std::to_string(failed) + " failed");
+ summarize(download, downloads_words(download, paused, failed), download_attention, "No downloads");
+ std::string prepare_words, prepare_attention;
+ if (prepare.running) join(prepare_words, "1 preparing");
+ if (prepare.waiting) join(prepare_words, std::to_string(prepare.waiting) + " waiting");
+ if (prepare.attention) join(prepare_attention, need_attention(prepare.attention));
+ join(prepare_words, prepare_attention);
+ summarize(prepare, prepare_words, prepare_attention, "No preparation queued");
+
+ std::string summary;
+ if (download.running) join(summary, std::to_string(download.running) + " downloading");
+ if (prepare.running) join(summary, "1 preparing");
+ if (download.waiting + prepare.waiting) join(summary, std::to_string(download.waiting + prepare.waiting) + " waiting");
+ if (download.attention + prepare.attention)
+ join(summary, need_attention(download.attention + prepare.attention));
+ if (summary.empty() && !layout.nothing())
+ summary = "No active work · " + std::to_string(download.completed + prepare.completed) + " completed";
+ layout.summary = summary;
+ return layout;
+}
+} // namespace playden::homebrew
diff --git a/src/homebrew/queue_layout.hpp b/src/homebrew/queue_layout.hpp
new file mode 100644
index 0000000..0c9c14b
--- /dev/null
+++ b/src/homebrew/queue_layout.hpp
@@ -0,0 +1,63 @@
+#pragma once
+// queue_layout.hpp - What the Queue screen shows: downloads and preparations, each section's rows and counts.
+// Copyright (c) 2026 Playden contributors
+// SPDX-License-Identifier: MIT
+#include "homebrew/simulation.hpp"
+
+#include <cstddef>
+#include <cstdint>
+#include <optional>
+#include <string>
+#include <vector>
+
+namespace playden::homebrew {
+inline constexpr const char* kQueueDownloads = "downloads";
+inline constexpr const char* kQueuePreparation = "preparation";
+
+// One game in a section. Downloads point at their job; preparations carry what their row says.
+struct QueueEntry {
+ std::string key; // the row's focus key: job-<id>, prep-<id>, prep-attn-<id>, prep-done-<id>-<time>
+ GameId game_id = 0;
+ const Job* job = nullptr;
+ std::string title;
+ std::string status; // the right-hand tag: "Up next", "Queued", "Waiting for the PS5", "Ready"
+ std::string note; // beside the title: why it waits or failed
+ std::string tone; // good, busy, attention, problem, quiet
+ int position = 0; // waiting preparations, from 1
+ bool completed = false;
+ std::int64_t finished_at = 0; // completed entries (Unix seconds), 0 unknown
+};
+
+struct QueueSection {
+ std::string id; // kQueueDownloads or kQueuePreparation
+ std::string name; // "Downloads", "Preparation"
+ // The running download or preparation, shown in the card; a paused or failed download at the front
+ // of the queue takes the card too, as Downloads always showed it.
+ std::optional<QueueEntry> active;
+ // Unfinished entries after the card (waiting, then needing attention), then completed ones, newest first.
+ std::vector<QueueEntry> rows;
+ std::size_t running = 0; // downloading or preparing now
+ std::size_t waiting = 0; // queued to run, card included when it only waits
+ std::size_t attention = 0; // paused, failed or blocked: not ordinary waiting work
+ std::size_t completed = 0;
+ bool expanded = false;
+ std::string summary; // the heading's right-hand words
+
+ [[nodiscard]] bool empty() const { return !active && rows.empty(); }
+ [[nodiscard]] bool unfinished() const { return active || rows.size() > completed; }
+};
+
+struct QueueLayout {
+ QueueSection downloads;
+ QueueSection preparation;
+ std::string summary; // the page's subtitle: "1 downloading · 1 preparing · 4 waiting"
+ [[nodiscard]] bool nothing() const { return downloads.empty() && preparation.empty(); }
+};
+
+// The section shown expanded: the one whose row has focus, else the player's choice when it still
+// has something to show, else Preparation when games wait there, Downloads with unfinished work,
+// then whichever has anything.
+QueueLayout BuildQueueLayout(const State& state);
+// The section a Queue focus key belongs to (a heading, card or row); empty for other keys.
+std::string QueueSectionOf(const std::string& key);
+} // namespace playden::homebrew
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 0882af1..797cc3c 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -9,6 +9,7 @@
#include "app/diagnostic_log.h"
#include "homebrew/browse.hpp"
#include "homebrew/json.hpp"
+#include "homebrew/queue_layout.hpp"
#include "homebrew/storage_sim.hpp"
#include "steam/install_volumes.h"
#include "steam/backend/json.h"
@@ -467,7 +468,8 @@ std::string action_label(const std::string& key) {
{"inject-logs-ready", "Inject ready logs"}, {"account-auth", "Authentication"},
{"account-last-sync", "Last library sync"}, {"account-sync", "Sync now"},
{"account-recover", "Reconnect account"}, {"account-switch", "Switch account"},
- {"account-reauth", "Sign in again"}, {"job-resume-all", "Resume all"}, {"job-clear-completed", "Clear completed"}, {"collection-new", "New collection"}, {"collection-manage", "Manage collections"},
+ {"account-reauth", "Sign in again"}, {"job-resume-all", "Resume all"}, {"job-clear-completed", "Clear completed"},
+ {"prep-clear-completed", "Clear completed"}, {"storage-close", "Close"}, {"collection-new", "New collection"}, {"collection-manage", "Manage collections"},
{"about-version", "Version"}, {"self-update-install", "Download and install"},
{"self-update-restart", "Restart Playden"}, {"self-update-cancel", "Cancel update"},
{"self-update-back-confirm", "Go back"}, {"release-notes-ok", "OK"},
@@ -480,7 +482,8 @@ std::string action_label(const std::string& key) {
for (const auto& [prefix, label] : std::initializer_list<std::pair<const char*, const char*>>{
{"job-pause-", "Pause download"}, {"job-resume-", "Resume download"}, {"job-retry-", "Retry download"},
{"job-cancel-", "Cancel download"}, {"job-now-", "Download now"}, {"job-up-", "Move up"}, {"job-down-", "Move down"},
- {"job-open-", "Open game"}, {"job-dismiss-", "Dismiss"}})
+ {"job-open-", "Open game"}, {"job-dismiss-", "Dismiss"}, {"prep-next-", "Prepare next"},
+ {"prep-open-", "Game details"}, {"prep-retry-", "Try again"}, {"prep-dismiss-", "Dismiss"}})
if (key.rfind(prefix, 0) == 0) return label;
std::string title = key;
std::replace(title.begin(), title.end(), '-', ' ');
@@ -969,6 +972,51 @@ void Simulation::RequestRuntimePrepare(GameId id) {
if (id != 0) pending_runtime_prepare_requests_.push_back(id);
}
+void Simulation::UpdatePreparationQueue(PreparationQueue queue) {
+ // A dismissal or Prepare next the runtime has not carried out yet keeps showing as asked; once the
+ // runtime's list no longer has the entry, or has the game first, it is done.
+ std::erase_if(prepared_dismissed_, [&queue](const LiveCompletedPreparation& done) {
+ return std::find(queue.completed.begin(), queue.completed.end(), done) == queue.completed.end();
+ });
+ for (const auto& done : prepared_dismissed_) std::erase(queue.completed, done);
+ if (prepare_next_asked_) {
+ const auto found = std::find(queue.waiting.begin(), queue.waiting.end(), *prepare_next_asked_);
+ if (found == queue.waiting.end() || found == queue.waiting.begin()) prepare_next_asked_.reset();
+ else std::rotate(queue.waiting.begin(), found, found + 1);
+ }
+ if (queue == state_.preparation_queue) return;
+ state_.preparation_queue = std::move(queue);
+ rebuild_view();
+}
+
+std::vector<GameId> Simulation::TakePrepareNextRequests() { return std::exchange(pending_prepare_next_requests_, {}); }
+
+std::vector<LiveCompletedPreparation> Simulation::TakePreparedDismissals() {
+ return std::exchange(pending_prepared_dismissals_, {});
+}
+
+bool Simulation::TakePreparedClear() { return std::exchange(pending_prepared_clear_, false); }
+
+// Moves a waiting game to the front of the preparation queue; the game being prepared now finishes first.
+// Focus stays on the game, now first.
+void Simulation::prepare_next(GameId id) {
+ auto& waiting = state_.preparation_queue.waiting;
+ const auto found = std::find(waiting.begin(), waiting.end(), id);
+ if (found == waiting.end() || found == waiting.begin()) return;
+ std::rotate(waiting.begin(), found, found + 1);
+ if (live()) {
+ pending_prepare_next_requests_.push_back(id);
+ prepare_next_asked_ = id;
+ }
+ state_.queue_expanded = kQueuePreparation;
+ state_.navigation.focus_key = "prep-" + std::to_string(id);
+ const auto* game = find_game(state_, id);
+ const auto& active = state_.preparation_queue.active;
+ const auto* current = active ? find_game(state_, *active) : nullptr;
+ push_notice({"prepare-next", (game ? game->title : std::string("The game")) + " is up next", "", false, kLiveNoticeSeconds,
+ false, current ? "After " + current->title : "It starts next"});
+}
+
std::vector<GameId> Simulation::TakeRuntimePlayRequests() {
auto requests = std::move(pending_runtime_play_requests_);
pending_runtime_play_requests_.clear();
@@ -3749,12 +3797,21 @@ void Simulation::rebuild_view() {
: status == "Failed" || status == "No kit" ? "problem"
: status == "Needs repair" || status == "Needs recovery" || status == "Registration pending" ||
status == "Removal incomplete" ? "attention" : "quiet";
- // The game being set up now, when this one waits for it.
+ // The game right ahead of this one in the preparation queue (the one being set up now when
+ // this one is next), and where this one waits.
std::string ahead;
- if (runtime && runtime->queued)
- for (const auto& [other_id, other] : state_.runtime_games)
- if (other_id != game->id && other.status == "Preparing")
- if (const auto* other_game = find_game(state_, other_id)) ahead = other_game->title;
+ const auto& queue = state_.preparation_queue;
+ const auto place = std::find(queue.waiting.begin(), queue.waiting.end(), game->id);
+ const auto position = place == queue.waiting.end() ? 0 : static_cast<std::size_t>(place - queue.waiting.begin()) + 1;
+ if (runtime && runtime->queued) {
+ if (position > 1) {
+ if (const auto* other_game = find_game(state_, queue.waiting[position - 2])) ahead = other_game->title;
+ } else {
+ for (const auto& [other_id, other] : state_.runtime_games)
+ if (other_id != game->id && other.status == "Preparing")
+ if (const auto* other_game = find_game(state_, other_id)) ahead = other_game->title;
+ }
+ }
auto& setup = row("details-setup", RowKind::Status, "Setup", "");
setup.value = waiting ? "Waiting for the PS5" : kit_update ? "Kit update available"
: status == "Not prepared" ? "Not set up" : status == "Needs recovery" ? "Interrupted"
@@ -3767,9 +3824,12 @@ void Simulation::rebuild_view() {
setup.tone = "busy";
}
std::string hint;
- if (runtime && runtime->queued && runtime->uninstall_status.empty())
+ if (runtime && runtime->queued && runtime->uninstall_status.empty()) {
hint = ahead.empty() ? "Setup starts when the game being set up is ready."
: "Setup starts when " + ahead + " is ready.";
+ if (position > 0 && queue.waiting.size() > 1)
+ hint = std::to_string(position) + " of " + std::to_string(queue.waiting.size()) + " waiting. " + hint;
+ }
else if (waiting) hint = "Quit Playden and " + game->title + " appears on the PS5 Home screen.";
else if (status == "Registration pending") hint = "The PS5 hasn't confirmed " + game->title + " yet.";
else if (status == "Removal incomplete") hint = "Removing " + game->title + " from the PS5 Home screen stopped partway.";
@@ -3790,36 +3850,53 @@ void Simulation::rebuild_view() {
note.tone = setup.tone;
note.enabled = false;
}
+ // Waiting behind other games: move it to the front; the game being set up now finishes first.
+ if (runtime && runtime->queued && runtime->uninstall_status.empty() && position > 1)
+ row("details-prepare-next", RowKind::Action, "Prepare next", "details-prepare-next").game_id = game->id;
}
row("details-favorite", RowKind::Toggle, "Favorite", "favorite").selected = game && state_.library.favorites.contains(game->id);
if (!live()) row("details-simulate-launch", RowKind::Action, "Simulate launch", "launch");
row("details-more", RowKind::Action, "More", "context");
view_.legends = {"Cross Select", "Options Actions", "Circle Back"};
} else if (state_.navigation.route == Route::Downloads) {
- view_.title = "Downloads";
- std::vector<const Job*> jobs;
- for (const auto& job : state_.jobs) if (job.state != JobState::Cancelled) jobs.push_back(&job);
- std::stable_sort(jobs.begin(), jobs.end(), [](const Job* left, const Job* right) { return left->queue_order < right->queue_order; });
- // The view draws the active transfer in the top card and the rest below it in queue order;
- // focus moves in that same order, so Up and Down follow what is on screen.
- const auto active = std::find_if(jobs.begin(), jobs.end(), [](const Job* job) {
- return job->state == JobState::Downloading || job->state == JobState::Verifying ||
- job->state == JobState::Pausing;
- });
- if (active != jobs.end()) std::rotate(jobs.begin(), active, active + 1);
- for (const auto* job_pointer : jobs) {
- const auto& job = *job_pointer;
- if (job.state == JobState::Cancelled) continue;
- const auto* game = find_game(state_, job.game_id);
- auto& item = row("job-" + job.id, RowKind::Job, !job.title.empty() ? job.title : game ? game->title : job.id,
- "job-action");
- item.game_id = job.game_id;
- item.subtitle = job.failure;
- item.value = !job.state_text.empty() ? job.state_text : job_state_name(job.state);
- item.progress = job.total_bytes == 0 ? 0.0F : static_cast<float>(job.completed_bytes) / static_cast<float>(job.total_bytes);
- }
- if (view_.rows.empty()) row("downloads-empty", RowKind::Status, "No active downloads", "");
- view_.legends = {"Cross Actions", "Options Actions", "L1/R1 Sections"};
+ // Queue: Downloads, then Preparation, one expanded at a time, then the drives. Rows come in screen
+ // order (heading, card, the expanded section's rows), so Up and Down follow what is on screen.
+ view_.title = "Queue";
+ const auto layout = BuildQueueLayout(state_);
+ view_.subtitle = layout.summary;
+ const auto entry_row = [&](const QueueEntry& entry, bool card) {
+ if (entry.job) {
+ const auto& job = *entry.job;
+ auto& item = row(entry.key, RowKind::Job, entry.title, "job-action");
+ item.game_id = job.game_id;
+ item.subtitle = job.failure;
+ item.value = !job.state_text.empty() ? job.state_text : job_state_name(job.state);
+ item.progress = job.total_bytes == 0 ? 0.0F : static_cast<float>(job.completed_bytes) / static_cast<float>(job.total_bytes);
+ return;
+ }
+ auto& item = row(entry.key, RowKind::Job, entry.title, "prep-action");
+ item.game_id = entry.game_id;
+ item.subtitle = entry.note;
+ item.value = entry.status;
+ item.tone = entry.tone;
+ item.section = kQueuePreparation;
+ if (card) item.badge = "card";
+ };
+ for (const auto* section : {&layout.downloads, &layout.preparation}) {
+ if (section->empty()) continue;
+ auto& heading = row(std::string("queue-") + section->id, RowKind::Heading, section->name, "queue-expand");
+ heading.value = section->summary;
+ heading.selected = section->expanded;
+ heading.section = section->id;
+ if (section->active) entry_row(*section->active, true);
+ if (section->expanded)
+ for (const auto& entry : section->rows) entry_row(entry, false);
+ }
+ for (const auto& volume : state_.volumes) {
+ auto& drive = row("storage-" + volume.id, RowKind::Volume, volume.label, "storage-details");
+ drive.section = "storage";
+ }
+ view_.legends = {"Cross Select", "Options Actions", "Circle Back", "L1/R1 Sections"};
} else if (state_.navigation.route == Route::Saves) {
view_.title = "Saves";
const auto all = save_games(false);
@@ -4130,6 +4207,28 @@ void Simulation::rebuild_view() {
});
if (focused != view_.rows.end()) state_.navigation.focus_key = focused->key;
}
+ // Queue: the focused row went away (dismissed, started, or its section closed). Focus the nearest
+ // row left in its section, else that section's heading, so focus never jumps across the screen.
+ if (focused == view_.rows.end() && !has_overlay && state_.navigation.route == Route::Downloads && !view_.rows.empty()) {
+ const auto section = QueueSectionOf(state_.navigation.focus_key);
+ const int last = static_cast<int>(view_.rows.size()) - 1;
+ const int origin = std::clamp(queue_focus_index_, 0, last);
+ int best = -1;
+ for (int distance = 0; distance <= last && best < 0 && !section.empty(); ++distance)
+ for (const int candidate : {origin + distance, origin - distance}) {
+ if (candidate < 0 || candidate > last) continue;
+ const auto& key = view_.rows[static_cast<std::size_t>(candidate)].key;
+ if (QueueSectionOf(key) == section && key.rfind("queue-", 0) != 0) { best = candidate; break; }
+ }
+ if (best < 0)
+ for (int index = 0; index <= last; ++index)
+ if (view_.rows[static_cast<std::size_t>(index)].key == "queue-" + section) best = index;
+ if (best >= 0) {
+ state_.navigation.selected_index = best;
+ state_.navigation.focus_key = view_.rows[static_cast<std::size_t>(best)].key;
+ focused = view_.rows.begin() + best;
+ }
+ }
// Settings: the focused row went away (a dialog deleted it, or its data changed). Focus
// the nearest row left in the same section, never the rail-only Quit entry.
if (focused == view_.rows.end() && !has_overlay && state_.navigation.route == Route::Settings &&
@@ -4168,6 +4267,8 @@ void Simulation::rebuild_view() {
if (!has_overlay && view_.rows[static_cast<std::size_t>(view_.focused_row)].game_id != 0)
state_.navigation.selected_game_id = view_.rows[static_cast<std::size_t>(view_.focused_row)].game_id;
}
+ if (!has_overlay && state_.navigation.route == Route::Downloads && focused != view_.rows.end())
+ queue_focus_index_ = view_.focused_row;
if (!has_overlay && state_.navigation.route == Route::Settings && view_.focused_row >= 0 &&
static_cast<std::size_t>(view_.focused_row) < view_.rows.size()) {
settings_focus_index_ = view_.focused_row;
@@ -5176,6 +5277,66 @@ void Simulation::activate() {
else if (job && job->state != JobState::Cancelled) actions.push_back("job-cancel-" + id);
actions.push_back("logs"); actions.push_back("cancel");
open_modal({"job-actions", "Download actions", selected.key, std::move(actions), 0, false});
+ } else if (action_name == "details-prepare-next") {
+ prepare_next(selected.game_id);
+ state_.navigation.focus_key = selected.key;
+ } else if (action_name == "queue-expand") {
+ state_.queue_expanded = selected.section;
+ } else if (action_name == "prep-action") {
+ // The same kind of menu as a download's: what this preparation allows, then Cancel.
+ const auto& key = selected.key;
+ const auto id = std::to_string(selected.game_id);
+ std::vector<std::string> actions;
+ if (key.rfind("prep-done-", 0) == 0) {
+ actions = {"prep-open-" + id, "prep-dismiss-" + key.substr(std::strlen("prep-done-"))};
+ if (state_.preparation_queue.completed.size() > 1) actions.push_back("prep-clear-completed");
+ } else if (key.rfind("prep-attn-", 0) == 0) {
+ const auto runtime = state_.runtime_games.find(selected.game_id);
+ if (runtime != state_.runtime_games.end() && runtime->second.can_prepare && !runtime->second.awaiting_registration)
+ actions.push_back("prep-retry-" + id);
+ actions.push_back("prep-open-" + id);
+ } else if (key.rfind("prep-active-", 0) == 0) {
+ actions.push_back("prep-open-" + id);
+ } else {
+ // Prepare next waits for the game being prepared now; the first waiting game is next already.
+ const auto& waiting = state_.preparation_queue.waiting;
+ if (!waiting.empty() && waiting.front() != selected.game_id) actions.push_back("prep-next-" + id);
+ actions.push_back("prep-open-" + id);
+ }
+ actions.push_back("cancel");
+ open_modal({"prep-actions", "Preparation actions", key, std::move(actions), 0, false});
+ } else if (action_name == "storage-details") {
+ open_modal({"storage-details", selected.title, selected.key, {"storage-close"}, 0, false});
+ } else if (action_name == "storage-close") {
+ close_modal();
+ } else if (action_name.rfind("prep-next-", 0) == 0) {
+ close_modal();
+ prepare_next(static_cast<GameId>(std::strtoul(action_name.c_str() + std::strlen("prep-next-"), nullptr, 10)));
+ } else if (action_name.rfind("prep-open-", 0) == 0) {
+ const auto id = static_cast<GameId>(std::strtoul(action_name.c_str() + std::strlen("prep-open-"), nullptr, 10));
+ close_modal();
+ state_.navigation.selected_game_id = id; state_.navigation.detail_id = id;
+ state_.navigation.detail_origin = Route::Downloads; state_.navigation.route = Route::Details;
+ } else if (action_name.rfind("prep-retry-", 0) == 0) {
+ const auto id = static_cast<GameId>(std::strtoul(action_name.c_str() + std::strlen("prep-retry-"), nullptr, 10));
+ close_modal();
+ RequestRuntimePrepare(id);
+ } else if (action_name.rfind("prep-dismiss-", 0) == 0) {
+ // prep-dismiss-<game>-<finish time>: that finish only; preparing the game again lists it again.
+ const auto rest = action_name.substr(std::strlen("prep-dismiss-"));
+ const auto dash = rest.find('-');
+ const LiveCompletedPreparation done{static_cast<GameId>(std::strtoul(rest.c_str(), nullptr, 10)),
+ dash == std::string::npos ? 0 : std::strtoll(rest.c_str() + dash + 1, nullptr, 10)};
+ close_modal();
+ pending_prepared_dismissals_.push_back(done);
+ prepared_dismissed_.push_back(done);
+ std::erase(state_.preparation_queue.completed, done);
+ } else if (action_name == "prep-clear-completed") {
+ close_modal();
+ pending_prepared_clear_ = true;
+ auto& completed = state_.preparation_queue.completed;
+ prepared_dismissed_.insert(prepared_dismissed_.end(), completed.begin(), completed.end());
+ completed.clear();
} else if (action_name == "saves-filter") {
state_.navigation.saves_filter = std::clamp(std::atoi(selected.key.c_str() + std::strlen("saves-filter-")), 0,
static_cast<int>(kSavesFilters.size()) - 1);
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 488f1ba..f478969 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -162,6 +162,21 @@ struct LiveRuntimeGame {
// Its setup waits for another game's to finish: Playden sets up one game at a time.
bool queued = false;
};
+// A preparation that ended Ready, listed in Queue after the waiting games.
+struct LiveCompletedPreparation {
+ GameId game_id = 0;
+ std::int64_t finished_at = 0; // Unix seconds
+ bool operator==(const LiveCompletedPreparation&) const = default;
+};
+// Live: the runtime's preparation queue, for Queue's Preparation section.
+struct PreparationQueue {
+ std::optional<GameId> active; // being prepared now
+ std::vector<GameId> waiting; // in the order they start
+ std::vector<LiveCompletedPreparation> completed; // newest first
+ // Why the latest preparation of a game that is neither prepared nor waiting was refused.
+ std::map<GameId, std::string> refused;
+ bool operator==(const PreparationQueue&) const = default;
+};
// Saves and settings kept from an uninstalled game (its private bottle).
struct LiveKeptBottle {
GameId game_id = 0;
@@ -467,6 +482,9 @@ struct State {
std::string default_volume_id; // live: where new installs go
std::map<GameId, LiveCloudGame> cloud; // live: Steam Cloud save state by game
std::map<GameId, LiveRuntimeGame> runtime_games; // live: per-game runtime state
+ PreparationQueue preparation_queue; // live: games being prepared, waiting and done
+ // Queue: the section the player expanded ("downloads", "preparation"); empty until they choose.
+ std::string queue_expanded;
std::size_t runtime_leftover_requests = 0; // live: unused settings requests to clean up
LiveKitInfo kit; // live: the compatibility kit in use
LiveSelfUpdate self_update; // live: Playden's own update
@@ -630,6 +648,12 @@ public:
void SetRuntimeLeftovers(std::size_t count);
void SetKitInfo(LiveKitInfo kit);
void UpdateRuntime(RuntimeState runtime, const std::vector<LiveRuntimeGame>& games);
+ // Live mode: the preparation queue for Queue, and what the player asked of it there: games to
+ // prepare next, finished preparations dismissed, and Clear completed.
+ void UpdatePreparationQueue(PreparationQueue queue);
+ [[nodiscard]] std::vector<GameId> TakePrepareNextRequests();
+ [[nodiscard]] std::vector<LiveCompletedPreparation> TakePreparedDismissals();
+ [[nodiscard]] bool TakePreparedClear();
// The game runtime could not start (raw: its log reason; empty: it runs). Shown on every screen
// until it is fixed, with the reason under Settings › Runtime status (#64).
void UpdateRuntimeProblem(const std::string& raw);
@@ -772,6 +796,12 @@ private:
bool system_keyboard_available_ = false;
std::vector<InstallRequest> pending_install_requests_;
std::vector<GameId> pending_runtime_prepare_requests_;
+ std::vector<GameId> pending_prepare_next_requests_;
+ std::vector<LiveCompletedPreparation> pending_prepared_dismissals_;
+ bool pending_prepared_clear_ = false;
+ // Asked of the runtime and not carried out yet: finished preparations dismissed, a game moved first.
+ std::vector<LiveCompletedPreparation> prepared_dismissed_;
+ std::optional<GameId> prepare_next_asked_;
std::vector<GameId> pending_runtime_play_requests_;
bool pending_runtime_cleanup_ = false;
bool library_catalog_received_ = false;
@@ -825,6 +855,7 @@ private:
bool details_primary_pending_ = false; // live Details: move focus to the first action once known
// Settings: the last focused row, so focus stays nearby when that row goes away.
int settings_focus_index_ = 0;
+ int queue_focus_index_ = 0; // Queue: the focused row's place, for when that row goes away
std::string settings_focus_section_;
struct OrganizationJournalEntry {
@@ -882,6 +913,7 @@ private:
void quit_to_home();
void change_route(int delta);
void open_modal(ModalEntry modal);
+ void prepare_next(GameId id);
void close_modal();
void start_editor(std::string purpose, std::string value, bool secret = false);
// Sign-in screen: opened in the remembered method, its actions, and the form's secrets wiped.
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index 96e2570..2d22475 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -2094,7 +2094,7 @@ void live_completed_downloads_follow_the_queue() {
requests = model.TakeInstallRequests();
check(requests.size() == 1 && requests[0].kind == InstallRequestKind::ClearCompleted, "Clear completed tells the service");
check(std::none_of(model.state().jobs.begin(), model.state().jobs.end(),
- [](const Job& job) { return job.state == JobState::Downloaded; }) && has_row(model, "downloads-empty"),
+ [](const Job& job) { return job.state == JobState::Downloaded; }) && !has_row(model, "queue-downloads"),
"Clear completed empties the list");
}
@@ -2147,10 +2147,11 @@ void live_download_card_keeps_queue_order() {
model.action("r1");
model.action("r1");
check(model.state().navigation.route == Route::Downloads, "Downloads open");
- check(!model.view().rows.empty() && model.view().rows[0].key == "job-42" && model.view().rows[1].key == "job-43",
+ check(model.view().rows.size() > 2 && model.view().rows[0].key == "queue-downloads" &&
+ model.view().rows[1].key == "job-42" && model.view().rows[2].key == "job-43",
"the first download in the queue keeps the top spot ahead of a failed one");
model.UpdateInstalls({{42, JobState::Queued, 0, 100, {}}, {43, JobState::Downloading, 5, 100, {}}}, {});
- check(model.view().rows[0].key == "job-43", "a running download takes the top spot");
+ check(model.view().rows[1].key == "job-43", "a running download takes the top spot");
}
void live_download_reorder_reaches_service() {
@@ -2205,6 +2206,183 @@ void live_sign_in_on_full_storage_offers_uninstall() {
"other storage trouble keeps the usual screen");
}
+// Keys of the Queue rows in screen order, storage left out.
+std::vector<std::string> queue_keys(const Simulation& model) {
+ std::vector<std::string> keys;
+ for (const auto& row : model.view().rows)
+ if (row.key.rfind("storage-", 0) != 0) keys.push_back(row.key);
+ return keys;
+}
+
+const playden::homebrew::ViewRow* queue_row(const Simulation& model, const std::string& key) {
+ for (const auto& row : model.view().rows)
+ if (row.key == key) return &row;
+ return nullptr;
+}
+
+// Queue: both workflows, one section expanded at a time. A collapsed section keeps its card and counts.
+// Waiting preparations are numbered in the runtime's order, completed ones follow them in the same list,
+// and Prepare next moves a waiting game first without touching the one being prepared.
+void live_queue_shows_downloads_and_preparations() {
+ using namespace playden::homebrew;
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(10, "Ninja"), game(11, "Shovel"), game(12, "Celeste"), game(13, "Stardew"),
+ game(14, "Thomas"), game(20, "Hollow"), game(21, "Dead Cells"), game(22, "Hades"),
+ game(23, "Monaco")}, false, {}, false, false, {}}), "library loaded");
+ model.UpdateInstalls({{20, JobState::Downloading, 64, 100, {}}, {21, JobState::Queued, 0, 100, {}},
+ {22, JobState::Queued, 0, 100, {}}},
+ {{10, 1, "internal", true}, {11, 1, "internal", true}, {12, 1, "internal", true},
+ {13, 1, "internal", true}, {14, 1, "internal", true}, {23, 1, "internal", true}},
+ {{23, 1, "internal", 1'000}});
+ LiveRuntimeGame preparing; preparing.game_id = 10; preparing.status = "Preparing"; preparing.detail = "Creating game files…";
+ std::vector<LiveRuntimeGame> runtime{preparing};
+ for (const GameId id : {11u, 12u, 13u}) {
+ LiveRuntimeGame waiting; waiting.game_id = id; waiting.status = "Not prepared"; waiting.queued = true;
+ runtime.push_back(waiting);
+ }
+ LiveRuntimeGame ready; ready.game_id = 14; ready.status = "Ready"; ready.ready = true; ready.prepared = true;
+ runtime.push_back(ready);
+ model.UpdateRuntime(RuntimeState::Ready, runtime);
+ model.UpdatePreparationQueue({10, {11, 12, 13}, {{14, 2'000}}, {}});
+ model.action("r1");
+ model.action("r1");
+ check(model.state().navigation.route == Route::Downloads && model.view().title == "Queue", "the Queue tab opens");
+ check(model.view().subtitle == "1 downloading · 1 preparing · 5 waiting", "the page counts running and waiting work");
+ check((queue_keys(model) == std::vector<std::string>{"queue-downloads", "job-20", "queue-preparation", "prep-active-10",
+ "prep-11", "prep-12", "prep-13", "prep-done-14-2000"}),
+ "games waiting for preparation open the Preparation section, its completed entry last");
+ check(queue_row(model, "queue-downloads")->value == "2 more games queued · 1 completed",
+ "collapsed Downloads keeps its card, how many more wait, and its completed count");
+ check(queue_row(model, "queue-preparation")->value == "1 preparing · 3 waiting · 1 completed",
+ "expanded Preparation separates preparing from waiting");
+ check(queue_row(model, "prep-11")->value == "Up next" && queue_row(model, "prep-11")->subtitle == "Starts after Ninja" &&
+ queue_row(model, "prep-12")->value == "Queued", "the first waiting game is up next");
+
+ activate(model, "queue-downloads");
+ check((queue_keys(model) == std::vector<std::string>{"queue-downloads", "job-20", "job-21", "job-22", "job-23",
+ "queue-preparation", "prep-active-10"}),
+ "Downloads expands and Preparation collapses to its card");
+ check(queue_row(model, "queue-preparation")->value == "3 more games queued · 1 completed", "collapsed Preparation counts");
+ model.UpdateInstalls({{20, JobState::Downloading, 70, 100, {}}, {21, JobState::Queued, 0, 100, {}},
+ {22, JobState::Queued, 0, 100, {}}},
+ {{10, 1, "internal", true}, {11, 1, "internal", true}, {12, 1, "internal", true},
+ {13, 1, "internal", true}, {14, 1, "internal", true}, {23, 1, "internal", true}},
+ {{23, 1, "internal", 1'000}});
+ check(has_row(model, "job-21") && !has_row(model, "prep-11"), "progress keeps the player's choice");
+
+ activate(model, "queue-preparation");
+ activate(model, "prep-11");
+ check(!has_row(model, "prep-next-11") && has_row(model, "prep-open-11"), "the game up next has no Prepare next");
+ model.action("circle");
+ activate(model, "prep-13");
+ check(has_row(model, "prep-next-13"), "a later waiting game offers Prepare next");
+ activate(model, "prep-next-13");
+ check(model.TakePrepareNextRequests() == std::vector<GameId>{13}, "Prepare next reaches the runtime");
+ check((queue_keys(model) == std::vector<std::string>{"queue-downloads", "job-20", "queue-preparation", "prep-active-10",
+ "prep-13", "prep-11", "prep-12", "prep-done-14-2000"}),
+ "the game moves first, the others keep their order, the game being prepared stays");
+ check(model.state().navigation.focus_key == "prep-13" && queue_row(model, "prep-13")->value == "Up next",
+ "focus stays on the game, now up next");
+
+ activate(model, "prep-done-14-2000");
+ check(has_row(model, "prep-open-14") && has_row(model, "prep-dismiss-14-2000") && !has_row(model, "prep-clear-completed"),
+ "a finished preparation offers Game details and Dismiss");
+ activate(model, "prep-dismiss-14-2000");
+ check((model.TakePreparedDismissals() == std::vector<LiveCompletedPreparation>{{14, 2'000}}), "Dismiss reaches the runtime");
+ check(!has_row(model, "prep-done-14-2000") && model.state().navigation.focus_key == "prep-12",
+ "the entry goes and focus stays in the section");
+ // The runtime's next snapshot, still listing it, doesn't bring it back.
+ model.UpdatePreparationQueue({10, {13, 11, 12}, {{14, 2'000}}, {}});
+ check(!has_row(model, "prep-done-14-2000"), "a dismissal waiting for the runtime holds");
+}
+
+// With nothing unfinished the completed entries stay; Clear completed clears only its own workflow.
+// With nothing at all only the drives are left.
+void live_queue_history_and_empty_states() {
+ using namespace playden::homebrew;
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(14, "Thomas"), game(15, "Metal Slug"), game(23, "Monaco")}, false, {}, false, false, {}}),
+ "library loaded");
+ model.action("r1");
+ model.action("r1");
+ check(model.view().subtitle.empty() && !has_row(model, "queue-downloads") && !has_row(model, "queue-preparation"),
+ "nothing in the queue");
+ model.UpdateInstalls({}, {{14, 1, "internal", true}, {15, 1, "internal", true}, {23, 1, "internal", true}},
+ {{23, 1, "internal", 1'000}});
+ model.UpdatePreparationQueue({std::nullopt, {}, {{15, 3'000}, {14, 2'000}}, {}});
+ check(model.view().subtitle == "No active work · 3 completed", "history alone says so");
+ check(queue_row(model, "queue-downloads")->value == "1 completed" &&
+ queue_row(model, "queue-preparation")->value == "2 completed", "both headings keep their history");
+ activate(model, "queue-preparation");
+ check(has_row(model, "prep-done-15-3000") && has_row(model, "prep-done-14-2000") && !has_row(model, "job-23"),
+ "a section with only completed entries expands");
+ activate(model, "prep-done-15-3000");
+ activate(model, "prep-clear-completed");
+ check(model.TakePreparedClear() && model.TakeInstallRequests().empty(), "Clear completed clears only preparations");
+ check(!has_row(model, "queue-preparation") && has_row(model, "job-23"), "Preparation empties; Downloads keeps its entry");
+}
+
+// A game whose preparation needs the player stays in Preparation without a running preparation.
+void live_queue_lists_preparations_needing_attention() {
+ using namespace playden::homebrew;
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(30, "Waits"), game(31, "Broke"), game(32, "Refused"), game(33, "Fine")}, false, {}, false,
+ false, {}}), "library loaded");
+ LiveRuntimeGame waits; waits.game_id = 30; waits.status = "Waiting for the PS5"; waits.awaiting_registration = true;
+ LiveRuntimeGame broke; broke.game_id = 31; broke.status = "Failed"; broke.detail = "Disk full"; broke.can_prepare = true;
+ LiveRuntimeGame refused; refused.game_id = 32; refused.status = "Not prepared"; refused.can_prepare = true;
+ LiveRuntimeGame fine; fine.game_id = 33; fine.status = "Ready"; fine.ready = true;
+ model.UpdateRuntime(RuntimeState::Ready, {waits, broke, refused, fine});
+ model.UpdatePreparationQueue({std::nullopt, {}, {}, {{32, "No verified compatibility kit is installed."}}});
+ model.action("r1");
+ model.action("r1");
+ check((queue_keys(model) == std::vector<std::string>{"queue-preparation", "prep-attn-30", "prep-attn-31", "prep-attn-32"}),
+ "waiting for the PS5, failed and refused games are listed");
+ check(queue_row(model, "queue-preparation")->value == "3 need attention" && model.view().subtitle == "3 need attention",
+ "they are not counted as waiting work");
+ check(queue_row(model, "prep-attn-30")->value == "Waiting for the PS5" &&
+ queue_row(model, "prep-attn-31")->subtitle == "Disk full" &&
+ queue_row(model, "prep-attn-32")->subtitle == "No verified compatibility kit is installed.",
+ "each says why");
+ activate(model, "prep-attn-31");
+ check(has_row(model, "prep-retry-31"), "a failed preparation can be tried again");
+ activate(model, "prep-retry-31");
+ check(model.TakeRuntimePrepareRequests() == std::vector<GameId>{31}, "Try again asks for it");
+ activate(model, "prep-attn-30");
+ check(!has_row(model, "prep-retry-30"), "a game waiting for the PS5 is not prepared again from here");
+}
+
+// The game page of a waiting game names the game right ahead of it and offers Prepare next.
+void live_details_prepare_next() {
+ using namespace playden::homebrew;
+ auto model = make_live();
+ model.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(model.UpdateLibrary({{game(40, "Busy"), game(41, "First"), game(42, "Second")}, false, {}, false, false, {}}),
+ "library loaded");
+ model.UpdateInstalls({}, {{40, 1, "internal", true}, {41, 1, "internal", true}, {42, 1, "internal", true}});
+ LiveRuntimeGame busy; busy.game_id = 40; busy.status = "Preparing";
+ LiveRuntimeGame first; first.game_id = 41; first.status = "Not prepared"; first.queued = true;
+ LiveRuntimeGame second; second.game_id = 42; second.status = "Not prepared"; second.queued = true;
+ model.UpdateRuntime(RuntimeState::Ready, {busy, first, second});
+ model.UpdatePreparationQueue({40, {41, 42}, {}, {}});
+ check(model.action("details:41"), "details open");
+ check(!has_row(model, "details-prepare-next") && find_row(model, "details-setup")->value == "Waiting for Busy",
+ "the first waiting game waits for the one being prepared");
+ model.action("circle");
+ check(model.action("details:42"), "details open");
+ check(find_row(model, "details-setup")->value == "Waiting for First" &&
+ find_row(model, "details-hint")->title == "2 of 2 waiting. Setup starts when First is ready.",
+ "a later game names the game right ahead and its place");
+ activate(model, "details-prepare-next");
+ check(model.TakePrepareNextRequests() == std::vector<GameId>{42} &&
+ (model.state().preparation_queue.waiting == std::vector<GameId>{42, 41}), "Prepare next from the game page");
+ check(find_row(model, "details-setup")->value == "Waiting for Busy" && !has_row(model, "details-prepare-next"),
+ "now it is next");
+}
+
int main() {
live_launch_failure_remains_visible_without_a_details_status_line();
live_download_reorder_reaches_service();
@@ -2240,6 +2418,10 @@ int main() {
preserves_identity_and_scroll_then_chooses_a_stable_neighbor();
live_details_keep_personal_edits_and_block_fixture_operations();
refresh_actions_preserve_authentication_and_wall_clock_is_external();
+ live_queue_shows_downloads_and_preparations();
+ live_queue_history_and_empty_states();
+ live_queue_lists_preparations_needing_attention();
+ live_details_prepare_next();
std::cout << "homebrew_library_model_test passed\n";
return 0;
}