llama.cpp on a jailbroken PS5: run any GGUF model natively on the console, starting with Qwen 3.8
App: Console page, the feed as a chat, Demo and Message, choice lists, one sound per action
Mert Cobanov559b637381d5
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex bf9c437..037c800 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -17,6 +17,11 @@ v0.1.x are the upstream payload releases by cobanov.d1 Omni, Clef, OpenJev and others. The planner gives them a 2048-token batch and a 4k context.- MiniCPM-V 4.7's image projector, and the other models of llama.cpp 04f7226.- `/data/PS5LM/env.txt`: driver and ggml switches set before the GPU opens, for measuring.+- **Console** page: temperature, power, GPU and CPU load charted over the last two minutes or the+ last hour, and a table of every reading.+- Home's request feed reads as a chat, and the console can ask itself: Square sends a demo+ request, Triangle opens a keyboard (with Turkish letters) for a message of your own.+- Settings with several choices open a list under the row; Cross picks, Circle cancels.### Changed- The app is **PS5LM** under its own title ID, **PPSA99575**, with a new icon and home screen@@ -26,6 +31,9 @@ v0.1.x are the upstream payload releases by cobanov.- Models with an image projector get a 2048-token ubatch, so images are no longer cut to 64 tokens.### Fixed+- The app opens on Home, not on the model list, and draws its splash before the GPU opens, so a+ restart for a model no longer shows a black screen.+- One sound for each kind of action, at one pitch: no two actions share a sound by accident.- A float in any request (`"temperature": 0.7`) stopped the server: the console's `localeconv()`reports an empty decimal point. The app now gives the C locale's.- An image projector llama.cpp cannot read no longer stops the server: the app restarts once anddiff --git a/README.md b/README.mdindex 892c7a0..e0ce2f6 100644--- a/README.md+++ b/README.md@@ -33,8 +33,10 @@ no PC while it runs, no cloud and no account.<img src="docs/media/app/home.jpg" width="49%" alt="Home: the model, its speed and the live requests"><img src="docs/media/app/models.jpg" width="49%" alt="Models: the ones suggested for the PS5"><img src="docs/media/app/home-decision.jpg" width="49%" alt="Home with a decision model">+ <img src="docs/media/app/console.jpg" width="49%" alt="Console: temperature, power and load over time"><img src="docs/media/app/api.jpg" width="49%" alt="API: the endpoints and an example">- <br><sub>Home, Models and API on the TV.</sub>+ <img src="docs/media/app/settings.jpg" width="49%" alt="Settings: a list of choices under the row">+ <br><sub>Home, Models, Console, API and Settings on the TV.</sub></p>## A model server under your TV@@ -47,8 +49,11 @@ no PC while it runs, no cloud and no account.any model name: the loaded one answers.- **It decides, too.** Load a decision model and the console answers TypeSafe's `/v1/systemone`:choice, score and yes-or-no questions about text and images, the API Ollaya serves on a PC.-- **It shows its work.** Every request streams across the TV as it is answered: which device asked,- what it asked, and the reply as it is written.+- **It shows its work.** Every request streams across the TV as a chat: which device asked, what it+ asked, and the reply as it is written. Square sends a demo and Triangle opens a keyboard, so the+ console can be tried from the couch.+- **It watches the console.** A Console page charts temperature, power, GPU and CPU load over the+ last two minutes or the last hour, beside a table of every reading.- **It picks what fits.** The planner reads each GGUF and gives it the longest context and best cachethat fit the memory free. A Suggested list holds models measured on the console, and the appdownloads from Hugging Face by itself, to internal storage, the M.2 drive or a USB drive.@@ -108,12 +113,14 @@ To update, copy the new folder over the old one. Settings, models and downloads| Where | Button | Does ||---|---|---|-| Everywhere | L1 / R1 | Home, Models, API, Settings |-| Home | Cross / Triangle | change the model / the API page |+| Everywhere | L1 / R1 | Home, Models, API, Console, Settings |+| Home | Cross | change the model |+| Home | Square / Triangle | send a demo request / type a message || Models | D-pad, Cross | choose a section and a model; load, unload or download it || Models, Search | L2 / R2, Square | change the search; check whether a file fits || Models, Downloads | Cross, Square | pause or resume; cancel (press twice) or clear |-| Settings | D-pad, Cross | choose a category and a row; change it |+| Console | L2 / R2 | the last two minutes / the last hour |+| Settings | D-pad, Cross | choose a category and a row; flip it, or pick from its list || Settings, Diagnostics | Square, Triangle | app or server log; errors only |## Want to tinker?diff --git a/docs/media/app/console.jpg b/docs/media/app/console.jpgnew file mode 100644index 0000000..00b598eBinary files /dev/null and b/docs/media/app/console.jpg differdiff --git a/docs/media/app/home-decision.jpg b/docs/media/app/home-decision.jpgindex 0649f7d..fe03fee 100644Binary files a/docs/media/app/home-decision.jpg and b/docs/media/app/home-decision.jpg differdiff --git a/docs/media/app/home.jpg b/docs/media/app/home.jpgindex fa4a63a..912b1ee 100644Binary files a/docs/media/app/home.jpg and b/docs/media/app/home.jpg differdiff --git a/docs/media/app/settings.jpg b/docs/media/app/settings.jpgnew file mode 100644index 0000000..7a78dfeBinary files /dev/null and b/docs/media/app/settings.jpg differdiff --git a/ps5/app/activity.cpp b/ps5/app/activity.cppindex e925ad8..f7ef71c 100644--- a/ps5/app/activity.cpp+++ b/ps5/app/activity.cpp@@ -12,6 +12,7 @@#include <map>#include <mutex>#include <string>+#include <thread>using json = nlohmann::ordered_json;@@ -95,6 +96,20 @@ std::string asked_from(const std::string & path, const json & j) {return {};}+// Without emoji, which the TV's fonts lack: 4-byte UTF-8 and U+FE0F go.+std::string printable(const std::string & s) {+ std::string out;+ for (size_t i = 0; i < s.size();) {+ const unsigned char c = (unsigned char) s[i];+ const size_t n = c >= 0xF0 ? 4 : c >= 0xE0 ? 3 : c >= 0xC0 ? 2 : 1;+ if (n != 4 && s.compare(i, 3, "\xEF\xB8\x8F") != 0) {+ out.append(s, i, n);+ }+ i += n;+ }+ return out;+}+// "spam yes 0.99, intent sell, urgency 1.02"std::string answers_of(const json & answers) {std::string out;@@ -156,6 +171,28 @@ namespace ps5lm {void set_activity_sink(StatsCollector * stats) { g_sink = stats; }+void ask_self(int port, const std::string & text, bool decision) {+ json body;+ if (decision) {+ // Two questions any text answers: what its writer wants, and their mood.+ body["state"] = text;+ body["questions"]["intent"] = { { "type", "choice" },+ { "instructions", "What does the writer want?" },+ { "criteria", { { "refund", nullptr }, { "information", nullptr },+ { "cancel", nullptr }, { "praise", nullptr } } } };+ body["questions"]["angry"] = { { "type", "noul" }, { "instructions", "Is the writer angry?" } };+ } else {+ // Short and without thinking: an answer on the TV in seconds.+ body["messages"] = json::array({ { { "role", "user" }, { "content", text } } });+ body["stream"] = true;+ body["max_tokens"] = 512;+ body["chat_template_kwargs"] = { { "enable_thinking", false } };+ }+ std::thread([port, decision, b = body.dump()] {+ http_post(port, decision ? "/v1/systemone" : "/v1/chat/completions", b, 300);+ }).detach();+}+} // namespace ps5lmextern "C" {@@ -168,7 +205,7 @@ void ps5lm_activity_begin(int id, const char * method, const char * path, const}const json j = json::parse(body, body + body_len, nullptr, false);const int questions = j.is_object() && j.contains("questions") && j["questions"].is_object() ? (int) j["questions"].size() : 0;- g_sink->activity_begin(id, remote ? remote : "", path ? path : "", one_line(asked_from(path ? path : "", j), 400), questions);+ g_sink->activity_begin(id, remote ? remote : "", path ? path : "", one_line(printable(asked_from(path ? path : "", j)), 400), questions);}void ps5lm_activity_data(int id, const char * data, size_t len) {@@ -203,6 +240,7 @@ void ps5lm_activity_data(int id, const char * data, size_t len) {}}}+ out = printable(out);if (!out.empty()) {g_sink->activity_text(id, out);}diff --git a/ps5/app/assets/audio/sfx/NOTICE.txt b/ps5/app/assets/audio/sfx/NOTICE.txtindex 7562b03..30373e7 100644--- a/ps5/app/assets/audio/sfx/NOTICE.txt+++ b/ps5/app/assets/audio/sfx/NOTICE.txt@@ -1,3 +1,17 @@Interface sounds from PocketVibe (MIT, Copyright (c) 2026 Mert Cobanov), made by its-tools/sfx/make_sfx.py: procedural glass-mallet tones, all in D major.-Converted to 48 kHz mono and named after ps5-homebrew-ui's cues.+tools/sfx/make_sfx.py: procedural glass-mallet tones, all in D major. Converted to+48 kHz mono and named after ps5-homebrew-ui's cues, one sound for each kind of action+(the list is at the top of ps5/app/dashboard.cpp):++ focus_01.wav nav_move the highlight moved+ error_01.wav nav_edge x0.6 it cannot+ tab_01.wav tab_switch another page or view+ select_01.wav confirm went in, or did it+ back_01.wav back came out, or cancelled+ modal_open_01.wav menu_open a question or a list of choices+ modal_close_01.wav menu_close ... closed without an answer+ toggle_01.wav toggle_on a switch flipped+ launch_01.wav launch_game a model starts loading+ notify_01.wav notification a model is ready+ complete_01.wav save_done a download is saved+ type_01.wav key_type a key on the message keyboarddiff --git a/ps5/app/assets/audio/sfx/error_01.wav b/ps5/app/assets/audio/sfx/error_01.wavindex 8672972..833453d 100644Binary files a/ps5/app/assets/audio/sfx/error_01.wav and b/ps5/app/assets/audio/sfx/error_01.wav differdiff --git a/ps5/app/assets/audio/sfx/open_01.wav b/ps5/app/assets/audio/sfx/open_01.wavdeleted file mode 100644index d243db0..0000000Binary files a/ps5/app/assets/audio/sfx/open_01.wav and /dev/null differdiff --git a/ps5/app/assets/audio/sfx/resume_01.wav b/ps5/app/assets/audio/sfx/resume_01.wavdeleted file mode 100644index eb16e3b..0000000Binary files a/ps5/app/assets/audio/sfx/resume_01.wav and /dev/null differdiff --git a/ps5/app/assets/audio/sfx/saved_01.wav b/ps5/app/assets/audio/sfx/saved_01.wavdeleted file mode 100644index f4f16d8..0000000Binary files a/ps5/app/assets/audio/sfx/saved_01.wav and /dev/null differdiff --git a/ps5/app/assets/audio/sfx/slider_01.wav b/ps5/app/assets/audio/sfx/slider_01.wavdeleted file mode 100644index a6add84..0000000Binary files a/ps5/app/assets/audio/sfx/slider_01.wav and /dev/null differdiff --git a/ps5/app/assets/audio/sfx/type_01.wav b/ps5/app/assets/audio/sfx/type_01.wavnew file mode 100644index 0000000..86fbe1dBinary files /dev/null and b/ps5/app/assets/audio/sfx/type_01.wav differdiff --git a/ps5/app/assets/audio/sfx/welcome_01.wav b/ps5/app/assets/audio/sfx/welcome_01.wavdeleted file mode 100644index 0507173..0000000Binary files a/ps5/app/assets/audio/sfx/welcome_01.wav and /dev/null differdiff --git a/ps5/app/dashboard.cpp b/ps5/app/dashboard.cppindex cbd94a7..86e19ff 100644--- a/ps5/app/dashboard.cpp+++ b/ps5/app/dashboard.cpp@@ -6,6 +6,21 @@// the console's temperature and power sit in the status line, where a car// shows the weather. Colour means state only: blue is what is active or// chosen, green a model that serves, red a fault. Everything else is grey.+//+// Sound works the same way: one sound for each kind of thing, on every page,+// always at the same pitch, so the ear learns them (PocketVibe's set, in+// assets/audio/sfx, named after the cue):+// focus the highlight moved+// error it cannot: the end of a list, a model too big+// tab another page, or another view of one (search, log, range)+// select went in, or did it: a section, a choice, a download, a pause+// back came out, or cancelled+// modal_open a question or a list of choices opened+// modal_close ... and closed without an answer+// toggle a switch flipped+// launch a model starts loading+// notify a model is ready (not from a button)+// complete a download is saved (not from a button)#include "dashboard.hpp"#include "suggested.hpp"#include "version.hpp"@@ -54,7 +69,7 @@ constexpr int kVisibleRows = 7;constexpr float kTau = 6.2831853f;constexpr const char * kDash = "\xE2\x80\x94";-constexpr const char * kPageNames[Dashboard::kPages] = { "Home", "Models", "API", "Settings" };+constexpr const char * kPageNames[Dashboard::kPages] = { "Home", "Models", "API", "Console", "Settings" };constexpr const char * kSectionNames[Dashboard::kSections] = { "On this PS5", "Suggested", "Search", "Downloads" };// The market's searches, switched with L2/R2: Hugging Face's most downloaded@@ -187,29 +202,33 @@ void meter(gfx::DrawList & l, float x, float y, float w, float share, Color c) {// The model's speed over the last two minutes as one line, newest on the// right, on a faint floor; Tesla's energy graph, not a dashboard chart.-void trace(gfx::DrawList & l, const std::vector<float> & v, const Rect & g, Color c) {- l.line(g.x, g.y + g.h, g.x + g.w, g.y + g.h, 1.5f, kHair);- if (v.size() < 2) {+// A series of up to 120 points between lo and hi, newest at the right edge.+void plot(gfx::DrawList & l, const std::vector<float> & v, const Rect & g, Color c, float lo, float hi) {+ if (v.size() < 2 || hi <= lo) {return;}- float top = 1.0f;- for (float x : v) {- top = std::max(top, x);- }- top *= 1.15f;const float step = g.w / 119.0f;+ const auto at = [&](float x) { return g.y + g.h - tween::clamp01((x - lo) / (hi - lo)) * g.h; };float lx = 0, ly = 0;for (size_t age = 0; age < v.size(); ++age) {const float x = g.x + g.w - (float) age * step;- const float y = g.y + g.h - v[v.size() - 1 - age] / top * g.h;+ const float y = at(v[v.size() - 1 - age]);if (age > 0) {l.line(lx, ly, x, y, 2.0f, c);}lx = x;ly = y;}- const float y = g.y + g.h - v.back() / top * g.h;- l.circle(g.x + g.w, y, 5, c);+ l.circle(g.x + g.w, at(v.back()), 5, c);+}++void trace(gfx::DrawList & l, const std::vector<float> & v, const Rect & g, Color c) {+ l.line(g.x, g.y + g.h, g.x + g.w, g.y + g.h, 1.5f, kHair);+ float top = 1.0f;+ for (float x : v) {+ top = std::max(top, x);+ }+ plot(l, v, g, c, 0, top * 1.15f);}// The dock's line icons, 32 px, drawn with strokes like the rest.@@ -246,6 +265,15 @@ void icon(gfx::DrawList & l, int page, float cx, float cy, Color c) {l.line(cx + 16, cy, cx + 7, cy + 10, w, c);l.line(cx + 3, cy - 13, cx - 3, cy + 13, w, c);break;+ case Dashboard::kConsolePage: {+ // A pulse: the line a monitor draws.+ const float px[] = { cx - 17, cx - 8, cx - 3, cx + 3, cx + 8, cx + 17 };+ const float py[] = { cy + 2, cy + 2, cy - 12, cy + 13, cy, cy };+ for (int i = 0; i < 5; ++i) {+ l.line(px[i], py[i], px[i + 1], py[i + 1], w, c);+ }+ break;+ }default: {const float knobs[] = { -6, 7, -1 };for (int i = 0; i < 3; ++i) {@@ -267,7 +295,9 @@ void toggle_switch(gfx::DrawList & l, float right, float cy, bool on) {}// Greedy word wrap to `width`; a word longer than a line is cut.-std::vector<std::string> wrap(const ui::FontRef & f, const std::string & text, float size, float width) {+std::vector<std::string> wrap(const ui::FontRef & f, const std::string & raw, float size, float width) {+ std::string text = raw; // line breaks and tabs have no glyph: spaces+ std::replace_if(text.begin(), text.end(), [](char c) { return c == '\n' || c == '\r' || c == '\t'; }, ' ');std::vector<std::string> lines;std::string line;size_t at = 0;@@ -380,86 +410,121 @@ bool toggle_value(const Settings & s, Setting id) {return id == Setting::auto_load ? s.auto_load : id == Setting::sounds ? s.sounds : s.tools;}-template <typename T, size_t N> bool step_in(const T (&steps)[N], T & value, int dir, int fallback) {- int at = fallback;- for (int i = 0; i < (int) N; ++i) {- if (steps[i] == value) {- at = i;- }- }- if (at + dir < 0 || at + dir >= (int) N) {- return false;- }- value = steps[at + dir];- return true;-}+// A row's choices, for the list X opens under it: each with the settings it+// would make, and whether it is the one set now.+struct Choice {+ std::string label, note;+ Settings value;+ bool current = false;+};-// Moves a stepper one place; false at either end.-bool step_setting(Settings & s, Setting id, int dir, const std::vector<ModelRow> & models, const std::vector<Drive> & drives) {+std::vector<Choice> choices_of(const Settings & s, Setting id, const std::vector<ModelRow> & models,+ const std::vector<Drive> & drives) {+ std::vector<Choice> out;+ const auto add = [&](std::string label, std::string note, bool current, auto set) {+ Choice c{ std::move(label), std::move(note), s, current };+ set(c.value);+ out.push_back(std::move(c));+ };switch (id) {- case Setting::default_model: {- // "None", then each model that fits, in the list's order.- std::vector<std::string> choices = { "" };+ case Setting::default_model:+ add("None", "Wait for a choice", s.default_model.empty(), [](Settings & v) { v.default_model.clear(); });for (const auto & m : models) {if (m.fits) {- choices.push_back(m.file);- }- }- int at = 0;- for (int i = 0; i < (int) choices.size(); ++i) {- if (choices[(size_t) i] == s.default_model) {- at = i;+ std::string name, build;+ split_name(m.label, &name, &build);+ add(name + " " + build, gb(m.size_gib), m.file == s.default_model,+ [&](Settings & v) { v.default_model = m.file; });}}- if (at + dir < 0 || at + dir >= (int) choices.size()) {- return false;+ break;+ case Setting::ctx_cap:+ for (uint32_t c : kCtxSteps) {+ add(format("%.0fk tokens", c / 1024.0), "", s.ctx_cap == c, [c](Settings & v) { v.ctx_cap = c; });}- s.default_model = choices[(size_t) (at + dir)];- return true;- }- case Setting::ctx_cap: return step_in(kCtxSteps, s.ctx_cap, dir, 4);+ break;case Setting::kv_type: {- int at = 0;+ const char * notes[] = { "The best that fits", "Full quality, the most memory", "Near full quality, half the memory",+ "A quarter of the memory" };for (int i = 0; i < 4; ++i) {- if (s.kv_type == kKvSteps[i]) {- at = i;- }+ const std::string t = kKvSteps[i];+ add(i == 0 ? "Auto" : t, notes[i], s.kv_type == t, [&](Settings & v) { v.kv_type = t; });}- if (at + dir < 0 || at + dir >= 4) {- return false;- }- s.kv_type = kKvSteps[at + dir];- return true;- }- case Setting::scratch_limit: return step_in(kScratchSteps, s.scratch_limit_gib, dir, 1);- case Setting::auto_load: s.auto_load = !s.auto_load; return true;- case Setting::sounds: s.sounds = !s.sounds; return true;- case Setting::tools: s.tools = !s.tools; return true;- case Setting::clear_scratch: return false;- case Setting::download_dir: {- int at = -1; // a missing drive counts as before the first- for (int i = 0; i < (int) drives.size(); ++i) {- if (drives[(size_t) i].models == s.download_dir) {- at = i;- }+ break;+ }+ case Setting::scratch_limit:+ for (uint32_t g : kScratchSteps) {+ add(format("%.0f GB", (double) g), "", s.scratch_limit_gib == g, [g](Settings & v) { v.scratch_limit_gib = g; });}- if (at + dir < 0 || at + dir >= (int) drives.size()) {- return false;+ break;+ case Setting::download_dir:+ for (const auto & d : drives) {+ add(d.name, d.total > 0 ? gb(d.free) + " free" : "", d.models == s.download_dir,+ [&](Settings & v) { v.download_dir = d.models; });}- s.download_dir = drives[(size_t) (at + dir)].models;- return true;- }+ break;+ default: break;}- return false;+ return out;}// The base name a suggestion's model file has on the console.const char * local_name(const SuggestedFile & f) { return f.save_as ? f.save_as : f.file; }+// What Square sends from Home, in turn: something to show the model off with.+constexpr const char * kChatDemos[] = {+ "In two sentences, how can a PS5 run a language model?",+ "Write a haiku about a game console that dreams in tokens.",+ "Give me three names for a home AI server that lives under the TV.",+ "What is 17 times 23? Show the steps in one line.",+};+constexpr const char * kDecisionDemos[] = {+ "I was charged twice this month. Refund me or I cancel.",+ "Love the new update, everything is so much faster now!",+ "Where can I find the invoice for last month?",+ "Third time asking. Cancel my subscription today.",+};+constexpr int kDemos = 4;+} // namespace// ---- state ------------------------------------------------------------------------+Dashboard::Dashboard(const ui::Fonts & fonts) : fonts_(fonts) {+ // The message prompt in the dashboard's own colours, with Turkish letters+ // over the space bar.+ ui::Theme & t = prompt_.style.theme;+ t.page = kBase;+ t.surface = kSurface;+ t.surface_high = kRaised;+ t.text = t.page_text = kInk;+ t.text_muted = t.page_text_muted = kInk2;+ t.primary = t.accent = kBlue;+ t.on_primary = t.on_secondary = kInk;+ t.secondary = kRaised;+ t.outline = kHair;+ t.focus = kBlue;+ t.heading = ui::FontRole::semibold;+ t.radius = 14;+ t.radius_card = 24;+ prompt_.style.frosted = false;+ prompt_.style.width = 1100;+ prompt_.style.max_length = 400;+ prompt_.keyboard.style.bindings = ui::KeyboardBindings::standard();+ prompt_.keyboard.style.pitch_by_column = false;+ prompt_.keyboard.style.erase = Cue::type;+ ui::KeyboardLayout letters = ui::KeyboardLayout::letters();+ const char * tr[][2] = { { "\xC3\xA7", "\xC3\x87" }, { "\xC4\x9F", "\xC4\x9E" }, { "\xC4\xB1", "I" },+ { "\xC4\xB0", "\xC4\xB0" }, { "\xC3\xB6", "\xC3\x96" }, { "\xC5\x9F", "\xC5\x9E" },+ { "\xC3\xBC", "\xC3\x9C" } };+ std::vector<ui::KeyboardKey> row;+ for (const auto & k : tr) {+ row.push_back({ ui::KeyKind::character, k[0], k[1] });+ }+ letters.rows.insert(letters.rows.end() - 1, row);+ prompt_.keyboard.set_layouts({ letters, ui::KeyboardLayout::symbols() });+}+void Dashboard::open_library() {page_from_ = page_;page_ = kModelsPage;@@ -487,7 +552,7 @@ void Dashboard::go_to(int page, ui::Feedback * feedback) {page_ = page;page_age_ = 0;if (feedback) {- feedback->play(Cue::tab, 1.0f + 0.04f * (float) page);+ feedback->play(Cue::tab);}}@@ -510,28 +575,59 @@ void Dashboard::refilter_logs() {void Dashboard::update(const hui::InputFrame & raw, float dt, ui::Feedback & feedback) {const hui::InputFrame none{};- const bool dialog = market_confirm_ || market_space_;+ const bool dialog = market_confirm_ || market_space_ || picker_;const hui::InputFrame & input = busy() ? none : raw; // busy: the screen says so, buttons waitage_ += dt;clock_ += dt;page_age_ += dt;- // L1/R1 walk the dock, unless a question is open.+ // Two sounds come from events, not buttons: a model ready, a download saved.+ const bool serving = live_.state == ServerState::ready || live_.state == ServerState::generating;+ if (serving && !was_serving_) {+ feedback.play(Cue::notify);+ }+ was_serving_ = serving;+ std::vector<std::string> unfinished;+ for (const auto & d : market_.downloads) {+ if (d.state != DownloadState::done) {+ unfinished.push_back(d.file);+ } else if (std::find(unfinished_.begin(), unfinished_.end(), d.file) != unfinished_.end()) {+ feedback.play(Cue::complete);+ }+ }+ unfinished_ = std::move(unfinished);++ // L1/R1 walk the dock, unless a question is open. A message being typed+ // takes every button until it is sent or dropped.const int step = input.is_pressed(Action::page_next) ? 1 : input.is_pressed(Action::page_prev) ? -1 : 0;- if (step != 0 && !dialog) {+ if (prompt_.is_open()) {+ if (prompt_.handle(input, feedback) == ui::Event::activated) {+ request_ = { Request::ask, prompt_.text() };+ }+ } else if (step != 0 && !dialog) {const int next = page_ + step;if (next >= 0 && next < kPages) {go_to(next, &feedback);} else {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}} else if (page_ == kHomePage) {update_home(input, feedback);} else if (page_ == kModelsPage) {update_models(input, feedback);+ } else if (page_ == kConsolePage) {+ // L2 the last two minutes, R2 the last hour.+ const int to = input.is_pressed(Action::jump_next) ? 1 : input.is_pressed(Action::jump_prev) ? 0 : -1;+ if (to >= 0 && (to == 1) != console_hour_) {+ console_hour_ = to == 1;+ feedback.play(Cue::tab);+ } else if (to >= 0) {+ feedback.play(Cue::error);+ }} else if (page_ == kSettingsPage) {update_settings(input, feedback);}+ prompt_.update(dt);// Where the highlight goes: a section or a row on Models, a category or a// row on Settings.@@ -564,11 +660,20 @@ void Dashboard::update(const hui::InputFrame & raw, float dt, ui::Feedback & fee}void Dashboard::update_home(const hui::InputFrame & input, ui::Feedback & feedback) {+ const bool decision = !live_.decision.empty();+ const bool serving = live_.state == ServerState::ready || live_.state == ServerState::generating;if (input.is_pressed(Action::confirm)) {open_library();- feedback.play(Cue::open);+ feedback.play(Cue::select);+ } else if ((input.is_pressed(Action::west) || input.is_pressed(Action::north)) && !serving) {+ feedback.play(Cue::error); // nothing answers yet+ } else if (input.is_pressed(Action::west)) {+ request_ = { Request::ask, (decision ? kDecisionDemos : kChatDemos)[demo_++ % kDemos] };+ feedback.play(Cue::select);} else if (input.is_pressed(Action::north)) {- go_to(kApiPage, &feedback);+ prompt_.set_title(decision ? "Text to decide on" : "Message");+ prompt_.field.set_placeholder(decision ? "A customer message, a review, a ticket" : "Ask anything");+ prompt_.open(feedback);}}@@ -582,13 +687,13 @@ void Dashboard::update_models(const hui::InputFrame & input, ui::Feedback & feedconst int next = section_ + (input.nav == Direction::down ? 1 : -1);if (next >= 0 && next < kSections) {section_ = next;- feedback.play(Cue::focus, 1.0f + 0.04f * (float) next);+ feedback.play(Cue::focus);if (section_ == kSearch && !market_searched_) {market_searched_ = true;request_ = { Request::market_search, "" };}} else if (!input.nav_repeat) {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}}if (input.nav == Direction::right || input.is_pressed(Action::confirm)) {@@ -623,11 +728,11 @@ bool walk(const hui::InputFrame & input, int & cursor, int count, ui::Feedback &const int next = cursor + (input.nav == Direction::down ? 1 : -1);if (next >= 0 && next < count) {cursor = next;- feedback.play(Cue::focus, 1.0f + 0.015f * (float) std::min(next, 12));+ feedback.play(Cue::focus);return true;}if (!input.nav_repeat) {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}return false;}@@ -642,7 +747,7 @@ void Dashboard::update_local(const hui::InputFrame & input, ui::Feedback & feedbconst ModelRow & m = live_.models[(size_t) local_cursor_];if (m.current) {request_ = { Request::unload, m.file };- feedback.play(Cue::back);+ feedback.play(Cue::select);} else if (m.fits) {request_ = { Request::load, m.file };feedback.play(Cue::launch);@@ -661,10 +766,10 @@ void Dashboard::update_suggested(const hui::InputFrame & input, ui::Feedback & fhere = here || m.label + ".gguf" == local_name(s.model);}if (here) {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);} else {request_ = { Request::suggested_download, settings_.download_dir, suggested_cursor_ };- feedback.play(Cue::complete);+ feedback.play(Cue::select);}}}@@ -676,7 +781,7 @@ void Dashboard::start_download(ui::Feedback & feedback) {feedback.play(Cue::modal_open);} else {request_ = { Request::market_download, market_dir_, market_.open, market_file_ };- feedback.play(Cue::complete);+ feedback.play(Cue::select);}}@@ -697,11 +802,11 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feedif (input.is_pressed(Action::north)) {request_ = { Request::market_download_unload, market_dir_, market_.open, market_file_ };market_confirm_ = false;- feedback.play(Cue::complete);+ feedback.play(Cue::select);} else if (input.is_pressed(Action::confirm)) {request_ = { Request::market_download, market_dir_, market_.open, market_file_ };market_confirm_ = false;- feedback.play(Cue::complete);+ feedback.play(Cue::select);} else if (input.is_pressed(Action::back)) {market_confirm_ = false;feedback.play(Cue::modal_close);@@ -718,7 +823,7 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feedrequest_ = { Request::market_search, next == 0 ? std::string() : std::string(kMarketChips[next]) };feedback.play(Cue::tab);} else {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}return;}@@ -734,7 +839,7 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feedrequest_ = { Request::market_open, "", cursor, -1 };market_files_ = true;market_file_ = 0;- feedback.play(Cue::open);+ feedback.play(Cue::select);} else if (market_files_ && open && cursor < files) {const MarketFile & f = open->files[(size_t) cursor];const double need = f.bytes / 1073741824.0 + 1.0; // and 1 GiB spare, as Market::download wants@@ -766,7 +871,7 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feedrequest_ = { Request::market_plan, "", market_.open, cursor };feedback.play(Cue::select);} else {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f); // checked already+ feedback.play(Cue::error); // checked already}}if (input.is_pressed(Action::back) && market_files_) {@@ -796,9 +901,9 @@ void Dashboard::update_downloads(const hui::InputFrame & input, ui::Feedback & ffeedback.play(Cue::select);} else if (d.state == DownloadState::paused || d.state == DownloadState::failed) {request_ = { Request::download_resume, "", dl_cursor_ };- feedback.play(Cue::complete);+ feedback.play(Cue::select);} else {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}}// Square: a finished one leaves the list; any other is cancelled and its@@ -807,7 +912,7 @@ void Dashboard::update_downloads(const hui::InputFrame & input, ui::Feedback & fif (d.state == DownloadState::done || dl_confirm_ == dl_cursor_) {request_ = { Request::download_remove, "", dl_cursor_ };dl_confirm_ = -1;- feedback.play(Cue::back);+ feedback.play(Cue::select);} else {dl_confirm_ = dl_cursor_;feedback.play(Cue::modal_open);@@ -816,6 +921,10 @@ void Dashboard::update_downloads(const hui::InputFrame & input, ui::Feedback & f}void Dashboard::update_settings(const hui::InputFrame & input, ui::Feedback & feedback) {+ if (picker_) {+ update_picker(input, feedback);+ return;+ }if (!in_rows_) {if (input.nav == Direction::up || input.nav == Direction::down) {const int next = setting_category_ + (input.nav == Direction::down ? 1 : -1);@@ -823,9 +932,9 @@ void Dashboard::update_settings(const hui::InputFrame & input, ui::Feedback & fesetting_category_ = next;setting_row_ = 0;log_scroll_ = 0;- feedback.play(Cue::focus, 1.0f + 0.04f * (float) next);+ feedback.play(Cue::focus);} else if (!input.nav_repeat) {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}}if (input.nav == Direction::right || input.is_pressed(Action::confirm)) {@@ -846,28 +955,41 @@ void Dashboard::update_settings(const hui::InputFrame & input, ui::Feedback & feconst SettingCategory & c = kCategories[setting_category_];walk(input, setting_row_, c.count, feedback);const Setting id = c.rows[setting_row_].id;- if (id == Setting::clear_scratch) {- if (input.is_pressed(Action::confirm)) {- request_ = { Request::clear_scratch, "" };- feedback.play(Cue::saved);- }+ if (!input.is_pressed(Action::confirm)) {return;}- int dir = input.nav == Direction::right ? 1 : 0;- if (is_toggle(id) && input.is_pressed(Action::confirm)) {- dir = 1;- }- if (dir == 0 && input.is_pressed(Action::west)) {- dir = -1; // Square steps back, as left once did- }- if (is_toggle(id) && input.nav == Direction::right && toggle_value(settings_, id)) {- dir = 0; // right turns a switch on; it is on+ // Cross does what the row is: clears, flips a switch, or opens its choices.+ if (id == Setting::clear_scratch) {+ request_ = { Request::clear_scratch, "" };+ feedback.play(Cue::select);+ } else if (is_toggle(id)) {+ bool & on = id == Setting::auto_load ? settings_.auto_load : id == Setting::sounds ? settings_.sounds : settings_.tools;+ on = !on;+ request_ = { Request::settings, "" };+ feedback.play(Cue::toggle);+ } else {+ const auto all = choices_of(settings_, id, live_.models, live_.drives);+ picker_ = true;+ picker_cursor_ = 0;+ for (int i = 0; i < (int) all.size(); ++i) {+ picker_cursor_ = all[(size_t) i].current ? i : picker_cursor_;+ }+ feedback.play(Cue::modal_open);}- if (dir != 0 && step_setting(settings_, id, dir, live_.models, live_.drives)) {+}++void Dashboard::update_picker(const hui::InputFrame & input, ui::Feedback & feedback) {+ const auto all = choices_of(settings_, kCategories[setting_category_].rows[setting_row_].id, live_.models, live_.drives);+ picker_cursor_ = std::clamp(picker_cursor_, 0, std::max(0, (int) all.size() - 1));+ walk(input, picker_cursor_, (int) all.size(), feedback);+ if (input.is_pressed(Action::confirm) && !all.empty()) {+ settings_ = all[(size_t) picker_cursor_].value;request_ = { Request::settings, "" };- feedback.play(is_toggle(id) ? Cue::toggle : Cue::slider, 1.0f + 0.05f * (float) dir);- } else if (dir != 0 && !input.nav_repeat) {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ picker_ = false;+ feedback.play(Cue::select);+ } else if (input.is_pressed(Action::back)) {+ picker_ = false;+ feedback.play(Cue::modal_close);}}@@ -877,15 +999,15 @@ void Dashboard::update_logs(const hui::InputFrame & input, ui::Feedback & feedbaconst int next = std::clamp(log_scroll_ + (input.nav == Direction::up ? 3 : -3), 0, most);if (next != log_scroll_) {log_scroll_ = next;- feedback.play(Cue::focus, 1.0f, 0.0f, 0.4f);+ feedback.play(Cue::focus);} else if (!input.nav_repeat) {- feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);+ feedback.play(Cue::error);}}if (input.is_pressed(Action::west)) {log_llama_ = !log_llama_;log_scroll_ = 0;- feedback.play(Cue::select);+ feedback.play(Cue::tab);}if (input.is_pressed(Action::north)) {log_errors_ = !log_errors_;@@ -918,6 +1040,7 @@ void Dashboard::draw(DashboardFrame & frame) const {case kHomePage: draw_home(scene); break;case kModelsPage: draw_models(scene); break;case kApiPage: draw_api(scene); break;+ case kConsolePage: draw_console(scene); break;default: draw_settings(scene); break;}scene.pop_opacity();@@ -926,6 +1049,13 @@ void Dashboard::draw(DashboardFrame & frame) const {draw_dock(scene);draw_hints(scene);draw_dialogs(frame.overlay);+ if (picker_ && page_ == kSettingsPage) {+ draw_picker(frame.overlay);+ }+ if (prompt_.visible()) {+ ui::Canvas canvas{ frame.overlay, fonts_, 0, clock_ };+ prompt_.draw(canvas);+ }if (busy()) {draw_busy(frame.overlay);}@@ -980,12 +1110,20 @@ void Dashboard::draw_hints(gfx::DrawList & l) const {layout.cy = 1018;layout.item_gap = 36;std::vector<ui::Hint> h;- if (market_confirm_ || market_space_) {+ if (market_confirm_ || market_space_ || prompt_.visible()) {return; // the dialog has its own}- if (page_ == kHomePage) {- h = { { ui::Button::l1, "Pages", ui::Button::r1 }, { ui::Button::triangle, "API" },- { ui::Button::cross, live_.model_label.empty() ? "Choose a model" : "Change model" } };+ if (picker_ && page_ == kSettingsPage) {+ h = { { ui::Button::circle, "Cancel" }, { ui::Button::cross, "Choose" } };+ } else if (page_ == kHomePage) {+ h = { { ui::Button::l1, "Pages", ui::Button::r1 } };+ if (live_.state == ServerState::ready || live_.state == ServerState::generating) {+ h.push_back({ ui::Button::square, "Demo" });+ h.push_back({ ui::Button::triangle, "Message" });+ }+ h.push_back({ ui::Button::cross, live_.model_label.empty() ? "Choose a model" : "Change model" });+ } else if (page_ == kConsolePage) {+ h = { { ui::Button::l1, "Pages", ui::Button::r1 }, { ui::Button::l2, "Range", ui::Button::r2 } };} else if (page_ == kModelsPage) {if (!in_list_) {h = { { ui::Button::dpad, "Choose" }, { ui::Button::cross, "Open" } };@@ -1028,7 +1166,7 @@ void Dashboard::draw_hints(gfx::DrawList & l) const {} else if (is_toggle(id)) {h = { { ui::Button::circle, "Back" }, { ui::Button::cross, "Switch" } };} else {- h = { { ui::Button::circle, "Back" }, { ui::Button::square, "Less" }, { ui::Button::dpad, "More" } };+ h = { { ui::Button::circle, "Back" }, { ui::Button::cross, "Change" } };}}ui::draw_hints(l, fonts_, style, h.data(), (int) h.size(), kRight, true, layout);@@ -1145,50 +1283,95 @@ void Dashboard::draw_home(gfx::DrawList & l) const {x, p.y + 162, 22, kInk3);l.line(x, p.y + 196, x + w, p.y + 196, 1.5f, kHair);- // The latest requests, newest first: who asked, what, and the answer as it arrives.- float y = p.y + 240;- const float bottom = p.y + p.h - 72;- if (live_.activity.empty()) {- put(l, f.regular, "Requests from other devices appear here as they arrive.", x, y + 8, 22, kInk3);+ // The conversation: what each device asked, on the right as a message+ // sent, and the model's answer under it on the left, newest at the bottom+ // as in any chat.+ struct Turn {+ const Exchange * e;+ std::vector<std::string> asked, answered;+ float h;+ };+ const float bubble = w * 0.78f; // the widest a request's bubble gets+ const auto clip = [&](std::vector<std::string> & lines, size_t keep, bool tail, float width) {+ if (lines.size() <= keep) {+ return;+ }+ if (tail) {+ lines.erase(lines.begin(), lines.end() - (long) keep); // streaming: the newest lines+ } else {+ lines.resize(keep);+ lines.back() = f.regular.font->fit(lines.back() + " \xE2\x80\xA6", 22, width);+ }+ };+ const float top = p.y + 222, bottom = p.y + p.h - 70;+ std::vector<Turn> turns;+ float total = 0;+ for (auto it = live_.activity.rbegin(); it != live_.activity.rend(); ++it) {+ const bool newest = it == live_.activity.rbegin();+ Turn t{ &*it, wrap(f.regular, it->asked.empty() ? std::string(kDash) : it->asked, 22, bubble - 40),+ wrap(f.regular, it->answered, 22, w), 0 };+ clip(t.asked, newest ? 3 : 2, false, bubble - 40);+ clip(t.answered, newest ? 6 : 3, it->status == 0, w);+ t.h = 26 + (float) t.asked.size() * 30 + 20 + 14 + (float) std::max<size_t>(1, t.answered.size()) * 31 + 34 + 26;+ total += t.h;+ turns.push_back(std::move(t));+ if (total > bottom - top) {+ break; // the oldest shown runs off the top, as a chat scrolls+ }}- for (auto it = live_.activity.rbegin(); it != live_.activity.rend() && y < bottom - 90; ++it) {- const Exchange & e = *it;+ if (turns.empty()) {+ put(l, f.regular, "Requests from other devices appear here, as a chat.", x, top + 40, 22, kInk3);+ if (live_.state == ServerState::ready || live_.state == ServerState::generating) {+ put(l, f.regular, "Square sends a demo, Triangle a message of your own.", x, top + 76, 22, kInk3);+ }+ }+ float y = bottom - total;+ for (auto t = turns.rbegin(); t != turns.rend(); ++t) {+ const Exchange & e = *t->e;const bool running = e.status == 0;const bool fault = e.status >= 400;- put(l, f.regular, e.client + " " + e.path, x, y, 19, kInk3);- if (running) {- const float tw = put(l, f.regular, "Answering", x + w, y, 19, kInk2, gfx::Align::right);- l.circle(x + w - tw - 14, y - 7, 5, kBlue.with_alpha(0.55f + 0.45f * std::sin(clock_ * 6.0f)));- } else {- put(l, f.regular, fault ? format("Error %.0f", (double) e.status) : format(e.seconds < 10 ? "%.1f s" : "%.0f s", e.seconds),- x + w, y, 19, fault ? kRed : kInk3, gfx::Align::right);- }- y += 34;- put(l, f.regular, f.regular.font->fit(e.asked.empty() ? std::string(kDash) : e.asked, 22, w), x, y, 22, kInk2);- y += 34;- // While it streams, the answer's last lines, so it reads as it is- // written; once done, its first ones.- std::vector<std::string> lines = wrap(f.regular, e.answered, 22, w);- const int keep = it == live_.activity.rbegin() ? 3 : 1;- if ((int) lines.size() > keep) {- if (running) {- lines.erase(lines.begin(), lines.end() - keep);- } else {- lines.resize((size_t) keep);- lines.back() = f.regular.font->fit(lines.back() + " \xE2\x80\xA6", 22, w);+ const std::string who = e.client.rfind("127.0.0.1", 0) == 0 ? std::string("This PS5") : e.client;+ if (y >= top) {+ put(l, f.regular, who + " " + e.path, x + w, y + 18, 17, kInk3, gfx::Align::right);+ }+ y += 26;+ float bw = 0;+ for (const auto & s : t->asked) {+ bw = std::max(bw, f.regular.measure(s, 22));+ }+ bw += 40;+ const float bh = (float) t->asked.size() * 30 + 20;+ if (y >= top) {+ l.rounded_rect({ x + w - bw, y, bw, bh }, 20, kBlue);+ for (size_t i = 0; i < t->asked.size(); ++i) {+ put(l, f.regular, t->asked[i], x + w - bw + 20, y + 32 + 30.0f * (float) i, 22, kInk);}}- if (lines.empty()) {- lines.push_back(running ? "" : kDash);+ y += bh + 14;+ if (t->answered.empty() && running) {+ // Nothing yet: three dots, as a chat shows the other side typing.+ for (int i = 0; i < 3; ++i) {+ l.circle(x + 8 + 20.0f * (float) i, y + 14, 5, kInk2.with_alpha(0.35f + 0.65f * (0.5f + 0.5f * std::sin(clock_ * 6.0f - (float) i))));+ }}- for (const auto & line : lines) {- if (y > bottom) {- break;+ for (size_t i = 0; i < t->answered.size(); ++i) {+ if (y + 31.0f * (float) i >= top) {+ put(l, f.regular, t->answered[i], x, y + 22 + 31.0f * (float) i, 22, fault ? kRed : kInk);}- put(l, f.regular, line, x, y, 22, fault ? kRed : kInk);- y += 31;}- y += 30;+ if (t->answered.empty() && !running && y >= top) {+ put(l, f.regular, kDash, x, y + 22, 22, kInk3);+ }+ y += (float) std::max<size_t>(1, t->answered.size()) * 31 + 6;+ std::string meta = running ? "Answering" : fault ? format("Error %.0f", (double) e.status)+ : format(e.seconds < 10 ? "%.1f s" : "%.0f s", e.seconds);+ if (!running && !fault && e.questions > 0) {+ meta += format(", %.0f ms per decision", 1000.0 * e.seconds / e.questions);+ }+ if (y >= top) {+ put(l, f.regular, meta, x, y + 22, 17, fault ? kRed : kInk3);+ }+ y += 28 + 26;}// What it has done since it started, like a trip meter.@@ -1443,6 +1626,120 @@ void Dashboard::draw_api(gfx::DrawList & l) const {put(l, f.mono, decision ? "" : "ANTHROPIC_BASE_URL=" + base, p.x + 218, p.y + p.h - 56, 21, kInk);}+// ---- drawing: Console -----------------------------------------------------------------++// Four charts on the left, the instruments' readings now on the right, as a+// car shows its energy page: the line first, the numbers beside it.+void Dashboard::draw_console(gfx::DrawList & l) const {+ const ui::Fonts & f = fonts_;+ put(l, f.semibold, "Console", kLeft, kTitleY, 44, kInk);+ const char * ranges[] = { "Last 2 minutes", "Last hour" };+ float rx = 1224;+ for (int i = 1; i >= 0; --i) {+ const bool on = (i == 1) == console_hour_;+ rx -= f.regular.measure(ranges[i], 22);+ const float tw = put(l, f.regular, ranges[i], rx, kTitleY - 8, 22, on ? kInk : kInk3);+ if (on) {+ l.rounded_rect({ rx, kTitleY + 6, tw, 3 }, 1.5f, kBlue);+ }+ rx -= 40;+ }++ struct Chart {+ const char * name;+ const std::vector<float> & v;+ const char * unit;+ bool share; // 0..1, shown as a percentage+ bool sensor; // read through ps5-exporter+ };+ const bool hour = console_hour_;+ const Chart charts[] = {+ { "Temperature", hour ? live_.temp_hour : live_.temp_history, "\xC2\xB0" "C", false, true },+ { "Power", hour ? live_.power_hour : live_.power_history, " W", false, true },+ { "GPU", hour ? live_.gpu_hour : live_.gpu_history, "%", true, false },+ { "CPU", hour ? live_.cpu_hour : live_.cpu_history, "%", true, false },+ };+ const float cw = (1224 - kLeft - 32) / 2, ch = (926 - kListY - 32) / 2;+ for (int i = 0; i < 4; ++i) {+ const Chart & c = charts[i];+ const Rect r{ kLeft + (cw + 32) * (float) (i % 2), kListY + (ch + 32) * (float) (i / 2), cw, ch };+ l.rounded_rect(r, 20, kSurface);+ put(l, f.regular, c.name, r.x + 32, r.y + 50, 22, kInk2);+ if (c.v.empty()) {+ put(l, f.regular, hour ? "The first point comes after 30 seconds" : c.sensor ? "Not read" : kDash, r.x + 32,+ r.y + r.h * 0.5f + 8, 22, kInk3);+ if (c.sensor && !hour) {+ put(l, f.regular, "With elfldr running, the app loads ps5-exporter to read it", r.x + 32, r.y + r.h * 0.5f + 44,+ 19, kInk3);+ }+ continue;+ }+ float lo = c.v[0], hi = c.v[0], sum = 0;+ for (float x : c.v) {+ lo = std::min(lo, x);+ hi = std::max(hi, x);+ sum += x;+ }+ const auto show = [&](float x) { return c.share ? format("%.0f%%", 100.0 * x) : format("%.0f", x) + c.unit; };+ put(l, f.regular, show(c.v.back()), r.x + r.w - 32, r.y + 54, 34, kInk, gfx::Align::right);+ // The scale: a share runs 0 to 100%; the rest a little past what was seen, in fives.+ const float pad = std::max(4.0f, (hi - lo) * 0.25f);+ const float bot = c.share ? 0.0f : std::max(0.0f, std::floor((lo - pad) / 5) * 5);+ const float top = c.share ? 1.0f : std::ceil((hi + pad) / 5) * 5;+ const Rect g{ r.x + 100, r.y + 96, r.w - 132, r.h - 96 - 70 };+ for (int k = 0; k < 3; ++k) {+ const float gy = g.y + g.h * (float) k * 0.5f;+ l.line(g.x, gy, g.x + g.w, gy, 1.0f, kHair);+ put(l, f.regular, show(top - (top - bot) * 0.5f * (float) k), g.x - 14, gy + 6, 16, kInk3, gfx::Align::right);+ }+ plot(l, c.v, g, kInk.with_alpha(0.85f), bot, top);+ put(l, f.regular, "Low " + show(lo) + " Average " + show(sum / (float) c.v.size()) + " High " + show(hi),+ r.x + 32, r.y + r.h - 26, 19, kInk3);+ }++ // The readings now, as a table.+ const Rect p{ 1264, kListY, kRight - 1264, 926 - kListY };+ l.rounded_rect(p, 24, kSurface);+ put(l, f.regular, "Now", p.x + 40, p.y + 52, 22, kInk2);+ const auto deg = [&](float t) { return t > -100 ? format("%.0f\xC2\xB0" "C", t) : std::string(kDash); };+ float soc_lo = 1000, soc_hi = -1000;+ for (const auto & [name, t] : live_.temps) {+ if (name.rfind("soc", 0) == 0) {+ soc_lo = std::min(soc_lo, t);+ soc_hi = std::max(soc_hi, t);+ }+ }+ std::vector<std::pair<std::string, std::string>> rows = {+ { "SoC", deg(live_.soc_temp) },+ { "CPU", deg(live_.cpu_temp) },+ { "SoC sensors", soc_hi > -100 ? format("%.0f", soc_lo) + " to " + deg(soc_hi) : std::string(kDash) },+ { "Fan", live_.fan >= 0 ? format("%.0f%%", 100.0 * live_.fan) : std::string(kDash) },+ { "", "" },+ { "Power", live_.soc_power_w > 0 ? format("%.0f W", live_.soc_power_w) : std::string(kDash) },+ { "Energy since start", format("%.1f Wh", live_.energy_wh) },+ { "CPU clock", live_.cpu_ghz > 0 ? format("%.1f GHz", live_.cpu_ghz) : std::string(kDash) },+ { "", "" },+ { "GPU busy", format("%.0f%%", 100.0 * live_.gpu_busy) },+ { "CPU use", format("%.0f%%", 100.0 * live_.cpu_use) },+ { "Memory", format("%.1f", live_.pool_gib - live_.free_gib) + " of " + gb(live_.pool_gib) },+ { "", "" },+ };+ for (const auto & d : live_.drives) {+ rows.push_back({ d.name, d.total > 0 ? format("%.0f", d.free) + " of " + format("%.0f GB free", d.total) : std::string(kDash) });+ }+ float y = p.y + 104;+ for (const auto & [name, value] : rows) {+ if (name.empty()) {+ l.line(p.x + 40, y - 14, p.x + p.w - 40, y - 14, 1.0f, kHair);+ y += 14;+ continue;+ }+ put(l, f.regular, name, p.x + 40, y, 20, kInk2);+ put(l, f.regular, value, p.x + p.w - 40, y, 20, kInk, gfx::Align::right);+ y += 38;+ }+}+// ---- drawing: Settings ----------------------------------------------------------------void Dashboard::draw_settings(gfx::DrawList & l) const {@@ -1474,11 +1771,12 @@ void Dashboard::draw_settings(gfx::DrawList & l) const {toggle_switch(l, kRight - 28, cy, toggle_value(settings_, r.id));} else if (r.id != Setting::clear_scratch) {const bool focus = in_rows_ && i == setting_row_;- put(l, f.regular, setting_text(settings_, r.id, live_.models, live_.drives), kRight - 64, y + 50, 24,- focus ? kInk : kInk2, gfx::Align::right);- if (focus) {- put(l, f.regular, "\xE2\x80\xBA", kRight - 34, y + 50, 30, kInk2); // a chevron: there is more- }+ const Color c = focus ? kInk : kInk2;+ put(l, f.regular, setting_text(settings_, r.id, live_.models, live_.drives), kRight - 68, y + 50, 24, c,+ gfx::Align::right);+ // A chevron down: X opens a list of the choices.+ l.line(kRight - 44, cy - 4, kRight - 36, cy + 4, 2.4f, c);+ l.line(kRight - 36, cy + 4, kRight - 28, cy - 4, 2.4f, c);} else if (live_.scratch_gib > 0) {put(l, f.regular, format("%.1f GB in it", live_.scratch_gib), kRight - 28, y + 50, 22, kInk2,gfx::Align::right);@@ -1486,6 +1784,40 @@ void Dashboard::draw_settings(gfx::DrawList & l) const {}}+// A row's choices in a list that drops from it, the one set now ticked.+void Dashboard::draw_picker(gfx::DrawList & l) const {+ const ui::Fonts & f = fonts_;+ const auto all = choices_of(settings_, kCategories[setting_category_].rows[setting_row_].id, live_.models, live_.drives);+ const int n = (int) all.size(), shown = std::min(n, 7);+ const float pitch = 64, w = 700, h = (float) shown * pitch + 24;+ const float below = kListY + kRowPitch * (float) setting_row_ + kRowH + 8;+ const Rect r{ kRight - w, std::min(below, kDockY - 24 - h), w, h };+ l.shadow({ r.x, r.y + 12, r.w, r.h }, 20, 40, kBlack.with_alpha(0.55f));+ l.rounded_rect({ r.x - 1.5f, r.y - 1.5f, r.w + 3, r.h + 3 }, 21.5f, kHair);+ l.rounded_rect(r, 20, kSurface);+ const int first = std::clamp(picker_cursor_ - shown / 2, 0, std::max(0, n - shown));+ for (int i = first; i < first + shown; ++i) {+ const Choice & c = all[(size_t) i];+ const float y = r.y + 12 + pitch * (float) (i - first);+ if (i == picker_cursor_) {+ l.rounded_rect({ r.x + 10, y, r.w - 20, pitch }, 14, kRaised);+ }+ put(l, f.regular, f.regular.font->fit(c.label, 24, r.w - 330), r.x + 32, y + 41, 24, kInk);+ put(l, f.regular, f.regular.font->fit(c.note, 19, 260), r.x + r.w - 76, y + 40, 19, kInk3, gfx::Align::right);+ if (c.current) {+ const float cx = r.x + r.w - 46, cy = y + pitch * 0.5f;+ l.line(cx - 9, cy, cx - 3, cy + 7, 2.6f, kBlue);+ l.line(cx - 3, cy + 7, cx + 9, cy - 7, 2.6f, kBlue);+ }+ }+ if (n > shown) {+ // How far down the list is, as a thin bar.+ const float track = h - 32, thumb = track * (float) shown / (float) n;+ l.rounded_rect({ r.x + r.w - 8, r.y + 16, 3, track }, 1.5f, kHair);+ l.rounded_rect({ r.x + r.w - 8, r.y + 16 + (track - thumb) * (float) first / (float) (n - shown), 3, thumb }, 1.5f, kInk3);+ }+}+void Dashboard::draw_logs(gfx::DrawList & l, const Rect & a) const {const ui::Fonts & f = fonts_;float x = a.x + 28;diff --git a/ps5/app/dashboard.hpp b/ps5/app/dashboard.hppindex 7cee394..6c7c2e2 100644--- a/ps5/app/dashboard.hpp+++ b/ps5/app/dashboard.hpp@@ -1,9 +1,10 @@-// PS5LM's screen on the TV, four pages along a dock, switched with L1/R1:+// PS5LM's screen on the TV, five pages along a dock, switched with L1/R1:// - Home: the loaded model and how fast it runs, and where the network// reaches it.// - Models: the models on this console, the ones suggested for it, a// Hugging Face search, and the downloads.// - API: the endpoints the loaded model answers, and how to call them.+// - Console: temperature, power and load over the last minutes or hour.// - Settings: categories of rows, with the logs under Diagnostics.//// SPDX-License-Identifier: GPL-3.0-or-later@@ -17,6 +18,7 @@#include "core/tween.hpp"#include "gfx/backdrop_spec.hpp"#include "gfx/draw_list.hpp"+#include "ui/components/input_prompt.hpp"#include "ui/feedback.hpp"#include "ui/fonts.hpp"#include "ui/motion.hpp"@@ -36,13 +38,13 @@ struct DashboardFrame {class Dashboard {public:- static constexpr int kPages = 4;- static constexpr int kHomePage = 0, kModelsPage = 1, kApiPage = 2, kSettingsPage = 3;+ static constexpr int kPages = 5;+ static constexpr int kHomePage = 0, kModelsPage = 1, kApiPage = 2, kConsolePage = 3, kSettingsPage = 4;// The Models page's sections.static constexpr int kSections = 4;static constexpr int kLocal = 0, kSuggested = 1, kSearch = 2, kDownloads = 3;- explicit Dashboard(const hui::ui::Fonts & fonts) : fonts_(fonts) {}+ explicit Dashboard(const hui::ui::Fonts & fonts);void set_live(const Live & live) { live_ = live; }// Slow work in progress: a spinner and these lines over everything, and@@ -67,8 +69,8 @@ class Dashboard {// changed (read them with settings()).struct Request {enum Kind { none, load, unload, settings, clear_scratch, market_search, market_open, market_plan, market_download,- market_download_unload, download_pause, download_resume, download_remove, suggested_download } kind = none;- std::string path; // a model, a market query, or the folder a download goes to (empty: the setting)+ market_download_unload, download_pause, download_resume, download_remove, suggested_download, ask } kind = none;+ std::string path; // a model, a market query, the folder a download goes to (empty: the setting), or what to askint repo = -1, file = -1; // a market file, a download's index (repo), or a suggestion's (repo)};Request take_request() {@@ -86,6 +88,7 @@ class Dashboard {void update_market(const hui::InputFrame & input, hui::ui::Feedback & feedback);void update_downloads(const hui::InputFrame & input, hui::ui::Feedback & feedback);void update_settings(const hui::InputFrame & input, hui::ui::Feedback & feedback);+ void update_picker(const hui::InputFrame & input, hui::ui::Feedback & feedback);void update_logs(const hui::InputFrame & input, hui::ui::Feedback & feedback);void start_download(hui::ui::Feedback & feedback);void refilter_logs();@@ -100,7 +103,9 @@ class Dashboard {void draw_market(hui::gfx::DrawList & list, const hui::gfx::Rect & area) const;void draw_downloads(hui::gfx::DrawList & list, const hui::gfx::Rect & area) const;void draw_api(hui::gfx::DrawList & list) const;+ void draw_console(hui::gfx::DrawList & list) const;void draw_settings(hui::gfx::DrawList & list) const;+ void draw_picker(hui::gfx::DrawList & list) const;void draw_logs(hui::gfx::DrawList & list, const hui::gfx::Rect & area) const;void draw_dialogs(hui::gfx::DrawList & list) const;void draw_busy(hui::gfx::DrawList & list) const;@@ -113,6 +118,10 @@ class Dashboard {float age_ = 0; // seconds since startfloat clock_ = 0; // idle motionstd::string busy_title_, busy_text_;+ hui::ui::InputPrompt prompt_; // a message typed on Home+ int demo_ = 0; // the next demo to send+ bool was_serving_ = false; // for the sound when a model becomes ready+ std::vector<std::string> unfinished_; // downloads not saved yet, for the sound when one isint page_ = 0;int page_from_ = 0;@@ -142,6 +151,11 @@ class Dashboard {int setting_category_ = 0;int setting_row_ = 0;bool in_rows_ = false; // the focus is on the rows, not the categories+ bool picker_ = false; // a row's choices are open in a list under it+ int picker_cursor_ = 0;++ // Console.+ bool console_hour_ = false; // the charts show the last hour, not the last two minutes// Diagnostics.std::vector<std::string> app_log_, llama_log_; // as readdiff --git a/ps5/app/main.cpp b/ps5/app/main.cppindex bedad6d..081678c 100644--- a/ps5/app/main.cpp+++ b/ps5/app/main.cpp@@ -599,6 +599,33 @@ int main(int, char **) {fonts.hand = fonts.regular;std::printf("ps5lm-app: dashboard %s\n", ui_ok ? "ready" : "failed");+ Dashboard dash(fonts);+ DashboardFrame frame;+ const auto render = [&] {+ frame.backdrop = {};+ frame.scene.clear();+ frame.overlay.clear();+ frame.glass = false;+ frame.glass_texture = renderer.glass_texture();+ dash.draw(frame);+ renderer.begin();+ renderer.backdrop(frame.backdrop);+ renderer.draw(frame.scene);+ if (frame.glass) {+ renderer.glass();+ }+ renderer.draw(frame.overlay);+ display.present(renderer);+ };+ // The splash before the slow part (the GPU opening, every model's header+ // read), so a restart for a model is never a black screen.+ if (ui_ok) {+ dash.set_busy("Starting", "Opening the GPU and reading the models");+ render();+ display.swap();+ }+ sceSystemServiceHideSplashScreen();+Models models;for (size_t i = 0; i < ggml_backend_dev_count(); i++) {ggml_backend_dev_t dev = ggml_backend_dev_get(i);@@ -682,12 +709,11 @@ int main(int, char **) {hui::audio::SoundBank sounds;sounds.load(std::string(kAssets) + "/audio/sfx");- Dashboard dash(fonts);+ dash.set_busy("");Market market;market.start(models.budget_gib);int saved_seen = 0; // downloads finished, as last seendash.set_settings(models.settings);- bool library_shown = false; // opened once at launch when no model is loadedbool scratch_warned = false;// Downloads left queued or running carry on, on their own page.unlink("/data/PS5LM/download.txt"); // the queue file replaced this one (v0.7.0)@@ -696,11 +722,9 @@ int main(int, char **) {// Running already, maybe: the queue's thread starts it at once.if (d.state == DownloadState::queued || d.state == DownloadState::running) {dash.show_downloads();- library_shown = true; // stay on Downloads, not the librarybreak;}}- DashboardFrame frame;hui::ui::Feedback feedback;hui::PadSample samples[64];int64_t last = hui::sys::monotonic_us();@@ -738,12 +762,6 @@ int main(int, char **) {models.publish(stats);}dash.set_live(live);- if (!library_shown && !live.models.empty()) {- library_shown = true;- if (live.state == ServerState::no_model) {- dash.open_library();- }- }feedback.clear();// A button pressed from the PC (scripts/ps5lm-app.sh press r1), for// testing the screens without a controller in hand.@@ -849,6 +867,7 @@ int main(int, char **) {std::printf("ps5lm-app: settings saved\n");}switch (req.kind) {+ case Dashboard::Request::ask: ask_self(kPort, req.path, !live.decision.empty()); break;case Dashboard::Request::market_search: market.search(req.path); break;case Dashboard::Request::market_open: market.open_repo(req.repo); break;case Dashboard::Request::market_plan: market.plan_file(req.repo, req.file); break;@@ -934,29 +953,13 @@ int main(int, char **) {}if (ui_ok) {- frame.backdrop = {};- frame.scene.clear();- frame.overlay.clear();- frame.glass = false;- frame.glass_texture = renderer.glass_texture();- dash.draw(frame);- renderer.begin();- renderer.backdrop(frame.backdrop);- renderer.draw(frame.scene);- if (frame.glass) {- renderer.glass();- }- renderer.draw(frame.overlay);- display.present(renderer);+ render();if (n % 60 == 45 && !take_request_file("/data/PS5LM/screenshot").empty()) {const bool ok = save_screen("/data/PS5LM/screen.bmp", display.width(), display.height());std::printf("ps5lm-app: screenshot %s\n", ok ? "saved" : "failed");}}display.swap();- if (n == 0) {- sceSystemServiceHideSplashScreen(); // the first picture is up- }if (n % 60 == 0) {quit_if_asked();}diff --git a/ps5/app/preview_main.cpp b/ps5/app/preview_main.cppindex 55dd9d2..b4ed94b 100644--- a/ps5/app/preview_main.cpp+++ b/ps5/app/preview_main.cpp@@ -100,6 +100,12 @@ ps5lm::Live sample(float seconds, bool generating) {L.cpu_history.push_back(on ? 0.11f + 0.03f * std::sin(i * 0.5f) : 0.02f);L.temp_history.push_back(on ? 60.0f + 2.0f * std::sin(i * 0.2f) : 52.0f);L.power_history.push_back(on ? 85.0f + 1.5f * std::sin(i * 0.4f) : 23.0f);+ // An hour: idle, then a long session with the 27B from minute 20.+ const bool busy = i > 40;+ L.temp_hour.push_back(busy ? 58.0f + 3.0f * std::sin(i * 0.15f) : 50.0f + 0.5f * std::sin(i * 0.4f));+ L.power_hour.push_back(busy ? 70.0f + 12.0f * std::sin(i * 0.23f) : 24.0f);+ L.gpu_hour.push_back(busy ? 0.7f + 0.2f * std::sin(i * 0.31f) : 0.02f);+ L.cpu_hour.push_back(busy ? 0.1f + 0.03f * std::sin(i * 0.5f) : 0.02f);}{// Requests from the network: two answered, the newest still streaming.@@ -421,18 +427,39 @@ int main(int argc, char ** argv) {shot("12-api-decision");g_decision = false;step(40, press(A::page_next), false);- shot("13-settings");+ shot("13-console");+ step(30, press(A::jump_next), false);+ shot("14-console-hour");+ step(40, press(A::page_next), false);+ shot("15-settings");step(20, press(A::confirm), false);step(30, nav(D::down), false);- shot("14-settings-row");+ shot("16-settings-row");+ step(30, press(A::confirm), false);+ shot("17-settings-picker");step(20, press(A::back), false);- for (int i = 0; i < 4; ++i) {+ step(20, press(A::back), false);+ step(20, nav(D::down), false);+ step(20, press(A::confirm), false);+ step(30, press(A::confirm), false);+ shot("18-settings-context");+ step(20, press(A::back), false);+ step(20, press(A::back), false);+ for (int i = 0; i < 3; ++i) {step(15, nav(D::down), false);}step(30, press(A::confirm), false);- shot("15-settings-diagnostics");+ shot("19-settings-diagnostics");+ step(20, press(A::back), false);+ for (int i = 0; i < 4; ++i) {+ step(15, press(A::page_prev), false);+ }+ step(30, press(A::north), true);+ step(60, {}, true);+ shot("20-home-message");+ step(30, press(A::back), true);dash.set_busy("Loading Qwen3.8 27B", "Restarting with the whole memory for it, about 90 seconds");step(30, {}, false);- shot("16-busy");+ shot("21-busy");return ok ? 0 : 1;}diff --git a/ps5/app/stats.cpp b/ps5/app/stats.cppindex 902d864..e6bee86 100644--- a/ps5/app/stats.cpp+++ b/ps5/app/stats.cpp@@ -124,7 +124,9 @@ long json_int(const std::string & text, const char * key) {} // namespace-std::string http_get(int port, const char * path, int timeout_s) {+std::string http_get(int port, const char * path, int timeout_s) { return http_post(port, path, {}, timeout_s); }++std::string http_post(int port, const char * path, const std::string & body, int timeout_s) {const int fd = socket(AF_INET, SOCK_STREAM, 0);if (fd < 0) {return {};@@ -141,9 +143,12 @@ std::string http_get(int port, const char * path, int timeout_s) {addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);std::string out;if (connect(fd, (sockaddr *) &addr, sizeof(addr)) == 0) {- char req[160];- const int n = std::snprintf(req, sizeof(req), "GET %s HTTP/1.0\r\nHost: localhost\r\n\r\n", path);- send(fd, req, (size_t) n, 0);+ std::string req = std::string(body.empty() ? "GET " : "POST ") + path + " HTTP/1.0\r\nHost: localhost\r\n";+ if (!body.empty()) {+ req += "Content-Type: application/json\r\nContent-Length: " + std::to_string(body.size()) + "\r\n";+ }+ req += "\r\n" + body;+ send(fd, req.data(), req.size(), 0);char buf[4096];for (ssize_t got; (got = recv(fd, buf, sizeof(buf), 0)) > 0;) {out.append(buf, (size_t) got);@@ -153,8 +158,8 @@ std::string http_get(int port, const char * path, int timeout_s) {}}close(fd);- const size_t body = out.find("\r\n\r\n");- return body == std::string::npos ? std::string() : out.substr(body + 4);+ const size_t at = out.find("\r\n\r\n");+ return at == std::string::npos ? std::string() : out.substr(at + 4);}double metric(const std::string & text, const char * name) {@@ -327,6 +332,9 @@ void StatsCollector::run() {double last_busy = 0, last_tokens = 0, last_gen_s = 0;bool have_last = false, last_working = false;double last_ptok = 0, last_psec = 0, last_decoded = 0;+ // The hour charts' sums since their last point: temperature, power, GPU, CPU.+ double hour_sum[4] = {};+ int hour_n[4] = {}, seconds = 0;for (;;) {std::this_thread::sleep_for(std::chrono::seconds(1));const double wall = now_s(), cpu = cpu_seconds();@@ -485,6 +493,23 @@ void StatsCollector::run() {}push(live_.gpu_history, live_.gpu_busy);push(live_.gen_history, live_.gen_tps);+ const float now[4] = { soc_t, watts, live_.gpu_busy, live_.cpu_use };+ const bool read[4] = { soc_t > -100, watts > 0, true, true };+ std::vector<float> * hour[4] = { &live_.temp_hour, &live_.power_hour, &live_.gpu_hour, &live_.cpu_hour };+ ++seconds;+ for (int i = 0; i < 4; ++i) {+ if (read[i]) {+ hour_sum[i] += now[i];+ ++hour_n[i];+ }+ if (seconds % 30 == 0) {+ if (hour_n[i] > 0) {+ push(*hour[i], (float) (hour_sum[i] / hour_n[i]));+ }+ hour_sum[i] = 0;+ hour_n[i] = 0;+ }+ }last_wall = wall;last_cpu = cpu;}diff --git a/ps5/app/stats.hpp b/ps5/app/stats.hppindex 876f588..e4537b1 100644--- a/ps5/app/stats.hpp+++ b/ps5/app/stats.hpp@@ -92,6 +92,8 @@ struct Live {bool sensors_from_exporter = false; // read from ps5-exporter, not the kernelstd::vector<float> temp_history; // SoC degrees C per secondstd::vector<float> power_history; // SoC watts per second+ // The same four over the last hour, a point per 30 seconds (their mean).+ std::vector<float> temp_hour, power_hour, gpu_hour, cpu_hour;double energy_wh = 0; // SoC energy since the app startedstd::vector<std::pair<std::string, float>> temps; // every sensor that answered ("cpu", "soc0", ...)@@ -161,6 +163,13 @@ std::string local_address();// A tiny HTTP GET over loopback; returns the body, or empty.std::string http_get(int port, const char * path, int timeout_s = 1);+// The same with a JSON body, as a POST; reads the answer to its end.+std::string http_post(int port, const char * path, const std::string & body, int timeout_s);++// Asks the app's own server, as Home's Message and Demo do, on a thread of its+// own: a chat message, or for a decision model a text to decide on. It shows+// in the feed like any other request (activity.cpp).+void ask_self(int port, const std::string & text, bool decision);// One value from Prometheus text ("llamacpp:tokens_predicted_total 42").double metric(const std::string & text, const char * name);