Skip to content

armgit / PS5LM

Public Imported from GitHub
0

llama.cpp on a jailbroken PS5: run any GGUF model natively on the console, starting with Qwen 3.8

App: a new screen, Home, Models, API and Settings

Mert Cobanovc5934c5260e2
diff --git a/ps5/app/assets/audio/sfx/NOTICE.txt b/ps5/app/assets/audio/sfx/NOTICE.txt
new file mode 100644
index 0000000..7562b03
--- /dev/null
+++ b/ps5/app/assets/audio/sfx/NOTICE.txt
@@ -0,0 +1,3 @@
+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.
diff --git a/ps5/app/assets/audio/sfx/back_01.wav b/ps5/app/assets/audio/sfx/back_01.wav
new file mode 100644
index 0000000..bfaea68
Binary files /dev/null and b/ps5/app/assets/audio/sfx/back_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/complete_01.wav b/ps5/app/assets/audio/sfx/complete_01.wav
new file mode 100644
index 0000000..f4f16d8
Binary files /dev/null and b/ps5/app/assets/audio/sfx/complete_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/error_01.wav b/ps5/app/assets/audio/sfx/error_01.wav
new file mode 100644
index 0000000..8672972
Binary files /dev/null and b/ps5/app/assets/audio/sfx/error_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/focus_01.wav b/ps5/app/assets/audio/sfx/focus_01.wav
new file mode 100644
index 0000000..e02b3ae
Binary files /dev/null and b/ps5/app/assets/audio/sfx/focus_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/launch_01.wav b/ps5/app/assets/audio/sfx/launch_01.wav
new file mode 100644
index 0000000..ebff48a
Binary files /dev/null and b/ps5/app/assets/audio/sfx/launch_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/modal_close_01.wav b/ps5/app/assets/audio/sfx/modal_close_01.wav
new file mode 100644
index 0000000..eb16e3b
Binary files /dev/null and b/ps5/app/assets/audio/sfx/modal_close_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/modal_open_01.wav b/ps5/app/assets/audio/sfx/modal_open_01.wav
new file mode 100644
index 0000000..d243db0
Binary files /dev/null and b/ps5/app/assets/audio/sfx/modal_open_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/notify_01.wav b/ps5/app/assets/audio/sfx/notify_01.wav
new file mode 100644
index 0000000..270c2ac
Binary files /dev/null and b/ps5/app/assets/audio/sfx/notify_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/open_01.wav b/ps5/app/assets/audio/sfx/open_01.wav
new file mode 100644
index 0000000..d243db0
Binary files /dev/null and b/ps5/app/assets/audio/sfx/open_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/resume_01.wav b/ps5/app/assets/audio/sfx/resume_01.wav
new file mode 100644
index 0000000..eb16e3b
Binary files /dev/null and b/ps5/app/assets/audio/sfx/resume_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/saved_01.wav b/ps5/app/assets/audio/sfx/saved_01.wav
new file mode 100644
index 0000000..f4f16d8
Binary files /dev/null and b/ps5/app/assets/audio/sfx/saved_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/select_01.wav b/ps5/app/assets/audio/sfx/select_01.wav
new file mode 100644
index 0000000..730aff2
Binary files /dev/null and b/ps5/app/assets/audio/sfx/select_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/slider_01.wav b/ps5/app/assets/audio/sfx/slider_01.wav
new file mode 100644
index 0000000..a6add84
Binary files /dev/null and b/ps5/app/assets/audio/sfx/slider_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/tab_01.wav b/ps5/app/assets/audio/sfx/tab_01.wav
new file mode 100644
index 0000000..19b93c7
Binary files /dev/null and b/ps5/app/assets/audio/sfx/tab_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/toggle_01.wav b/ps5/app/assets/audio/sfx/toggle_01.wav
new file mode 100644
index 0000000..bdefce1
Binary files /dev/null and b/ps5/app/assets/audio/sfx/toggle_01.wav differ
diff --git a/ps5/app/assets/audio/sfx/welcome_01.wav b/ps5/app/assets/audio/sfx/welcome_01.wav
new file mode 100644
index 0000000..0507173
Binary files /dev/null and b/ps5/app/assets/audio/sfx/welcome_01.wav differ
diff --git a/ps5/app/assets/fonts/manrope-200.huifont b/ps5/app/assets/fonts/manrope-200.huifont
new file mode 100644
index 0000000..f959cd9
Binary files /dev/null and b/ps5/app/assets/fonts/manrope-200.huifont differ
diff --git a/ps5/app/assets/fonts/manrope-500.huifont b/ps5/app/assets/fonts/manrope-500.huifont
new file mode 100644
index 0000000..920df2a
Binary files /dev/null and b/ps5/app/assets/fonts/manrope-500.huifont differ
diff --git a/ps5/app/assets/fonts/manrope-600.huifont b/ps5/app/assets/fonts/manrope-600.huifont
new file mode 100644
index 0000000..8fd5c07
Binary files /dev/null and b/ps5/app/assets/fonts/manrope-600.huifont differ
diff --git a/ps5/app/assets/fonts/manrope-LICENSE.txt b/ps5/app/assets/fonts/manrope-LICENSE.txt
new file mode 100644
index 0000000..e271172
--- /dev/null
+++ b/ps5/app/assets/fonts/manrope-LICENSE.txt
@@ -0,0 +1,93 @@
+Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.
diff --git a/ps5/app/dashboard.cpp b/ps5/app/dashboard.cpp
index 365a715..8b2a308 100644
--- a/ps5/app/dashboard.cpp
+++ b/ps5/app/dashboard.cpp
@@ -1,20 +1,22 @@
// SPDX-License-Identifier: GPL-3.0-or-later
//
-// Layout, palette, panels, the focus ring and spatial navigation follow
-// ps5-homebrew-ui's src/concepts/dashboard.cpp ("Pulse Dashboard",
-// BlackBearReloaded, GPL-3.0-or-later); the tiles and their data are PS5LM's.
+// PS5LM's screen. One idea runs through it: the model is the thing, and the
+// network is where it goes. Home shows the model and how fast it runs on the
+// left, the address other devices use on the right, and nothing else large;
+// 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.
#include "dashboard.hpp"
+#include "suggested.hpp"
#include "version.hpp"
#include "ui/glyphs.hpp"
#include <algorithm>
-#include <array>
#include <cctype>
-#include <iterator>
#include <cmath>
#include <cstdio>
-#include <span>
+#include <iterator>
namespace ps5lm {
@@ -25,150 +27,42 @@ using hui::gfx::Rect;
namespace gfx = hui::gfx;
namespace ui = hui::ui;
namespace tween = hui::tween;
+using Cue = hui::audio::Cue;
namespace {
-// ---- the design language (Pulse Dashboard's) --------------------------------
-
-const Color kInk = Color::rgb(0xf2f2f7);
-const Color kClear = Color::rgb(0x000000, 0.0f);
-const Color kBlack = Color::rgb(0x000000);
-const Color kPanelTop = Color::rgb(0x17171f);
-const Color kPanelBottom = Color::rgb(0x0e0e14);
-const Color kCyan = Color::rgb(0x4fe0ff); // speed and the GPU
-const Color kLime = Color::rgb(0xb8f26b); // the CPU and the model
-const Color kAmber = Color::rgb(0xffc24a); // memory
-const Color kRose = Color::rgb(0xff6f9c); // GPU memory
-const Color kBrand = Color::rgb(0x8288f0); // PS5LM's periwinkle, and the context
-const Color kHeat = Color::rgb(0xff8a5c); // temperatures
-
-constexpr float kMuted = 0.62f;
-constexpr float kFaint = 0.38f;
-
-constexpr float kGridX = 96.0f, kGridY = 164.0f, kGridW = 1728.0f, kGridH = 800.0f;
-constexpr float kGap = 20.0f, kRadius = 28.0f, kPad = 28.0f;
-constexpr float kLabelY = 46.0f, kLabelSize = 17.0f, kLift = 0.02f;
+// ---- the design language -------------------------------------------------------
+
+const Color kBase = Color::rgb(0x121314);
+const Color kSurface = Color::rgb(0x1c1d1f); // sheets and panels
+const Color kRaised = Color::rgb(0x28292c); // the focused row
+const Color kHair = Color::rgb(0x2c2e31); // dividers
+const Color kInk = Color::rgb(0xf4f4f5);
+const Color kInk2 = Color::rgb(0xa3a5aa);
+const Color kInk3 = Color::rgb(0x6b6e74);
+const Color kBlue = Color::rgb(0x3e6ae1);
+const Color kRed = Color::rgb(0xe5484d);
+const Color kGreen = Color::rgb(0x3dbe7a);
+const Color kBlack = Color::rgb(0x000000);
+
+constexpr float kLeft = 96.0f, kRight = 1824.0f;
+constexpr float kTitleY = 182.0f; // page titles' baseline
+constexpr float kDockY = 966.0f; // the dock's top edge
+constexpr float kRailW = 330.0f, kRailPitch = 76.0f, kRailH = 64.0f;
+constexpr float kListX = 486.0f, kListY = 236.0f, kRowPitch = 92.0f, kRowH = 80.0f;
+constexpr int kVisibleRows = 7;
constexpr float kTau = 6.2831853f;
constexpr const char * kDash = "\xE2\x80\x94";
-enum Tile : int { kSpeed, kUsage, kPower, kMemory, kContext, kStorage, kThermals, kModel };
-
-struct TileSpec {
- const char * label;
- int column, row, columns, rows;
- std::uint32_t accent;
-};
-
-// In reading order: ties in the navigation go to the earlier tile.
-constexpr TileSpec kSpec[Dashboard::kTiles] = {
- { "GENERATION", 0, 0, 6, 2, 0x4fe0ff },
- { "USAGE", 6, 0, 3, 2, 0x4fe0ff },
- { "POWER", 9, 0, 3, 2, 0xffd166 },
- { "MEMORY", 0, 2, 6, 1, 0xffc24a },
- { "CONTEXT", 0, 3, 3, 1, 0x8288f0 },
- { "STORAGE", 3, 3, 3, 1, 0xff6f9c },
- { "THERMALS", 6, 2, 3, 2, 0xff8a5c },
- { "MODEL", 9, 2, 3, 2, 0xb8f26b },
-};
-
-Color accent_of(int tile) { return Color::rgb(kSpec[tile].accent); }
-
-Rect tile_rect(int tile) {
- const TileSpec & s = kSpec[tile];
- const float column = (kGridW - 11.0f * kGap) / 12.0f;
- const float row = (kGridH - 3.0f * kGap) / 4.0f;
- return { kGridX + s.column * (column + kGap), kGridY + s.row * (row + kGap),
- s.columns * (column + kGap) - kGap, s.rows * (row + kGap) - kGap };
-}
-
-Rect scaled(const Rect & r, float scale) {
- return { r.cx() - r.w * scale * 0.5f, r.cy() - r.h * scale * 0.5f, r.w * scale, r.h * scale };
-}
-
-// Pulse Dashboard's spatial navigation: the candidate beyond the leading
-// edge with the least travel, a penalty for missing sideways, and a light
-// pull toward the aligned one.
-int spatial_next(std::span<const Rect> rects, int from, Direction direction) {
- if (direction == Direction::none) {
- return -1;
- }
- const bool horizontal = direction == Direction::left || direction == Direction::right;
- const float sign = direction == Direction::right || direction == Direction::down ? 1.0f : -1.0f;
- auto main_low = [=](const Rect & r) { return horizontal ? r.x : r.y; };
- auto main_size = [=](const Rect & r) { return horizontal ? r.w : r.h; };
- auto cross_low = [=](const Rect & r) { return horizontal ? r.y : r.x; };
- auto cross_size = [=](const Rect & r) { return horizontal ? r.h : r.w; };
- const Rect & o = rects[(size_t) from];
- const float leading = sign > 0 ? main_low(o) + main_size(o) : main_low(o);
- int best = -1;
- float best_score = 0;
- for (int i = 0; i < (int) rects.size(); ++i) {
- if (i == from) {
- continue;
- }
- const Rect & c = rects[(size_t) i];
- if ((main_low(c) + main_size(c) * 0.5f - leading) * sign <= 0) {
- continue;
- }
- const float facing = sign > 0 ? main_low(c) : main_low(c) + main_size(c);
- const float along = std::max(0.0f, (facing - leading) * sign);
- const float miss = std::max({ 0.0f, cross_low(c) - (cross_low(o) + cross_size(o)),
- cross_low(o) - (cross_low(c) + cross_size(c)) });
- const float offset = std::fabs((cross_low(c) + cross_size(c) * 0.5f) - (cross_low(o) + cross_size(o) * 0.5f));
- const float score = along + 2.0f * miss + 0.25f * offset;
- if (best < 0 || score < best_score - 0.01f) {
- best = i;
- best_score = score;
- }
- }
- return best;
-}
-
-Direction opposite(Direction d) {
- switch (d) {
- case Direction::left: return Direction::right;
- case Direction::right: return Direction::left;
- case Direction::up: return Direction::down;
- case Direction::down: return Direction::up;
- default: return Direction::none;
- }
-}
-
-float rise(float time, int index = 0, float step = 0.05f, float duration = 0.7f) {
- return tween::cubic_out(tween::clamp01((time - step * (float) index) / duration));
-}
-
-const char * state_word(ServerState s) {
- switch (s) {
- case ServerState::loading: return "LOADING";
- case ServerState::ready: return "READY";
- case ServerState::generating: return "GENERATING";
- case ServerState::failed: return "FAILED";
- default: return "NO MODEL";
- }
-}
-
-Color state_color(ServerState s) {
- switch (s) {
- case ServerState::ready: return kLime;
- case ServerState::generating: return kCyan;
- case ServerState::failed: return kRose;
- default: return kAmber;
- }
-}
-
-constexpr float kRowH = 78.0f;
-constexpr Rect kLibrary{ 360.0f, 150.0f, 1200.0f, 800.0f };
-constexpr const char * kPageNames[Dashboard::kPages] = { "Dashboard", "Settings", "Logs", "Get models", "Downloads" };
+constexpr const char * kPageNames[Dashboard::kPages] = { "Home", "Models", "API", "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
// GGUF repositories, then the families the presets know.
constexpr const char * kMarketChips[] = { "Popular", "Qwen", "Gemma", "Llama", "Mistral", "Phi", "Granite" };
constexpr int kMarketChipCount = 7;
-constexpr float kMarketRowH = 66.0f;
-constexpr int kMarketRows = 9;
-// ---- Settings: categories of rows, after the kit's "Control Room" ---------------
+// ---- Settings -------------------------------------------------------------------
enum class Setting : int { auto_load, default_model, ctx_cap, kv_type, sounds, tools, scratch_limit, clear_scratch, download_dir };
@@ -179,216 +73,249 @@ struct SettingRow {
};
struct SettingCategory {
- const char * name;
- const char * about;
- SettingRow rows[4];
- int count;
+ const char * name;
+ SettingRow rows[3];
+ int count;
};
constexpr SettingCategory kCategories[] = {
- { "Startup", "What the app does when it opens.",
- { { Setting::auto_load, "Load a model at launch", "Off: the app opens the library and waits for a choice." },
- { Setting::default_model, "Model to load", "One of the models the library lists." } },
+ { "Startup",
+ { { Setting::auto_load, "Load a model at launch", "Off: the app opens and waits for a choice" },
+ { Setting::default_model, "Model to load", "One of the models on this PS5" } },
2 },
- { "Model", "How the planner sizes a model. Applies the next time a model loads.",
- { { Setting::ctx_cap, "Longest context", "The planner picks the longest context up to this that fits." },
- { Setting::kv_type, "KV cache", "Auto picks the best that fits; a fixed type trades context for quality." } },
+ { "Model",
+ { { Setting::ctx_cap, "Longest context", "The longest that fits, up to this; applies at the next load" },
+ { Setting::kv_type, "Context cache", "Auto picks the best that fits; a fixed type trades length for quality" } },
2 },
- { "Chat", "The browser chat's tools, and the folder they work in.",
- { { Setting::tools, "File tools", "The model may read, write and search files in /data/PS5LM/scratch. Applies at the next load." },
- { Setting::scratch_limit, "Warn above", "A notification when the scratch folder grows past this." },
- { Setting::clear_scratch, "Clear the scratch folder", "Deletes everything the chat's tools wrote." } },
+ { "Chat",
+ { { Setting::tools, "File tools", "The browser chat may read and write files in /data/PS5LM/scratch" },
+ { Setting::scratch_limit, "Warn above", "A notification when that folder grows past this" },
+ { Setting::clear_scratch, "Clear the scratch folder", "Deletes everything the chat's tools wrote" } },
3 },
- { "App", "The app itself.",
- { { Setting::sounds, "Sounds", "Interface sounds on the TV." },
- { Setting::download_dir, "Download to", "Where Get models saves: internal storage, or PS5LM/models on an M.2 or USB drive." } },
+ { "Sound and storage",
+ { { Setting::sounds, "Sounds", "Interface sounds on the TV" },
+ { Setting::download_dir, "Save downloads to", "Internal storage, or PS5LM/models on an M.2 or USB drive" } },
2 },
+ { "Diagnostics", {}, 0 },
};
-constexpr int kCategoryCount = 4;
+constexpr int kCategoryCount = 5;
+constexpr int kDiagnostics = 4;
constexpr uint32_t kCtxSteps[] = { 4096, 8192, 16384, 32768, 65536, 131072 };
constexpr const char * kKvSteps[] = { "auto", "f16", "q8_0", "q4_0" };
+constexpr uint32_t kScratchSteps[] = { 1, 2, 5, 10, 20 };
-constexpr float kRailX = 96.0f, kRailY = 236.0f, kRailW = 372.0f, kRailH = 72.0f, kRailPitch = 84.0f;
-constexpr Rect kSettingsPanel{ 504.0f, 236.0f, 1320.0f, 692.0f };
-constexpr float kSetRowsY = kSettingsPanel.y + 112.0f, kSetRowH = 80.0f, kSetRowPitch = 92.0f;
-
-Rect rail_rect(int category) { return { kRailX, kRailY + category * kRailPitch, kRailW, kRailH }; }
-Rect setting_rect(int row) {
- return { kSettingsPanel.x + 24, kSetRowsY + row * kSetRowPitch, kSettingsPanel.w - 48, kSetRowH };
-}
+constexpr int kLogLines = 20;
+constexpr float kLogLineH = 29.0f;
-// ---- Logs ---------------------------------------------------------------------------
+// ---- small helpers ----------------------------------------------------------------
-constexpr Rect kLogPanel{ 96.0f, 164.0f, 1728.0f, 800.0f };
-constexpr float kLogLineH = 27.0f;
-constexpr int kLogLines = 25;
+float put(gfx::DrawList & l, const ui::FontRef & f, std::string_view v, float x, float y, float size, Color c,
+ gfx::Align a = gfx::Align::left) {
+ return ui::text(l, f, v, x, y, size, c, a);
+}
-} // namespace
+std::string format(const char * fmt, double v) {
+ char t[48];
+ std::snprintf(t, sizeof(t), fmt, v);
+ return t;
+}
-// ---- update -------------------------------------------------------------------
+// "9,120"
+std::string thousands(uint64_t v) {
+ std::string s = std::to_string(v);
+ for (int i = (int) s.size() - 3; i > 0; i -= 3) {
+ s.insert((size_t) i, ",");
+ }
+ return s;
+}
-Rect Dashboard::ring_rect() const {
- return scaled(tile_rect(focus_), 1.0f + kLift).inset(-5.0f);
+// Sizes as the console's own screens give them: binary gigabytes, called GB.
+std::string gb(double gib) { return format("%.1f GB", gib); }
+std::string gb_text(std::string s) {
+ for (size_t at = s.find("GiB"); at != std::string::npos; at = s.find("GiB", at)) {
+ s.replace(at, 3, "GB");
+ }
+ return s;
}
-void Dashboard::update(const hui::InputFrame & raw, float dt, ui::Feedback & feedback) {
- const hui::InputFrame none{};
- const hui::InputFrame & input = busy() ? none : raw; // busy: the screen says so, buttons wait
- age_ += dt;
- clock_ += dt;
- page_age_ += dt;
+// "Qwen3.8-27B-UD-IQ2_XXS" -> "Qwen3.8 27B" and "UD-IQ2_XXS": the build starts
+// at the first part that names a quantization.
+bool quant_part(const std::string & p) {
+ std::string u = p;
+ std::transform(u.begin(), u.end(), u.begin(), [](unsigned char c) { return (char) std::toupper(c); });
+ const auto starts = [&](const char * s) { return u.rfind(s, 0) == 0; };
+ return u == "UD" || u == "BF16" || u == "F16" || u == "F32" || starts("MXFP") || u.find("_K") != std::string::npos ||
+ (u.size() > 1 && (u[0] == 'Q' || starts("IQ") || starts("TQ") || starts("PQ")) &&
+ std::isdigit((unsigned char) u[u[0] == 'Q' ? 1 : 2]));
+}
- // L1/R1 change the page, unless an overlay has the focus.
- const bool overlay = library_open_ || details_open_;
- const int step = input.is_pressed(Action::page_next) ? 1 : input.is_pressed(Action::page_prev) ? -1 : 0;
- if (step != 0 && !overlay) {
- const int next = page_ + step;
- if (next >= 0 && next < kPages) {
- page_from_ = page_;
- page_ = next;
- page_age_ = 0;
- feedback.play(hui::audio::Cue::tab, 1.0f + 0.04f * (float) page_, 0.0f);
- if (page_ == kLogsPage) {
- log_scroll_ = 0;
- }
- if (page_ == kMarketPage && !market_searched_) {
- market_searched_ = true;
- request_ = { Request::market_search, "" };
- }
- } else {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
+void split_name(const std::string & label, std::string * name, std::string * build) {
+ std::vector<std::string> parts;
+ size_t at = 0;
+ while (at <= label.size()) {
+ const size_t dash = label.find('-', at);
+ parts.push_back(label.substr(at, dash == std::string::npos ? std::string::npos : dash - at));
+ if (dash == std::string::npos) {
+ break;
}
- } else if (page_ == 0 || overlay) {
- update_dashboard(input, feedback);
- } else if (page_ == 1) {
- update_settings(input, feedback);
- } else if (page_ == kLogsPage) {
- update_logs(input, feedback);
- } else if (page_ == kDownloadsPage) {
- update_downloads(input, feedback);
- } else {
- update_market(input, feedback);
+ at = dash + 1;
+ }
+ name->clear();
+ build->clear();
+ bool in_build = false;
+ for (const auto & p : parts) {
+ in_build = in_build || quant_part(p);
+ std::string & to = in_build ? *build : *name;
+ if (!in_build && (p == "it" || p == "Instruct" || p == "GGUF")) {
+ continue;
+ }
+ to += (to.empty() ? "" : in_build ? "-" : " ") + p;
+ }
+ if (name->empty()) {
+ *name = label;
}
+}
- for (int i = 0; i < kTiles; ++i) {
- lift_[i].target = i == focus_ ? 1.0f : 0.0f;
- lift_[i].update(dt, 16.0f);
- }
- ring_.target(ring_rect());
- ring_.update(dt, 20.0f);
- refusal_.update(dt, 9.0f);
- library_.target = library_open_ ? 1.0f : 0.0f;
- library_.update(dt, 13.0f);
- details_.target = details_open_ ? 1.0f : 0.0f;
- details_.update(dt, 13.0f);
- cursor_y_.target = (float) slot(library_cursor_);
- cursor_y_.update(dt, 20.0f);
- const Rect target = in_rows_ ? setting_rect(setting_row_) : rail_rect(setting_category_);
- if (age_ <= dt) {
- setting_focus_.snap(target);
+// A slim bar: the track, and the share filled.
+void meter(gfx::DrawList & l, float x, float y, float w, float share, Color c) {
+ l.rounded_rect({ x, y, w, 4 }, 2, kHair);
+ if (share > 0.002f) {
+ l.rounded_rect({ x, y, std::max(4.0f, w * tween::clamp01(share)), 4 }, 2, c);
}
- setting_focus_.target(target);
- setting_focus_.update(dt, 20.0f);
}
-void Dashboard::update_dashboard(const hui::InputFrame & input, ui::Feedback & feedback) {
- const int rows = (int) live_.models.size();
- if (details_open_) {
- if (input.is_pressed(Action::north) && detail_tile_ == kModel) {
- details_open_ = false;
- open_library();
- feedback.play(hui::audio::Cue::open);
- } else if (input.is_pressed(Action::back) || input.is_pressed(Action::confirm)) {
- details_open_ = false;
- feedback.play(hui::audio::Cue::back);
- }
+// 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) {
return;
}
- if (library_open_) {
- if (input.nav == Direction::up || input.nav == Direction::down) {
- const int next = library_cursor_ + (input.nav == Direction::down ? 1 : -1);
- if (next >= 0 && next < rows) {
- library_cursor_ = next;
- feedback.play(hui::audio::Cue::focus, 1.0f + 0.03f * (float) next);
- } else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- refusal_.trigger();
- }
+ float top = 1.0f;
+ for (float x : v) {
+ top = std::max(top, x);
+ }
+ top *= 1.15f;
+ const float step = g.w / 119.0f;
+ 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;
+ if (age > 0) {
+ l.line(lx, ly, x, y, 2.0f, c);
}
- if (input.is_pressed(Action::confirm) && rows > 0) {
- const ModelRow & m = live_.models[(size_t) library_cursor_];
- if (m.current) {
- request_ = { Request::unload, m.file };
- library_open_ = false;
- feedback.play(hui::audio::Cue::back);
- } else if (m.fits) {
- request_ = { Request::load, m.file };
- library_open_ = false;
- feedback.play(hui::audio::Cue::complete);
- } else {
- feedback.play(hui::audio::Cue::error);
- refusal_.trigger();
+ 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);
+}
+
+// The dock's line icons, 32 px, drawn with strokes like the rest.
+void icon(gfx::DrawList & l, int page, float cx, float cy, Color c) {
+ const float w = 2.6f;
+ switch (page) {
+ case Dashboard::kHomePage:
+ l.line(cx - 16, cy - 1, cx, cy - 14, w, c);
+ l.line(cx, cy - 14, cx + 16, cy - 1, w, c);
+ l.line(cx - 11, cy - 5, cx - 11, cy + 13, w, c);
+ l.line(cx + 11, cy - 5, cx + 11, cy + 13, w, c);
+ l.line(cx - 11, cy + 13, cx + 11, cy + 13, w, c);
+ l.line(cx - 3, cy + 13, cx - 3, cy + 4, w, c);
+ l.line(cx + 3, cy + 13, cx + 3, cy + 4, w, c);
+ l.line(cx - 3, cy + 4, cx + 3, cy + 4, w, c);
+ break;
+ case Dashboard::kModelsPage: {
+ // A cube: the hexagon and the three edges that meet in front.
+ const float r = 15, h = 13;
+ const float px[] = { cx, cx + h, cx + h, cx, cx - h, cx - h };
+ const float py[] = { cy - r, cy - r / 2, cy + r / 2, cy + r, cy + r / 2, cy - r / 2 };
+ for (int i = 0; i < 6; ++i) {
+ l.line(px[i], py[i], px[(i + 1) % 6], py[(i + 1) % 6], w, c);
}
+ l.line(cx, cy, cx - h, cy - r / 2, w, c);
+ l.line(cx, cy, cx + h, cy - r / 2, w, c);
+ l.line(cx, cy, cx, cy + r, w, c);
+ break;
}
- if (input.is_pressed(Action::back)) {
- library_open_ = false;
- feedback.play(hui::audio::Cue::back);
+ case Dashboard::kApiPage:
+ l.line(cx - 7, cy - 10, cx - 16, cy, w, c);
+ l.line(cx - 16, cy, cx - 7, cy + 10, w, c);
+ l.line(cx + 7, cy - 10, cx + 16, cy, w, 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;
+ default: {
+ const float knobs[] = { -6, 7, -1 };
+ for (int i = 0; i < 3; ++i) {
+ const float y = cy - 10 + 10.0f * (float) i;
+ l.line(cx - 16, y, cx + 16, y, w, c);
+ l.circle(cx + knobs[i], y, 5.5f, kBase);
+ l.ring(cx + knobs[i], y, 5.0f, w, c);
+ }
+ break;
}
- return;
}
- if (input.nav != Direction::none) {
- std::array<Rect, kTiles> rects;
- for (int i = 0; i < kTiles; ++i) {
- rects[(size_t) i] = tile_rect(i);
- }
- int next = input.nav == opposite(came_by_) ? came_from_ : spatial_next(rects, focus_, input.nav);
- if (next < 0) {
- next = spatial_next(rects, focus_, input.nav);
- }
- if (next >= 0) {
- came_from_ = focus_;
- came_by_ = input.nav;
- focus_ = next;
- const Rect r = tile_rect(focus_);
- feedback.play(hui::audio::Cue::focus, 1.08f - 0.16f * (r.cy() - kGridY) / kGridH, ui::pan_for_x(r.cx()));
- } else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- feedback.rumble(0.25f, 0.05f);
- refusal_.trigger();
- refusal_x_ = input.nav == Direction::right ? 1.0f : input.nav == Direction::left ? -1.0f : 0.0f;
- refusal_y_ = input.nav == Direction::down ? 1.0f : input.nav == Direction::up ? -1.0f : 0.0f;
- }
+}
+
+// A Tesla-style switch: a pill, blue and knob right when on.
+void toggle_switch(gfx::DrawList & l, float right, float cy, bool on) {
+ const Rect r{ right - 64, cy - 18, 64, 36 };
+ l.rounded_rect(r, 18, on ? kBlue : kHair);
+ l.circle(on ? r.x + r.w - 18 : r.x + 18, cy, 14, on ? kInk : kInk2);
+}
+
+int first_visible(int cursor, int rows) {
+ return std::clamp(cursor - kVisibleRows / 2, 0, std::max(0, rows - kVisibleRows));
+}
+
+// 2 error, 1 warning, 0 neither. llama.cpp marks its lines " E " and " W ";
+// the rest is matched by words, so "failures=0" is not an error.
+int log_level(const std::string & line) {
+ std::string low = line;
+ std::transform(low.begin(), low.end(), low.begin(), [](unsigned char ch) { return (char) std::tolower(ch); });
+ const auto has = [&](const char * w) { return low.find(w) != std::string::npos; };
+ if (line.find(" E ") != std::string::npos || has("error") || has("failed") || has("exception") || has("fatal") ||
+ has("abort")) {
+ return 2;
}
- // USAGE and POWER expand on Cross.
- if ((focus_ == kUsage || focus_ == kPower) && input.is_pressed(Action::confirm)) {
- details_open_ = true;
- detail_tile_ = focus_;
- feedback.play(hui::audio::Cue::open);
- return;
+ if (line.find(" W ") != std::string::npos || has("warn")) {
+ return 1;
}
- // The Model tile: Cross shows the loaded model's details (or the library
- // when nothing is loaded), Triangle the library.
- if (focus_ == kModel && input.is_pressed(Action::north)) {
- open_library();
- feedback.play(hui::audio::Cue::open);
- } else if (focus_ == kModel && input.is_pressed(Action::confirm)) {
- if (live_.model_label.empty()) {
- open_library();
+ return 0;
+}
+
+// "2.1 of 10.4 GB, 3.8 MB/s, 37 min left", or the note of one that waits.
+std::string download_line(const Download & d) {
+ char t[200];
+ const double done = d.done / 1073741824.0, all = d.bytes / 1073741824.0;
+ if (d.state == DownloadState::running && d.mbps > 0.05) {
+ const double left_s = (double) (d.bytes - std::min(d.done, d.bytes)) / (d.mbps * 1e6);
+ if (left_s >= 3600) {
+ std::snprintf(t, sizeof(t), "%.1f of %.1f GB, %.1f MB/s, %.0f h %02.0f min left", done, all, d.mbps,
+ std::floor(left_s / 3600), std::fmod(left_s / 60, 60));
} else {
- details_open_ = true;
- detail_tile_ = kModel;
+ std::snprintf(t, sizeof(t), "%.1f of %.1f GB, %.1f MB/s, %.0f min left", done, all, d.mbps, std::ceil(left_s / 60));
}
- feedback.play(hui::audio::Cue::open);
+ return t;
+ }
+ std::snprintf(t, sizeof(t), "%.1f of %.1f GB", done, all);
+ if (d.state == DownloadState::running) {
+ return std::string(t) + ", starting";
}
+ if (d.state == DownloadState::done) {
+ return d.note;
+ }
+ if (!d.note.empty()) {
+ return std::string(t) + ", " + d.note;
+ }
+ return d.state == DownloadState::queued ? std::string(t) + ", waiting its turn" : t;
}
-namespace {
-
-// The value of a setting as the row shows it, and one step of it.
+// The value of a setting as its row shows it, and one step of it.
std::string setting_text(const Settings & s, Setting id, const std::vector<ModelRow> & models,
const std::vector<Drive> & drives) {
- char t[32];
switch (id) {
case Setting::default_model: {
if (s.default_model.empty()) {
@@ -396,26 +323,23 @@ std::string setting_text(const Settings & s, Setting id, const std::vector<Model
}
for (const auto & m : models) {
if (m.file == s.default_model) {
- return m.label;
+ std::string name, build;
+ split_name(m.label, &name, &build);
+ return name + " " + build;
}
}
- const size_t slash = s.default_model.find_last_of('/');
- return s.default_model.substr(slash == std::string::npos ? 0 : slash + 1) + " (missing)";
+ return "Missing";
}
- case Setting::ctx_cap:
- std::snprintf(t, sizeof(t), "%uk tokens", s.ctx_cap / 1024);
- return t;
+ case Setting::ctx_cap: return format("%.0fk tokens", s.ctx_cap / 1024.0);
case Setting::kv_type: return s.kv_type == "auto" ? "Auto" : s.kv_type;
- case Setting::scratch_limit:
- std::snprintf(t, sizeof(t), "%u GiB", s.scratch_limit_gib);
- return t;
+ case Setting::scratch_limit: return format("%.0f GB", (double) s.scratch_limit_gib);
case Setting::download_dir: {
for (const auto & d : drives) {
if (d.models == s.download_dir) {
return d.name;
}
}
- return s.download_dir.rfind("/mnt/ext", 0) == 0 ? "M.2 drive (not found)" : "USB drive (not found)";
+ return s.download_dir.rfind("/mnt/ext", 0) == 0 ? "M.2 drive, not found" : "USB drive, not found";
}
default: return "";
}
@@ -427,13 +351,25 @@ bool toggle_value(const Settings & s, Setting id) {
return id == Setting::auto_load ? s.auto_load : id == Setting::sounds ? s.sounds : s.tools;
}
-constexpr uint32_t kScratchSteps[] = { 1, 2, 5, 10, 20 };
+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;
+}
// 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) {
switch (id) {
case Setting::default_model: {
- // "None", then each model that fits, in the library's order.
+ // "None", then each model that fits, in the list's order.
std::vector<std::string> choices = { "" };
for (const auto & m : models) {
if (m.fits) {
@@ -446,26 +382,13 @@ bool step_setting(Settings & s, Setting id, int dir, const std::vector<ModelRow>
at = i;
}
}
- const int next = at + dir;
- if (next < 0 || next >= (int) choices.size()) {
- return false;
- }
- s.default_model = choices[(size_t) next];
- return true;
- }
- case Setting::ctx_cap: {
- int at = 4;
- for (int i = 0; i < 6; ++i) {
- if (kCtxSteps[i] == s.ctx_cap) {
- at = i;
- }
- }
- if (at + dir < 0 || at + dir >= 6) {
+ if (at + dir < 0 || at + dir >= (int) choices.size()) {
return false;
}
- s.ctx_cap = kCtxSteps[at + dir];
+ s.default_model = choices[(size_t) (at + dir)];
return true;
}
+ case Setting::ctx_cap: return step_in(kCtxSteps, s.ctx_cap, dir, 4);
case Setting::kv_type: {
int at = 0;
for (int i = 0; i < 4; ++i) {
@@ -479,143 +402,255 @@ bool step_setting(Settings & s, Setting id, int dir, const std::vector<ModelRow>
s.kv_type = kKvSteps[at + dir];
return true;
}
- case Setting::scratch_limit: {
- int at = 1;
- for (int i = 0; i < 5; ++i) {
- if (kScratchSteps[i] == s.scratch_limit_gib) {
- at = i;
- }
- }
- if (at + dir < 0 || at + dir >= 5) {
- return false;
- }
- s.scratch_limit_gib = kScratchSteps[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: {
- // Each mounted drive in turn; a missing one counts as before the first.
- int at = -1;
+ 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;
}
}
- const int next = at + dir;
- if (next < 0 || next >= (int) drives.size()) {
+ if (at + dir < 0 || at + dir >= (int) drives.size()) {
return false;
}
- s.download_dir = drives[(size_t) next].models;
+ s.download_dir = drives[(size_t) (at + dir)].models;
return true;
}
}
return false;
}
+// 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; }
+
} // namespace
-void Dashboard::update_settings(const hui::InputFrame & input, ui::Feedback & feedback) {
- const SettingCategory & c = kCategories[setting_category_];
- if (!in_rows_) {
- if (input.nav == Direction::up || input.nav == Direction::down) {
- const int next = setting_category_ + (input.nav == Direction::down ? 1 : -1);
- if (next >= 0 && next < kCategoryCount) {
- setting_category_ = next;
- setting_row_ = 0;
- feedback.play(hui::audio::Cue::focus, 1.0f + 0.04f * (float) next);
- } else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- }
- }
- if (input.nav == Direction::right || input.is_pressed(Action::confirm)) {
- in_rows_ = true;
- feedback.play(hui::audio::Cue::select);
+// ---- state ------------------------------------------------------------------------
+
+void Dashboard::open_library() {
+ page_from_ = page_;
+ page_ = kModelsPage;
+ page_age_ = 0;
+ section_ = kLocal;
+ in_list_ = true;
+ local_cursor_ = 0;
+ for (int i = 0; i < (int) live_.models.size(); ++i) {
+ if (live_.models[(size_t) i].current) {
+ local_cursor_ = i;
}
- return;
}
- if (input.nav == Direction::up || input.nav == Direction::down) {
- const int next = setting_row_ + (input.nav == Direction::down ? 1 : -1);
- if (next >= 0 && next < c.count) {
- setting_row_ = next;
- feedback.play(hui::audio::Cue::focus, 1.0f + 0.04f * (float) next);
- } else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- }
+}
+
+void Dashboard::show_downloads() {
+ go_to(kModelsPage, nullptr);
+ section_ = kDownloads;
+ in_list_ = true;
+}
+
+bool Dashboard::wants_logs() const { return page_ == kSettingsPage && setting_category_ == kDiagnostics; }
+
+void Dashboard::go_to(int page, ui::Feedback * feedback) {
+ page_from_ = page_;
+ page_ = page;
+ page_age_ = 0;
+ if (feedback) {
+ feedback->play(Cue::tab, 1.0f + 0.04f * (float) page);
}
- 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(hui::audio::Cue::saved);
+}
+
+void Dashboard::set_logs(std::vector<std::string> app, std::vector<std::string> llama) {
+ app_log_ = std::move(app);
+ llama_log_ = std::move(llama);
+ refilter_logs();
+}
+
+void Dashboard::refilter_logs() {
+ const auto keep = [&](const std::string & line) { return !log_errors_ || log_level(line) > 0; };
+ app_view_.clear();
+ llama_view_.clear();
+ std::copy_if(app_log_.begin(), app_log_.end(), std::back_inserter(app_view_), keep);
+ std::copy_if(llama_log_.begin(), llama_log_.end(), std::back_inserter(llama_view_), keep);
+ log_scroll_ = std::min(log_scroll_, std::max(0, (int) log_view().size() - kLogLines));
+}
+
+// ---- input ------------------------------------------------------------------------
+
+void Dashboard::update(const hui::InputFrame & raw, float dt, ui::Feedback & feedback) {
+ const hui::InputFrame none{};
+ const bool dialog = market_confirm_ || market_space_;
+ const hui::InputFrame & input = busy() ? none : raw; // busy: the screen says so, buttons wait
+ age_ += dt;
+ clock_ += dt;
+ page_age_ += dt;
+
+ // L1/R1 walk the dock, unless a question is open.
+ const int step = input.is_pressed(Action::page_next) ? 1 : input.is_pressed(Action::page_prev) ? -1 : 0;
+ 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);
}
- if (input.is_pressed(Action::back)) {
- in_rows_ = false;
- feedback.play(hui::audio::Cue::back);
+ } else if (page_ == kHomePage) {
+ update_home(input, feedback);
+ } else if (page_ == kModelsPage) {
+ update_models(input, feedback);
+ } else if (page_ == kSettingsPage) {
+ update_settings(input, feedback);
+ }
+
+ // Where the highlight goes: a section or a row on Models, a category or a
+ // row on Settings.
+ float target = kListY;
+ if (page_ == kModelsPage) {
+ int row = section_;
+ if (in_list_) {
+ const int cursor = section_ == kLocal ? local_cursor_ : section_ == kSuggested ? suggested_cursor_
+ : section_ == kDownloads ? dl_cursor_ : market_files_ ? market_file_ : market_repo_;
+ const int count = section_ == kLocal ? (int) live_.models.size() : section_ == kSuggested ? kSuggestionCount
+ : section_ == kDownloads ? (int) market_.downloads.size()
+ : market_files_ && market_.open >= 0 && market_.open < (int) market_.repos.size()
+ ? (int) market_.repos[(size_t) market_.open].files.size() : (int) market_.repos.size();
+ row = cursor - first_visible(cursor, count);
+ target = kListY + (section_ == kSearch ? 72.0f : 0.0f) + (float) row * kRowPitch;
+ } else {
+ target = kListY + (float) row * kRailPitch;
}
- return;
+ } else if (page_ == kSettingsPage) {
+ target = in_rows_ && setting_category_ != kDiagnostics ? kListY + (float) setting_row_ * kRowPitch
+ : kListY + (float) setting_category_ * kRailPitch;
}
- int dir = 0;
- if (input.nav == Direction::left || input.nav == Direction::right) {
- dir = input.nav == Direction::right ? 1 : -1;
+ if (age_ <= dt) {
+ rows_y_.snap(target);
+ }
+ rows_y_.target = target;
+ rows_y_.update(dt, 22.0f);
+ dock_x_.target = (float) page_;
+ dock_x_.update(dt, 18.0f);
+ const bool decision = !live_.decision.empty();
+ hero_.target = decision ? live_.prompt_tps : live_.gen_tps;
+ hero_.update(dt, 6.0f);
+}
+
+void Dashboard::update_home(const hui::InputFrame & input, ui::Feedback & feedback) {
+ if (input.is_pressed(Action::confirm)) {
+ open_library();
+ feedback.play(Cue::open);
+ } else if (input.is_pressed(Action::north)) {
+ go_to(kApiPage, &feedback);
}
- if (is_toggle(id) && input.is_pressed(Action::confirm)) {
- dir = 1;
+}
+
+void Dashboard::update_models(const hui::InputFrame & input, ui::Feedback & feedback) {
+ if (market_confirm_ || market_space_) {
+ update_market(input, feedback);
+ return;
}
- if (dir != 0) {
- if (is_toggle(id) && (input.nav == Direction::left || input.nav == Direction::right)) {
- // Left turns a switch off, right on; the other way refuses.
- const bool on = toggle_value(settings_, id);
- if (on == (dir > 0)) {
- if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
+ if (!in_list_) {
+ if (input.nav == Direction::up || input.nav == Direction::down) {
+ const 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);
+ if (section_ == kSearch && !market_searched_) {
+ market_searched_ = true;
+ request_ = { Request::market_search, "" };
}
- dir = 0;
+ } else if (!input.nav_repeat) {
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
}
}
- if (dir != 0 && step_setting(settings_, id, dir, live_.models, live_.drives)) {
- request_ = { Request::settings, "" };
- feedback.play(is_toggle(id) ? hui::audio::Cue::toggle : hui::audio::Cue::slider, 1.0f + 0.05f * (float) dir);
- } else if (dir != 0 && !input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
+ if (input.nav == Direction::right || input.is_pressed(Action::confirm)) {
+ in_list_ = true;
+ feedback.play(Cue::select);
}
+ return;
}
- if (input.is_pressed(Action::back)) {
- in_rows_ = false;
- feedback.play(hui::audio::Cue::back);
+ // Left from a list's top level, or Circle there, goes back to the sections.
+ const bool top = !(section_ == kSearch && market_files_);
+ if (top && (input.nav == Direction::left || input.is_pressed(Action::back))) {
+ in_list_ = false;
+ dl_confirm_ = -1;
+ feedback.play(Cue::back);
+ return;
+ }
+ switch (section_) {
+ case kLocal: update_local(input, feedback); break;
+ case kSuggested: update_suggested(input, feedback); break;
+ case kSearch: update_market(input, feedback); break;
+ default: update_downloads(input, feedback); break;
}
}
namespace {
-// 2 error, 1 warning, 0 neither. llama.cpp marks its lines " E " and " W ";
-// the rest is matched by words, so "failures=0" is not an error.
-int log_level(const std::string & line) {
- std::string low = line;
- std::transform(low.begin(), low.end(), low.begin(), [](unsigned char ch) { return (char) std::tolower(ch); });
- const auto has = [&](const char * w) { return low.find(w) != std::string::npos; };
- if (line.find(" E ") != std::string::npos || has("error") || has("failed") || has("exception") || has("fatal") ||
- has("abort")) {
- return 2;
+// Up and down through a list: true when the cursor moved.
+bool walk(const hui::InputFrame & input, int & cursor, int count, ui::Feedback & feedback) {
+ if (input.nav != Direction::up && input.nav != Direction::down) {
+ return false;
}
- if (line.find(" W ") != std::string::npos || has("warn")) {
- return 1;
+ 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));
+ return true;
}
- return 0;
+ if (!input.nav_repeat) {
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
+ }
+ return false;
}
} // namespace
-// After the space check: ask about a loaded model first, or start.
-void Dashboard::start_download(ui::Feedback & feedback) {
- if (!live_.model_label.empty() && live_.free_gib < 2.0) {
- market_confirm_ = true; // a model holds the memory: ask first
- feedback.play(hui::audio::Cue::modal_open);
- } else {
- request_ = { Request::market_download, market_dir_, market_.open, market_file_ };
- feedback.play(hui::audio::Cue::complete);
+void Dashboard::update_local(const hui::InputFrame & input, ui::Feedback & feedback) {
+ const int rows = (int) live_.models.size();
+ local_cursor_ = std::clamp(local_cursor_, 0, std::max(0, rows - 1));
+ walk(input, local_cursor_, rows, feedback);
+ if (input.is_pressed(Action::confirm) && rows > 0) {
+ const ModelRow & m = live_.models[(size_t) local_cursor_];
+ if (m.current) {
+ request_ = { Request::unload, m.file };
+ feedback.play(Cue::back);
+ } else if (m.fits) {
+ request_ = { Request::load, m.file };
+ feedback.play(Cue::launch);
+ } else {
+ feedback.play(Cue::error);
+ }
+ }
+}
+
+void Dashboard::update_suggested(const hui::InputFrame & input, ui::Feedback & feedback) {
+ walk(input, suggested_cursor_, kSuggestionCount, feedback);
+ if (input.is_pressed(Action::confirm)) {
+ const Suggestion & s = kSuggestions[suggested_cursor_];
+ bool here = false;
+ for (const auto & m : live_.models) {
+ here = here || m.label + ".gguf" == local_name(s.model);
+ }
+ if (here) {
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
+ } else {
+ request_ = { Request::suggested_download, settings_.download_dir, suggested_cursor_ };
+ feedback.play(Cue::complete);
+ }
+ }
+}
+
+// After the space check: ask about a loaded model first, or start.
+void Dashboard::start_download(ui::Feedback & feedback) {
+ if (!live_.model_label.empty() && live_.free_gib < 2.0) {
+ market_confirm_ = true; // a model holds the memory: ask first
+ feedback.play(Cue::modal_open);
+ } else {
+ request_ = { Request::market_download, market_dir_, market_.open, market_file_ };
+ feedback.play(Cue::complete);
}
}
@@ -627,7 +662,7 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feed
start_download(feedback);
} else if (input.is_pressed(Action::back)) {
market_space_ = false;
- feedback.play(hui::audio::Cue::back);
+ feedback.play(Cue::modal_close);
}
return;
}
@@ -636,28 +671,28 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feed
if (input.is_pressed(Action::north)) {
request_ = { Request::market_download_unload, market_dir_, market_.open, market_file_ };
market_confirm_ = false;
- feedback.play(hui::audio::Cue::complete);
+ feedback.play(Cue::complete);
} else if (input.is_pressed(Action::confirm)) {
request_ = { Request::market_download, market_dir_, market_.open, market_file_ };
market_confirm_ = false;
- feedback.play(hui::audio::Cue::complete);
+ feedback.play(Cue::complete);
} else if (input.is_pressed(Action::back)) {
market_confirm_ = false;
- feedback.play(hui::audio::Cue::back);
+ feedback.play(Cue::modal_close);
}
return;
}
- const int step = input.is_pressed(Action::jump_next) ? 1 : input.is_pressed(Action::jump_prev) ? -1 : 0;
- if (step != 0) {
- const int next = market_chip_ + step;
+ const int chip = input.is_pressed(Action::jump_next) ? 1 : input.is_pressed(Action::jump_prev) ? -1 : 0;
+ if (chip != 0) {
+ const int next = market_chip_ + chip;
if (next >= 0 && next < kMarketChipCount) {
market_chip_ = next;
market_repo_ = 0;
market_files_ = false;
request_ = { Request::market_search, next == 0 ? std::string() : std::string(kMarketChips[next]) };
- feedback.play(hui::audio::Cue::tab);
+ feedback.play(Cue::tab);
} else {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
}
return;
}
@@ -665,25 +700,15 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feed
const MarketRepo * open = market_.open >= 0 && market_.open < repos ? &market_.repos[(size_t) market_.open] : nullptr;
const int files = open ? (int) open->files.size() : 0;
int & cursor = market_files_ ? market_file_ : market_repo_;
- const int count = market_files_ ? files : repos;
- if (input.nav == Direction::up || input.nav == Direction::down) {
- const int next = cursor + (input.nav == Direction::down ? 1 : -1);
- if (next >= 0 && next < count) {
- cursor = next;
- feedback.play(hui::audio::Cue::focus, 1.0f + 0.02f * (float) next);
- if (market_files_) {
- request_ = { Request::market_plan, "", market_.open, cursor };
- }
- } else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- }
+ if (walk(input, cursor, market_files_ ? files : repos, feedback) && market_files_) {
+ request_ = { Request::market_plan, "", market_.open, cursor };
}
if (input.is_pressed(Action::confirm)) {
if (!market_files_ && cursor < repos) {
request_ = { Request::market_open, "", cursor, -1 };
market_files_ = true;
market_file_ = 0;
- feedback.play(hui::audio::Cue::open);
+ feedback.play(Cue::open);
} 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
@@ -698,11 +723,11 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feed
}
market_dir_.clear();
if (f.fits == 0) {
- feedback.play(hui::audio::Cue::error); // too big
+ feedback.play(Cue::error); // too big
} else if (!to || (to->total > 0 && to->free < need)) { // unknown space (no exporter) does not block
market_space_ = true;
market_dir_ = other ? other->models : "";
- feedback.play(hui::audio::Cue::modal_open);
+ feedback.play(Cue::modal_open);
} else {
start_download(feedback);
}
@@ -713,35 +738,111 @@ void Dashboard::update_market(const hui::InputFrame & input, ui::Feedback & feed
const MarketFile & f = open->files[(size_t) cursor];
if (f.fits == -1 || f.fits == -2) {
request_ = { Request::market_plan, "", market_.open, cursor };
- feedback.play(hui::audio::Cue::select);
+ feedback.play(Cue::select);
} else {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f); // checked already
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f); // checked already
}
}
if (input.is_pressed(Action::back) && market_files_) {
market_files_ = false;
- feedback.play(hui::audio::Cue::back);
+ feedback.play(Cue::back);
}
// The first file of a freshly opened repository gets planned too.
- if (request_.kind == Request::none && market_files_ && files > 0 && market_file_ == 0 && open->files[0].fits == -1 && !open->files[0].checking &&
- !market_.busy) {
+ if (request_.kind == Request::none && market_files_ && files > 0 && market_file_ == 0 && open->files[0].fits == -1 &&
+ !open->files[0].checking && !market_.busy) {
request_ = { Request::market_plan, "", market_.open, 0 };
}
}
-void Dashboard::set_logs(std::vector<std::string> app, std::vector<std::string> llama) {
- app_log_ = std::move(app);
- llama_log_ = std::move(llama);
- refilter_logs();
+void Dashboard::update_downloads(const hui::InputFrame & input, ui::Feedback & feedback) {
+ const int rows = (int) market_.downloads.size();
+ dl_cursor_ = std::clamp(dl_cursor_, 0, std::max(0, rows - 1));
+ if (walk(input, dl_cursor_, rows, feedback)) {
+ dl_confirm_ = -1;
+ }
+ if (rows == 0) {
+ return;
+ }
+ const Download & d = market_.downloads[(size_t) dl_cursor_];
+ if (input.is_pressed(Action::confirm)) {
+ if (d.state == DownloadState::running || d.state == DownloadState::retrying || d.state == DownloadState::queued) {
+ request_ = { Request::download_pause, "", dl_cursor_ };
+ feedback.play(Cue::select);
+ } else if (d.state == DownloadState::paused || d.state == DownloadState::failed) {
+ request_ = { Request::download_resume, "", dl_cursor_ };
+ feedback.play(Cue::complete);
+ } else {
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
+ }
+ }
+ // Square: a finished one leaves the list; any other is cancelled and its
+ // partial file deleted, after a second press.
+ if (input.is_pressed(Action::west)) {
+ if (d.state == DownloadState::done || dl_confirm_ == dl_cursor_) {
+ request_ = { Request::download_remove, "", dl_cursor_ };
+ dl_confirm_ = -1;
+ feedback.play(Cue::back);
+ } else {
+ dl_confirm_ = dl_cursor_;
+ feedback.play(Cue::modal_open);
+ }
+ }
}
-void Dashboard::refilter_logs() {
- const auto keep = [&](const std::string & line) { return !log_errors_ || log_level(line) > 0; };
- app_view_.clear();
- llama_view_.clear();
- std::copy_if(app_log_.begin(), app_log_.end(), std::back_inserter(app_view_), keep);
- std::copy_if(llama_log_.begin(), llama_log_.end(), std::back_inserter(llama_view_), keep);
- log_scroll_ = std::min(log_scroll_, std::max(0, (int) log_view().size() - kLogLines));
+void Dashboard::update_settings(const hui::InputFrame & input, ui::Feedback & feedback) {
+ if (!in_rows_) {
+ if (input.nav == Direction::up || input.nav == Direction::down) {
+ const int next = setting_category_ + (input.nav == Direction::down ? 1 : -1);
+ if (next >= 0 && next < kCategoryCount) {
+ setting_category_ = next;
+ setting_row_ = 0;
+ log_scroll_ = 0;
+ feedback.play(Cue::focus, 1.0f + 0.04f * (float) next);
+ } else if (!input.nav_repeat) {
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
+ }
+ }
+ if (input.nav == Direction::right || input.is_pressed(Action::confirm)) {
+ in_rows_ = true;
+ feedback.play(Cue::select);
+ }
+ return;
+ }
+ if (input.is_pressed(Action::back) || input.nav == Direction::left) {
+ in_rows_ = false;
+ feedback.play(Cue::back);
+ return;
+ }
+ if (setting_category_ == kDiagnostics) {
+ update_logs(input, feedback);
+ return;
+ }
+ const 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);
+ }
+ 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
+ }
+ if (dir != 0 && step_setting(settings_, id, dir, live_.models, live_.drives)) {
+ 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);
+ }
}
void Dashboard::update_logs(const hui::InputFrame & input, ui::Feedback & feedback) {
@@ -750,1305 +851,653 @@ void Dashboard::update_logs(const hui::InputFrame & input, ui::Feedback & feedba
const int next = std::clamp(log_scroll_ + (input.nav == Direction::up ? 3 : -3), 0, most);
if (next != log_scroll_) {
log_scroll_ = next;
- feedback.play(hui::audio::Cue::focus, 1.0f, 0.0f, 0.4f);
+ feedback.play(Cue::focus, 1.0f, 0.0f, 0.4f);
} else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
+ feedback.play(Cue::error, 1.0f, 0.0f, 0.6f);
}
}
if (input.is_pressed(Action::west)) {
log_llama_ = !log_llama_;
log_scroll_ = 0;
- feedback.play(hui::audio::Cue::select);
+ feedback.play(Cue::select);
}
if (input.is_pressed(Action::north)) {
log_errors_ = !log_errors_;
refilter_logs();
log_scroll_ = 0;
- feedback.play(hui::audio::Cue::select);
+ feedback.play(Cue::toggle);
}
if (input.is_pressed(Action::confirm)) {
log_scroll_ = 0; // back to the newest
- feedback.play(hui::audio::Cue::back);
+ feedback.play(Cue::select);
}
}
-// ---- drawing helpers -----------------------------------------------------------
+// ---- drawing: the frame ---------------------------------------------------------------
-namespace {
-
-float caps(gfx::DrawList & list, const ui::Fonts & f, std::string_view v, float x, float y, float size, Color c,
- gfx::Align a = gfx::Align::left) {
- return ui::text(list, f.semibold, v, x, y, size, c, a, 3.0f);
-}
-
-// A value, or a dash while there is nothing measured.
-float number(gfx::DrawList & list, const ui::Fonts & f, bool known, const char * format, double v, float x, float y,
- float size, Color c, gfx::Align a = gfx::Align::left) {
- char text[32];
- if (known) {
- std::snprintf(text, sizeof(text), format, v);
- } else {
- std::snprintf(text, sizeof(text), "%s", kDash);
- }
- return ui::text(list, f.mono, text, x, y, size, known ? c : c.with_alpha(kFaint), a);
-}
+void Dashboard::draw(DashboardFrame & frame) const {
+ frame.backdrop.mode = gfx::BackdropMode::gradient;
+ frame.backdrop.colors[0] = Color::rgb(0x151618);
+ frame.backdrop.colors[1] = kBase;
+ frame.backdrop.colors[2] = kBase;
+ frame.backdrop.time = clock_;
-// A filled history chart, newest on the right, scaled to `top`.
-void history(gfx::DrawList & list, const std::vector<float> & v, const Rect & g, float top, Color c, float t) {
- const float base = g.y + g.h;
- list.rounded_rect({ g.x, base - 1.0f, g.w, 2.0f }, 1, kInk.with_alpha(0.22f));
- if (v.size() < 2) {
- list.rounded_rect({ g.x, base - 1.5f, g.w, 3.0f }, 1.5f, c.with_alpha(0.45f));
- return;
+ gfx::DrawList & scene = frame.scene;
+ // A page fades in and settles from a little below, the way a card rises
+ // out of a car's dock.
+ const float in = tween::cubic_out(tween::clamp01(page_age_ / 0.32f));
+ scene.push_transform(1.0f, 960, 540, 0, 18.0f * (1.0f - in));
+ scene.push_opacity(in);
+ switch (page_) {
+ case kHomePage: draw_home(scene); break;
+ case kModelsPage: draw_models(scene); break;
+ case kApiPage: draw_api(scene); break;
+ default: draw_settings(scene); break;
}
- const float grow = rise(t, 0, 0.0f, 0.9f);
- const float step = g.w / 119.0f;
- float lx = 0, ly = 0;
- for (size_t age = 0; age < v.size(); ++age) {
- const float value = v[v.size() - 1 - age];
- const float x = g.x + g.w - (float) age * step;
- const float y = base - tween::clamp01(value / top) * g.h * grow;
- list.gradient_rect({ x - step * 0.5f, y, step, base - y }, 0, c.with_alpha(0.5f * (base - y) / g.h),
- c.with_alpha(0.0f));
- if (age > 0) {
- list.line(lx, ly, x, y, 2.5f, c);
- }
- lx = x;
- ly = y;
+ scene.pop_opacity();
+ scene.pop_transform();
+ draw_status(scene);
+ draw_dock(scene);
+ draw_hints(scene);
+ draw_dialogs(frame.overlay);
+ if (busy()) {
+ draw_busy(frame.overlay);
}
- const float newest = base - tween::clamp01(v.back() / top) * g.h * grow;
- list.circle(g.x + g.w, newest, 6, c);
- list.circle(g.x + g.w, newest, 3, kPanelBottom);
-}
-
-void bar(gfx::DrawList & list, const Rect & r, float share, Color c) {
- list.rounded_rect(r, r.h * 0.5f, kInk.with_alpha(0.1f));
- list.rounded_rect({ r.x, r.y, std::max(r.h, r.w * tween::clamp01(share)), r.h }, r.h * 0.5f, c);
-}
-
-void draw_panel(gfx::DrawList & list, const Rect & r, float radius, float lit, Color accent) {
- list.gradient_rect(r, radius, gfx::mix(kPanelTop, accent, 0.05f * lit).with_alpha(0.9f),
- gfx::mix(kPanelBottom, accent, 0.02f * lit).with_alpha(0.92f));
- list.bordered_rect(r, radius, kClear, 1.5f, gfx::mix(kInk.with_alpha(0.09f), accent.with_alpha(0.5f), lit));
}
-std::string gib(double v) {
- char t[24];
- std::snprintf(t, sizeof(t), "%.1f", v);
- return t;
+void Dashboard::draw_status(gfx::DrawList & l) const {
+ const ui::Fonts & f = fonts_;
+ const float y = 72;
+ float w = put(l, f.semibold, "PS5", kLeft, y, 28, kInk);
+ put(l, f.semibold, "LM", kLeft + w, y, 28, kBlue);
+ // Right to left: how long it has been up, power, temperature.
+ std::vector<std::string> items;
+ if (live_.soc_temp > -100) {
+ items.push_back(format("%.0f\xC2\xB0" "C", live_.soc_temp));
+ }
+ if (live_.soc_power_w > 0) {
+ items.push_back(format("%.0f W", live_.soc_power_w));
+ }
+ if (live_.uptime_s > 0) {
+ const double m = live_.uptime_s / 60.0;
+ items.push_back(m < 60 ? format("Up %.0f min", std::floor(m)) : format("Up %.1f h", m / 60.0));
+ }
+ float x = kRight;
+ for (auto it = items.rbegin(); it != items.rend(); ++it) {
+ x -= put(l, f.regular, *it, x, y, 22, kInk2, gfx::Align::right) + 40;
+ }
+ put(l, f.regular, "v" PS5LM_VERSION, x, y, 22, kInk3, gfx::Align::right);
}
-// "2.1 of 10.4 GiB · 3.8 MB/s · 37 min left", or the note of one that waits.
-std::string download_line(const Download & d) {
- char t[200];
- const double done = d.done / 1073741824.0, all = d.bytes / 1073741824.0;
- if (d.state == DownloadState::running && d.mbps > 0.05) {
- const double left_s = (double) (d.bytes - std::min(d.done, d.bytes)) / (d.mbps * 1e6);
- if (left_s >= 3600) {
- std::snprintf(t, sizeof(t), "%.1f of %.1f GiB \xC2\xB7 %.1f MB/s \xC2\xB7 %.0f h %02.0f min left", done, all,
- d.mbps, std::floor(left_s / 3600), std::fmod(left_s / 60, 60));
- } else {
- std::snprintf(t, sizeof(t), "%.1f of %.1f GiB \xC2\xB7 %.1f MB/s \xC2\xB7 %.0f min left", done, all, d.mbps,
- std::ceil(left_s / 60));
- }
- return t;
- }
- std::snprintf(t, sizeof(t), "%.1f of %.1f GiB", done, all);
- if (d.state == DownloadState::running) {
- return std::string(t) + " \xC2\xB7 starting";
- }
- if (!d.note.empty() && d.state != DownloadState::done) {
- return std::string(t) + " \xC2\xB7 " + d.note;
- }
- return d.state == DownloadState::done ? d.note : d.state == DownloadState::queued ? std::string(t) + " \xC2\xB7 waiting its turn" : t;
+void Dashboard::draw_dock(gfx::DrawList & l) const {
+ const ui::Fonts & f = fonts_;
+ l.line(kLeft, kDockY, kRight, kDockY, 1.5f, kHair);
+ constexpr float pitch = 168;
+ for (int i = 0; i < kPages; ++i) {
+ const float cx = kLeft + 44 + pitch * (float) i;
+ const float lit = tween::clamp01(1.0f - std::fabs(dock_x_.value - (float) i));
+ const Color c = gfx::mix(kInk3, kInk, lit);
+ icon(l, i, cx, 1004, c);
+ put(l, f.regular, kPageNames[i], cx, 1056, 20, c, gfx::Align::center);
+ }
+ // The current tab's marker slides between them.
+ const float mx = kLeft + 44 + pitch * dock_x_.value;
+ l.rounded_rect({ mx - 18, 1068, 36, 4 }, 2, kBlue);
}
-} // namespace
-
-// ---- tiles ------------------------------------------------------------------------
-
-void Dashboard::draw_content(gfx::DrawList & list, int tile, const Rect & r, float t) const {
- const ui::Fonts & f = fonts_;
- const Live & L = live_;
- const bool serving = L.state == ServerState::ready || L.state == ServerState::generating;
- const float up = rise(t, 0, 0.0f, 0.9f);
- char text[96];
-
- switch (tile) {
- case kSpeed: {
- float peak = 1, sum = 0, mn = 1e9f;
- int n = 0;
- for (float v : L.gen_history) {
- if (v > 0) {
- peak = std::max(peak, v);
- mn = std::min(mn, v);
- sum += v;
- n++;
- }
- }
- // Idle, the big figure keeps the last generation's speed.
- float shown = L.gen_tps;
- for (auto it = L.gen_history.rbegin(); shown <= 0 && it != L.gen_history.rend(); ++it) {
- shown = *it;
- }
- caps(list, f, "TOK/S", r.x + r.w - kPad, r.y + 84, 17, kInk.with_alpha(kMuted), gfx::Align::right);
- number(list, f, serving && shown > 0, "%.1f", shown * up, r.x + r.w - kPad - 76, r.y + 84, 64,
- L.state == ServerState::generating ? kInk : kInk.with_alpha(0.8f), gfx::Align::right);
- if (L.state == ServerState::loading) {
- const float p = std::max(0.0f, L.load_progress);
- std::snprintf(text, sizeof(text), "Loading the model onto the GPU \xC2\xB7 %.0f%%", p * 100.0f);
- const Rect lb{ r.x + kPad, r.y + 196, r.w - 2 * kPad, 14 };
- list.rounded_rect(lb, 7, kInk.with_alpha(0.08f));
- // A bright sheen runs along the filled part while it grows.
- const float w = std::max(14.0f, lb.w * p);
- list.rounded_rect({ lb.x, lb.y, w, lb.h }, 7, kCyan);
- const float sheen = std::fmod(clock_ * 0.6f, 1.0f);
- list.glow({ lb.x + w * sheen - 20, lb.y, 40, lb.h }, 7, 16, kInk.with_alpha(0.35f));
- std::snprintf(size_text_, sizeof(size_text_), "%.1f of %.1f GiB on the GPU", p * (L.model_gib + L.kv_gib),
- L.model_gib + L.kv_gib);
- ui::text(list, f.regular, size_text_, r.x + kPad, r.y + 250, 20, kInk.with_alpha(kFaint));
- } else if (!serving) {
- std::snprintf(text, sizeof(text), "%s", "Not serving");
- } else if (L.state == ServerState::generating) {
- std::snprintf(text, sizeof(text), "Generating now");
- } else if (n == 0) {
- std::snprintf(text, sizeof(text), "Waiting for the first prompt");
- } else {
- std::snprintf(text, sizeof(text), "Idle, %llu tokens so far", (unsigned long long) L.tokens);
- }
- ui::text(list, f.regular, text, r.x + kPad, r.y + 84, 22, kInk.with_alpha(kMuted));
- if (L.state != ServerState::loading) {
- history(list, L.gen_history, { r.x + kPad, r.y + 116, r.w - 2 * kPad, 186 }, peak * 1.2f, kCyan, t);
- }
- const char * names[] = { "MIN", "AVG", "MAX" };
- const float vals[] = { n ? mn : 0, n ? sum / n : 0, n ? peak : 0 };
- for (int k = 0; k < 3; ++k) {
- const float x = r.x + kPad + k * 170.0f;
- caps(list, f, names[k], x, r.y + 352, 15, kInk.with_alpha(kMuted));
- number(list, f, n > 0, "%.1f", vals[k], x + 56, r.y + 354, 26, kInk);
- }
- const float uw = ui::text(list, f.regular, "tok/s", r.x + r.w - kPad, r.y + 353, 20, kInk.with_alpha(kFaint),
- gfx::Align::right);
- const float pw = number(list, f, L.prompt_tps > 0, "%.0f", L.prompt_tps, r.x + r.w - kPad - uw - 10, r.y + 354, 26,
- kInk, gfx::Align::right);
- caps(list, f, "PROMPT", r.x + r.w - kPad - uw - pw - 26, r.y + 352, 15, kInk.with_alpha(kMuted), gfx::Align::right);
- break;
- }
- case kUsage: {
- // The GPU and the CPU side by side over one chart: cyan the GPU,
- // lime the app's CPUs.
- const float half = (r.w - 2 * kPad) * 0.5f;
- caps(list, f, "GPU", r.x + kPad, r.y + 86, 15, kCyan);
- caps(list, f, "CPU", r.x + kPad + half, r.y + 86, 15, kLime);
- float w = number(list, f, serving, "%.0f", L.gpu_busy * 100.0f * up, r.x + kPad, r.y + 140, 52, kInk);
- ui::text(list, f.regular, "%", r.x + kPad + w + 6, r.y + 140, 22, kInk.with_alpha(kMuted));
- w = number(list, f, true, "%.0f", L.cpu_use * 100.0f * up, r.x + kPad + half, r.y + 140, 52, kInk);
- ui::text(list, f.regular, "%", r.x + kPad + half + w + 6, r.y + 140, 22, kInk.with_alpha(kMuted));
- const Rect g{ r.x + kPad, r.y + 170, r.w - 2 * kPad, 110 };
- history(list, L.cpu_history, g, 1.0f, kLime, t);
- history(list, L.gpu_history, g, 1.0f, kCyan, t);
- list.rounded_rect({ r.x + kPad, r.y + 300, r.w - 2 * kPad, 1 }, 0, kInk.with_alpha(0.1f));
- caps(list, f, "CLOCK", r.x + kPad, r.y + 338, 15, kInk.with_alpha(kMuted));
- std::snprintf(text, sizeof(text), "%d CPUs, %.1f GHz", L.cpus, L.cpu_ghz);
- ui::text(list, f.mono, L.cpu_ghz > 0 ? text : kDash, r.x + r.w - kPad, r.y + 340, 22, kInk, gfx::Align::right);
- break;
- }
- case kPower: {
- const bool known = L.soc_power_w > 0;
- const float pw = number(list, f, known, "%.0f", L.soc_power_w * up, r.x + kPad, r.y + 118, 60, kInk);
- ui::text(list, f.regular, "W, the SoC", r.x + kPad + pw + 10, r.y + 118, 22, kInk.with_alpha(kMuted));
- if (known && L.state == ServerState::generating && L.gen_tps > 0) {
- std::snprintf(text, sizeof(text), "%.1f J per token", L.soc_power_w / L.gen_tps);
- } else if (known) {
- std::snprintf(text, sizeof(text), "CPU, GPU and memory together");
- } else {
- std::snprintf(text, sizeof(text), "Load ps5-exporter to read it");
- }
- ui::text(list, f.regular, text, r.x + kPad, r.y + 152, 20, kInk.with_alpha(kFaint));
- float peak = 60;
- for (float v : L.power_history) {
- peak = std::max(peak, v);
- }
- history(list, L.power_history, { r.x + kPad, r.y + 186, r.w - 2 * kPad, 90 }, peak * 1.15f,
- Color::rgb(0xffd166), t);
- list.rounded_rect({ r.x + kPad, r.y + 300, r.w - 2 * kPad, 1 }, 0, kInk.with_alpha(0.1f));
- caps(list, f, "THIS SESSION", r.x + kPad, r.y + 338, 15, kInk.with_alpha(kMuted));
- number(list, f, L.energy_wh > 0, "%.2f Wh", L.energy_wh, r.x + r.w - kPad, r.y + 340, 22, kInk, gfx::Align::right);
- break;
- }
- case kMemory: {
- // One pool: the GPU and the CPU share the title's direct memory.
- // Each part is capped at what is in use, so a model still loading
- // never pushes the bar past the pool.
- const bool known = L.pool_gib > 0;
- const double used = std::max(0.0, L.pool_gib - L.free_gib);
- const double model = std::min(L.model_gib, used);
- const double kv = std::min(L.kv_gib, used - model);
- const double other = used - model - kv;
- const double parts[4] = { model, kv, other, L.free_gib };
- const char * names[4] = { "Model", "KV cache", "Other", "Free" };
- const Color colors[4] = { kAmber, Color::rgb(0xffe2a0), Color::rgb(0xb48cff), kInk.with_alpha(0.16f) };
- std::snprintf(text, sizeof(text), "of %s GiB, GPU and CPU", gib(L.pool_gib).c_str());
- const float w = f.regular.measure(text, 22);
- ui::text(list, f.regular, text, r.x + r.w - kPad, r.y + 50, 22, kInk.with_alpha(kMuted), gfx::Align::right);
- const float uw = number(list, f, known, "%.1f", used * up, r.x + r.w - kPad - w - 12, r.y + 50, 34, kInk,
- gfx::Align::right);
- number(list, f, known, "%.0f%%", (known ? used / L.pool_gib * 100.0 : 0.0) * up,
- r.x + r.w - kPad - w - uw - 34, r.y + 50, 34, kAmber, gfx::Align::right);
- const Rect b{ r.x + kPad, r.y + 76, r.w - 2 * kPad, 28 };
- list.rounded_rect(b, 10, kInk.with_alpha(0.05f));
- float x = b.x;
- for (int k = 0; k < 4 && known; ++k) {
- const float full = b.w * (float) (parts[k] / L.pool_gib);
- const float seg = std::max(0.0f, full * rise(t, k, 0.16f, 0.5f) - 4.0f);
- if (seg > 1.0f) {
- list.rounded_rect({ x, b.y, seg, b.h }, 10, colors[k]);
- }
- x += full * rise(t, k, 0.16f, 0.5f);
- }
- x = r.x + kPad;
- for (int k = 0; k < 4; ++k) {
- list.circle(x + 7, r.y + 143, 7, k == 3 ? kInk.with_alpha(0.45f) : colors[k]);
- x += 24;
- x += ui::text(list, f.regular, names[k], x, r.y + 150, 20, kInk.with_alpha(0.85f));
- x += 10 + ui::text(list, f.mono, gib(parts[k]), x + 10, r.y + 150, 20, kInk.with_alpha(kMuted));
- x += 36;
- }
- break;
- }
- case kContext: {
- const int s = (int) L.uptime_s;
- if (L.ctx == 0) {
- ui::text(list, f.regular, "No model loaded", r.x + kPad, r.y + 104, 26, kInk.with_alpha(kFaint));
- } else {
- const float share = (float) L.ctx_used / (float) L.ctx;
- const float w = number(list, f, true, "%.0f", (double) L.ctx_used, r.x + kPad, r.y + 104, 40, kInk);
- std::snprintf(text, sizeof(text), "of %uk tokens", L.ctx / 1024);
- ui::text(list, f.regular, text, r.x + kPad + w + 12, r.y + 104, 22, kInk.with_alpha(kMuted));
- bar(list, { r.x + kPad, r.y + 126, r.w - 2 * kPad, 10 }, share * up, kBrand);
- }
- char up_text[16];
- std::snprintf(up_text, sizeof(up_text), "%02d:%02d:%02d", s / 3600 % 100, s / 60 % 60, s % 60);
- ui::text(list, f.mono, up_text, r.x + r.w - kPad, r.y + kLabelY, 18, kInk.with_alpha(kMuted), gfx::Align::right);
- std::snprintf(text, sizeof(text), "%llu out \xC2\xB7 %llu in \xC2\xB7 %llu replies",
- (unsigned long long) L.tokens, (unsigned long long) L.prompt_tokens,
- (unsigned long long) L.requests);
- ui::text(list, f.regular, f.regular.font->fit(text, 18, r.w - 2 * kPad), r.x + kPad, r.y + 164, 18,
- kInk.with_alpha(kMuted));
- break;
- }
- case kStorage: {
- // Internal storage and the first two drives; no drive shows as such.
- const size_t n = std::min<size_t>(L.drives.size(), 3);
- for (size_t k = 0; k < n; ++k) {
- const Drive & d = L.drives[k];
- const float y = n > 2 ? r.y + 80 + (float) k * 40.0f : r.y + 92 + (float) k * 52.0f; // three fit tighter
- caps(list, f, d.name.substr(0, d.name.find(' ')), r.x + kPad, y, 15, kInk.with_alpha(kMuted));
- if (d.total <= 0) {
- ui::text(list, f.regular, kDash, r.x + r.w - kPad, y, 20, kInk.with_alpha(kFaint), gfx::Align::right);
- continue;
- }
- std::snprintf(text, sizeof(text), "%.0f GiB free", d.free);
- ui::text(list, f.mono, text, r.x + r.w - kPad, y, 20, kInk, gfx::Align::right);
- bar(list, { r.x + kPad, y + 14, r.w - 2 * kPad, 8 }, (float) ((d.total - d.free) / d.total) * up, kRose);
- }
- if (n == 1) {
- caps(list, f, "USB / M.2", r.x + kPad, r.y + 144, 15, kInk.with_alpha(kMuted));
- ui::text(list, f.regular, "No drive", r.x + r.w - kPad, r.y + 144, 20, kInk.with_alpha(kFaint), gfx::Align::right);
+void Dashboard::draw_hints(gfx::DrawList & l) const {
+ ui::GlyphStyle style = ui::GlyphStyle::dark();
+ style.label = kInk2;
+ ui::HintLayout layout;
+ layout.size = 32;
+ layout.text_size = 20;
+ layout.cy = 1018;
+ layout.item_gap = 36;
+ std::vector<ui::Hint> h;
+ if (market_confirm_ || market_space_) {
+ 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" } };
+ } else if (page_ == kModelsPage) {
+ if (!in_list_) {
+ h = { { ui::Button::dpad, "Choose" }, { ui::Button::cross, "Open" } };
+ } else if (section_ == kLocal) {
+ const ModelRow * m = local_cursor_ < (int) live_.models.size() ? &live_.models[(size_t) local_cursor_] : nullptr;
+ h = { { ui::Button::circle, "Back" } };
+ if (m && (m->current || m->fits)) {
+ h.push_back({ ui::Button::cross, m->current ? "Unload" : "Load" });
}
- break;
- }
- case kThermals: {
- const bool known = L.soc_temp > -100;
- const float tw = number(list, f, known, "%.0f", L.soc_temp, r.x + kPad, r.y + 118, 60, kInk);
- ui::text(list, f.regular, "\xC2\xB0" "C, the SoC", r.x + kPad + tw + 10, r.y + 118, 22, kInk.with_alpha(kMuted));
- if (L.cpu_temp > -100 && L.fan >= 0) {
- std::snprintf(text, sizeof(text), "CPU %.0f \xC2\xB0" "C \xC2\xB7 fan %.0f%%", L.cpu_temp, L.fan * 100.0f);
- } else if (L.cpu_temp > -100) {
- std::snprintf(text, sizeof(text), "CPU %.0f \xC2\xB0" "C", L.cpu_temp);
- } else if (!L.sensors_from_exporter) {
- std::snprintf(text, sizeof(text), "Load ps5-exporter to read them");
- } else {
- std::snprintf(text, sizeof(text), "No sensor answered");
- }
- ui::text(list, f.regular, text, r.x + kPad, r.y + 152, 20, kInk.with_alpha(kFaint));
- history(list, L.temp_history, { r.x + kPad, r.y + 186, r.w - 2 * kPad, 90 }, 100.0f, kHeat, t);
- list.rounded_rect({ r.x + kPad, r.y + 300, r.w - 2 * kPad, 1 }, 0, kInk.with_alpha(0.1f));
- // The hottest sensor, so a hot spot shows without opening POWER.
- const std::pair<std::string, float> * hot = nullptr;
- for (const auto & tp : L.temps) {
- if (!hot || tp.second > hot->second) {
- hot = &tp;
+ } else if (section_ == kSuggested) {
+ h = { { ui::Button::circle, "Back" }, { ui::Button::cross, "Download" } };
+ } else if (section_ == kSearch) {
+ h = market_files_ ? std::vector<ui::Hint>{ { ui::Button::circle, "Back" }, { ui::Button::square, "Check fit" },
+ { ui::Button::cross, "Download" } }
+ : std::vector<ui::Hint>{ { ui::Button::l2, "Search", ui::Button::r2 }, { ui::Button::circle, "Back" },
+ { ui::Button::cross, "Open" } };
+ } else {
+ const Download * d = dl_cursor_ < (int) market_.downloads.size() ? &market_.downloads[(size_t) dl_cursor_] : nullptr;
+ h = { { ui::Button::circle, "Back" } };
+ if (d) {
+ const bool runs = d->state == DownloadState::running || d->state == DownloadState::retrying ||
+ d->state == DownloadState::queued;
+ h.push_back({ ui::Button::square, d->state == DownloadState::done ? "Clear" : dl_confirm_ == dl_cursor_ ? "Yes, delete it" : "Cancel" });
+ if (d->state != DownloadState::done) {
+ h.push_back({ ui::Button::cross, runs ? "Pause" : d->state == DownloadState::failed ? "Try again" : "Resume" });
}
}
- caps(list, f, "HOTTEST", r.x + kPad, r.y + 338, 15, kInk.with_alpha(kMuted));
- if (hot) {
- const std::string who = hot->first == "cpu" ? std::string("CPU") : "SoC " + hot->first.substr(3);
- std::snprintf(text, sizeof(text), "%s, %.0f \xC2\xB0" "C", who.c_str(), hot->second);
- }
- ui::text(list, f.mono, hot ? text : kDash, r.x + r.w - kPad, r.y + 340, 22, kInk, gfx::Align::right);
- break;
}
- default: { // kModel
- const float width = r.w - 2 * kPad;
- if (L.model_label.empty()) {
- ui::text(list, f.semibold, "No model loaded", r.x + kPad, r.y + 104, 34, kInk);
- ui::text(list, f.regular, "Cross opens the library", r.x + kPad, r.y + 138, 20, kInk.with_alpha(kMuted));
- std::snprintf(text, sizeof(text), "%zu found", L.models.size());
- ui::text(list, f.regular, text, r.x + kPad, r.y + 352, 20, kInk.with_alpha(kFaint));
- break;
- }
- const std::string name = L.model_label.empty() ? std::string("No model") : L.model_label;
- ui::text(list, f.semibold, f.semibold.font->fit(L.preset.empty() ? name : L.preset, 34, width), r.x + kPad,
- r.y + 104, 34, kInk);
- ui::text(list, f.regular, f.regular.font->fit(name, 20, width), r.x + kPad, r.y + 138, 20,
- kInk.with_alpha(kMuted));
- const std::string rows[3][2] = {
- { "SIZE", gib(L.model_gib) + " GiB" },
- { "CONTEXT", L.ctx ? std::to_string(L.ctx / 1024) + "k, " + L.kv_type : std::string(kDash) },
- { "ARCH", L.model_arch.empty() ? std::string(kDash) : L.model_arch },
- };
- for (int k = 0; k < 3; ++k) {
- const float y = r.y + 196 + k * 46.0f;
- caps(list, f, rows[k][0], r.x + kPad, y, 15, kInk.with_alpha(kMuted));
- ui::text(list, f.mono, rows[k][1], r.x + r.w - kPad, y + 2, 22, kInk, gfx::Align::right);
- }
- std::snprintf(text, sizeof(text), "%zu found", L.models.size());
- ui::text(list, f.regular, text, r.x + kPad, r.y + 352, 20, kInk.with_alpha(kFaint));
- break;
+ } else if (page_ == kApiPage) {
+ h = { { ui::Button::l1, "Pages", ui::Button::r1 } };
+ } else if (!in_rows_) {
+ h = { { ui::Button::dpad, "Choose" }, { ui::Button::cross, "Open" } };
+ } else if (setting_category_ == kDiagnostics) {
+ h = { { ui::Button::dpad, "Scroll" }, { ui::Button::square, log_llama_ ? "App log" : "Server log" },
+ { ui::Button::triangle, log_errors_ ? "All lines" : "Errors only" } };
+ } else {
+ const Setting id = kCategories[setting_category_].rows[setting_row_].id;
+ if (id == Setting::clear_scratch) {
+ h = { { ui::Button::circle, "Back" }, { ui::Button::cross, "Clear" } };
+ } 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" } };
}
}
+ ui::draw_hints(l, fonts_, style, h.data(), (int) h.size(), kRight, true, layout);
}
-void Dashboard::draw_tile(gfx::DrawList & list, int tile) const {
- const float in = tween::stagger(age_, tile, 0.06f, 0.5f);
- const float lift = lift_[tile].value;
- const Color accent = accent_of(tile);
- Rect r = tile_rect(tile);
- r.y += 28.0f * (1.0f - in);
- float dx = 0, dy = 0;
- if (tile == focus_ && !library_open_) {
- const float nudge = ui::shake(refusal_.value, clock_, 10.0f, 9.0f);
- dx = nudge * refusal_x_;
- dy = nudge * refusal_y_;
- }
- list.push_opacity(in);
- list.push_transform(1.0f + kLift * lift, r.cx(), r.cy(), dx, dy);
- if (lift > 0.01f) {
- list.shadow({ r.x, r.y + 16, r.w, r.h }, kRadius, 38, kBlack.with_alpha(0.5f * lift));
- list.glow(r, kRadius, 26, accent.with_alpha((0.16f + 0.1f * ui::breathe(clock_)) * lift));
- }
- draw_panel(list, r, kRadius, lift, accent);
- caps(list, fonts_, kSpec[tile].label, r.x + kPad, r.y + kLabelY, kLabelSize, accent);
- draw_content(list, tile, r, age_ - 0.25f - 0.06f * tile);
- list.pop_transform();
- list.pop_opacity();
-}
-
-void Dashboard::draw_header(gfx::DrawList & list) const {
- const float in = tween::stagger(age_, 0, 0.05f, 0.5f);
- list.push_opacity(in);
- const float y = 124 - 10.0f * (1.0f - in);
- float w = ui::text(list, fonts_.display, "PS5", kGridX - 3, y, 56, kInk);
- w += ui::text(list, fonts_.display, "LM", kGridX - 3 + w, y, 56, kBrand);
- std::string sub = "v" PS5LM_VERSION " \xC2\xB7 " + live_.address;
- ui::text(list, fonts_.regular, sub, kGridX + w + 24, y, 24, kInk.with_alpha(kMuted));
-
- const char * word = state_word(live_.state);
- const Color dot = state_color(live_.state);
- const float chip_w = 70.0f + fonts_.semibold.measure(word, 17) + 3.0f * (float) std::char_traits<char>::length(word);
- const Rect chip{ kGridX + kGridW - chip_w, 82, chip_w, 48 };
- list.bordered_rect(chip, 24, kPanelTop.with_alpha(0.9f), 1.5f, dot.with_alpha(0.4f));
- const float beat = live_.state == ServerState::loading || live_.state == ServerState::generating ? ui::breathe(clock_, 1.2f) : 0.6f;
- list.glow({ chip.x + 20, chip.cy() - 7, 14, 14 }, 7, 12, dot.with_alpha(0.7f * beat));
- list.circle(chip.x + 27, chip.cy(), 7, dot);
- caps(list, fonts_, word, chip.x + 48, chip.cy() + 6, 17, kInk);
- list.pop_opacity();
-}
+// ---- drawing: Home -------------------------------------------------------------------
-void Dashboard::draw_library(gfx::DrawList & list, std::uint32_t glass) const {
- const float t = library_.value;
- if (t <= 0.01f) {
- return;
- }
+void Dashboard::draw_home(gfx::DrawList & l) const {
const ui::Fonts & f = fonts_;
- Rect panel = kLibrary;
- panel.y += 30.0f * (1.0f - t);
- list.push_opacity(t);
- list.shadow({ panel.x, panel.y + 20, panel.w, panel.h }, 40, 50, kBlack.with_alpha(0.55f));
- if (glass) {
- list.glass(glass, panel, 40, Color::rgb(0xffffff));
- }
- draw_panel(list, panel, 40, 1.0f, kLime);
- caps(list, f, "MODEL LIBRARY", panel.x + 56, panel.y + 60, 20, kLime);
- ui::text(list, f.regular,
- f.regular.font->fit("Settings fit the memory free now. Models go in /data/PS5LM/models, or PS5LM/models on USB.",
- 20, panel.w - 112),
- panel.x + 56, panel.y + 98, 20, kInk.with_alpha(kMuted));
-
- const float top = panel.y + 132;
- const int rows = (int) live_.models.size();
- if (rows == 0) {
- ui::text(list, f.regular, "No models found yet", panel.cx(), panel.cy(), 26, kInk.with_alpha(kFaint), gfx::Align::center);
- }
- // Eight lines show, section headers included; the list scrolls to keep
- // the cursor among them.
- const int first = rows > 0 ? std::max(0, slot(library_cursor_) - 7) : 0;
- const Rect hl{ panel.x + 36, top + (cursor_y_.value - (float) first) * kRowH, panel.w - 72, kRowH - 8 };
- if (rows > 0) {
- list.glow(hl, 18, 18, kLime.with_alpha(0.25f));
- list.bordered_rect(hl, 18, kLime.with_alpha(0.1f), 2.0f, kLime.with_alpha(0.7f));
- }
- for (int i = 0; i < rows; ++i) {
- const ModelRow & m = live_.models[(size_t) i];
- const int s = slot(i);
- if (i == 0 || m.drive != live_.models[(size_t) i - 1].drive) {
- const int h = s - 1;
- if (h >= first && h < first + 8) {
- const float hy = top + (float) (h - first) * kRowH;
- std::string head = m.drive.empty() ? "OTHER" : m.drive;
- for (char & c : head) {
- c = (char) std::toupper((unsigned char) c);
+ const bool loaded = !live_.model_label.empty();
+ const bool decision = !live_.decision.empty();
+
+ // Left: the model.
+ if (!loaded || live_.state == ServerState::no_model) {
+ put(l, f.regular, "Nothing is loaded", kLeft, 260, 26, kInk2);
+ put(l, f.regular, "Choose a model", kLeft, 340, 64, kInk);
+ put(l, f.regular, "It runs on the PS5's GPU and answers every device on your network.", kLeft, 400, 24, kInk2);
+ put(l, f.regular, format("%.0f models on this PS5", (double) live_.models.size()), kLeft, 444, 24, kInk3);
+ } else {
+ std::string name, build;
+ split_name(live_.model_label, &name, &build);
+ put(l, f.regular, decision ? "Decision model" : "Language model", kLeft, 250, 26, kInk2);
+ put(l, f.regular, f.regular.font->fit(name, 64, 860), kLeft, 326, 64, kInk);
+ std::string detail = build;
+ if (live_.ctx > 0) {
+ detail += (detail.empty() ? "" : " ") + format("%.0fk context", live_.ctx / 1024.0);
+ }
+ detail += (detail.empty() ? "" : " ") + gb(live_.model_gib);
+ put(l, f.regular, detail, kLeft, 372, 24, kInk3);
+
+ // The state, as a car shows its gear: one word, coloured only when it matters.
+ const char * word = live_.state == ServerState::loading ? "Loading"
+ : live_.state == ServerState::generating ? (decision ? "Deciding" : "Generating")
+ : live_.state == ServerState::failed ? "Stopped" : "Ready";
+ const Color dot = live_.state == ServerState::failed ? kRed
+ : live_.state == ServerState::generating ? kBlue
+ : live_.state == ServerState::loading ? kInk2.with_alpha(0.5f + 0.5f * std::sin(clock_ * 4.0f)) : kGreen;
+ l.circle(kLeft + 7, 432, 7, dot);
+ put(l, f.regular, word, kLeft + 26, 441, 26, kInk);
+
+ // The large number: speed while serving, progress while loading.
+ float big = 0;
+ std::string unit;
+ bool known = true;
+ if (live_.state == ServerState::loading) {
+ big = std::max(0.0f, live_.load_progress) * 100.0f;
+ unit = "% on the GPU";
+ } else if (decision) {
+ big = hero_.value;
+ unit = "tokens read per second";
+ known = live_.prompt_tps > 0;
+ } else {
+ big = hero_.value;
+ unit = "tokens per second";
+ known = live_.gen_tps > 0;
+ if (!known) {
+ // Idle: the last reply's speed, quieter.
+ for (auto it = live_.gen_history.rbegin(); it != live_.gen_history.rend(); ++it) {
+ if (*it > 0) {
+ big = *it;
+ unit = "tokens per second, last reply";
+ known = true;
+ break;
+ }
}
- const bool internal = m.drive.rfind("Internal", 0) == 0;
- caps(list, f, head, panel.x + 60, hy + 50, 16, internal ? kCyan : kAmber);
- list.rounded_rect({ panel.x + 60, hy + 62, panel.w - 120, 1 }, 0, kInk.with_alpha(0.12f));
}
}
- if (s < first || s >= first + 8) {
- continue;
- }
- const float y = top + (float) (s - first) * kRowH;
- const float ink = m.fits ? 1.0f : 0.45f;
- ui::text(list, f.semibold, f.semibold.font->fit(m.label, 24, 620), panel.x + 60, y + 32, 24, kInk.with_alpha(ink));
- std::string sub = m.plan;
- if (!m.preset.empty()) {
- sub = m.preset + " preset \xC2\xB7 " + sub;
- }
- ui::text(list, f.regular, f.regular.font->fit(sub, 18, 700), panel.x + 60, y + 58, 18, kInk.with_alpha(kMuted * ink));
- char size[24];
- std::snprintf(size, sizeof(size), "%.1f GiB", m.size_gib);
- ui::text(list, f.mono, size, panel.x + panel.w - 260, y + 44, 22, kInk.with_alpha(ink), gfx::Align::right);
- const char * tag = m.current ? "LOADED" : m.fits ? "LOAD" : "TOO BIG";
- const Color tc = m.current ? kCyan : m.fits ? kLime : kRose;
- caps(list, f, tag, panel.x + panel.w - 60, y + 44, 15, tc, gfx::Align::right);
- }
- list.pop_opacity();
+ const bool quiet = live_.state != ServerState::generating && live_.state != ServerState::loading;
+ const std::string number = !known ? kDash : big >= 100 || live_.state == ServerState::loading ? format("%.0f", big) : format("%.1f", big);
+ const float nw = put(l, f.display, number, kLeft - 8, 660, 232, quiet ? kInk2 : kInk);
+ put(l, f.regular, unit, kLeft + nw + 12, 660, 26, kInk2);
+
+ if (live_.state == ServerState::loading) {
+ meter(l, kLeft, 712, 860, live_.load_progress, kInk);
+ } else if (!decision) {
+ trace(l, live_.gen_history, { kLeft, 702, 860, 100 }, kInk.with_alpha(0.75f));
+ }
+
+ // Two quiet meters: what the model holds, and how much of its context is used.
+ const double used = live_.pool_gib - live_.free_gib;
+ const float my = 868;
+ put(l, f.regular, "Memory", kLeft, my, 22, kInk2);
+ put(l, f.regular, format("%.1f", used) + " of " + gb(live_.pool_gib), kLeft + 400, my, 22, kInk,
+ gfx::Align::right);
+ meter(l, kLeft, my + 16, 400, live_.pool_gib > 0 ? (float) (used / live_.pool_gib) : 0, kInk.with_alpha(0.8f));
+ put(l, f.regular, "Context", kLeft + 460, my, 22, kInk2);
+ put(l, f.regular, thousands(live_.ctx_used) + " of " + format("%.0fk", live_.ctx / 1024.0), kLeft + 860, my, 22, kInk,
+ gfx::Align::right);
+ meter(l, kLeft + 460, my + 16, 400, live_.ctx > 0 ? (float) live_.ctx_used / (float) live_.ctx : 0, kInk.with_alpha(0.8f));
+ }
+
+ // Right: where the model is reached. A single panel, as a car gives the map.
+ const Rect p{ 1056, 196, kRight - 1056, 728 };
+ l.rounded_rect(p, 24, kSurface);
+ const float x = p.x + 56;
+ put(l, f.regular, "On your network", x, p.y + 76, 24, kInk2);
+ const std::string url = live_.address.empty() ? std::string("Not connected") : "http://" + live_.address;
+ put(l, f.regular, f.regular.font->fit(url, 44, p.w - 112), x, p.y + 136, 44, live_.address.empty() ? kInk3 : kInk);
+ const bool serving = loaded && (live_.state == ServerState::ready || live_.state == ServerState::generating);
+ put(l, f.regular,
+ !loaded ? "Load a model and it answers here"
+ : decision ? "Answers the TypeSafe decision API"
+ : "Answers the OpenAI and Anthropic APIs, and a chat page",
+ x, p.y + 184, 24, kInk2);
+
+ struct Ep { const char * method; const char * path; };
+ const Ep chat[] = { { "POST", "/v1/chat/completions" }, { "POST", "/v1/messages" }, { "GET", "/v1/models" } };
+ const Ep dec[] = { { "POST", "/v1/systemone" }, { "GET", "/v1/models" } };
+ const Ep * eps = decision ? dec : chat;
+ const int n = decision ? 2 : 3;
+ for (int i = 0; i < n; ++i) {
+ const float y = p.y + 268 + 52.0f * (float) i;
+ const Color c = serving ? kInk : kInk3;
+ put(l, f.mono, eps[i].method, x, y, 24, kInk3);
+ put(l, f.mono, eps[i].path, x + 96, y, 24, c);
+ }
+
+ // What it has done since it started, like a trip meter.
+ l.line(x, p.y + 470, p.x + p.w - 56, p.y + 470, 1.5f, kHair);
+ struct Fig { std::string value; const char * label; };
+ const Fig figs[] = { { thousands(live_.requests), "requests" },
+ { thousands(live_.prompt_tokens), "tokens in" },
+ { thousands(live_.tokens), "tokens out" } };
+ const int figures = decision ? 2 : 3;
+ for (int i = 0; i < figures; ++i) {
+ const float fx = x + 230.0f * (float) i;
+ put(l, f.display, figs[i].value, fx - 2, p.y + 572, 60, loaded ? kInk : kInk3);
+ put(l, f.regular, figs[i].label, fx, p.y + 614, 22, kInk3);
+ }
+ put(l, f.regular, decision || !loaded ? "" : "Open the address in a browser to chat", x, p.y + 680, 22, kInk3);
}
-void Dashboard::open_library() {
- library_open_ = true;
- library_cursor_ = 0;
- for (int i = 0; i < (int) live_.models.size(); ++i) {
- if (live_.models[(size_t) i].current) {
- library_cursor_ = i;
- }
- }
- cursor_y_.snap((float) slot(library_cursor_));
-}
+// ---- drawing: Models ------------------------------------------------------------------
-// Rows come sorted by path, so they group by drive (/data, then /mnt/ext0,
-// /mnt/usb0...); each group gets a header line above it.
-int Dashboard::slot(int row) const {
- int s = row + 1;
- for (int i = 1; i <= row; ++i) {
- s += live_.models[(size_t) i].drive != live_.models[(size_t) i - 1].drive;
- }
- return s;
-}
-
-void Dashboard::draw_tabs(gfx::DrawList & list) const {
- // Left of the state chip: L1, the three page names, R1. The active name
- // is lit and underlined; the underline glides between names.
+void Dashboard::draw_models(gfx::DrawList & l) const {
const ui::Fonts & f = fonts_;
- const char * word = state_word(live_.state);
- const float chip_w = 70.0f + f.semibold.measure(word, 17) + 3.0f * (float) std::char_traits<char>::length(word);
- float x = kGridX + kGridW - chip_w - 40;
- const ui::GlyphStyle style = ui::GlyphStyle::dark();
- const float in = tween::stagger(age_, 1, 0.05f, 0.5f);
- list.push_opacity(in);
- x -= ui::button_width(ui::Button::r1, 26);
- ui::draw_button(list, f, style, ui::Button::r1, x, 106, 26);
- std::array<float, kPages> xs{}, ws{};
- for (int i = kPages - 1; i >= 0; --i) {
- ws[(size_t) i] = f.semibold.measure(kPageNames[i], 22);
- x -= 28 + ws[(size_t) i];
- xs[(size_t) i] = x;
- ui::text(list, i == page_ ? f.semibold : f.regular, kPageNames[i], x, 114, 22,
- kInk.with_alpha(i == page_ ? 1.0f : kMuted));
- }
- x -= 16 + ui::button_width(ui::Button::l1, 26);
- ui::draw_button(list, f, style, ui::Button::l1, x, 106, 26);
- const float t = tween::cubic_out(tween::clamp01(page_age_ / 0.3f));
- const float ux = xs[(size_t) page_from_] + (xs[(size_t) page_] - xs[(size_t) page_from_]) * t;
- const float uw = ws[(size_t) page_from_] + (ws[(size_t) page_] - ws[(size_t) page_from_]) * t;
- list.rounded_rect({ ux, 128, uw, 3 }, 1.5f, kCyan);
- list.pop_opacity();
-}
+ put(l, f.semibold, "Models", kLeft, kTitleY, 44, kInk);
-namespace {
+ // The highlight: on a section, or on a row of the list.
+ const float hx = in_list_ ? kListX : kLeft - 20;
+ const float hw = in_list_ ? kRight - kListX : kRailW;
+ const float hh = in_list_ ? kRowH : kRailH;
+ l.rounded_rect({ hx, rows_y_.value, hw, hh }, 14, kRaised);
-// llama-server's arguments as flag and value pairs, one per line.
-std::vector<std::string> arg_lines(const std::vector<std::string> & args) {
- std::vector<std::string> out;
- for (size_t i = 0; i < args.size(); ++i) {
- std::string line = args[i];
- const bool flag = line.size() > 1 && line[0] == '-' && !std::isdigit((unsigned char) line[1]);
- if (flag && i + 1 < args.size()) {
- const std::string & v = args[i + 1];
- if (!(v.size() > 1 && v[0] == '-' && !std::isdigit((unsigned char) v[1]))) {
- line += " " + v;
- ++i;
+ for (int i = 0; i < kSections; ++i) {
+ const float y = kListY + kRailPitch * (float) i;
+ const bool on = i == section_;
+ if (on) {
+ l.rounded_rect({ kLeft - 20, y + 16, 4, kRailH - 32 }, 2, kBlue);
+ }
+ put(l, f.regular, kSectionNames[i], kLeft, y + 42, 26, on ? kInk : kInk2);
+ std::string count;
+ if (i == kLocal) {
+ count = std::to_string(live_.models.size());
+ } else if (i == kDownloads && !market_.downloads.empty()) {
+ int active = 0;
+ for (const auto & d : market_.downloads) {
+ active += d.state != DownloadState::done;
}
+ count = active ? std::to_string(active) : "";
}
- out.push_back(line);
+ put(l, f.regular, count, kLeft + kRailW - 44, y + 42, 22, kInk3, gfx::Align::right);
}
- return out;
-}
-} // namespace
-
-void Dashboard::draw_details(gfx::DrawList & list, std::uint32_t glass) const {
- const float t = details_.value;
- if (t <= 0.01f) {
- return;
+ const Rect area{ kListX, kListY, kRight - kListX, kDockY - 40 - kListY };
+ switch (section_) {
+ case kLocal: draw_local(l, area); break;
+ case kSuggested: draw_suggested(l, area); break;
+ case kSearch: draw_market(l, area); break;
+ default: draw_downloads(l, area); break;
}
- const ui::Fonts & f = fonts_;
- const Live & L = live_;
- Rect panel = kLibrary;
- panel.y += 30.0f * (1.0f - t);
- list.push_opacity(t);
- list.shadow({ panel.x, panel.y + 20, panel.w, panel.h }, 40, 50, kBlack.with_alpha(0.55f));
- if (glass) {
- list.glass(glass, panel, 40, Color::rgb(0xffffff));
- }
- if (detail_tile_ == kUsage || detail_tile_ == kPower) {
- draw_panel(list, panel, 40, 1.0f, accent_of(detail_tile_));
- if (detail_tile_ == kUsage) {
- draw_usage_details(list, panel);
- } else {
- draw_power_details(list, panel);
- }
- list.pop_opacity();
- return;
- }
- draw_panel(list, panel, 40, 1.0f, kLime);
- caps(list, f, "LOADED MODEL", panel.x + 56, panel.y + 60, 20, kLime);
- ui::text(list, f.semibold, f.semibold.font->fit(L.preset.empty() ? L.model_label : L.preset, 40, panel.w - 112),
- panel.x + 56, panel.y + 116, 40, kInk);
- ui::text(list, f.regular, f.regular.font->fit(L.model_file, 20, panel.w - 112), panel.x + 56, panel.y + 150, 20,
- kInk.with_alpha(kMuted));
-
- // Left: the facts. Right: every argument llama-server got.
- char text[96];
- std::snprintf(text, sizeof(text), "%s GiB", gib(L.model_gib).c_str());
- std::string ctx = L.ctx ? std::to_string(L.ctx / 1024) + "k tokens" : std::string(kDash);
- std::string cache = L.kv_type.empty() ? std::string(kDash) : L.kv_type + ", " + gib(L.kv_gib) + " GiB";
- const std::string facts[][2] = {
- { "SIZE", text },
- { "ARCHITECTURE", L.model_arch.empty() ? std::string(kDash) : L.model_arch },
- { "CONTEXT", ctx },
- { "KV CACHE", cache },
- { "PRESET", L.preset.empty() ? std::string("None") : L.preset },
- };
- const float lx = panel.x + 56, lw = 400;
- for (int k = 0; k < 5; ++k) {
- const float y = panel.y + 220 + k * 62.0f;
- caps(list, f, facts[k][0], lx, y, 15, kInk.with_alpha(kMuted));
- ui::text(list, f.mono, f.mono.font->fit(facts[k][1], 24, lw), lx, y + 32, 24, kInk);
- }
- caps(list, f, "PLAN", lx, panel.y + 548, 15, kInk.with_alpha(kMuted));
- ui::paragraph(list, f.regular, L.plan.empty() ? std::string("Set by app-args.txt") : L.plan, lx, panel.y + 580, 20,
- lw, 28, kInk.with_alpha(0.85f), 3);
-
- const float ax = panel.x + 520, aw = panel.w - 520 - 56;
- list.rounded_rect({ ax - 32, panel.y + 196, 1, panel.h - 260 }, 0, kInk.with_alpha(0.1f));
- caps(list, f, "ARGUMENTS", ax, panel.y + 220, 15, kInk.with_alpha(kMuted));
- const auto lines = arg_lines(L.args);
- const int per_column = 17;
- const float col_w = lines.size() > (size_t) per_column ? aw * 0.5f : aw;
- for (size_t i = 0; i < lines.size() && i < (size_t) per_column * 2; ++i) {
- const float x = ax + (float) (i / per_column) * col_w;
- const float y = panel.y + 256 + (float) (i % per_column) * 30.0f;
- ui::text(list, f.mono, f.mono.font->fit(lines[i], 18, col_w - 16), x, y, 18, kInk.with_alpha(0.9f));
- }
- list.pop_opacity();
}
-// Everything the console is doing, one section each.
-void Dashboard::draw_usage_details(gfx::DrawList & list, const Rect & panel) const {
+void Dashboard::draw_local(gfx::DrawList & l, const Rect & a) const {
const ui::Fonts & f = fonts_;
- const Live & L = live_;
- const bool serving = L.state == ServerState::ready || L.state == ServerState::generating;
- char text[96];
- caps(list, f, "USAGE", panel.x + 56, panel.y + 60, 20, kCyan);
- ui::text(list, f.regular, "What the console is doing for PS5LM, over the last two minutes.", panel.x + 56,
- panel.y + 96, 20, kInk.with_alpha(kMuted));
-
- const float x0 = panel.x + 56, colw = (panel.w - 112 - 48) * 0.5f, x1 = x0 + colw + 48;
- // GPU and CPU, each with its chart.
- const struct {
- const char * name;
- Color c;
- float now;
- bool known;
- const std::vector<float> * hist;
- std::string sub;
- float x;
- } parts[2] = {
- { "GPU", kCyan, L.gpu_busy, serving, &L.gpu_history,
- "Vulkan (RADV), " + gib(L.model_gib + L.kv_gib) + " GiB on it", x0 },
- { "CPU", kLime, L.cpu_use, true, &L.cpu_history,
- std::to_string(L.cpus) + " CPUs" + (L.cpu_ghz > 0 ? ", " + gib(L.cpu_ghz) + " GHz" : std::string()) +
- ", heap " + gib(L.heap_gib) + " GiB",
- x1 },
- };
- for (const auto & p : parts) {
- caps(list, f, p.name, p.x, panel.y + 160, 16, p.c);
- const float w = number(list, f, p.known, "%.0f", p.now * 100.0f, p.x, panel.y + 222, 56, kInk);
- ui::text(list, f.regular, "% busy", p.x + w + 10, panel.y + 222, 22, kInk.with_alpha(kMuted));
- ui::text(list, f.regular, f.regular.font->fit(p.sub, 20, colw), p.x, panel.y + 256, 20, kInk.with_alpha(kFaint));
- history(list, *p.hist, { p.x, panel.y + 280, colw, 150 }, 1.0f, p.c, 10.0f);
- }
-
- // Memory and storage.
- list.rounded_rect({ x0, panel.y + 470, panel.w - 112, 1 }, 0, kInk.with_alpha(0.1f));
- caps(list, f, "MEMORY", x0, panel.y + 514, 16, kAmber);
- const double used = std::max(0.0, L.pool_gib - L.free_gib);
- std::snprintf(text, sizeof(text), "%s of %s GiB, GPU and CPU", gib(used).c_str(), gib(L.pool_gib).c_str());
- ui::text(list, f.mono, text, x0 + colw, panel.y + 514, 20, kInk, gfx::Align::right);
- bar(list, { x0, panel.y + 534, colw, 12 }, L.pool_gib > 0 ? (float) (used / L.pool_gib) : 0.0f, kAmber);
-
- caps(list, f, "STORAGE", x1, panel.y + 514, 16, kRose);
- const size_t n = std::min<size_t>(L.drives.size(), 3);
- for (size_t k = 0; k < n; ++k) {
- const Drive & d = L.drives[k];
- const float y = panel.y + 570 + (float) k * 56.0f;
- ui::text(list, f.regular, d.name, x1, y, 20, kInk.with_alpha(0.85f));
- if (d.total <= 0) {
- ui::text(list, f.regular, kDash, x1 + colw, y, 20, kInk.with_alpha(kFaint), gfx::Align::right);
- continue;
- }
- std::snprintf(text, sizeof(text), "%.0f of %.0f GiB free", d.free, d.total);
- ui::text(list, f.mono, text, x1 + colw, y, 20, kInk, gfx::Align::right);
- bar(list, { x1, y + 16, colw, 10 }, (float) ((d.total - d.free) / d.total), kRose);
- }
- if (n == 1) {
- ui::text(list, f.regular, "USB or M.2", x1, panel.y + 626, 20, kInk.with_alpha(0.85f));
- ui::text(list, f.regular, "No drive", x1 + colw, panel.y + 626, 20, kInk.with_alpha(kFaint), gfx::Align::right);
+ const int rows = (int) live_.models.size();
+ if (rows == 0) {
+ put(l, f.regular, "No models yet", a.x + 28, a.y + 46, 30, kInk);
+ put(l, f.regular, "Get one from Suggested, or copy a .gguf to /data/PS5LM/models.", a.x + 28, a.y + 90, 22, kInk2);
+ return;
}
- caps(list, f, "MODELS", x0, panel.y + 610, 16, kInk.with_alpha(kMuted));
- double on_disk = 0;
- for (const auto & m : L.models) {
- on_disk += m.size_gib;
+ const int first = first_visible(local_cursor_, rows);
+ for (int i = first; i < std::min(rows, first + kVisibleRows); ++i) {
+ const ModelRow & m = live_.models[(size_t) i];
+ const float y = a.y + kRowPitch * (float) (i - first);
+ std::string name, build;
+ split_name(m.label, &name, &build);
+ const float nw = put(l, f.regular, f.regular.font->fit(name, 26, 640), a.x + 28, y + 36, 26, m.fits ? kInk : kInk3);
+ put(l, f.regular, build, a.x + 28 + nw + 14, y + 36, 21, kInk3);
+ std::string meta = (m.decision.empty() ? "Language" : "Decision") + std::string(" ") + gb(m.size_gib);
+ if (m.drive != "Internal storage" && !m.drive.empty()) {
+ meta += " " + m.drive;
+ }
+ std::string plan = gb_text(m.plan);
+ if (plan.rfind("decision model (", 0) == 0 && plan.find("), ") != std::string::npos) {
+ plan = plan.substr(plan.find("), ") + 3); // the kind is said already
+ }
+ meta += " " + plan;
+ put(l, f.regular, f.regular.font->fit(meta, 20, a.w - 260), a.x + 28, y + 66, 20, kInk3);
+ const char * state = m.current ? "Running" : m.fits ? "" : "Too big";
+ put(l, f.semibold, state, a.x + a.w - 28, y + 50, 22, m.current ? kBlue : kInk3, gfx::Align::right);
}
- std::snprintf(text, sizeof(text), "%zu found, %s GiB", L.models.size(), gib(on_disk).c_str());
- ui::text(list, f.mono, text, x0 + colw, panel.y + 610, 20, kInk, gfx::Align::right);
-}
-
-// The SoC's power, the energy it took, and every temperature it reports.
-void Dashboard::draw_power_details(gfx::DrawList & list, const Rect & panel) const {
- const ui::Fonts & f = fonts_;
- const Live & L = live_;
- const Color kGold = Color::rgb(0xffd166);
- char text[96];
- caps(list, f, "POWER", panel.x + 56, panel.y + 60, 20, kGold);
- ui::text(list, f.regular, "The SoC's own reading: CPU, GPU and memory together.", panel.x + 56, panel.y + 96, 20,
- kInk.with_alpha(kMuted));
-
- const float x0 = panel.x + 56, lw = 640, x1 = x0 + lw + 64, rw = panel.x + panel.w - 56 - x1;
- const float w = number(list, f, L.soc_power_w > 0, "%.0f", L.soc_power_w, x0, panel.y + 200, 72, kInk);
- ui::text(list, f.regular, "W now", x0 + w + 12, panel.y + 200, 24, kInk.with_alpha(kMuted));
- float mn = 1e9f, mx = 0, sum = 0;
- for (float v : L.power_history) {
- mn = std::min(mn, v);
- mx = std::max(mx, v);
- sum += v;
- }
- const size_t n = L.power_history.size();
- history(list, L.power_history, { x0, panel.y + 236, lw, 200 }, std::max(60.0f, mx * 1.15f), kGold, 10.0f);
- const char * names[3] = { "MIN", "AVG", "MAX" };
- const float vals[3] = { n ? mn : 0, n ? sum / (float) n : 0, mx };
- for (int k = 0; k < 3; ++k) {
- const float x = x0 + k * 190.0f;
- caps(list, f, names[k], x, panel.y + 486, 15, kInk.with_alpha(kMuted));
- number(list, f, n > 0, "%.0f W", vals[k], x + 56, panel.y + 488, 24, kInk);
- }
- const struct {
- const char * name;
- std::string value;
- } rows[3] = {
- { "THIS SESSION", [&] { char t[24]; std::snprintf(t, sizeof(t), "%.2f Wh", L.energy_wh); return std::string(t); }() },
- { "PER TOKEN", L.gen_tps > 0 && L.soc_power_w > 0 ? gib(L.soc_power_w / L.gen_tps) + " J while generating"
- : std::string(kDash) },
- { "FAN", L.fan >= 0 ? std::to_string((int) (L.fan * 100.0f + 0.5f)) + "% duty" : std::string(kDash) },
- };
- for (int k = 0; k < 3; ++k) {
- const float y = panel.y + 556 + k * 50.0f;
- caps(list, f, rows[k].name, x0, y, 15, kInk.with_alpha(kMuted));
- ui::text(list, f.mono, rows[k].value, x0 + lw, y + 2, 22, kInk, gfx::Align::right);
- }
-
- // Every sensor, hottest first by bar length.
- list.rounded_rect({ x1 - 32, panel.y + 150, 1, panel.h - 220 }, 0, kInk.with_alpha(0.1f));
- caps(list, f, "TEMPERATURES", x1, panel.y + 160, 15, kHeat);
- if (L.temps.empty()) {
- ui::text(list, f.regular, "No sensor answered", x1, panel.y + 200, 20, kInk.with_alpha(kFaint));
- }
- for (size_t k = 0; k < L.temps.size() && k < 12; ++k) {
- const float y = panel.y + 204 + (float) k * 40.0f;
- std::string name = L.temps[k].first;
- if (name == "cpu") {
- name = "CPU";
- } else {
- name = "SoC " + name.substr(3);
- }
- ui::text(list, f.regular, name, x1, y, 20, kInk.with_alpha(0.85f));
- std::snprintf(text, sizeof(text), "%.0f \xC2\xB0" "C", L.temps[k].second);
- ui::text(list, f.mono, text, x1 + rw, y, 20, kInk, gfx::Align::right);
- bar(list, { x1 + 90, y - 8, rw - 180, 6 }, L.temps[k].second / 100.0f, kHeat);
- }
- ui::paragraph(list, f.regular,
- "The console reports the SoC's total only. CPU and GPU power apart, and voltages, are not available to "
- "homebrew.",
- x0, panel.y + panel.h - 52, 17, panel.w - 112, 24, kInk.with_alpha(kFaint), 2);
}
-void Dashboard::draw_settings(gfx::DrawList & list) const {
+void Dashboard::draw_suggested(gfx::DrawList & l, const Rect & a) const {
const ui::Fonts & f = fonts_;
- const SettingCategory & c = kCategories[setting_category_];
- const float in = tween::cubic_out(tween::clamp01(page_age_ / 0.35f));
-
- // The rail: a quiet plate marks the active category even while the focus
- // is on the rows.
- list.rounded_rect(rail_rect(setting_category_), 18, kInk.with_alpha(0.06f));
- draw_panel(list, kSettingsPanel, kRadius, 0.0f, kBrand);
-
- // The one focus rectangle, travelling between the rail and the rows.
- const Rect focus = setting_focus_.value();
- const float breath = ui::breathe(clock_);
- list.shadow({ focus.x, focus.y + 10, focus.w, focus.h }, 18, 24, kBlack.with_alpha(0.4f));
- list.glow(focus, 18, 18, kCyan.with_alpha(0.14f + 0.1f * breath));
- list.rounded_rect(focus, 18, gfx::mix(kPanelTop, kCyan, 0.17f));
- list.bordered_rect(focus, 18, kClear, 2.0f, kCyan);
-
- for (int i = 0; i < kCategoryCount; ++i) {
- const Rect r = rail_rect(i);
- const bool active = i == setting_category_;
- const float x = r.x - 28.0f * (1.0f - tween::stagger(page_age_, i, 0.05f, 0.4f));
- ui::text(list, active ? f.semibold : f.regular, kCategories[i].name, x + 40, r.cy() + 10, 28,
- kInk.with_alpha(active ? 1.0f : 0.68f));
- }
- list.rounded_rect({ kRailX + 8, rail_rect(setting_category_).y + 20, 4, kRailH - 40 }, 2, kCyan);
-
- caps(list, f, ui::upper(c.name), kSettingsPanel.x + 48, kSettingsPanel.y + 56, 18, kBrand);
- ui::text(list, f.regular, c.about, kSettingsPanel.x + 48, kSettingsPanel.y + 90, 22, kInk.with_alpha(kMuted));
- for (int i = 0; i < c.count; ++i) {
- const Rect r = setting_rect(i);
- const bool focused = in_rows_ && i == setting_row_;
- const float y = r.y + 16.0f * (1.0f - tween::stagger(page_age_, i + 1, 0.06f, 0.4f));
- const Rect row{ r.x, y, r.w, r.h };
- if (!focused) {
- list.rounded_rect(row, 18, kInk.with_alpha(0.035f));
- }
- const SettingRow & sr = c.rows[i];
- ui::text(list, focused ? f.semibold : f.regular, sr.label, row.x + 28, row.cy() + 10, 28,
- kInk.with_alpha(focused ? 1.0f : 0.84f));
- const float right = row.x + row.w - 28;
- if (is_toggle(sr.id)) {
- const bool on = toggle_value(settings_, sr.id);
- const Rect pill{ right - 84, row.cy() - 22, 84, 44 };
- if (focused) {
- list.glow(pill, 22, 12, kCyan.with_alpha(on ? 0.45f : 0.18f));
+ const int first = first_visible(suggested_cursor_, kSuggestionCount);
+ for (int i = first; i < std::min(kSuggestionCount, first + kVisibleRows); ++i) {
+ const Suggestion & s = kSuggestions[i];
+ const float y = a.y + kRowPitch * (float) (i - first);
+ const float nw = put(l, f.regular, s.name, a.x + 28, y + 36, 26, kInk);
+ const double bytes = (double) s.model.bytes + (double) (s.mmproj.file ? s.mmproj.bytes : 0);
+ put(l, f.regular, format("%.1f GB", bytes / 1073741824.0), a.x + 28 + nw + 14, y + 36, 21, kInk3);
+ const std::string about = std::string(s.decision ? "Decision" : s.mmproj.file ? "Language, images" : "Language") + " " + s.about;
+ put(l, f.regular, f.regular.font->fit(about, 20, a.w - 260), a.x + 28, y + 66, 20, kInk3);
+ // On the console already, on its way, or ready to get.
+ std::string state;
+ Color c = kInk3;
+ for (const auto & m : live_.models) {
+ if (m.label + ".gguf" == local_name(s.model)) {
+ state = m.current ? "Running" : "On this PS5";
+ c = m.current ? kBlue : kInk3;
}
- list.bordered_rect(pill, 22, on ? kCyan : Color::rgb(0x2a3550), 1.5f, on ? kCyan : kInk.with_alpha(0.3f));
- const Rect thumb{ on ? pill.x + pill.w - 39 : pill.x + 5, pill.cy() - 17, 34, 34 };
- list.shadow({ thumb.x, thumb.y + 2, thumb.w, thumb.h }, 17, 8, kBlack.with_alpha(0.45f));
- list.rounded_rect(thumb, 17, on ? kPanelBottom : kInk);
- ui::text(list, f.regular, on ? "On" : "Off", pill.x - 20, row.cy() + 8, 24,
- kInk.with_alpha(focused ? 0.95f : 0.66f), gfx::Align::right);
- } else if (sr.id == Setting::clear_scratch) {
- // An action row: what it would delete, and a chevron.
- char t[48];
- std::snprintf(t, sizeof(t), "%.2f GiB in the folder", live_.scratch_gib);
- ui::text(list, f.regular, t, right - 34, row.cy() + 8, 24, kInk.with_alpha(focused ? 0.8f : 0.55f),
- gfx::Align::right);
- const Color ink = focused ? kRose : kInk.with_alpha(0.6f);
- list.line(right - 12, row.cy() - 9, right - 3, row.cy(), 3.0f, ink);
- list.line(right - 12, row.cy() + 9, right - 3, row.cy(), 3.0f, ink);
- } else {
- // A stepper: the value between two triangles, dimmed at the ends.
- const float w = 420, cx = right - w * 0.5f;
- if (focused) {
- list.rounded_rect({ cx - w * 0.5f + 34, row.cy() - 24, w - 68, 48 }, 14, kBlack.with_alpha(0.25f));
+ }
+ for (const auto & d : market_.downloads) {
+ if (state.empty() && d.repo == s.repo && d.file == s.model.file && d.state != DownloadState::done) {
+ state = d.bytes ? format("%.0f%%", 100.0 * (double) d.done / (double) d.bytes) : "Waiting";
+ c = kInk2;
}
- const std::string v = setting_text(settings_, sr.id, live_.models, live_.drives);
- ui::text(list, f.semibold, f.semibold.font->fit(v, 26, w - 100), cx, row.cy() + 9, 26,
- focused ? kInk : kInk.with_alpha(0.84f), gfx::Align::center);
- Settings probe = settings_;
- const bool left_ok = step_setting(probe, sr.id, -1, live_.models, live_.drives);
- probe = settings_;
- const bool right_ok = step_setting(probe, sr.id, 1, live_.models, live_.drives);
- const Color tint = focused ? kCyan : kInk;
- const float rest = focused ? 1.0f : 0.5f;
- ui::text(list, f.mono, "\xE2\x97\x80", cx - w * 0.5f + 12, row.cy() + 10, 30,
- tint.with_alpha(left_ok ? rest : 0.16f), gfx::Align::center);
- ui::text(list, f.mono, "\xE2\x96\xB6", cx + w * 0.5f - 12, row.cy() + 10, 30,
- tint.with_alpha(right_ok ? rest : 0.16f), gfx::Align::center);
}
+ if (state.empty() && in_list_ && i == suggested_cursor_) {
+ state = "Get";
+ c = kBlue;
+ }
+ put(l, f.semibold, state, a.x + a.w - 28, y + 50, 22, c, gfx::Align::right);
}
- // The focused row's help under a hairline at the foot of the panel.
- const float foot = kSettingsPanel.y + kSettingsPanel.h - 84;
- list.rounded_rect({ kSettingsPanel.x + 24, foot, kSettingsPanel.w - 48, 1.5f }, 0, kInk.with_alpha(0.1f));
- const char * help = in_rows_ ? c.rows[setting_row_].help : "Changes are saved at once, to /data/PS5LM/settings.json.";
- ui::text(list, f.regular, help, kSettingsPanel.x + 48, foot + 50, 22, kInk.with_alpha(kMuted * in));
}
-// Two panes in the Logs page's frame: the repositories of the search on the
-// left, the open one's GGUF files on the right with whether each fits.
-void Dashboard::draw_market(gfx::DrawList & list) const {
+void Dashboard::draw_market(gfx::DrawList & l, const Rect & a) const {
const ui::Fonts & f = fonts_;
- const Rect & p = kLogPanel;
- const MarketView & M = market_;
- draw_panel(list, p, kRadius, 0.0f, kLime);
- // The searches as chips; L2/R2 move between them.
- float x = p.x + kPad;
- for (int k = 0; k < kMarketChipCount; ++k) {
- const bool on = k == market_chip_;
- const float w = f.semibold.measure(kMarketChips[k], 18) + 40;
- const Rect chip{ x, p.y + 22, w, 38 };
- list.bordered_rect(chip, 19, on ? kLime.with_alpha(0.16f) : kClear, 1.5f, on ? kLime : kInk.with_alpha(0.16f));
- ui::text(list, on ? f.semibold : f.regular, kMarketChips[k], chip.cx(), chip.cy() + 7, 18,
- on ? kInk : kInk.with_alpha(kMuted), gfx::Align::center);
- x += w + 12;
- }
- const char * status = M.busy ? "Working" : M.status.c_str();
- ui::text(list, f.regular, f.regular.font->fit(status, 20, 420), p.x + p.w - kPad, p.y + 48, 20,
- kInk.with_alpha(kMuted), gfx::Align::right);
- list.rounded_rect({ p.x + kPad, p.y + 76, p.w - 2 * kPad, 1 }, 0, kInk.with_alpha(0.1f));
-
- const float lx = p.x + kPad, lw = 620, rx = lx + lw + 40, rw = p.x + p.w - kPad - rx, top = p.y + 96;
- list.rounded_rect({ rx - 20, top, 1, kMarketRows * kMarketRowH }, 0, kInk.with_alpha(0.1f));
- char text[256];
- // Repositories.
- const int repos = (int) M.repos.size();
- const int rfirst = std::max(0, market_repo_ - (kMarketRows - 1));
- for (int i = rfirst; i < repos && i < rfirst + kMarketRows; ++i) {
- const MarketRepo & r = M.repos[(size_t) i];
- const float y = top + (float) (i - rfirst) * kMarketRowH;
- const bool cur = i == market_repo_;
- if (cur) {
- const Color c = market_files_ ? kInk.with_alpha(0.08f) : kLime.with_alpha(0.12f);
- list.bordered_rect({ lx - 8, y, lw + 16, kMarketRowH - 8 }, 14, c, 2.0f,
- market_files_ ? kInk.with_alpha(0.2f) : kLime.with_alpha(0.7f));
- }
- ui::text(list, cur ? f.semibold : f.regular, f.regular.font->fit(r.id, 22, lw - 150), lx + 12, y + 37, 22,
- kInk.with_alpha(cur ? 1.0f : 0.85f));
- std::snprintf(text, sizeof(text), "%.1fk", r.downloads / 1000.0);
- ui::text(list, f.mono, text, lx + lw - 8, y + 37, 18, kInk.with_alpha(kMuted), gfx::Align::right);
- }
- if (repos == 0) {
- ui::text(list, f.regular, M.busy ? "Searching Hugging Face" : "No repositories", lx + 12, top + 40, 22,
- kInk.with_alpha(kFaint));
- }
-
- // The open repository's files.
- const MarketRepo * open = M.open >= 0 && M.open < repos ? &M.repos[(size_t) M.open] : nullptr;
- if (!open) {
- ui::paragraph(list, f.regular, "Cross opens a repository: its GGUF files, their sizes, and the context each would get on this console.",
- rx, top + 40, 22, rw, 32, kInk.with_alpha(kFaint), 3);
- } else {
- ui::text(list, f.semibold, f.semibold.font->fit(open->id, 22, rw), rx, top + 4, 22, kLime);
- const int files = (int) open->files.size();
- const int ffirst = std::max(0, market_file_ - (kMarketRows - 2));
- for (int i = ffirst; i < files && i < ffirst + kMarketRows - 1; ++i) {
- const MarketFile & mf = open->files[(size_t) i];
- const float y = top + 26 + (float) (i - ffirst) * kMarketRowH;
- const bool cur = market_files_ && i == market_file_;
- if (cur) {
- list.bordered_rect({ rx - 8, y, rw + 16, kMarketRowH - 8 }, 14, kLime.with_alpha(0.12f), 2.0f,
- kLime.with_alpha(0.7f));
- }
- const size_t slash = mf.name.find_last_of('/');
- const std::string short_name = mf.name.substr(slash == std::string::npos ? 0 : slash + 1);
- ui::text(list, cur ? f.semibold : f.regular, f.regular.font->fit(short_name, 20, rw - 270), rx + 12, y + 26,
- 20, kInk.with_alpha(mf.fits == 0 ? 0.45f : 1.0f));
- ui::text(list, f.regular, f.regular.font->fit(mf.checking ? std::string("Reading its header to plan the context it would get") : mf.plan.empty() ? std::string("Not checked yet: Square checks whether it fits") : mf.plan, 16, rw - 270),
- rx + 12, y + 50, 16, kInk.with_alpha(kFaint));
- std::snprintf(text, sizeof(text), "%.1f GiB", mf.bytes / 1073741824.0);
- ui::text(list, f.mono, text, rx + rw - 150, y + 36, 18, kInk.with_alpha(0.85f), gfx::Align::right);
- const char * tag = mf.checking ? "CHECKING" : mf.fits == 1 ? "FITS" : mf.fits == 0 ? "TOO BIG" : mf.fits == -2 ? "UNKNOWN" : "UNCHECKED";
- const Color tc = mf.fits == 1 ? kLime : mf.fits == 0 ? kRose : kInk.with_alpha(kMuted);
- caps(list, f, tag, rx + rw - 8, y + 36, 14, tc, gfx::Align::right);
+ // The searches, as tabs.
+ float x = a.x + 28;
+ for (int i = 0; i < kMarketChipCount; ++i) {
+ const bool on = i == market_chip_;
+ const float w = put(l, f.regular, kMarketChips[i], x, a.y + 34, 22, on ? kInk : kInk3);
+ if (on) {
+ l.rounded_rect({ x, a.y + 48, w, 3 }, 1.5f, kBlue);
}
+ x += w + 36;
}
-
- // A question over the lists: a title, a headline, a paragraph, buttons.
- const auto dialog = [&](Color c, const char * title, const std::string & head, const char * body, const ui::Hint * hints,
- int n) {
- const Rect d{ p.cx() - 430, p.cy() - 150, 860, 300 };
- list.rounded_rect(p, kRadius, kBlack.with_alpha(0.55f)); // a scrim over the lists
- list.shadow({ d.x, d.y + 18, d.w, d.h }, 28, 40, kBlack.with_alpha(0.6f));
- draw_panel(list, d, 28, 1.0f, c);
- caps(list, f, title, d.x + 44, d.y + 56, 18, c);
- ui::text(list, f.semibold, f.semibold.font->fit(head, 24, d.w - 88), d.x + 44, d.y + 104, 24, kInk);
- ui::paragraph(list, f.regular, body, d.x + 44, d.y + 144, 21, d.w - 88, 30, kInk.with_alpha(kMuted), 3);
- ui::HintLayout layout;
- layout.size = 34.0f;
- layout.text_size = 22.0f;
- layout.cy = d.y + d.h - 40;
- layout.item_gap = 32.0f;
- ui::draw_hints(list, fonts_, ui::GlyphStyle::dark(), hints, n, d.x + d.w - 44, true, layout);
- };
- // The download does not fit where it would go.
- if (market_space_ && open && market_file_ < (int) open->files.size()) {
- const MarketFile & mf = open->files[(size_t) market_file_];
- const Drive * to = nullptr;
- const Drive * other = nullptr;
- for (const auto & d : live_.drives) {
- to = d.models == settings_.download_dir ? &d : to;
- other = d.models == market_dir_ ? &d : other;
- }
- char head[160];
- std::snprintf(head, sizeof(head), "%s needs %.1f GiB.", mf.name.c_str(), mf.bytes / 1073741824.0);
- char where[96];
- if (to) {
- std::snprintf(where, sizeof(where), "%s has %.1f GiB free", to->name.c_str(), to->free);
- } else {
- std::snprintf(where, sizeof(where), "The drive in Settings is not connected");
- }
- if (other) {
- std::snprintf(text, sizeof(text), "%s, and 1 GiB stays spare. %s has %.0f GiB free; this one download can go "
- "there. Download to in Settings keeps the default.", where, other->name.c_str(), other->free);
- } else {
- std::snprintf(text, sizeof(text), "%s, and 1 GiB stays spare. No other drive has room: free some space, or "
- "connect a USB drive or an M.2 drive.", where);
+ put(l, f.regular, market_.busy ? "Searching" : market_.status, a.x + a.w - 28, a.y + 34, 20, kInk3, gfx::Align::right);
+ const float top = a.y + 72;
+ const int repos = (int) market_.repos.size();
+ const MarketRepo * open = market_.open >= 0 && market_.open < repos ? &market_.repos[(size_t) market_.open] : nullptr;
+ if (!market_files_) {
+ const int first = first_visible(market_repo_, repos);
+ for (int i = first; i < std::min(repos, first + kVisibleRows); ++i) {
+ const MarketRepo & r = market_.repos[(size_t) i];
+ const float y = top + kRowPitch * (float) (i - first);
+ const size_t slash = r.id.find('/');
+ put(l, f.regular, f.regular.font->fit(slash == std::string::npos ? r.id : r.id.substr(slash + 1), 26, a.w - 300), a.x + 28,
+ y + 36, 26, kInk);
+ put(l, f.regular, (slash == std::string::npos ? std::string() : r.id.substr(0, slash)) + " " +
+ thousands(r.downloads) + " downloads", a.x + 28, y + 66, 20, kInk3);
+ }
+ if (repos == 0 && !market_.busy) {
+ put(l, f.regular, "Nothing found", a.x + 28, top + 46, 26, kInk2);
}
- const std::string save = other ? "Save to " + other->name : "";
- const ui::Hint hints[] = { { ui::Button::cross, save.c_str() }, { ui::Button::circle, "Cancel" } };
- dialog(kRose, "NOT ENOUGH SPACE", head, text, other ? hints : hints + 1, other ? 2 : 1);
+ return;
}
- // The question before downloading next to a loaded model.
- if (market_confirm_) {
- std::snprintf(text, sizeof(text), "%s holds most of the memory.", live_.model_label.c_str());
- const std::string head = text;
- std::snprintf(text, sizeof(text),
- "%.1f GiB is free. The download may be slower while it stays loaded. Unloading restarts the app "
- "without it, and the download starts on its own.",
- live_.free_gib);
- const ui::Hint hints[] = { { ui::Button::triangle, "Unload and download" }, { ui::Button::cross, "Download anyway" },
- { ui::Button::circle, "Cancel" } };
- dialog(kAmber, "A MODEL IS LOADED", head, text, hints, 3);
- }
-
- // The download, under both panes.
- const float by = p.y + p.h - 64;
- list.rounded_rect({ p.x + kPad, by - 24, p.w - 2 * kPad, 1 }, 0, kInk.with_alpha(0.1f));
- const Download * active = nullptr;
- int waiting = 0;
- for (const auto & d : M.downloads) {
- if ((d.state == DownloadState::running || d.state == DownloadState::retrying) && !active) {
- active = &d; // the worker runs one at a time; the first is it
- } else if (d.state == DownloadState::queued) {
- ++waiting;
- }
+ if (!open) {
+ return;
}
- if (active) {
- std::string line = active->file + " \xC2\xB7 " + download_line(*active);
- if (waiting > 0) {
- line += " \xC2\xB7 " + std::to_string(waiting) + " more queued";
- }
- ui::text(list, f.regular, f.regular.font->fit(line, 20, p.w - 2 * kPad - 420), p.x + kPad, by + 6, 20, kInk);
- bar(list, { p.x + p.w - kPad - 380, by - 4, 380, 12 },
- active->bytes ? (float) ((double) active->done / (double) active->bytes) : 0.0f,
- active->state == DownloadState::retrying ? kAmber : kLime);
- } else {
- const std::string note = !M.note.empty() ? M.note + " \xC2\xB7 R1 for Downloads"
- : "Downloads go to " + settings_.download_dir + " \xC2\xB7 change in Settings";
- ui::text(list, f.regular, f.regular.font->fit(note, 20, p.w - 2 * kPad), p.x + kPad, by + 6, 20, kInk.with_alpha(kMuted));
+ put(l, f.regular, open->id, a.x + a.w - 28, top - 4, 20, kInk2, gfx::Align::right);
+ const int files = (int) open->files.size();
+ const int first = first_visible(market_file_, files);
+ for (int i = first; i < std::min(files, first + kVisibleRows); ++i) {
+ const MarketFile & m = open->files[(size_t) i];
+ const float y = top + kRowPitch * (float) (i - first);
+ put(l, f.regular, f.regular.font->fit(m.name, 26, a.w - 300), a.x + 28, y + 36, 26, m.fits == 0 ? kInk3 : kInk);
+ const std::string plan = m.checking ? "Reading its header" : m.fits == -1 ? "Square checks whether it fits" : m.plan;
+ put(l, f.regular, f.regular.font->fit(format("%.1f GB", m.bytes / 1073741824.0) + " " + gb_text(plan), 20, a.w - 300), a.x + 28, y + 66,
+ 20, kInk3);
+ put(l, f.semibold, m.fits == 1 ? "Fits" : m.fits == 0 ? "Too big" : "", a.x + a.w - 28, y + 50, 22,
+ m.fits == 1 ? kInk2 : kInk3, gfx::Align::right);
}
}
-void Dashboard::update_downloads(const hui::InputFrame & input, ui::Feedback & feedback) {
+void Dashboard::draw_downloads(gfx::DrawList & l, const Rect & a) const {
+ const ui::Fonts & f = fonts_;
const int rows = (int) market_.downloads.size();
- dl_cursor_ = std::clamp(dl_cursor_, 0, std::max(0, rows - 1));
- if (input.nav == Direction::up || input.nav == Direction::down) {
- const int next = dl_cursor_ + (input.nav == Direction::down ? 1 : -1);
- if (next >= 0 && next < rows) {
- dl_cursor_ = next;
- dl_confirm_ = -1;
- feedback.play(hui::audio::Cue::focus, 1.0f + 0.02f * (float) next);
- } else if (!input.nav_repeat) {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- }
- }
if (rows == 0) {
+ put(l, f.regular, "No downloads", a.x + 28, a.y + 46, 30, kInk);
+ put(l, f.regular, "Models you get from Suggested or Search wait here until they are saved.", a.x + 28, a.y + 90, 22, kInk2);
return;
}
- const Download & d = market_.downloads[(size_t) dl_cursor_];
- if (input.is_pressed(Action::confirm)) {
- if (d.state == DownloadState::running || d.state == DownloadState::retrying || d.state == DownloadState::queued) {
- request_ = { Request::download_pause, "", dl_cursor_ };
- feedback.play(hui::audio::Cue::select);
- } else if (d.state == DownloadState::paused || d.state == DownloadState::failed) {
- request_ = { Request::download_resume, "", dl_cursor_ };
- feedback.play(hui::audio::Cue::complete);
- } else {
- feedback.play(hui::audio::Cue::error, 1.0f, 0.0f, 0.6f);
- }
- }
- // Square: a finished one leaves the list; any other is cancelled and its
- // partial file deleted, after a second press.
- if (input.is_pressed(Action::west)) {
- if (d.state == DownloadState::done || dl_confirm_ == dl_cursor_) {
- request_ = { Request::download_remove, "", dl_cursor_ };
- dl_confirm_ = -1;
- feedback.play(hui::audio::Cue::back);
+ const int first = first_visible(dl_cursor_, rows);
+ for (int i = first; i < std::min(rows, first + kVisibleRows); ++i) {
+ const Download & d = market_.downloads[(size_t) i];
+ const float y = a.y + kRowPitch * (float) (i - first);
+ put(l, f.regular, f.regular.font->fit(d.file, 26, a.w - 320), a.x + 28, y + 34, 26,
+ d.state == DownloadState::done ? kInk2 : kInk);
+ const bool fault = d.state == DownloadState::failed;
+ put(l, f.regular, f.regular.font->fit(download_line(d), 20, a.w - 320), a.x + 28, y + 64, 20, fault ? kRed : kInk3);
+ const char * state = d.state == DownloadState::running ? "" : d.state == DownloadState::paused ? "Paused"
+ : d.state == DownloadState::failed ? "Failed" : d.state == DownloadState::done ? "Saved"
+ : d.state == DownloadState::retrying ? "Retrying" : "Waiting";
+ if (d.state == DownloadState::running && d.bytes) {
+ const float share = (float) ((double) d.done / (double) d.bytes);
+ meter(l, a.x + a.w - 248, y + 42, 220, share, kBlue);
} else {
- dl_confirm_ = dl_cursor_;
- feedback.play(hui::audio::Cue::modal_open);
+ put(l, f.semibold, state, a.x + a.w - 28, y + 50, 22, fault ? kRed : kInk3, gfx::Align::right);
}
}
}
-void Dashboard::draw_downloads(gfx::DrawList & list) const {
+// ---- drawing: API -----------------------------------------------------------------
+
+void Dashboard::draw_api(gfx::DrawList & l) const {
+ const ui::Fonts & f = fonts_;
+ const bool decision = !live_.decision.empty();
+ const bool loaded = !live_.model_label.empty();
+ put(l, f.semibold, "API", kLeft, kTitleY, 44, kInk);
+ const std::string base = live_.address.empty() ? std::string("http://<PS5 address>:8081") : "http://" + live_.address;
+ put(l, f.regular, "Base address", kLeft, 262, 24, kInk2);
+ put(l, f.regular, base + "/v1", kLeft, 316, 44, kInk);
+ put(l, f.regular, "Any device on this network can call it, with any model name: the loaded one answers.", kLeft, 360, 22,
+ kInk3);
+
+ struct Ep { const char * method; const char * path; const char * about; bool decision; };
+ const Ep all[] = {
+ { "POST", "/v1/chat/completions", "OpenAI chat, streaming and tools", false },
+ { "POST", "/v1/messages", "Anthropic Messages, for Claude Code and its SDKs", false },
+ { "POST", "/v1/completions", "Plain text completion", false },
+ { "POST", "/v1/systemone", "TypeSafe decisions: choice, score and yes-or-no questions", true },
+ { "GET", "/v1/models", "The loaded model", false },
+ { "GET", "/health", "Ready or loading", false },
+ };
+ float y = 452;
+ for (const auto & e : all) {
+ const bool here = loaded && (e.decision == decision || std::string(e.method) == "GET");
+ put(l, f.mono, e.method, kLeft, y, 24, kInk3);
+ put(l, f.mono, e.path, kLeft + 96, y, 24, here ? kInk : kInk3);
+ put(l, f.regular, e.about, kLeft + 96, y + 34, 20, here ? kInk2 : kInk3);
+ y += 84;
+ }
+
+ // An example for what is loaded, in a quiet panel.
+ const Rect p{ 1000, 236, kRight - 1000, 688 };
+ l.rounded_rect(p, 24, kSurface);
+ put(l, f.regular, "Try it", p.x + 48, p.y + 68, 24, kInk2);
+ std::vector<std::string> code;
+ if (decision) {
+ code = { "curl " + base + "/v1/systemone \\", " -H 'Content-Type: application/json' \\", " -d '{", " \"state\": \"Refund me now or I cancel.\",",
+ " \"questions\": {", " \"angry\": {", " \"type\": \"noul\",", " \"instructions\": \"Is the customer angry?\"",
+ " }", " }", " }'" };
+ } else {
+ code = { "curl " + base + "/v1/chat/completions \\", " -H 'Content-Type: application/json' \\", " -d '{", " \"messages\": [",
+ " {\"role\": \"user\",", " \"content\": \"Hello from my PS5\"}", " ]", " }'" };
+ }
+ float cy = p.y + 130;
+ for (const auto & line : code) {
+ put(l, f.mono, f.mono.font->fit(line, 21, p.w - 96), p.x + 48, cy, 21, kInk);
+ cy += 34;
+ }
+ l.line(p.x + 48, p.y + p.h - 150, p.x + p.w - 48, p.y + p.h - 150, 1.5f, kHair);
+ put(l, f.regular, decision ? "Ollaya and TypeSafe clients:" : "OpenAI SDKs:", p.x + 48, p.y + p.h - 100, 22, kInk2);
+ put(l, f.mono, decision ? "base_url=" + base : "base_url=" + base + "/v1", p.x + 48 + (decision ? 300 : 170), p.y + p.h - 100, 21, kInk);
+ put(l, f.regular, decision ? "" : "Claude Code:", p.x + 48, p.y + p.h - 56, 22, kInk2);
+ put(l, f.mono, decision ? "" : "ANTHROPIC_BASE_URL=" + base, p.x + 218, p.y + p.h - 56, 21, kInk);
+}
+
+// ---- drawing: Settings ----------------------------------------------------------------
+
+void Dashboard::draw_settings(gfx::DrawList & l) const {
const ui::Fonts & f = fonts_;
- const Rect & p = kLogPanel;
- draw_panel(list, p, kRadius, 0.0f, kLime);
- caps(list, f, "DOWNLOADS", p.x + kPad, p.y + kLabelY, kLabelSize, kLime);
- double left = 0;
- for (const auto & d : market_.downloads) {
- if (d.state != DownloadState::done) {
- left += (double) (d.bytes - std::min(d.done, d.bytes));
+ put(l, f.semibold, "Settings", kLeft, kTitleY, 44, kInk);
+ const bool rows = in_rows_ && setting_category_ != kDiagnostics;
+ l.rounded_rect({ rows ? kListX : kLeft - 20, rows_y_.value, rows ? kRight - kListX : kRailW, rows ? kRowH : kRailH }, 14,
+ in_rows_ && setting_category_ == kDiagnostics ? kSurface : kRaised);
+ for (int i = 0; i < kCategoryCount; ++i) {
+ const float y = kListY + kRailPitch * (float) i;
+ const bool on = i == setting_category_;
+ if (on) {
+ l.rounded_rect({ kLeft - 20, y + 16, 4, kRailH - 32 }, 2, kBlue);
}
+ put(l, f.regular, kCategories[i].name, kLeft, y + 42, 26, on ? kInk : kInk2);
}
- char text[160];
- std::snprintf(text, sizeof(text), "%zu in the list \xC2\xB7 %.1f GiB to go \xC2\xB7 they carry on after a lost connection or a restart",
- market_.downloads.size(), left / 1073741824.0);
- ui::text(list, f.regular, text, p.x + p.w - kPad, p.y + kLabelY, 18, kInk.with_alpha(kMuted), gfx::Align::right);
- if (market_.downloads.empty()) {
- ui::text(list, f.regular, "Nothing downloading. Get models (L1) lists what fits; Cross on a file adds it here.",
- p.cx(), p.cy(), 24, kInk.with_alpha(kFaint), gfx::Align::center);
+ if (setting_category_ == kDiagnostics) {
+ draw_logs(l, { kListX, kListY, kRight - kListX, kDockY - 40 - kListY });
return;
}
- constexpr float kRow = 112.0f;
- constexpr int kShown = 6;
- const int first = std::max(0, dl_cursor_ - (kShown - 1));
- for (int i = first; i < (int) market_.downloads.size() && i < first + kShown; ++i) {
- const Download & d = market_.downloads[(size_t) i];
- const Rect r{ p.x + kPad, p.y + 84 + (float) (i - first) * kRow, p.w - 2 * kPad, kRow - 14 };
- if (i == dl_cursor_) {
- list.glow(r, 18, 18, kLime.with_alpha(0.2f));
- list.bordered_rect(r, 18, kLime.with_alpha(0.08f), 2.0f, kLime.with_alpha(0.7f));
- }
- const bool retrying = d.state == DownloadState::retrying;
- const char * tag = d.state == DownloadState::running ? "DOWNLOADING" : retrying ? "RECONNECTING"
- : d.state == DownloadState::queued ? "QUEUED" : d.state == DownloadState::paused ? "PAUSED"
- : d.state == DownloadState::failed ? "FAILED" : "DONE";
- const Color tc = d.state == DownloadState::running ? kLime : retrying ? kAmber : d.state == DownloadState::failed ? kRose
- : d.state == DownloadState::done ? kCyan : kInk.with_alpha(kMuted);
- ui::text(list, f.semibold, f.semibold.font->fit(d.file, 24, r.w - 420), r.x + 20, r.y + 34, 24, kInk);
- caps(list, f, tag, r.x + r.w - 20, r.y + 34, 15, tc, gfx::Align::right);
- std::string sub = d.repo + " \xC2\xB7 " + drive_name(d.dir) + " \xC2\xB7 " + download_line(d);
- if (dl_confirm_ == i) {
- sub = "Square again cancels it and deletes the " + gib(d.done / 1073741824.0) + " GiB downloaded so far";
+ const SettingCategory & c = kCategories[setting_category_];
+ for (int i = 0; i < c.count; ++i) {
+ const SettingRow & r = c.rows[i];
+ const float y = kListY + kRowPitch * (float) i;
+ put(l, f.regular, r.label, kListX + 28, y + 36, 26, kInk);
+ put(l, f.regular, r.help, kListX + 28, y + 66, 20, kInk3);
+ const float cy = y + kRowH * 0.5f;
+ if (is_toggle(r.id)) {
+ 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
+ }
+ } 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);
}
- ui::text(list, f.regular, f.regular.font->fit(sub, 18, r.w - 40), r.x + 20, r.y + 62, 18,
- dl_confirm_ == i ? kRose : kInk.with_alpha(kMuted));
- bar(list, { r.x + 20, r.y + 78, r.w - 40, 8 }, d.bytes ? (float) ((double) d.done / (double) d.bytes) : 0.0f,
- d.state == DownloadState::done ? kCyan : retrying ? kAmber : d.state == DownloadState::failed ? kRose : kLime);
}
}
-void Dashboard::draw_logs(gfx::DrawList & list) const {
+void Dashboard::draw_logs(gfx::DrawList & l, const Rect & a) const {
const ui::Fonts & f = fonts_;
- const Rect & p = kLogPanel;
- draw_panel(list, p, kRadius, 0.0f, kCyan);
- // Two sources as tabs, the filter as a chip, and the position.
- float x = p.x + kPad;
- const char * names[2] = { "APP.LOG", "LLAMA.LOG" };
- for (int k = 0; k < 2; ++k) {
- const bool on = (k == 1) == log_llama_;
- const float w = caps(list, f, names[k], x, p.y + kLabelY, kLabelSize, on ? kCyan : kInk.with_alpha(kFaint));
+ float x = a.x + 28;
+ const char * tabs[] = { "App", "Server" };
+ for (int i = 0; i < 2; ++i) {
+ const bool on = (i == 1) == log_llama_;
+ const float w = put(l, f.regular, tabs[i], x, a.y + 40, 24, on ? kInk : kInk3);
if (on) {
- list.rounded_rect({ x, p.y + kLabelY + 12, w, 3 }, 1.5f, kCyan);
+ l.rounded_rect({ x, a.y + 54, w, 3 }, 1.5f, kBlue);
}
x += w + 36;
}
- if (log_errors_) {
- const Rect chip{ x, p.y + 22, 170, 34 };
- list.bordered_rect(chip, 17, kRose.with_alpha(0.12f), 1.5f, kRose.with_alpha(0.6f));
- caps(list, f, "ERRORS ONLY", chip.cx(), chip.cy() + 6, 14, kRose, gfx::Align::center);
- }
- const auto & lines = log_view();
- char text[64];
- if (log_scroll_ > 0) {
- std::snprintf(text, sizeof(text), "%zu %s, %d up from the newest", lines.size(), lines.size() == 1 ? "line" : "lines", log_scroll_);
- } else {
- std::snprintf(text, sizeof(text), "%zu %s, following the newest", lines.size(), lines.size() == 1 ? "line" : "lines");
- }
- ui::text(list, f.regular, text, p.x + p.w - kPad, p.y + kLabelY, 20, kInk.with_alpha(kMuted), gfx::Align::right);
- list.rounded_rect({ p.x + kPad, p.y + 72, p.w - 2 * kPad, 1 }, 0, kInk.with_alpha(0.1f));
-
- if (lines.empty()) {
- ui::text(list, f.regular, log_errors_ ? "No errors or warnings" : "Nothing logged yet", p.cx(), p.cy(), 26,
- kInk.with_alpha(kFaint), gfx::Align::center);
- return;
+ put(l, f.regular, log_errors_ ? "Errors and warnings only" : "Every line", a.x + a.w - 28, a.y + 40, 20, kInk3,
+ gfx::Align::right);
+ const auto & v = log_view();
+ const int last = (int) v.size() - log_scroll_;
+ const int first = std::max(0, last - kLogLines);
+ float y = a.y + 96;
+ for (int i = first; i < last; ++i) {
+ const int level = log_level(v[(size_t) i]);
+ put(l, f.mono, f.mono.font->fit(v[(size_t) i], 18, a.w - 56), a.x + 28, y, 18,
+ level == 2 ? kRed : level == 1 ? kInk : kInk2);
+ y += kLogLineH;
+ }
+ if (v.empty()) {
+ put(l, f.regular, "Nothing here yet", a.x + 28, a.y + 120, 24, kInk3);
}
- const int last = (int) lines.size() - 1 - log_scroll_;
- const int first = std::max(0, last - kLogLines + 1);
- for (int i = first; i <= last; ++i) {
- const std::string & line = lines[(size_t) i];
- const int level = log_level(line);
- const Color c = level == 2 ? kRose : level == 1 ? kAmber : line.rfind("ps5lm-app:", 0) == 0 ? kInk : kInk.with_alpha(kMuted);
- const float y = p.y + 108 + (float) (i - first) * kLogLineH;
- ui::text(list, f.mono, f.mono.font->fit(line, 17, p.w - 2 * kPad - 24), p.x + kPad, y, 17, c);
- }
- // Where the view is in the log.
- const float track_h = kLogLines * kLogLineH;
- const float shown = std::min(1.0f, (float) kLogLines / (float) lines.size());
- const float top = 1.0f - (float) (last + 1) / (float) lines.size();
- list.rounded_rect({ p.x + p.w - 18, p.y + 88, 4, track_h }, 2, kInk.with_alpha(0.08f));
- list.rounded_rect({ p.x + p.w - 18, p.y + 88 + track_h * top, 4, std::max(24.0f, track_h * shown) }, 2,
- kCyan.with_alpha(0.8f));
}
-void Dashboard::draw_hints(DashboardFrame & frame) const {
- const ui::GlyphStyle style = ui::GlyphStyle::dark();
- if (library_.value > 0.5f) {
- const bool on = library_cursor_ < (int) live_.models.size();
- const ModelRow * m = on ? &live_.models[(size_t) library_cursor_] : nullptr;
- const char * act = !m ? "Load" : m->current ? "Unload" : "Load";
- const ui::Hint hints[] = { { ui::Button::dpad, "Choose" }, { ui::Button::cross, act }, { ui::Button::circle, "Back" } };
- ui::draw_hints(frame.overlay, fonts_, style, hints, 3, kGridX + kGridW, true);
- } else if (details_.value > 0.5f) {
- const ui::Hint hints[] = { { ui::Button::triangle, "Library" }, { ui::Button::circle, "Back" } };
- const bool model = detail_tile_ == kModel;
- ui::draw_hints(frame.overlay, fonts_, style, model ? hints : hints + 1, model ? 2 : 1, kGridX + kGridW, true);
- } else if (page_ == 1) {
- const Setting row_id = kCategories[setting_category_].rows[setting_row_].id;
- const bool toggle = in_rows_ && (is_toggle(row_id) || row_id == Setting::clear_scratch);
- if (!in_rows_) {
- const ui::Hint hints[] = { { ui::Button::dpad, "Choose" }, { ui::Button::cross, "Open" } };
- ui::draw_hints(frame.scene, fonts_, style, hints, 2, kGridX + kGridW, true);
- } else {
- const ui::Hint hints[] = { { ui::Button::dpad, "Change" },
- { ui::Button::cross, row_id == Setting::clear_scratch ? "Clear" : "Switch" },
- { ui::Button::circle, "Back" } };
- const ui::Hint plain[] = { { ui::Button::dpad, "Change" }, { ui::Button::circle, "Back" } };
- ui::draw_hints(frame.scene, fonts_, style, toggle ? hints : plain, toggle ? 3 : 2, kGridX + kGridW, true);
- }
- } else if (page_ == kMarketPage && (market_confirm_ || market_space_)) {
- // The dialog carries its own buttons.
- } else if (page_ == kMarketPage) {
- const ui::Hint browse[] = { { ui::Button::l2, "Search" }, { ui::Button::dpad, "Choose" }, { ui::Button::cross, "Open" } };
- const ui::Hint files[] = { { ui::Button::dpad, "Choose" }, { ui::Button::square, "Check fit" }, { ui::Button::cross, "Download" },
- { ui::Button::circle, "Back" } };
- ui::draw_hints(frame.scene, fonts_, style, market_files_ ? files : browse, market_files_ ? 4 : 3, kGridX + kGridW, true);
- } else if (page_ == kDownloadsPage) {
- const Download * d = dl_cursor_ < (int) market_.downloads.size() ? &market_.downloads[(size_t) dl_cursor_] : nullptr;
- const bool runs = d && (d->state == DownloadState::running || d->state == DownloadState::retrying ||
- d->state == DownloadState::queued);
- const char * cross = !d ? "" : runs ? "Pause" : d->state == DownloadState::done ? "" : d->state == DownloadState::failed ? "Try again" : "Resume";
- const char * square = !d ? "" : d->state == DownloadState::done ? "Clear from list" : dl_confirm_ == dl_cursor_ ? "Yes, delete it" : "Cancel";
- const ui::Hint all[] = { { ui::Button::dpad, "Choose" }, { ui::Button::square, square }, { ui::Button::cross, cross } };
- const ui::Hint done[] = { { ui::Button::dpad, "Choose" }, { ui::Button::square, square } };
- if (d) {
- const bool has_cross = d->state != DownloadState::done;
- ui::draw_hints(frame.scene, fonts_, style, has_cross ? all : done, has_cross ? 3 : 2, kGridX + kGridW, true);
- }
- } else if (page_ == kLogsPage) {
- const ui::Hint hints[] = { { ui::Button::dpad, "Scroll" },
- { ui::Button::square, log_llama_ ? "app.log" : "llama.log" },
- { ui::Button::triangle, log_errors_ ? "All lines" : "Errors only" },
- { ui::Button::cross, "Newest" } };
- ui::draw_hints(frame.scene, fonts_, style, hints, 4, kGridX + kGridW, true);
- } else if (focus_ == kModel) {
- const bool loaded = !live_.model_label.empty();
- const ui::Hint hints[] = { { ui::Button::dpad, "Move" },
- { ui::Button::cross, loaded ? "Details" : "Library" },
- { ui::Button::triangle, "Library" } };
- ui::draw_hints(frame.scene, fonts_, style, hints, loaded ? 3 : 2, kGridX + kGridW, true);
- } else {
- const ui::Hint hints[] = { { ui::Button::dpad, "Move" }, { ui::Button::cross, "Expand" } };
- const bool expands = focus_ == kUsage || focus_ == kPower;
- ui::draw_hints(frame.scene, fonts_, style, hints, expands ? 2 : 1, kGridX + kGridW, true);
- }
+// ---- drawing: dialogs and the busy sheet -------------------------------------------------
+
+namespace {
+
+void sheet(gfx::DrawList & l, const Rect & r) {
+ l.rounded_rect({ 0, 0, 1920, 1080 }, 0, kBlack.with_alpha(0.62f));
+ l.shadow({ r.x, r.y + 16, r.w, r.h }, 24, 48, kBlack.with_alpha(0.5f));
+ l.rounded_rect(r, 24, kSurface);
}
-void Dashboard::draw(DashboardFrame & frame) const {
- frame.backdrop.mode = gfx::BackdropMode::dots;
- frame.backdrop.colors[0] = Color::rgb(0x05070f);
- frame.backdrop.colors[1] = Color::rgb(0x0b1122);
- frame.backdrop.colors[2] = gfx::mix(Color::rgb(0x2b3d66), kBrand, 0.35f);
- frame.backdrop.time = clock_;
+} // namespace
- gfx::DrawList & scene = frame.scene;
- // A page arrives from the side it was asked for and fades in.
- const float in = tween::cubic_out(tween::clamp01(page_age_ / 0.35f));
- const float from = page_ > page_from_ ? 1.0f : -1.0f;
- scene.push_transform(1.0f, 960, 564, 60.0f * from * (1.0f - in), 0);
- scene.push_opacity(in);
- if (page_ == 0) {
- const float open = std::max(library_.value, details_.value);
- scene.push_transform(1.0f - 0.04f * open, 960, 564, 0, 0);
- scene.push_opacity(1.0f - 0.6f * open);
- for (int i = 0; i < kTiles; ++i) {
- if (i != focus_) {
- draw_tile(scene, i);
- }
- }
- draw_tile(scene, focus_); // last: its glow and shadow sit on its neighbours
- const float alpha = tween::stagger(age_, focus_, 0.06f, 0.5f) * (1.0f - tween::clamp01(open * 4.0f));
- if (alpha > 0.01f) {
- Rect ring = ring_.value();
- const float nudge = ui::shake(refusal_.value, clock_, 10.0f, 9.0f);
- ring.x += nudge * refusal_x_;
- ring.y += nudge * refusal_y_;
- scene.bordered_rect(ring, kRadius + 5.0f, kClear, 3.0f, accent_of(focus_).with_alpha(alpha));
- }
- scene.pop_opacity();
- scene.pop_transform();
- } else if (page_ == 1) {
- draw_settings(scene);
- } else if (page_ == kLogsPage) {
- draw_logs(scene);
- } else if (page_ == kDownloadsPage) {
- draw_downloads(scene);
- } else {
- draw_market(scene);
+void Dashboard::draw_dialogs(gfx::DrawList & l) const {
+ if (!(page_ == kModelsPage && (market_confirm_ || market_space_))) {
+ return;
}
- scene.pop_opacity();
- scene.pop_transform();
- draw_header(scene);
- draw_tabs(scene);
- if (library_.value > 0.01f || details_.value > 0.01f) {
- frame.glass = true;
- draw_library(frame.overlay, frame.glass_texture);
- draw_details(frame.overlay, frame.glass_texture);
- }
- draw_hints(frame);
- if (busy()) {
- draw_busy(frame.overlay); // the overlay draws last, over the library too
+ const ui::Fonts & f = fonts_;
+ const Rect r{ 960 - 440, 540 - 170, 880, 340 };
+ sheet(l, r);
+ ui::GlyphStyle style = ui::GlyphStyle::dark();
+ style.label = kInk2;
+ ui::HintLayout layout;
+ layout.size = 32;
+ layout.text_size = 22;
+ layout.cy = r.y + r.h - 56;
+ if (market_confirm_) {
+ put(l, f.semibold, "Unload the model first?", r.x + 56, r.y + 86, 34, kInk);
+ put(l, f.regular, "The download is faster with the memory free. The model can load again after.", r.x + 56, r.y + 136, 22, kInk2);
+ const ui::Hint h[] = { { ui::Button::circle, "Cancel" }, { ui::Button::cross, "Keep it loaded" }, { ui::Button::triangle, "Unload and download" } };
+ ui::draw_hints(l, fonts_, style, h, 3, r.x + r.w - 56, true, layout);
+ } else {
+ put(l, f.semibold, "Not enough space there", r.x + 56, r.y + 86, 34, kInk);
+ put(l, f.regular, market_dir_.empty() ? "No drive has room for it. Free some space and try again."
+ : "It fits on " + drive_name(market_dir_) + ".",
+ r.x + 56, r.y + 136, 22, kInk2);
+ const ui::Hint h[] = { { ui::Button::circle, "Cancel" }, { ui::Button::cross, "Save it there" } };
+ ui::draw_hints(l, fonts_, style, h, market_dir_.empty() ? 1 : 2, r.x + r.w - 56, true, layout);
}
}
-// Slow work: a scrim, a turning arc and what is happening, so a pause never
-// looks like a hang.
-void Dashboard::draw_busy(gfx::DrawList & list) const {
+// Slow work: a turning arc and what is happening, so a pause never looks like a hang.
+void Dashboard::draw_busy(gfx::DrawList & l) const {
const ui::Fonts & f = fonts_;
- list.rounded_rect({ 0, 0, 1920, 1080 }, 0, kBlack.with_alpha(0.6f));
- const Rect d{ 960 - 420, 540 - 120, 840, 240 };
- list.shadow({ d.x, d.y + 18, d.w, d.h }, 28, 40, kBlack.with_alpha(0.6f));
- draw_panel(list, d, 28, 1.0f, kCyan);
+ const Rect d{ 960 - 440, 540 - 110, 880, 220 };
+ sheet(l, d);
const float cx = d.x + 92, cy = d.cy();
- list.ring(cx, cy, 34, 6, kInk.with_alpha(0.12f));
- const float sweep = 1.6f + 0.9f * std::sin(clock_ * 2.1f);
- list.arc(cx, cy, 34, 6, clock_ * 5.0f, sweep, kCyan);
- ui::text(list, f.semibold, f.semibold.font->fit(busy_title_, 28, d.w - 200), d.x + 160, cy - 10, 28, kInk);
+ l.ring(cx, cy, 30, 4, kHair);
+ l.arc(cx, cy, 30, 4, clock_ * 5.0f, 1.4f + 0.8f * std::sin(clock_ * 2.1f), kBlue);
+ put(l, f.semibold, f.semibold.font->fit(busy_title_, 30, d.w - 220), d.x + 156, cy - 6, 30, kInk);
if (!busy_text_.empty()) {
- ui::text(list, f.regular, f.regular.font->fit(busy_text_, 21, d.w - 200), d.x + 160, cy + 30, 21,
- kInk.with_alpha(kMuted));
+ put(l, f.regular, f.regular.font->fit(busy_text_, 21, d.w - 220), d.x + 156, cy + 32, 21, kInk2);
}
}
diff --git a/ps5/app/dashboard.hpp b/ps5/app/dashboard.hpp
index b329564..39b57e7 100644
--- a/ps5/app/dashboard.hpp
+++ b/ps5/app/dashboard.hpp
@@ -1,11 +1,10 @@
-// PS5LM's screen, three pages switched with L1/R1:
-// - Dashboard: a bento grid of live tiles in the language of
-// ps5-homebrew-ui's "Pulse Dashboard" design (its palette, grid, panels,
-// focus ring and spatial navigation). Cross on the Model tile opens the
-// model's details, Triangle the model library.
-// - Settings: a rail of categories and rows of toggles and steppers, after
-// the kit's "Control Room" design, in the Pulse palette.
-// - Logs: app.log and llama.log, scrollable.
+// PS5LM's screen on the TV, four 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.
+// - Settings: categories of rows, with the logs under Diagnostics.
//
// SPDX-License-Identifier: GPL-3.0-or-later
#pragma once
@@ -37,13 +36,13 @@ struct DashboardFrame {
class Dashboard {
public:
- static constexpr int kTiles = 8;
- static constexpr int kPages = 5;
- static constexpr int kLogsPage = 2;
- static constexpr int kMarketPage = 3;
- static constexpr int kDownloadsPage = 4;
+ static constexpr int kPages = 4;
+ static constexpr int kHomePage = 0, kModelsPage = 1, kApiPage = 2, kSettingsPage = 3;
+ // 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) { ring_.snap(ring_rect()); }
+ explicit Dashboard(const hui::ui::Fonts & fonts) : fonts_(fonts) {}
void set_live(const Live & live) { live_ = live; }
// Slow work in progress: a spinner and these lines over everything, and
@@ -53,21 +52,14 @@ class Dashboard {
busy_text_ = std::move(text);
}
bool busy() const { return !busy_title_.empty(); }
- void open_library(); // over the dashboard, cursor on the loaded model
+ void open_library(); // the models on this console, cursor on the loaded one
+ void show_downloads();
void set_settings(const Settings & s) { settings_ = s; }
const Settings & settings() const { return settings_; }
void set_logs(std::vector<std::string> app, std::vector<std::string> llama);
+ bool wants_logs() const; // the logs are on screen: keep them fresh
void set_market(MarketView view) { market_ = std::move(view); }
int page() const { return page_; }
- void show_page(int page) {
- page_from_ = page_;
- page_ = page;
- page_age_ = 0;
- if (page == kMarketPage && !market_searched_) {
- market_searched_ = true;
- request_ = { Request::market_search, "" }; // the popular list, as arriving with R1 does
- }
- }
void update(const hui::InputFrame & input, float dt, hui::ui::Feedback & feedback);
void draw(DashboardFrame & frame) const;
@@ -75,9 +67,9 @@ 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 } kind = none;
+ 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)
- int repo = -1, file = -1; // a market file, or (repo) a download's index
+ int repo = -1, file = -1; // a market file, a download's index (repo), or a suggestion's (repo)
};
Request take_request() {
Request r = request_;
@@ -86,83 +78,78 @@ class Dashboard {
}
private:
- hui::gfx::Rect ring_rect() const;
- void draw_tile(hui::gfx::DrawList & list, int tile) const;
- void draw_content(hui::gfx::DrawList & list, int tile, const hui::gfx::Rect & r, float t) const;
- void draw_header(hui::gfx::DrawList & list) const;
- void draw_library(hui::gfx::DrawList & list, std::uint32_t glass) const;
- void draw_hints(DashboardFrame & frame) const;
- void draw_tabs(hui::gfx::DrawList & list) const;
- void draw_details(hui::gfx::DrawList & list, std::uint32_t glass) const;
- void draw_usage_details(hui::gfx::DrawList & list, const hui::gfx::Rect & panel) const;
- void draw_power_details(hui::gfx::DrawList & list, const hui::gfx::Rect & panel) const;
- void draw_settings(hui::gfx::DrawList & list) const;
- void draw_logs(hui::gfx::DrawList & list) const;
- void update_dashboard(const hui::InputFrame & input, hui::ui::Feedback & feedback);
+ void go_to(int page, hui::ui::Feedback * feedback);
+ void update_home(const hui::InputFrame & input, hui::ui::Feedback & feedback);
+ void update_models(const hui::InputFrame & input, hui::ui::Feedback & feedback);
+ void update_local(const hui::InputFrame & input, hui::ui::Feedback & feedback);
+ void update_suggested(const hui::InputFrame & input, hui::ui::Feedback & feedback);
+ 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_logs(const hui::InputFrame & input, hui::ui::Feedback & feedback);
- void update_market(const hui::InputFrame & input, hui::ui::Feedback & feedback);
void start_download(hui::ui::Feedback & feedback);
- void update_downloads(const hui::InputFrame & input, hui::ui::Feedback & feedback);
- void draw_downloads(hui::gfx::DrawList & list) const;
- void draw_market(hui::gfx::DrawList & list) const;
- const std::vector<std::string> & log_view() const { return log_llama_ ? llama_view_ : app_view_; }
void refilter_logs();
+ const std::vector<std::string> & log_view() const { return log_llama_ ? llama_view_ : app_view_; }
+
+ void draw_status(hui::gfx::DrawList & list) const;
+ void draw_dock(hui::gfx::DrawList & list) const;
+ void draw_home(hui::gfx::DrawList & list) const;
+ void draw_models(hui::gfx::DrawList & list) const;
+ void draw_local(hui::gfx::DrawList & list, const hui::gfx::Rect & area) const;
+ void draw_suggested(hui::gfx::DrawList & list, const hui::gfx::Rect & area) const;
+ 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_settings(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;
+ void draw_hints(hui::gfx::DrawList & list) const;
const hui::ui::Fonts & fonts_;
Live live_;
Request request_;
- float age_ = 0; // seconds since start: the entrance
+ float age_ = 0; // seconds since start
float clock_ = 0; // idle motion
std::string busy_title_, busy_text_;
- void draw_busy(hui::gfx::DrawList & list) const;
- int focus_ = 0;
- int came_from_ = -1;
- hui::Direction came_by_ = hui::Direction::none;
- hui::ui::SpringRect ring_;
- hui::tween::Spring lift_[kTiles];
- hui::ui::Pulse refusal_;
- float refusal_x_ = 0, refusal_y_ = 0;
-
- bool library_open_ = false;
- int library_cursor_ = 0;
- hui::tween::Spring library_; // 0 closed, 1 open
- hui::tween::Spring cursor_y_; // the highlight's slot
- int slot(int row) const; // a model row's line in the list, after the section headers
-
- bool details_open_ = false;
- int detail_tile_ = 0; // which tile the open details belong to
- hui::tween::Spring details_; // 0 closed, 1 open
int page_ = 0;
int page_from_ = 0;
- float page_age_ = 10; // seconds since the page changed
+ float page_age_ = 10; // seconds since the page changed
+ hui::tween::Spring dock_x_; // the current tab's marker
+ hui::tween::Spring rows_y_; // the focused row's highlight, on the Models and Settings pages
+ hui::tween::Spring hero_; // the speed the Home page shows, eased
+
+ // Models.
+ int section_ = kLocal;
+ bool in_list_ = false; // the focus is on the list, not the sections
+ int local_cursor_ = 0;
+ int suggested_cursor_ = 0;
+ int market_chip_ = 0; // which search the chips select
+ int market_repo_ = 0; // cursor in the repositories
+ int market_file_ = 0; // cursor in the open repository's files
+ bool market_files_ = false; // the cursor is in the files
+ bool market_searched_ = false;
+ bool market_confirm_ = false; // asking whether to unload the model first
+ bool market_space_ = false; // telling that the download does not fit where it would go
+ std::string market_dir_; // where this download goes instead of the setting, or empty
+ int dl_cursor_ = 0;
+ int dl_confirm_ = -1; // the row Square was pressed on once (a second press deletes)
+ MarketView market_;
+ // Settings.
Settings settings_;
int setting_category_ = 0;
int setting_row_ = 0;
- bool in_rows_ = false; // the focus is on the rows, not the rail
- hui::ui::SpringRect setting_focus_;
+ bool in_rows_ = false; // the focus is on the rows, not the categories
+ // Diagnostics.
std::vector<std::string> app_log_, llama_log_; // as read
std::vector<std::string> app_view_, llama_view_; // after the filter
bool log_llama_ = false;
bool log_errors_ = false;
- int log_scroll_ = 0; // lines up from the newest
-
- MarketView market_;
- int market_chip_ = 0; // which search the chips select
- int market_repo_ = 0; // cursor in the repositories
- int market_file_ = 0; // cursor in the open repository's files
- bool market_files_ = false; // the cursor is in the files
- bool market_searched_ = false;
- bool market_confirm_ = false; // asking whether to unload the model first
- bool market_space_ = false; // telling that the download does not fit where it would go
- std::string market_dir_; // where this download goes instead of the setting, or empty
- int dl_cursor_ = 0; // the Downloads page's row
- int dl_confirm_ = -1; // the row Square was pressed on once (a second press deletes)
- mutable char size_text_[64] = {};
+ int log_scroll_ = 0; // lines up from the newest
};
} // namespace ps5lm
diff --git a/ps5/app/main.cpp b/ps5/app/main.cpp
index 693b130..dd67e35 100644
--- a/ps5/app/main.cpp
+++ b/ps5/app/main.cpp
@@ -45,6 +45,7 @@
#include "model_plan.hpp"
#include "settings.hpp"
#include "stats.hpp"
+#include "suggested.hpp"
#include "version.hpp"
#include <ps5platform/heap.h>
@@ -446,6 +447,7 @@ struct Models {
row.fits = p.fits;
row.size_gib = m.file_bytes / 1073741824.0;
row.preset = pre ? pre->label : "";
+ row.decision = m.decision;
row.current = path == running;
rows.push_back(row);
std::printf("ps5lm-app: model %s (%s): %s\n", m.file_name.c_str(), m.arch.c_str(), p.why.c_str());
@@ -472,6 +474,7 @@ struct Models {
model_part.args = p.args;
model_part.model_arch = m.arch;
model_part.preset = pre ? pre->label : "";
+ model_part.decision = m.decision;
model_part.model_gib = m.file_bytes / 1073741824.0;
model_part.ctx = p.ctx;
model_part.kv_type = p.kv_type;
@@ -573,9 +576,9 @@ int main(int, char **) {
hui::gfx::Renderer renderer;
hui::gfx::Font regular, semibold, headline, mono;
hui::ui::Fonts fonts;
- const bool ui_ok = renderer.init() && load_font(renderer, "inter-regular.huifont", &regular, &fonts.regular) &&
- load_font(renderer, "inter-semibold.huifont", &semibold, &fonts.semibold) &&
- load_font(renderer, "montserrat-medium.huifont", &headline, &fonts.display) &&
+ const bool ui_ok = renderer.init() && load_font(renderer, "manrope-500.huifont", &regular, &fonts.regular) &&
+ load_font(renderer, "manrope-600.huifont", &semibold, &fonts.semibold) &&
+ load_font(renderer, "manrope-200.huifont", &headline, &fonts.display) &&
load_font(renderer, "dejavu-sans-mono.huifont", &mono, &fonts.mono);
fonts.pixel = fonts.mono;
fonts.hand = fonts.regular;
@@ -676,7 +679,7 @@ int main(int, char **) {
for (const auto & d : market.snapshot().downloads) {
// Running already, maybe: the queue's thread starts it at once.
if (d.state == DownloadState::queued || d.state == DownloadState::running) {
- dash.show_page(Dashboard::kDownloadsPage);
+ dash.show_downloads();
library_shown = true; // stay on Downloads, not the library
break;
}
@@ -712,7 +715,7 @@ int main(int, char **) {
}
const bool serving = live.state == ServerState::ready || live.state == ServerState::generating;
if (serving && !was_serving) {
- notify("PS5LM: ready, chat in a browser on this network");
+ notify(live.decision.empty() ? "PS5LM: ready, chat in a browser on this network" : "PS5LM: ready for decisions at /v1/systemone");
}
was_serving = serving;
if (n % 30 == 0) {
@@ -793,7 +796,7 @@ int main(int, char **) {
}
dash.set_market(std::move(mv));
}
- if (dash.page() == Dashboard::kLogsPage && n % 60 == 0) {
+ if (dash.wants_logs() && n % 60 == 0) {
dash.set_logs(tail_lines(kLog), tail_lines(kLlamaLog));
}
@@ -840,6 +843,17 @@ int main(int, char **) {
}
break;
}
+ case Dashboard::Request::suggested_download: {
+ const Suggestion & s = kSuggestions[std::clamp(req.repo, 0, kSuggestionCount - 1)];
+ const std::string dir = req.path.empty() ? models.settings.download_dir : req.path;
+ for (const SuggestedFile * f : { &s.model, &s.mmproj }) {
+ if (f->file) {
+ market.enqueue({ s.repo, f->file, f->sha256, dir, f->bytes, f->save_as ? f->save_as : "" }, free_gib(dir));
+ }
+ }
+ dash.show_downloads();
+ break;
+ }
case Dashboard::Request::download_pause: market.pause(req.repo); break;
case Dashboard::Request::download_resume: market.resume(req.repo); break;
case Dashboard::Request::download_remove: market.remove(req.repo); break;
diff --git a/ps5/app/market.cpp b/ps5/app/market.cpp
index a4b14f8..c6ea6d3 100644
--- a/ps5/app/market.cpp
+++ b/ps5/app/market.cpp
@@ -250,7 +250,7 @@ const char * state_name(DownloadState s) {
std::string part_path(const Download & d) {
const size_t slash = d.file.find_last_of('/');
- return d.dir + "/" + d.file.substr(slash == std::string::npos ? 0 : slash + 1) + ".part";
+ return d.dir + "/" + (d.save_as.empty() ? d.file.substr(slash == std::string::npos ? 0 : slash + 1) : d.save_as) + ".part";
}
uint64_t file_size(const std::string & path) {
@@ -264,7 +264,7 @@ void Market::save_queue() {
nlohmann::json j = nlohmann::json::array();
for (const auto & d : view_.downloads) {
j.push_back({ { "repo", d.repo }, { "file", d.file }, { "sha256", d.sha256 }, { "dir", d.dir }, { "bytes", d.bytes },
- { "state", state_name(d.state) }, { "note", d.note }, { "resume", d.resume } });
+ { "state", state_name(d.state) }, { "note", d.note }, { "resume", d.resume }, { "save_as", d.save_as } });
}
std::ofstream(kQueue) << j.dump(1) << "\n";
}
@@ -284,6 +284,7 @@ void Market::load_queue() {
d.dir = e.value("dir", std::string());
d.bytes = e.value("bytes", (uint64_t) 0);
d.note = e.value("note", std::string());
+ d.save_as = e.value("save_as", std::string());
const std::string st = e.value("state", std::string());
// Running when the app stopped: carry on.
d.state = st == "paused" ? DownloadState::paused : st == "failed" ? DownloadState::failed
diff --git a/ps5/app/market.hpp b/ps5/app/market.hpp
index 146c098..db35b65 100644
--- a/ps5/app/market.hpp
+++ b/ps5/app/market.hpp
@@ -34,6 +34,7 @@ struct MarketRepo {
struct MarketJob {
std::string repo, file, sha256, dir;
uint64_t bytes = 0;
+ std::string save_as; // the name on the console when it is not the file's ("mmproj-<model>.gguf")
};
enum class DownloadState : uint8_t { queued, running, retrying, paused, failed, done };
diff --git a/ps5/app/preview_main.cpp b/ps5/app/preview_main.cpp
index 4e7b0cf..1dbf288 100644
--- a/ps5/app/preview_main.cpp
+++ b/ps5/app/preview_main.cpp
@@ -52,6 +52,8 @@ bool load_font(hui::gfx::Renderer & r, const std::string & path, hui::gfx::Font
// A run as the console measured it: Qwen3.8-27B UD-Q2_K_XL, 64k, q4_0 cache.
float g_loading = -1; // >= 0: draw the loading state at this progress
+bool g_decision = false; // d1 Omni 600M instead of Qwen 3.8
+bool g_empty = false; // nothing loaded
ps5lm::Live sample(float seconds, bool generating) {
ps5lm::Live L;
@@ -134,6 +136,46 @@ ps5lm::Live sample(float seconds, bool generating) {
usb.preset = "Gemma 4";
usb.size_gib = 5.30;
L.models.push_back(usb);
+ L.models[0].decision = "";
+ {
+ ps5lm::ModelRow d;
+ d.file = "/data/PS5LM/models/d1-omni-600M-BF16.gguf";
+ d.label = "d1-omni-600M-BF16";
+ d.plan = "decision model (lfm2-d1-omni), 4k context, f16 cache, images: 2.9 of 11.0 GiB";
+ d.decision = "lfm2-d1-omni";
+ d.size_gib = 0.71;
+ d.fits = true;
+ d.drive = "Internal storage";
+ L.models.push_back(d);
+ }
+ if (g_decision) {
+ for (auto & m : L.models) {
+ m.current = m.decision == "lfm2-d1-omni";
+ }
+ L.state = generating ? ps5lm::ServerState::generating : ps5lm::ServerState::ready;
+ L.model_label = "d1-omni-600M-BF16";
+ L.model_arch = "lfm2";
+ L.decision = "lfm2-d1-omni";
+ L.preset = "";
+ L.model_gib = 0.71;
+ L.ctx = 4096;
+ L.ctx_used = 793;
+ L.prompt_tps = 2140.0f;
+ L.gen_tps = 0;
+ L.tokens = 0;
+ L.prompt_tokens = 88412;
+ L.requests = 131;
+ L.free_gib = 8.6;
+ }
+ if (g_empty) {
+ L.state = ps5lm::ServerState::no_model;
+ L.model_label.clear();
+ L.decision.clear();
+ L.requests = L.tokens = L.prompt_tokens = 0;
+ for (auto & m : L.models) {
+ m.current = false;
+ }
+ }
if (g_loading >= 0) {
L.state = ps5lm::ServerState::loading;
L.load_progress = g_loading;
@@ -147,11 +189,11 @@ ps5lm::Live sample(float seconds, bool generating) {
} // namespace
int main(int argc, char ** argv) {
- if (argc < 3) {
- std::fprintf(stderr, "usage: %s <kit assets dir> <output dir>\n", argv[0]);
+ if (argc < 4) {
+ std::fprintf(stderr, "usage: %s <kit assets dir> <output dir> <app assets dir>\n", argv[0]);
return 2;
}
- const std::string assets = argv[1], out = argv[2];
+ const std::string assets = argv[1], out = argv[2], app = argv[3];
const int W = 1920, H = 1080;
if (!open_context()) {
std::fprintf(stderr, "no surfaceless EGL OpenGL 4.5 context\n");
@@ -161,9 +203,9 @@ int main(int argc, char ** argv) {
hui::gfx::Renderer renderer;
hui::gfx::Font regular, semibold, display, mono, pixel, hand;
hui::ui::Fonts fonts;
- if (!renderer.init() || !load_font(renderer, assets + "/fonts/inter-regular.huifont", &regular, &fonts.regular) ||
- !load_font(renderer, assets + "/fonts/inter-semibold.huifont", &semibold, &fonts.semibold) ||
- !load_font(renderer, assets + "/fonts/montserrat-medium.huifont", &display, &fonts.display) ||
+ if (!renderer.init() || !load_font(renderer, app + "/fonts/manrope-500.huifont", &regular, &fonts.regular) ||
+ !load_font(renderer, app + "/fonts/manrope-600.huifont", &semibold, &fonts.semibold) ||
+ !load_font(renderer, app + "/fonts/manrope-200.huifont", &display, &fonts.display) ||
!load_font(renderer, assets + "/fonts/dejavu-sans-mono.huifont", &mono, &fonts.mono)) {
return 1;
}
@@ -301,72 +343,69 @@ int main(int argc, char ** argv) {
return in;
};
+ using D = hui::Direction;
+ using A = hui::Action;
g_loading = 0.45f;
step(90, {}, false);
- shot("00-loading");
+ shot("00-home-loading");
g_loading = -1;
step(120, {}, true);
- shot("01-dashboard");
- // USAGE, POWER, then down to the Model tile.
- step(20, nav(hui::Direction::right), true);
- step(40, press(hui::Action::confirm), true);
- shot("02a-usage");
- step(30, press(hui::Action::back), true);
- step(20, nav(hui::Direction::right), true);
- step(40, press(hui::Action::confirm), true);
- shot("02b-power");
- step(30, press(hui::Action::back), true);
- step(40, nav(hui::Direction::down), false);
- shot("02-model-focus");
- step(60, press(hui::Action::confirm), false);
- shot("03-details");
- step(60, press(hui::Action::north), false);
- shot("03-library");
- step(30, nav(hui::Direction::up), false);
- shot("04-library-choose");
- for (int i = 0; i < 3; ++i) {
- step(25, nav(hui::Direction::down), false);
- }
- shot("05-library-usb");
- step(30, press(hui::Action::back), false);
- step(40, press(hui::Action::page_next), false);
- shot("06-settings");
- step(20, press(hui::Action::confirm), false);
- step(30, nav(hui::Direction::down), false);
- shot("07-settings-row");
- step(20, press(hui::Action::back), false);
- step(20, nav(hui::Direction::down), false);
- step(30, press(hui::Action::confirm), false);
- shot("08-settings-model");
- step(20, press(hui::Action::back), false);
- step(20, nav(hui::Direction::down), false);
- step(20, press(hui::Action::confirm), false);
- step(20, nav(hui::Direction::down), false);
- step(30, nav(hui::Direction::down), false);
- shot("08-settings-chat");
- step(40, press(hui::Action::page_next), false);
- shot("09-logs");
- step(30, press(hui::Action::north), false);
- shot("10-logs-errors");
- step(40, press(hui::Action::page_next), false);
- shot("11-market");
- step(30, press(hui::Action::confirm), false);
- step(20, nav(hui::Direction::down), false);
- shot("12-market-files");
+ shot("01-home");
+ step(60, {}, false);
+ shot("02-home-idle");
+ g_decision = true;
+ step(60, {}, true);
+ shot("03-home-decision");
+ g_decision = false;
+ g_empty = true;
+ step(60, {}, false);
+ shot("04-home-empty");
+ g_empty = false;
+ step(40, press(A::confirm), false);
+ shot("05-models-local");
+ step(20, press(A::back), false);
+ step(20, nav(D::down), false);
+ step(20, press(A::confirm), false);
+ step(20, nav(D::down), false);
+ step(30, nav(D::down), false);
+ shot("06-models-suggested");
+ step(20, press(A::back), false);
+ step(20, nav(D::down), false);
+ step(20, press(A::confirm), false);
+ step(30, nav(D::down), false);
+ shot("07-models-search");
+ step(30, press(A::confirm), false);
dash.set_market(mv);
- step(30, press(hui::Action::confirm), false);
- shot("13-market-space");
- step(30, press(hui::Action::confirm), false);
- shot("14-market-confirm");
- step(20, press(hui::Action::back), false);
- step(30, press(hui::Action::page_next), false);
- shot("15-downloads");
- step(20, nav(hui::Direction::down), false);
- step(20, nav(hui::Direction::down), false);
- step(20, press(hui::Action::west), false);
- shot("16-downloads-cancel");
- dash.set_busy("Applying the new limits", "Planning every model again for 32k tokens and the q8_0 cache");
- step(20, press(hui::Action::back), false);
- shot("17-busy");
+ step(20, nav(D::down), false);
+ shot("08-models-files");
+ step(30, press(A::confirm), false);
+ shot("09-models-space");
+ step(20, press(A::back), false);
+ step(20, press(A::back), false);
+ step(20, press(A::back), false);
+ step(20, nav(D::down), false);
+ step(20, press(A::confirm), false);
+ step(30, nav(D::down), false);
+ shot("10-models-downloads");
+ step(40, press(A::page_next), false);
+ shot("11-api");
+ g_decision = true;
+ step(40, {}, false);
+ shot("12-api-decision");
+ g_decision = false;
+ step(40, press(A::page_next), false);
+ shot("13-settings");
+ step(20, press(A::confirm), false);
+ step(30, nav(D::down), false);
+ shot("14-settings-row");
+ step(20, press(A::back), false);
+ for (int i = 0; i < 4; ++i) {
+ step(15, nav(D::down), false);
+ }
+ step(30, press(A::confirm), false);
+ shot("15-settings-diagnostics");
+ dash.set_busy("Loading Qwen3.8 27B", "Restarting with the whole memory for it, about 90 seconds");
+ step(30, {}, false);
+ shot("16-busy");
return ok ? 0 : 1;
}
diff --git a/ps5/app/stats.cpp b/ps5/app/stats.cpp
index 143616b..4c76125 100644
--- a/ps5/app/stats.cpp
+++ b/ps5/app/stats.cpp
@@ -242,6 +242,7 @@ void StatsCollector::set_model(const Live & m) {
live_.model_label = m.model_label;
live_.model_arch = m.model_arch;
live_.preset = m.preset;
+ live_.decision = m.decision;
live_.model_gib = m.model_gib;
live_.ctx = m.ctx;
live_.kv_type = m.kv_type;
diff --git a/ps5/app/stats.hpp b/ps5/app/stats.hpp
index d566b76..c9a42dc 100644
--- a/ps5/app/stats.hpp
+++ b/ps5/app/stats.hpp
@@ -33,6 +33,7 @@ struct ModelRow {
std::string arch;
std::string plan; // the planner's line ("64k context, q8_0 cache: 9.9 of 11.0 GiB")
std::string preset; // the preset that filled its sampling ("Qwen 3.8"), or empty
+ std::string decision; // its decision type ("clef", "lfm2-d1"), empty for a language model
double size_gib = 0;
bool fits = false;
bool current = false;
@@ -47,6 +48,7 @@ struct Live {
std::string model_label;
std::string model_arch;
std::string preset; // "Qwen 3.8"
+ std::string decision; // the decision type, empty for a language model
double model_gib = 0;
uint32_t ctx = 0;
std::string kv_type;
diff --git a/ps5/app/suggested.hpp b/ps5/app/suggested.hpp
new file mode 100644
index 0000000..ca080de
--- /dev/null
+++ b/ps5/app/suggested.hpp
@@ -0,0 +1,57 @@
+// The models the Models page suggests: the ones that run well on this console,
+// picked by hand and checked on it. Each is one file (and its image encoder,
+// when it reads images) from Hugging Face, pinned by size and sha256.
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+#include <cstdint>
+
+namespace ps5lm {
+
+struct SuggestedFile {
+ const char * file; // in the repository
+ uint64_t bytes;
+ const char * sha256;
+ const char * save_as; // the name on the console, or null for the same
+};
+
+struct Suggestion {
+ const char * name; // what the list calls it
+ bool decision; // answers /v1/systemone, not chat
+ const char * about; // one line: what it is good at here
+ const char * repo;
+ SuggestedFile model;
+ SuggestedFile mmproj; // file null: text only
+};
+
+inline constexpr Suggestion kSuggestions[] = {
+ { "Qwen 3.8 27B", false, "The strongest model that fits, with a 64k context", "unsloth/Qwen3.8-27B-GGUF",
+ { "Qwen3.8-27B-UD-IQ2_XXS.gguf", 7266070528ull, "e792d8fb3142fe6d9171876d6da0f71f05a71028718debc72dbec93ff645e67d", nullptr },
+ {} },
+ { "Qwen 3.5 9B", false, "Fast all-rounder that leaves room for long chats", "unsloth/Qwen3.5-9B-GGUF",
+ { "Qwen3.5-9B-Q4_K_M.gguf", 5680522464ull, "03b74727a860a56338e042c4420bb3f04b2fec5734175f4cb9fa853daf52b7e8", nullptr },
+ {} },
+ { "Gemma 4 E4B", false, "Reads images, quick replies", "ggml-org/gemma-4-E4B-it-GGUF",
+ { "gemma-4-E4B-it-Q4_0.gguf", 4590807392ull, "a555b900214b477d8880e7832e0b8925e139b0159640036b09fe472b6f2097f2", nullptr },
+ { "mmproj-gemma-4-E4B-it-Q8_0.gguf", 559874816ull, "197f49a93027f9843772bd24a6a9e0be2a32a788de5a3def330e9c585d86edd1", nullptr } },
+ { "MiniCPM-V 4.7 1B", false, "Small and very fast, reads images", "openbmb/MiniCPM-V-4.7-1B-gguf",
+ { "MiniCPM-V-4_7-1B-Q4_K_M.gguf", 672003680ull, "588c6c94c82f756b86dba35c42ed9ba9ec187d65824eb52f039c347df563e63d", nullptr },
+ { "mmproj-model-f16.gguf", 1110117984ull, "fb9cc047a3cdad5317fd8433a4aeda2d22f00f02ca4bd93b34ad84165b25a900",
+ "mmproj-MiniCPM-V-4_7-1B-f16.gguf" } },
+ { "Qwen 3.5 0.8B", false, "Tiny and instant, for simple tasks", "unsloth/Qwen3.5-0.8B-GGUF",
+ { "Qwen3.5-0.8B-Q4_K_M.gguf", 532517120ull, "bd258782e35f7f458f8aced1adc053e6e92e89bc735ba3be89d38a06121dc517", nullptr },
+ {} },
+ { "d1 Omni 600M", true, "Decisions about text, images and sound in a fraction of a second", "LiquidAI/d1-omni-600M-GGUF",
+ { "d1-omni-600M-BF16.gguf", 764049056ull, "9bf4f344835f64264978907a0b0bc43c9f0e59804f15176f8b5630c930c3c9df", nullptr },
+ { "mmproj-d1-omni-600M-BF16.gguf", 442441792ull, "1aed7f0ff41f354c66cf3fa41c9eb43f1a76b3ea9453edd8e804567674a9041e", nullptr } },
+ { "d1 3B", true, "Sharper decisions about text and images", "LiquidAI/d1-3B-GGUF",
+ { "d1-3B-Q8_0.gguf", 2874781280ull, "2f0942d5a5f64cf69c3356d2be439b71644b1f0eb3a580912a5a0179eeaba77d", nullptr },
+ { "mmproj-d1-3B-Q8_0.gguf", 583109728ull, "2505920ce464b7c54acd8b7b74a931c0c671f06d0c8833760b2fbceeb253e92a", nullptr } },
+ { "Clef Flash", true, "Answers every question of a request together", "ggml-org/Clef-Flash-GGUF",
+ { "Clef-Flash-Q4_K_M.gguf", 6486448288ull, "3626116623ca8d89641952471fac9ce12af84fb3517520029a2ac6f5146868a2", nullptr },
+ { "mmproj-Clef-Flash-Q8_0.gguf", 624229728ull, "9dd8bc279f57d33b0697d4d0fe900fe751a24c9e3d30ab90969d4714ffc0722d", nullptr } },
+};
+inline constexpr int kSuggestionCount = (int) (sizeof(kSuggestions) / sizeof(kSuggestions[0]));
+
+} // namespace ps5lm
diff --git a/scripts/bake-fonts.sh b/scripts/bake-fonts.sh
new file mode 100755
index 0000000..84ae4c4
--- /dev/null
+++ b/scripts/bake-fonts.sh
@@ -0,0 +1,23 @@
+#!/usr/bin/env bash
+# Bakes the dashboard's typeface, Manrope (OFL, third_party/fonts/manrope), into
+# the SDF .huifont files the app loads from assets/fonts: weight 500 for text,
+# 600 for titles and 200 for the large numbers. Needs fontTools and a host clang++.
+set -euo pipefail
+
+root="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
+kit="$root/third_party/ps5-homebrew-ui"
+src="$root/third_party/fonts/manrope"
+out="$root/ps5/app/assets/fonts"
+tmp="$root/build/fonts"
+mkdir -p "$tmp" "$out"
+"${HOST_CXX:-clang++}" -std=c++20 -O2 -w "$kit/tools/font-baker/bake_font.cpp" -o "$tmp/bake_font"
+for weight in 200 500 600; do
+ python3 -c 'import sys
+from fontTools.ttLib import TTFont
+from fontTools.varLib.instancer import instantiateVariableFont
+instantiateVariableFont(TTFont(sys.argv[1]), {"wght": int(sys.argv[2])}).save(sys.argv[3])' \
+ "$src/Manrope[wght].ttf" "$weight" "$tmp/manrope-$weight.ttf"
+ "$tmp/bake_font" "$tmp/manrope-$weight.ttf" "$out/manrope-$weight.huifont" 64 8 1024
+done
+cp "$src/OFL.txt" "$out/manrope-LICENSE.txt"
+echo "bake-fonts: $out"
diff --git a/scripts/build-app.sh b/scripts/build-app.sh
index a0ad59d..200b1cc 100755
--- a/scripts/build-app.sh
+++ b/scripts/build-app.sh
@@ -209,13 +209,16 @@ if [ ! -f "$sce_sys/pic0.dds" ] || [ "$sce_sys/source/background.png" -nt "$sce_
fi
cp "$sce_sys/icon0.png" "$sce_sys/pic0.dds" "$sce_sys/pic1.dds" "$app/sce_sys/"
cp "$vk/runtime/libc.prx" "$app/sce_module/libc.prx"
-# The dashboard's fonts and interface sounds (ps5-homebrew-ui's, with their licences).
+# The dashboard's fonts and interface sounds, with their licences.
mkdir -p "$app/assets/fonts" "$app/assets/audio"
-for font in inter-regular inter-semibold montserrat-medium dejavu-sans-mono; do
- cp "$root/third_party/ps5-homebrew-ui/assets/fonts/$font.huifont" "$app/assets/fonts/"
-done
-cp "$root/third_party/ps5-homebrew-ui/assets/fonts/"*LICENSE* "$app/assets/fonts/"
-cp -r "$root/third_party/ps5-homebrew-ui/assets/audio/sfx" "$app/assets/audio/"
+# Manrope for the screen (scripts/bake-fonts.sh), the kit's DejaVu Sans Mono for logs and code.
+cp "$root/ps5/app/assets/fonts/"manrope-* "$app/assets/fonts/"
+cp "$root/third_party/ps5-homebrew-ui/assets/fonts/"{dejavu-sans-mono.huifont,DejaVu-LICENSE.txt} "$app/assets/fonts/"
+# The interface sounds are PocketVibe's (ps5/app/assets/audio/sfx).
+# shortcut: they take the kit's default set name (glass), so no kit change picks
+# them; give them a set of their own if the kit ever lets an app add one.
+mkdir -p "$app/assets/audio/sfx/glass"
+cp "$root/ps5/app/assets/audio/sfx/"* "$app/assets/audio/sfx/glass/"
# ps5-exporter (Marice, GPL-3.0): a title may not read the temperature, fan or
# SoC power sensors, a payload may. The app sends it to elfldr when it is not
# running. Pinned by version and hash, downloaded once into .deps.
diff --git a/scripts/preview-app-ui.sh b/scripts/preview-app-ui.sh
index 8b0f8db..856957e 100755
--- a/scripts/preview-app-ui.sh
+++ b/scripts/preview-app-ui.sh
@@ -41,4 +41,4 @@ export -f compile
export root kit obj cxx cc
mapfile -t objects < <(printf '%s\n' "${sources[@]}" | xargs -P "$(nproc)" -I{} bash -c 'compile "$@"' _ {})
$cxx "${objects[@]}" -lEGL -lGL -lm -pthread -o "$out/ps5lm_preview"
-"$out/ps5lm_preview" "$kit/assets" "$out"
+"$out/ps5lm_preview" "$kit/assets" "$out" "$root/ps5/app/assets"
diff --git a/third_party/fonts/manrope/Manrope[wght].ttf b/third_party/fonts/manrope/Manrope[wght].ttf
new file mode 100644
index 0000000..75274da
Binary files /dev/null and b/third_party/fonts/manrope/Manrope[wght].ttf differ
diff --git a/third_party/fonts/manrope/OFL.txt b/third_party/fonts/manrope/OFL.txt
new file mode 100644
index 0000000..e271172
--- /dev/null
+++ b/third_party/fonts/manrope/OFL.txt
@@ -0,0 +1,93 @@
+Copyright 2018 The Manrope Project Authors (https://github.com/googlefonts/manrope)
+
+This Font Software is licensed under the SIL Open Font License, Version 1.1.
+This license is copied below, and is also available with a FAQ at:
+http://scripts.sil.org/OFL
+
+
+-----------------------------------------------------------
+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
+-----------------------------------------------------------
+
+PREAMBLE
+The goals of the Open Font License (OFL) are to stimulate worldwide
+development of collaborative font projects, to support the font creation
+efforts of academic and linguistic communities, and to provide a free and
+open framework in which fonts may be shared and improved in partnership
+with others.
+
+The OFL allows the licensed fonts to be used, studied, modified and
+redistributed freely as long as they are not sold by themselves. The
+fonts, including any derivative works, can be bundled, embedded,
+redistributed and/or sold with any software provided that any reserved
+names are not used by derivative works. The fonts and derivatives,
+however, cannot be released under any other type of license. The
+requirement for fonts to remain under this license does not apply
+to any document created using the fonts or their derivatives.
+
+DEFINITIONS
+"Font Software" refers to the set of files released by the Copyright
+Holder(s) under this license and clearly marked as such. This may
+include source files, build scripts and documentation.
+
+"Reserved Font Name" refers to any names specified as such after the
+copyright statement(s).
+
+"Original Version" refers to the collection of Font Software components as
+distributed by the Copyright Holder(s).
+
+"Modified Version" refers to any derivative made by adding to, deleting,
+or substituting -- in part or in whole -- any of the components of the
+Original Version, by changing formats or by porting the Font Software to a
+new environment.
+
+"Author" refers to any designer, engineer, programmer, technical
+writer or other person who contributed to the Font Software.
+
+PERMISSION & CONDITIONS
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of the Font Software, to use, study, copy, merge, embed, modify,
+redistribute, and sell modified and unmodified copies of the Font
+Software, subject to the following conditions:
+
+1) Neither the Font Software nor any of its individual components,
+in Original or Modified Versions, may be sold by itself.
+
+2) Original or Modified Versions of the Font Software may be bundled,
+redistributed and/or sold with any software, provided that each copy
+contains the above copyright notice and this license. These can be
+included either as stand-alone text files, human-readable headers or
+in the appropriate machine-readable metadata fields within text or
+binary files as long as those fields can be easily viewed by the user.
+
+3) No Modified Version of the Font Software may use the Reserved Font
+Name(s) unless explicit written permission is granted by the corresponding
+Copyright Holder. This restriction only applies to the primary font name as
+presented to the users.
+
+4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
+Software shall not be used to promote, endorse or advertise any
+Modified Version, except to acknowledge the contribution(s) of the
+Copyright Holder(s) and the Author(s) or with their explicit written
+permission.
+
+5) The Font Software, modified or unmodified, in part or in whole,
+must be distributed entirely under this license, and must not be
+distributed under any other license. The requirement for fonts to
+remain under this license does not apply to any document created
+using the Font Software.
+
+TERMINATION
+This license becomes null and void if any of the above conditions are
+not met.
+
+DISCLAIMER
+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
+OTHER DEALINGS IN THE FONT SOFTWARE.