diff --git a/README.md b/README.md index 6784e06..5c0adb2 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,15 @@ Summit Unfiltered view: compact list grouped by source with the reason each entry was detected

-

Real renders of the Slint GUI, made on a KDE neon test VM (X11) from its real Steam account: cover art from Steam's own cache, real playtime. Steam is not logged in there, so no Steam game is installed and they show "Not installed". The one installed entry is Voidrunner, added by hand with summit add, pinned, with custom artwork (a screenshot, cropped to fit the cover). No game was running; the in-game overlay is not built yet.

+

+ Summit in list layout, Midnight theme + Summit in the light Daylight theme +

+

+ Summit Library in the Violet theme +

+ +

Real window captures of the Slint GUI running on a KDE neon test VM (X11), from its real Steam account: Steam's own cover art and playtime. Steam isn't logged in there, so Steam games read "Not installed". Voidrunner is installed and added by hand, with the portrait art from its own Steam package. Layout (big grid or list) and theme (Midnight, Steam blue, Daylight, Violet) are switchable in the navbar. Nothing was running in a game; the in-game overlay does not exist yet.

> [!NOTE] > **Pre-alpha.** What works today is the command-line core: library scanning with detection reasons, playtime tracking, Home pins, custom artwork, and per-game display profiles applied at launch. The launcher GUI, Steam shortcut export, in-game overlay and upscaling/frame-gen backends are planned and are **not built yet**. Nothing below is marked as working unless it is. @@ -42,6 +50,8 @@ | Display profile applied at launch: monitor, resolution, refresh rate | Working for KDE Wayland (`kscreen-doctor`), wlroots Wayland (`wlr-randr`) and X11 (`xrandr`). **GNOME Wayland has no stable tool, so Summit says so and skips it. Command plans are unit tested; real monitor changes are not yet verified on hardware.** | | Per-game fullscreen, focus, upscaler and frame-gen settings | Stored. Fullscreen, focus and the upscaling are not applied yet. | | Launcher GUI (Slint): Home / Library / Unfiltered, tweakable animations | Working (first version). Built with Slint; cover art from Steam's cache, tab animations with a speed slider. Run `summit-gui`. Not yet: launching from it, artwork editing, install buttons. | +| Big grid or list layout, four themes, switchable in the navbar | Working (not yet saved between runs, no full-screen "big picture" mode yet) | +| Instant replay with a PS5-style length picker: keep 15 s to 10 min, save 15 s, 30 s, 1 m, 3 m, 5 m or 10 m with Ctrl+1..6 (R saves the default length) | **Engine working** (tested with a synthetic stream on the 3090: a 15 s save and a 600 s request capped at the 40 s actually buffered). Not tested on a live game, and there is no GUI settings page for it yet. Key binds work in the engine's own window only; a global key is not built for Linux yet. | | In-game overlay with a watermark showing the project URL | Planned | | One-click "Add to Steam" with SteamGridDB artwork | Planned | | "My PS5" and "Capture Card" entries (Remote Play, capture cards, Moonlight, Sunshine) | Planned. Reuses the SmoovPlay pipeline. | @@ -83,6 +93,10 @@ summit enhance capture:0 --profile my-console # capture card, live window (unt The engine needs an NVIDIA GPU and its own Python environment (`engine/`, torch with CUDA). The installer for that is not built yet. +## Clips + +The engine keeps a rolling buffer of what you played (hardware encoded, so it costs little), like the PS5's Share button. Pick how far back to keep with `--replay` (15, 30, 60, 180, 300 or 600 seconds) and what a save writes with `--clip-length`. In the video window, **R** saves the default length and **Ctrl+1 to Ctrl+6** save 15 s, 30 s, 1 m, 3 m, 5 m or 10 m. A clip is never longer than the buffer holds. + ## The three views - **Home**: your most played games, from Steam's own playtime data. diff --git a/crates/summit-gui/src/main.rs b/crates/summit-gui/src/main.rs index 557bd47..397964d 100644 --- a/crates/summit-gui/src/main.rs +++ b/crates/summit-gui/src/main.rs @@ -58,6 +58,8 @@ fn main() { ui.set_unfiltered(ModelRc::new(VecModel::from(unf))); ui.set_stats(format!("{} games in library · {} installed · {:.0} h on Steam", games.len(), games.iter().filter(|e| e.installed).count(), total as f64 / 60.0).into()); ui.set_session(format!("{:?} · {:?}", display::detect_session(), display::detect_desktop()).into()); + if let Ok(t) = std::env::var("SUMMIT_LAYOUT") { ui.set_layout(t.parse().unwrap_or(0)); } + if let Ok(t) = std::env::var("SUMMIT_THEME") { ui.set_theme(t.parse().unwrap_or(0)); } if let Ok(t) = std::env::var("SUMMIT_TAB") { ui.set_tab(t.parse().unwrap_or(0)); } if let Ok(s) = std::env::var("SUMMIT_ANIM") { ui.set_anim_speed(s.parse().unwrap_or(1.0)); } ui diff --git a/crates/summit-gui/ui/app.slint b/crates/summit-gui/ui/app.slint index 87e2597..4416e8e 100644 --- a/crates/summit-gui/ui/app.slint +++ b/crates/summit-gui/ui/app.slint @@ -6,12 +6,14 @@ export struct Card { } global Theme { - out property bg: #0b0d12; - out property panel: #12151c; - out property line: #1f2430; - out property text: #e8ebf2; - out property dim: #8a93a6; - out property accent: #ffb02e; + // 0 Midnight, 1 Steam blue, 2 Daylight, 3 Violet + in-out property id: 0; + out property bg: id == 0 ? #0b0d12 : id == 1 ? #171a21 : id == 2 ? #eef0f4 : #120d1f; + out property panel: id == 0 ? #12151c : id == 1 ? #1b2838 : id == 2 ? #ffffff : #1b1430; + out property line: id == 0 ? #1f2430 : id == 1 ? #2a475e : id == 2 ? #d5d9e2 : #2c2150; + out property text: id == 2 ? #14171f : #e8ebf2; + out property dim: id == 2 ? #5b6475 : id == 1 ? #8f98a0 : #8a93a6; + out property accent: id == 0 ? #ffb02e : id == 1 ? #66c0f4 : id == 2 ? #2563eb : #b388ff; // Animation speed multiplier, user tweakable (1.0 = default, 0 = off). in-out property speed: 1.0; pure public function ms(base: int) -> duration { return (base * 1ms) / Math.max(root.speed, 0.01) * (root.speed > 0 ? 1 : 0); } @@ -58,6 +60,36 @@ component CoverCard inherits Rectangle { ta := TouchArea { clicked => { root.pin(); } } } +component ListRow inherits Rectangle { + in property c; + callback pin; + height: 64px; border-radius: 8px; + background: ta.has-hover ? Theme.panel : transparent; + animate background { duration: Theme.ms(140); } + Rectangle { x: 10px; y: 6px; width: 38px; height: 52px; border-radius: 5px; clip: true; background: Theme.line; + if root.c.has-cover: Image { source: root.c.cover; width: parent.width; height: parent.height; image-fit: cover; opacity: root.c.installed ? 1.0 : 0.5; } + if !root.c.has-cover: Rectangle { background: root.c.accent; } } + Text { x: 64px; text: root.c.title; color: root.c.installed ? Theme.text : Theme.dim; font-size: 15px; font-weight: 600; vertical-alignment: center; width: 420px; overflow: elide; } + Text { x: 500px; text: root.c.hours; color: Theme.accent; font-size: 13px; font-weight: 700; vertical-alignment: center; width: 110px; } + Text { x: 620px; text: root.c.source; color: Theme.dim; font-size: 12px; vertical-alignment: center; width: 200px; } + Text { x: 830px; text: root.c.installed ? "Installed" : "Not installed"; color: Theme.dim; font-size: 12px; vertical-alignment: center; } + if root.c.pinned: Text { x: parent.width - 40px; text: "★"; color: Theme.accent; font-size: 16px; vertical-alignment: center; } + ta := TouchArea { clicked => { root.pin(); } } +} + +component CardView inherits Rectangle { + in property <[Card]> cards; + in property layout; + callback pin(int); + height: layout == 0 ? 345px * ceil(cards.length / 7.0) : 66px * cards.length; + if root.layout == 0: Rectangle { + for c[i] in root.cards: CoverCard { c: c; x: mod(i, 7) * 208px; y: floor(i / 7) * 345px; pin => { root.pin(i); } } + } + if root.layout == 1: Rectangle { + for c[i] in root.cards: ListRow { c: c; y: i * 66px; width: root.width; pin => { root.pin(i); } } + } +} + export component MainWindow inherits Window { title: "Summit"; preferred-width: 1600px; preferred-height: 900px; background: Theme.bg; @@ -67,6 +99,8 @@ export component MainWindow inherits Window { in property stats; in property session; in-out property tab: 0; + in-out property layout: 0; + in-out property theme <=> Theme.id; in-out property anim-speed <=> Theme.speed; callback pin(int); @@ -80,6 +114,14 @@ export component MainWindow inherits Window { Tab { label: "Library"; active: root.tab == 1; clicked => { root.tab = 1; } } Tab { label: "Unfiltered"; active: root.tab == 2; clicked => { root.tab = 2; } } Rectangle { horizontal-stretch: 1; } + Rectangle { width: 74px; height: 30px; y: 17px; border-radius: 6px; background: Theme.line; + Text { text: root.layout == 0 ? "Big grid" : "List"; color: Theme.text; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; } + TouchArea { clicked => { root.layout = root.layout == 0 ? 1 : 0; } } } + Rectangle { width: 6px; } + Rectangle { width: 92px; height: 30px; y: 17px; border-radius: 6px; background: Theme.line; + Text { text: root.theme == 0 ? "Midnight" : root.theme == 1 ? "Steam blue" : root.theme == 2 ? "Daylight" : "Violet"; color: Theme.accent; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; } + TouchArea { clicked => { root.theme = mod(root.theme + 1, 4); } } } + Rectangle { width: 14px; } Text { text: "Animations"; color: Theme.dim; font-size: 12px; vertical-alignment: center; } Slider { width: 110px; minimum: 0; maximum: 2; value <=> Theme.speed; } Rectangle { width: 14px; } @@ -96,9 +138,7 @@ export component MainWindow inherits Window { Text { text: "Your most played"; color: Theme.text; font-size: 24px; font-weight: 800; } Text { text: root.stats; color: Theme.dim; font-size: 13px; } Rectangle { height: 6px; } - Rectangle { height: 340px * ceil(root.home.length / 7.0); - for c[i] in root.home: CoverCard { c: c; x: mod(i, 7) * 208px; y: floor(i / 7) * 345px; pin => { root.pin(i); } } - } + CardView { cards: root.home; layout: root.layout; pin(i) => { root.pin(i); } } } } } @@ -109,9 +149,7 @@ export component MainWindow inherits Window { Text { text: "Library"; color: Theme.text; font-size: 24px; font-weight: 800; } Text { text: "Installed and not installed. Click a cover to pin it to Home."; color: Theme.dim; font-size: 13px; } Rectangle { height: 6px; } - Rectangle { height: 345px * ceil(root.library.length / 7.0); - for c[i] in root.library: CoverCard { c: c; x: mod(i, 7) * 208px; y: floor(i / 7) * 345px; pin => { root.pin(i); } } - } + CardView { cards: root.library; layout: root.layout; pin(i) => { root.pin(i); } } } } } diff --git a/docs/media/summit-daylight.png b/docs/media/summit-daylight.png new file mode 100644 index 0000000..d4da428 Binary files /dev/null and b/docs/media/summit-daylight.png differ diff --git a/docs/media/summit-home.png b/docs/media/summit-home.png index 9152f78..9190893 100644 Binary files a/docs/media/summit-home.png and b/docs/media/summit-home.png differ diff --git a/docs/media/summit-library.png b/docs/media/summit-library.png index e76a0ef..010a92b 100644 Binary files a/docs/media/summit-library.png and b/docs/media/summit-library.png differ diff --git a/docs/media/summit-list.png b/docs/media/summit-list.png new file mode 100644 index 0000000..19914ac Binary files /dev/null and b/docs/media/summit-list.png differ diff --git a/docs/media/summit-unfiltered.png b/docs/media/summit-unfiltered.png index 4a9312f..617871f 100644 Binary files a/docs/media/summit-unfiltered.png and b/docs/media/summit-unfiltered.png differ diff --git a/docs/media/summit-violet.png b/docs/media/summit-violet.png new file mode 100644 index 0000000..7ce54ec Binary files /dev/null and b/docs/media/summit-violet.png differ diff --git a/engine/framegen/io.py b/engine/framegen/io.py index bef0ae8..abcf9eb 100644 --- a/engine/framegen/io.py +++ b/engine/framegen/io.py @@ -1369,6 +1369,8 @@ class GLWindowSink: st.set("fullscreen", not st.fullscreen) elif key == glfw.KEY_L: self.cmd = "delay_test" # the pipeline runs it (PS5 Remote Play only) + elif mods & glfw.MOD_CONTROL and glfw.KEY_1 <= key <= glfw.KEY_6: + self.cmd = "save_replay:" + str((15, 30, 60, 180, 300, 600)[key - glfw.KEY_1]) # PS5-style length picker elif key == glfw.KEY_R: self.cmd = "save_replay" # instant replay (framegen/replay.py), through the pipeline elif key == glfw.KEY_B: diff --git a/engine/framegen/pipeline.py b/engine/framegen/pipeline.py index 9814d1c..90e67bb 100644 --- a/engine/framegen/pipeline.py +++ b/engine/framegen/pipeline.py @@ -792,9 +792,10 @@ class Pipeline: delay_test, test_mark, ov_next = delaytest.DelayTest(remote.press, remote.press_sent), len( st.real_delay_ms), 0.0 print("[pipeline] delay test started") - if cmd in ("save_replay", "save_compare"): # R and B + if cmd in ("save_replay", "save_compare") or (cmd or "").startswith("save_replay:"): # R, Ctrl+1..6, B if replay is not None: - replay.save("compare" if cmd == "save_compare" else None) + n = int(cmd.split(":")[1]) if ":" in cmd else getattr(settings, "replay_clip", 0) + replay.save("compare" if cmd == "save_compare" else None, length=n or None) elif hasattr(sink, "toast"): sink.toast("Instant replay isn't available here", 4.0) if cmd == "toggle_interp": # the OpenCV window's i key (the GL window changes settings itself) diff --git a/engine/framegen/replay.py b/engine/framegen/replay.py index ff0d7e4..93fee1f 100644 --- a/engine/framegen/replay.py +++ b/engine/framegen/replay.py @@ -47,7 +47,7 @@ ROOT = Path(__file__).resolve().parents[1] SAVING_DIR = oslayer.cache_dir() / "saving" # Windows: %APPDATA%\\framegen\\saving, as before TB = 90000 # MPEG-TS clock: every timestamp here is in 1/90000 s OFFSET = 10 * TB # timestamps start 10 s in, so none is ever negative -LENGTHS = (0, 30, 60, 120, 300) # settings.replay's choices, in seconds (0: off) +LENGTHS = (0, 15, 30, 60, 180, 300, 600) # settings.replay's choices, in seconds (0: off) KEEP_EXTRA_S = 2.0 # kept beyond the length, so a cut can start at the keyframe before it KEY_EVERY_S = 1.0 # a keyframe at least this often: where a saved clip can start # Bits per pixel per frame. An encoder's rate control spreads its bit rate over its nominal frame rate, so the bit @@ -803,7 +803,7 @@ class Recorder: for n, tr in self.tracks.items()} # ---- saving - def save(self, kind: str | None = None, layout: str | None = None, wait: bool = False) -> list: + def save(self, kind: str | None = None, layout: str | None = None, wait: bool = False, length: int | None = None) -> list: """Save the replay: "smoovplay" (what was shown), "compare" (before & after) or "both"; default self.clip. In the background unless wait=True, which returns the files written.""" kind, layout = kind or self.clip, layout or self.layout @@ -811,15 +811,15 @@ class Recorder: self._notify("Instant replay is off: turn it on in Settings > Instant replay", 5.0) return [] if wait: - return self._save(kind, layout) + return self._save(kind, layout, False, length) # A daemon: close() waits for the clip itself, and a before & after video carries on in its own process. - t = threading.Thread(target=self._save, args=(kind, layout, True), name="replay-save", daemon=True) + t = threading.Thread(target=self._save, args=(kind, layout, True, length), name="replay-save", daemon=True) with self._cv: self._quick += 1 t.start() return [] - def _save(self, kind: str, layout: str, counted: bool = False) -> list: + def _save(self, kind: str, layout: str, counted: bool = False, length: int | None = None) -> list: handed = threading.Event() def handoff() -> None: # the clip is written: close() needn't wait for this save any more @@ -829,7 +829,7 @@ class Recorder: self._quick -= 1 self._cv.notify_all() try: - return self._save_inner(kind, layout, handoff) + return self._save_inner(kind, layout, handoff, length) except Exception as e: # noqa: BLE001 - e.g. a full disk print(f"[replay] save failed: {type(e).__name__}: {e}") self._notify(f"Couldn't save the replay: {str(e)[:120]}", 8.0) @@ -837,11 +837,11 @@ class Recorder: finally: handoff() - def _save_inner(self, kind: str, layout: str, handoff=lambda: None) -> list: + def _save_inner(self, kind: str, layout: str, handoff=lambda: None, want: int | None = None) -> list: self.flush(1.0) with self._lock: snap = {n: (tr.head, list(tr.ring)) for n, tr in self.tracks.items()} - length = self.length + length = min(want, self.length) if want else self.length # a shorter clip than the buffer, never longer head, ring = snap["after"] if len(ring) < 2: self._notify("Instant replay has nothing to save yet", 4.0) diff --git a/engine/framegen/settings.py b/engine/framegen/settings.py index e4591a3..e7c5e89 100644 --- a/engine/framegen/settings.py +++ b/engine/framegen/settings.py @@ -316,23 +316,29 @@ SPECS: tuple[Spec, ...] = ( Spec("ui_scale", "Menu size", (0.6, 0.75, 0.9, 1.0), 1.0, PCT_SIZE, group="Display", help="How big the settings menu and its messages are (100% is as big as the window allows)."), # framegen/replay.py. Memory in the hints: replay.memory_mb() for 1080p at 90 fps (tests/test_replay.py checks). - Spec("replay", "Instant replay", (0, 30, 60, 120, 300), 0, - {0: "Off", 30: "Last 30 seconds", 60: "Last minute", 120: "Last 2 minutes", 300: "Last 5 minutes"}, + Spec("replay", "Instant replay", (0, 15, 30, 60, 180, 300, 600), 0, + {0: "Off", 15: "Last 15 seconds", 30: "Last 30 seconds", 60: "Last minute", 180: "Last 3 minutes", + 300: "Last 5 minutes", 600: "Last 10 minutes"}, group="Instant replay", - hints={0: "Nothing is kept.", 30: "Keeps about 160 MB in memory (1080p at 90 fps).", - 60: "Keeps about 310 MB in memory (1080p at 90 fps).", - 120: "Keeps about 610 MB in memory (1080p at 90 fps).", - 300: "Keeps about 1.5 GB in memory (1080p at 90 fps)."}, - help="Keeps the last stretch of what you played, so you can save it after something good happens: press R " - "in the video window, or Ctrl+Alt+R from anywhere. Clips go to your Videos folder, in SmoovPlay, as " - "MP4 at the frame rate you see, with the game's own sound (PS5 Remote Play and capture cards; window " - "capture has none). B saves a before & after video instead.", + hints={0: "Nothing is kept.", 15: "Keeps about 90 MB in memory (1080p at 90 fps).", + 30: "Keeps about 160 MB in memory (1080p at 90 fps).", + 60: "Keeps about 310 MB in memory (1080p at 90 fps).", + 180: "Keeps about 910 MB in memory (1080p at 90 fps).", + 300: "Keeps about 1.5 GB in memory (1080p at 90 fps).", + 600: "Keeps about 3 GB in memory (1080p at 90 fps)."}, + help="Keeps the last stretch of what you played, like the PS5's Share button. Press R in the video window " + "to save the default length, or Ctrl+1..6 to pick 15 s, 30 s, 1 m, 3 m, 5 m or 10 m (never more than " + "the buffer holds). Ctrl+Alt+R saves from anywhere. B saves a before & after video instead.", impact={"picture": "None.", "speed": "About 0.3 ms of graphics card time a frame; the encoding is on its video encoder, not " "the AI's part."}), + Spec("replay_clip", "Default clip length", (15, 30, 60, 180, 300, 600), 30, + {15: "15 seconds", 30: "30 seconds", 60: "1 minute", 180: "3 minutes", 300: "5 minutes", 600: "10 minutes"}, + group="Instant replay", applies=("replay", (15, 30, 60, 180, 300, 600)), + help="How much R saves. It is capped at the buffer length above."), Spec("replay_save", "Saved clip", ("smoovplay", "compare", "both"), "smoovplay", {"smoovplay": "SmoovPlay video", "compare": "Before & after", "both": "Both"}, - group="Instant replay", applies=("replay", (30, 60, 120, 300)), + group="Instant replay", applies=("replay", (15, 30, 60, 180, 300, 600)), hints={"smoovplay": "What you saw, with the game's sound. Saved in a second or two.", "compare": "The game's own frames next to SmoovPlay's, in one video. Made in the background, in " "about as long as the clip.", @@ -342,14 +348,14 @@ SPECS: tuple[Spec, ...] = ( "and takes about as long as the clip. B always saves a before & after video."), Spec("replay_layout", "Before & after layout", ("split", "side"), "split", {"split": "Split screen", "side": "Side by side"}, group="Instant replay", - applies=("replay", (30, 60, 120, 300)), + applies=("replay", (15, 30, 60, 180, 300, 600)), hints={"split": "One picture: the left half as the game sent it, the right half from SmoovPlay.", "side": "Both whole pictures next to each other, in a video twice as wide."}, help="How a before & after video is laid out. Split screen is one picture: the left half as the game sent " "it, the right half from SmoovPlay, with a line between. Side by side shows both whole pictures, in " "a video twice as wide."), Spec("look_clips", "Looks in clips", (False, True), False, ON_OFF, group="Instant replay", - applies=("replay", (30, 60, 120, 300)), + applies=("replay", (15, 30, 60, 180, 300, 600)), help="Puts the look you're using into saved clips too. Off keeps clips as the game looked, whatever look " "you play with. In a before & after video, only the SmoovPlay side gets the look.", impact={"picture": "Clips look like what you see, look included.", "speed": LOOK_CLIPS_SPEED}), diff --git a/engine/run.py b/engine/run.py index ae304f5..c00fbed 100644 --- a/engine/run.py +++ b/engine/run.py @@ -299,6 +299,10 @@ def main() -> int: ap.add_argument("--trt", action="store_true", help="same as --engine trt") ap.add_argument("--no-graph", action="store_true", help="disable CUDA graphs") ap.add_argument("--dup-threshold", type=float, default=2.0) + ap.add_argument("--replay", type=int, default=None, choices=[0, 15, 30, 60, 180, 300, 600], metavar="SECONDS", + help="keep this many seconds for instant replay (0 off)") + ap.add_argument("--clip-length", type=int, default=None, choices=[15, 30, 60, 180, 300, 600], metavar="SECONDS", + help="how much the save key writes (never more than --replay)") ap.add_argument("--off", action="store_true", help="start with interpolation disabled (toggle with 'i')") ap.add_argument("--look", default=None, metavar="ID", help="turn a Look on for this run (not saved), e.g. my:capture-cleanup; 'off' turns Looks off") @@ -426,7 +430,7 @@ def main() -> int: ("interp", False if a.off else None), ("vsync", a.vsync), ("fullscreen", a.fullscreen), ("minimize_chiaki", a.minimize_chiaki), ("simulate_30", True if a.test_mode else None), ("steady_hud", a.steady_hud), ("vfg_quality", a.vfg_quality), ("present", a.present), - ("hdr", a.hdr), ("fill", a.fill)): + ("hdr", a.hdr), ("fill", a.fill), ("replay", a.replay), ("replay_clip", a.clip_length)): if value is not None: settings.override(key, value) if a.look: diff --git a/engine/tests/test_clip_length.py b/engine/tests/test_clip_length.py new file mode 100644 index 0000000..b53f698 --- /dev/null +++ b/engine/tests/test_clip_length.py @@ -0,0 +1,21 @@ +"""Clip length picker: a save asks for N seconds, never more than the buffer holds.""" +import sys, pathlib +sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1])) +from framegen import replay +from framegen.settings import BY_KEY + + +def test_lengths_match_ps5_style_menu(): + assert replay.LENGTHS == (0, 15, 30, 60, 180, 300, 600) + assert BY_KEY["replay"].choices == replay.LENGTHS + assert BY_KEY["replay_clip"].choices == (15, 30, 60, 180, 300, 600) + + +def test_clip_never_longer_than_buffer(): + # the cut length is min(wanted, buffer): mirrors Recorder._save_inner + for buffer, want, expect in ((60, 600, 60), (600, 15, 15), (300, None, 300)): + assert (min(want, buffer) if want else buffer) == expect + + +def test_memory_for_ten_minutes_is_reasonable(): + assert 2500 < replay.memory_mb(600) < 3500