Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5.5 e528fe5be6 fix(app): the Trend unticks a metric left in a third unit when the selected metric changes - every ticked box has its line
With two units ticked beside the selected metric (degC and a frame rate, say), changing the selected
metric to a third unit (watts) left three units ticked; TrendChart draws two, so one box stayed ticked
naming a line that was not there. BuildTrendLines now keeps the selected metric's unit and the first
ticked unit in the list and unticks the rest, before it sets which options can be ticked.

Test: TheOverviewAndTheTrendDrawSeveralMetricsTwoUnitsAtMost goes on to tick degC and the 1% low,
select watts, and finds two units drawn and one line per ticked box. 08_UI says it.
./build.ps1 check: ALL GATES PASSED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 11:32:02 +07:00
poli0981andClaude Opus 5.5 6197583420 fix(app): Delete all sessions closes only the summary windows still open after the ledger read - one the user closed meanwhile is not closed twice
SessionSummaryOpener.CloseDeletedAsync awaits a read per window; a window the user closed during it
has left the list (its Closed handler removes it), and WPF's Window.Close on a closed window can
throw. Each window is closed only while it is still in the list. ./build.ps1 check: ALL GATES PASSED.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 11:22:25 +07:00
poli0981andClaude Opus 5.5 898155232d fix(app): after Delete all sessions, a summary window open on a deleted session closes and File > Export lets go of it - from Settings too
The plan for D40 said the summary windows of deleted sessions close; they did not. A summary is
a window of its own, so after a delete it stayed open on a session that is gone, and a note
written from it would have gone to whichever session takes the id next (the table has no
AUTOINCREMENT). And File > Export's selection was let go of only by the game page: a delete from
Settings > Data left it naming a deleted session.

Both now happen in SessionDeletion, the App's one path to DeleteSessions, after the Agent
answers Deleted: the selection is cleared when its session is no longer in the ledger
(ISessionRepository.FindByIdAsync - a session of another game stays selected), and the summary
windows close the ones whose session is gone (ISessionWindows, which SessionSummaryOpener now
implements over the windows it opened; DI registers the one opener under both interfaces). A
failure there is logged and not the delete's. The game page's own clearing moved there.

Tests: AfterADeleteWhatNamedADeletedSessionLetsGoOfIt (the selection cleared, a kept session
still selected, the windows asked after each delete and not after a refused one); the game page
test builds its SessionDeletion with the selection. 08_UI and the CHANGELOG entry say it.
./build.ps1 check: ALL GATES PASSED (App 399).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 11:12:40 +07:00
poli0981andClaude Opus 5.5 fcece084d6 fix(app): the overview draws Native and Displayed only for sessions that generated frames - on the others Native is the Presented rate, and a second line on the same points read as a second measurement
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 10:48:45 +07:00
poli0981andClaude Opus 5.5 a95ea9181b feat: delete all sessions of a game or of every game, charts across a game's sessions, and no Settings row without a control (D39, D40, beta.11)
Owner requests 2026-10-03; when asked, the owner chose both charts (an overview on the Sessions
tab and several metrics on the Trend) and both places for Delete all sessions (the game's page
and Settings > Data).

Delete all sessions (D40, FR-1.7):
- A pipe request, DeleteSessions { gameId? } -> DeleteSessionsAck { gameId?, games, sessions }.
  The rows are the Agent's (06_DATA_MODEL Writer ownership), so the Agent deletes them through
  ISessionRepository.DeleteSessionsAsync in one transaction - segments, frame and sensor series and
  annotations cascade - and answers Error SessionRunning while a session of that game (of any
  game, for all; CaptureOrchestrator.IsRecording / IsRecordingAny) is being recorded.
- App: SessionDeletion asks; the game page's Sessions tab and Settings > Data (a new section, one
  row) ask first through IConfirmations.DeleteSessionsAsync with the count; the strip says what
  was deleted or why nothing was (a recording, no agent, an older agent). The game page reloads
  and clears File > Export's selection when it pointed at a deleted session (ids are reused).

Charts across sessions (D39, FR-6.6):
- The Sessions tab opens with "Sessions at a glance": every hooked session's Presented FPS, or
  Native and Displayed where frame generation was measured (rule 6), and the 1% / 0.1% lows,
  oldest first, partial sessions hollow (TrendSeriesBuilder.Overview); a click near a session's
  points selects it in the grid (TrendChart.SessionClicked).
- The Trend keeps its selector and adds "Also draw": ticked metrics are drawn on the same chart,
  their unit (TrendSeriesBuilder.UnitOf: FPS, degC, %, W, MB, x) on the left when it is the
  selected metric's and on the right when it is a second one; a third unit cannot be ticked.
  TrendChart.Show takes TrendLines; one line keeps its name on the axis as before.

Settings, no row without a control (owner request): the hooked-games card shows only while a game
has hooking on; the Elevation row became the admin mode row's status line; the language note is
gone; the retention message names Settings > Recording.

Strings en/vi/ja (ja marked review); docs 02_SPEC (FR-1.7, FR-6.6, FR-10), 06_DATA_MODEL, 07_IPC,
08_UI; CHANGELOG. Tests: repository delete + cascade; the handler's delete and its malformed
payload; IsRecordingAny; SessionDeletion's outcomes; the game page asks, deletes through the
Agent and reloads; Settings asks with the total; the overview and the two-unit Trend; units.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 10:48:45 +07:00
42 changed files with 1504 additions and 84 deletions

No files matched your search

+14
View File
@@ -42,6 +42,16 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
and pushed the new ones out of sight. *Show the N games already in the library* brings them back, dimmed, and a row
that cannot be imported has its box disabled (a tick on it was taken and ignored).
- **Delete all sessions** (owner decision D40, beta.11): on a game's page, every session of that game; in Settings ▸
**Data**, every session of every game — with their frame and sensor data and notes, after a confirmation that says how
many. The library, the settings and every game's hooking consent stay. The capture agent deletes them (the rows are its)
and refuses while a session is being recorded; an older agent is told to restart. A summary window still open on a
deleted session closes. A new pipe request, `DeleteSessions`.
- **Charts across a game's sessions** (owner decision D39, beta.11): the Sessions tab opens with *Sessions at a glance* —
every hooked session's frame rate (Presented FPS, or Native and Displayed where frame generation was measured, never one
inflated line) and its 1% and 0.1% lows, oldest first; click a point to select that session. The Trend keeps its metric
and can **draw more beside it** (*Also draw*), a second unit against the right axis, two units at most.
- **Three CrackProof titles on the anti-cheat title list** (owner request, beta.11): Umamusume: Pretty Derby (Steam
`3224770`), Heaven Burns Red (`1973710`) and Madoka Magica Magia Exedra (`2987800`). Each store page states *"Uses
Kernel Level Anti-Cheat"* and names HyperTech's CrackProof; its driver loads from `System32` under a numbered name,
@@ -68,6 +78,10 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
### Fixed
- **Settings has no row without a control** (owner request, beta.11): *Games with hooking on* shows only while a game has
hooking on, the *Elevation* row became the admin mode row's status line, and the note under the language row is gone.
The retention message now names Settings ▸ Recording, where retention lives.
- **The exception's card and list say what is true** (found with D38): an eligible game's *Anti-cheat* card said hooking
"cannot be turned on" beside a usable *Make exception…* — it now says hooking is off unless you make one; the Settings
list showed each game's session count twice and listed games that could never qualify, with no action — it lists only
+3 -1
View File
@@ -10,6 +10,7 @@ Requirement IDs (`FR-x`, `NFR-x`) are referenced by other docs, commits, and tes
- FR-1.3 Editable metadata (name, cover, publisher, version, notes); auto-detected fields badged and overridable.
- FR-1.4 Remove game (asks whether to keep or delete its sessions).
- FR-1.5 "Supports" row shows shipped-capability hints (DLSS/FSR/XeSS/FG) — visually distinct from measured per-session values (`05_DETECTION` §Capability hints).
- FR-1.7 Delete all sessions (beta.11, owner decision D40): of one game from its page, or of every game from Settings ▸ Data, after a confirmation that says how many — with their frame and sensor series and notes; the library, the settings and every consent stay. The Agent deletes them (the rows are its, `06_DATA_MODEL` §Writer ownership) and refuses while a session it would delete under is being recorded.
- FR-1.6 Recording switch per entry (2026-09-23, HANDOFF D29): off, the program is not watched at all — no session, no measurement, no injection — and a session of it that is running stops. On by default; entries an old import made for Steam's own tools start with it off. The library card says "Not recorded".
### FR-2 Hooking consent & control (new, safety-critical — see `19_SAFETY`)
@@ -55,6 +56,7 @@ Requirement IDs (`FR-x`, `NFR-x`) are referenced by other docs, commits, and tes
- FR-6.1 Sessions table per game: date, duration, tier badge, Native, Displayed, FG×, lows, resolution + upscaler, RT/PT/RR chips, crash badge, tags.
- FR-6.2 Compare 2–5 sessions; **mixed-tier comparisons require explicit acknowledgement** and are marked on the chart.
- FR-6.3 Hardware snapshot per session; trend charts mark changes ("GPU driver 572.16 → 576.02").
- FR-6.6 Charts across a game's sessions (beta.11, owner decision D39): the Sessions tab opens with an overview of every hooked session's rate and lows (Presented FPS, or Native and Displayed where frame generation was measured; 1% and 0.1% lows), a click selecting the session; and the Trend draws more metrics beside the selected one, two units at most (the second against the right axis).
- FR-6.4 Sessions with mid-session settings changes are excluded from trends by default, with a toggle.
- FR-6.5 Session tags and notes.
@@ -79,7 +81,7 @@ Requirement IDs (`FR-x`, `NFR-x`) are referenced by other docs, commits, and tes
> **beta.10 (D34):** "Agent elevation (optional — explains what it unlocks)" is the admin mode — *Run the agent as
> administrator*, off by default, a disclosure before it turns on, Windows' prompt at every Agent start (`01_ARCHITECTURE`
> ADR-9, `08_UI` §Settings).
Language (en/vi/ja), theme, start with Windows, minimize to tray, background capture, **global hooking kill switch**, min session length, telemetry interval, retention, Agent elevation (optional — explains what it unlocks), Vulkan layer registration state, update channel, online metadata opt-in, reopen legal documents.
Language (en/vi/ja), theme, start with Windows, minimize to tray, background capture, **global hooking kill switch**, min session length, telemetry interval, retention, Agent elevation (optional — explains what it unlocks), Vulkan layer registration state, update channel, online metadata opt-in, reopen legal documents. **beta.11 (owner request 2026-10-03: no row without a control):** Delete all sessions (FR-1.7, a *Data* section); the elevation state is a line of the admin mode's own row, not a row of its own; the hook-enabled list shows only while a game has hooking on; the language row carries no separate note.
### FR-11 Legal Gate
First run blocks until the user accepts EULA, GPLv3 notice, Disclaimer, Privacy Policy. Re-shown when a document version increments. The injection risk is stated in the Disclaimer *and* repeated at per-game consent (FR-2.1) — once is not enough for something that can cost an account.
+1 -1
View File
@@ -2,7 +2,7 @@
`%LOCALAPPDATA%\FrameLedger\ledger.db`. Pragmas: `journal_mode=WAL`, `synchronous=NORMAL`, `foreign_keys=ON`, `busy_timeout=5000`. `Microsoft.Data.Sqlite` + Dapper; all writes in explicit transactions.
**Writer ownership:** Agent writes `sessions`, `session_segments`, `frame_blobs`, `sensor_blobs`, `hardware_snapshots`, the hook-state columns on `games`, **and since P4 PR-1 (2026-09-14) the *detected* columns on `games`** — `engine`, `engine_version`, `platform` under the per-field provenance rule (`05_DETECTION` §Caching: a `user` field is never touched), `capability_flags` whole, and the cache key `detection_rules_version` / `detection_exe_size_bytes` / `detection_exe_mtime_ms`, and since schema 0011 (2026-09-25) the executable's own facts `exe_machine` / `exe_file_version` / `exe_product_version` / `library_versions`, written whole like the flags — through `IGameRepository.ApplyDetectionAsync` only. The UI and the Agent were both already writers of `games`; this adds columns to the Agent's half, not a third writer (HANDOFF §P4). **And since P4 PR-4 the UI's library import writes `platform`, `store_id` and `game_version` through `ApplyStoreMetadataAsync`** — the same per-field provenance rule, badged `detected` (a store's record is not the user's typing), on columns the UI already owned. **And since 2026-09-23 the Agent's relocator merges two entries for one executable under two drive letters** (`IGameMerge`, HANDOFF D26, `19_SAFETY` §A moved drive is the same executable): in one transaction it re-parents the dropped entry's `sessions` to the survivor (before the delete — `sessions.game_id` cascades), carries a block or a crash auto-disable still in force to the survivor (`hook_enabled` only ever to 0; `hook_blocked_reason` is copied, never originated or cleared), adds the crash counts, deletes the dropped `games` row, and then moves the survivor to the file's path (after the delete — `exe_path` is UNIQUE). It is the one Agent write that deletes a `games` row; it never touches a consent column. **And since 2026-09-23 the UI writes `record_sessions`** (schema 0009, FR-1.6): the entry's recording switch, which the Agent only reads — off, the watcher does not watch for the program. The script's one data change switches it off for entries an old import made for Steam's own tools (`SteamLibrarySource.KnownTools`, the ids as of the script); a twin merge keeps it off when either twin had it off. **And since 2026-09-25 the Agent's pre-scan of the library (`19_SAFETY` §What a finding does to the game) writes the hook-state columns of every entry, not only of those the user asked to hook** — `hook_prescan_state`, and on a finding `hook_enabled = 0` and `hook_blocked_reason` — and its own key, `hook_prescan_rules_version` / `hook_prescan_exe_size_bytes` / `hook_prescan_exe_mtime_ms` (schema 0010), through `IGameConsentStore.RecordPreScanAsync` only: columns that were already the Agent's, never over a block, never a new row. **And since 2026-09-26 (schema 0014, D33) the Agent writes the user-mode exception's columns** — `ac_exception_*` on `games` through `IGameConsentStore` only (eligibility from the sweep, a grant from the `SetAntiCheatException` command, every end), and `sessions.ac_exception_family` with the session — the grant only after the user accepted its disclosure in the UI, which asks and never writes. **Maintenance (P4 PR-7) adds no writer:** the retention sweep on demand is the Agent's, asked over the pipe; the UI's `VACUUM` rewrites pages with the same contents and changes no row (§Retention built note). UI writes `games` (user-editable fields — since P3 PR-3 that is the FR-1.3 metadata, the `*_default` tri-states, and `removed_at`; never a `hook_*` column), `session_annotations` (tags, notes, and since schema 0002 the FR-8.3 overrides — which is WHY they are on this table and not on `sessions`), `settings`, `legal_acceptance`. Both read everything. The ports say the same in their names: `IGameRepository.UpdateMetadataAsync` / `SetTriStateDefaultAsync` / `RemoveAsync`, `ISessionAnnotationRepository`, `RegisteredSettings`, `ILegalAcceptanceStore.RecordAsync` (all P3 PR-3).
**Writer ownership:** Agent writes `sessions`, `session_segments`, `frame_blobs`, `sensor_blobs`, `hardware_snapshots`, the hook-state columns on `games`, **and since P4 PR-1 (2026-09-14) the *detected* columns on `games`** — `engine`, `engine_version`, `platform` under the per-field provenance rule (`05_DETECTION` §Caching: a `user` field is never touched), `capability_flags` whole, and the cache key `detection_rules_version` / `detection_exe_size_bytes` / `detection_exe_mtime_ms`, and since schema 0011 (2026-09-25) the executable's own facts `exe_machine` / `exe_file_version` / `exe_product_version` / `library_versions`, written whole like the flags — through `IGameRepository.ApplyDetectionAsync` only. The UI and the Agent were both already writers of `games`; this adds columns to the Agent's half, not a third writer (HANDOFF §P4). **And since P4 PR-4 the UI's library import writes `platform`, `store_id` and `game_version` through `ApplyStoreMetadataAsync`** — the same per-field provenance rule, badged `detected` (a store's record is not the user's typing), on columns the UI already owned. **And since 2026-09-23 the Agent's relocator merges two entries for one executable under two drive letters** (`IGameMerge`, HANDOFF D26, `19_SAFETY` §A moved drive is the same executable): in one transaction it re-parents the dropped entry's `sessions` to the survivor (before the delete — `sessions.game_id` cascades), carries a block or a crash auto-disable still in force to the survivor (`hook_enabled` only ever to 0; `hook_blocked_reason` is copied, never originated or cleared), adds the crash counts, deletes the dropped `games` row, and then moves the survivor to the file's path (after the delete — `exe_path` is UNIQUE). It is the one Agent write that deletes a `games` row; it never touches a consent column. **And since 2026-09-23 the UI writes `record_sessions`** (schema 0009, FR-1.6): the entry's recording switch, which the Agent only reads — off, the watcher does not watch for the program. The script's one data change switches it off for entries an old import made for Steam's own tools (`SteamLibrarySource.KnownTools`, the ids as of the script); a twin merge keeps it off when either twin had it off. **And since 2026-09-25 the Agent's pre-scan of the library (`19_SAFETY` §What a finding does to the game) writes the hook-state columns of every entry, not only of those the user asked to hook** — `hook_prescan_state`, and on a finding `hook_enabled = 0` and `hook_blocked_reason` — and its own key, `hook_prescan_rules_version` / `hook_prescan_exe_size_bytes` / `hook_prescan_exe_mtime_ms` (schema 0010), through `IGameConsentStore.RecordPreScanAsync` only: columns that were already the Agent's, never over a block, never a new row. **And since 2026-09-26 (schema 0014, D33) the Agent writes the user-mode exception's columns** — `ac_exception_*` on `games` through `IGameConsentStore` only (eligibility from the sweep, a grant from the `SetAntiCheatException` command, every end), and `sessions.ac_exception_family` with the session — the grant only after the user accepted its disclosure in the UI, which asks and never writes. **And since 2026-10-03 (beta.11, D40) the Agent deletes sessions on request** — every session of one game or of every game, `DeleteSessions` over the pipe, through `ISessionRepository.DeleteSessionsAsync` in one transaction (segments, blobs and annotations cascade), never while one is being recorded; the UI asks and never deletes a session row itself. **Maintenance (P4 PR-7) adds no writer:** the retention sweep on demand is the Agent's, asked over the pipe; the UI's `VACUUM` rewrites pages with the same contents and changes no row (§Retention built note). UI writes `games` (user-editable fields — since P3 PR-3 that is the FR-1.3 metadata, the `*_default` tri-states, and `removed_at`; never a `hook_*` column), `session_annotations` (tags, notes, and since schema 0002 the FR-8.3 overrides — which is WHY they are on this table and not on `sessions`), `settings`, `legal_acceptance`. Both read everything. The ports say the same in their names: `IGameRepository.UpdateMetadataAsync` / `SetTriStateDefaultAsync` / `RemoveAsync`, `ISessionAnnotationRepository`, `RegisteredSettings`, `ILegalAcceptanceStore.RecordAsync` (all P3 PR-3).
## Schema (v2 — hook architecture)
+1
View File
@@ -396,6 +396,7 @@ Unchanged in spirit from v1, bumped to `v2` for the new message set.
| `StopSession` | UI→A | `{ sessionGuid }` — graceful ~~unhook~~ stop + finalize → `StopAck { sessionGuid, accepted, reason? }`. *(Built 2026-09-13, PR-1b: the orchestrator names every session it starts and cancels THAT session's stop token; the loop reads it at its next tick, drains once more, and ends as `SessionEndReason.StoppedByUser` — `exit_status = normal`, the row stored like any other, the target left running. A guid nobody runs is `accepted: false`. Distinct from the host's cancellation, which leaves a `.partial`.)* |
| `UpdateRules` | UI→A | **no payload** — a trigger, not a source. The Agent re-reads only its own `%LOCALAPPDATA%\FrameLedger\rules\` copy → `UpdateRulesAck { outcome }`. *(Built 2026-09-13, PR-1b: the seeder's `EnsureSeededAsync` outcome; a payload naming a path is ignored, and a test sends one to prove it.)* |
| `Shutdown` | UI→A | graceful stop → `ShutdownAck`, then the host stops (sessions finalize inside its grace window). *(Built 2026-09-13, PR-1b: `IAgentLifetime`, the host's under `--serve`, a logged no-op under `--console`.)* |
| `DeleteSessions` | UI→A | **Added 2026-10-03 (beta.11, D40).** `{ gameId? }` — every session of that game, or of every game when it is null, with their segments, frame and sensor series and annotations (they cascade) → `DeleteSessionsAck { gameId?, games, sessions }`. `Error SessionRunning` and nothing deleted while a session of that game — of any game, for all — is being recorded (`CaptureOrchestrator.IsRecording` / `IsRecordingAny`). The client names no rows beyond the game: they are the Agent's (§Writer ownership). Additive: an older Agent answers `Error UnknownType`, which the App says as "restart the agent". Carries no safety fact. |
| `SweepRetention` | UI→A | **no payload** — a trigger, like `UpdateRules`: the Agent applies `06_DATA_MODEL` §Retention to every game with the `retention.raw_sessions_per_game` it reads itself → `SweepRetentionAck { keep, games, sessions }` (`keep` 0 = unlimited, and then nothing was swept). *(Built 2026-09-15, P4 PR-7, for Tools ▸ Database maintenance: `Application.Recording.RetentionSweep` over `ISessionRepository.SweepRetentionAllAsync`, composed into `AgentCommandHandler` under `--serve`. The client names no number because the rows are the Agent's (§Writer ownership). Additive: an older Agent answers `Error UnknownType`, which the dialog reads as "restart the Agent". Carries no safety fact.)* |
| `SessionStarted` | A→UI | `{ sessionGuid, gameId, gameName, pid, tier, startedAt, hold? }` — **published once per session**: at the attach (tier 1, `startedAt` the attach), or — **since 2026-09-23** — at the first tick of a session held unhooked (tier 2, `startedAt` the session's start, `pid` 0 when the loop never opened the process, as a hooking-off hold never does). ~~a session that never attaches has no `SessionStarted`, only its `SessionCompleted` (tier 2)~~ — that was the beta.5 wire, and every hooking-off, refused or unreadable game read "Nothing is being captured." for as long as it ran. **`hold` (optional, tier 2 only)** is why nothing is measured: `{ reason, guardReason?, family?, signal?, hookingTurnedOff }` — the loop's `SessionEndReason` and, when the guard said anything but allow, its reason, family and signal: the same words the row's `capture_notes` will carry, so the live card and the summary read one sentence (`Formats.Tier2HoldReason` / `Tier2Reason`). The refusal's own event (`CaptureRefused` and the rest, below) goes out with this start rather than when the game exits, and is not repeated at the end |
| `SessionHeld` | A→UI | **Added 2026-09-23.** 1 Hz while a client listens, for a session held unhooked only: `{ sessionGuid, elapsedS, gpuTempC?, cpuTempC?, gpuLoadPct?, cpuLoadPct? }` — how long it has run and the machine's sensors. **Never `SessionProgress`**: its `presents5s`, `presentedQualifier` and `fgMode` are required, and zeros there would put measured-looking numbers on the wire for a session that measures nothing (rule 6 has nothing to show and shows nothing) |
+20
View File
@@ -293,6 +293,19 @@ All screens are `Page`s registered with the navigation page provider and navigat
3. **Distribution** — FPS histogram + percentile curve of selected session(s).
4. **Trend** — metric-over-date line (selector: Native avg / Displayed avg / 1% Low / 0.1% Low / max GPU temp), vertical **hardware-change markers** with tooltip "GPU driver 572.16 → 576.02" (FR-6.3).
> **Across sessions, beta.11 (owner decision D39, FR-6.6).** The **Sessions** tab opens with *Sessions at a glance*: a
> `TrendChart` of every hooked session's Presented FPS (sessions that counted no generated frame), Native and Displayed
> (sessions where frame generation was measured — rule 6, never one inflated line) and 1% / 0.1% lows, oldest first,
> partial sessions hollow (`TrendSeriesBuilder.Overview`); a click near a session's points selects it in the grid and
> scrolls to it (`TrendChart.SessionClicked`). Under it, **Delete all sessions…** (FR-1.7) for this game. The **Trend**
> keeps its selector and adds *Also draw*: any other metric ticked is drawn on the same chart, its unit
> (`TrendSeriesBuilder.UnitOf`: FPS, °C, %, W, MB, ×) on the left axis when it is the selected metric's and on the right
> when it is a second one (marked ▸ in the legend); a metric in a third unit cannot be ticked, and when the selected
> metric changes to a third unit only the first ticked unit in the list stays ticked, so every ticked box has its line;
> the selected metric is not offered beside itself. One line alone keeps its name on the axis, as before. After any delete — here or in
> Settings — a summary window still open on a deleted session closes, and File ▸ Export lets go of it (`SessionDeletion`;
> ids are reused once the newest is gone). Tests: `SessionDeletionAndOverviewTests`.
>
> **The display mode, beta.10 (FR-7.4, `03_METRICS` §Display mode).** The **Last session measured** row adds how that
> session was shown — the mode that lasted longest with its share and the window's size (`Display: Borderless 92% ·
> 2560×1440`); the **Sessions** tab has a *Display* column for every session, Tier 2 included (the mode shown longest,
@@ -464,6 +477,13 @@ Tail view of `ui-*.log` / `agent-*.log` (toggle), level filter, search (`ui:Auto
> `PagesLoadTests`.
### Settings
> **beta.11 (owner request 2026-10-03: "remove the Settings rows that have no button or similar").** Every row has a control
> now: the *Games with hooking on* card shows only while a game has hooking on (its empty sentence is gone); the *Elevation*
> card is gone and its state is the third line of *Run the agent as administrator* (its explanation a tooltip on it); the
> sentence under the language row is gone. A **Data** section has one row, **Delete all sessions…** (FR-1.7): the
> confirmation names how many, the Agent deletes them (`DeleteSessions`), and the strip says what happened or why nothing
> was deleted (a session being recorded, no agent, an older agent). Tests: `SettingsViewModelTests.DeleteAllSessionsAsksWithTheTotalThenGoesThroughTheAgent`.
Sections per FR-10 using the WPF UI settings idiom: `ui:CardControl`/`ui:CardExpander` rows with `ToggleSwitch`, `ComboBox`, `ui:NumberBox` (numeric inputs — min session length, sensor interval, retention). Language switch applies immediately (09_I18N). Theme selector (Light/Dark/System) drives `ApplicationThemeManager` (16 §Theming). **Capture section (top, most important):** the global **hooking kill switch** (`ToggleSwitch`, prominent) with a one-line summary of what it does; a list of games currently hook-enabled with a per-game revoke; Vulkan layer registration state + Register/Unregister; a link to the safety documentation. Turning the global switch off must take effect immediately, including for the Vulkan layer.
**System (2026-09-21, FR "show the user's hardware"):** a card above Legal stating this PC as a session's hardware snapshot would record it right now — processor, graphics card, graphics driver, memory, Windows build, primary display — through the same `IHardwareSnapshotSource` the Agent stamps sessions with, read on the thread pool when the page opens, a field that could not be read as N/A, with **Copy** (the same lines as text) and a note that nothing is sent anywhere and what CPU temperature needs. Its own `SystemInfoViewModel`, not `SettingsViewModel`'s. The same snapshot is one tertiary line under the session summary's header (it was loaded for the export and shown nowhere), and `--diag` prints it; the bug bundle's `sysinfo.json` is deliberately NOT given it — its keys are the issue link's prefill.
@@ -272,7 +272,9 @@ internal static class AgentServices
// D33: the user-mode exception's option and disclosure version (D38: no session count any more).
new AntiCheatExceptionCommands(
sp.GetRequiredService<IUserModeExceptionSwitch>(),
AntiCheatExceptionDisclosure.Version));
AntiCheatExceptionDisclosure.Version),
// beta.11 (D40): Delete all sessions, of one game or of every game — the Agent's rows, deleted by the Agent.
sp.GetRequiredService<ISessionRepository>());
/// <summary>
/// <c>HelloAck.telemetrySource</c>: the layers this machine composes, read once on the first <c>Hello</c> by
+5 -1
View File
@@ -280,6 +280,8 @@ public partial class App : System.Windows.Application
// The admin mode's disclosure (beta.10, D34), shown before capture.run_elevated is turned on.
builder.Services.AddSingleton<IAgentAdminPrompt, AgentAdminPrompt>();
builder.Services.AddSingleton<AntiCheatExceptions>();
// beta.11 (D40): Delete all sessions, of one game (its page) or of every game (Settings ▸ Data), through the Agent.
builder.Services.AddSingleton<SessionDeletion>();
AddLibrary(builder.Services);
@@ -350,7 +352,9 @@ public partial class App : System.Windows.Application
services.AddTransient<SystemInfoViewModel>();
services.AddSingleton<Charts.SessionSeriesLoader>();
services.AddSingleton<IFileSaver, FileSaver>();
services.AddSingleton<ISessionSummaryOpener, SessionSummaryOpener>();
services.AddSingleton<SessionSummaryOpener>();
services.AddSingleton<ISessionSummaryOpener>(static sp => sp.GetRequiredService<SessionSummaryOpener>());
services.AddSingleton<ISessionWindows>(static sp => sp.GetRequiredService<SessionSummaryOpener>()); // beta.11: Delete all sessions closes them
services.AddSingleton<IMixedTierPrompt, MixedTierPrompt>();
// Settings, the safety notices and the Logs page (P3 PR-8a): the Run entry, the notices over the pipe's
@@ -0,0 +1,7 @@
namespace FrameLedger.App.Charts;
/// <summary>A click on a trend landed on a session's points (beta.11, D39): which session.</summary>
public sealed class SessionClickedEventArgs(long sessionId) : EventArgs
{
public long SessionId { get; } = sessionId;
}
+118 -24
View File
@@ -1,18 +1,33 @@
using System.Windows.Controls;
using System.Windows.Input;
using ScottPlot;
using ScottPlot.Plottables;
namespace FrameLedger.App.Charts;
/// <summary>The trend line (one point per session, oldest first) with FR-6.3's hardware-change markers as labelled vertical lines.</summary>
/// <summary>
/// The trend: one point per session, oldest first, with FR-6.3's hardware-change markers as labelled vertical lines. Since
/// beta.11 (owner decision D39) it draws several metrics at once — every line in the first unit against the left axis, a
/// second unit against the right — and a click near a session's points raises <see cref="SessionClicked"/>, which the
/// Sessions tab's overview uses to select that session.
/// </summary>
public partial class TrendChart : UserControl
{
/// <summary>How near a click must land to a session's points, in device-independent pixels.</summary>
private const double _clickReach = 14;
private TrendPoint[] _all = [];
public TrendChart()
{
InitializeComponent();
ChartTheme.Attach(Plot);
Plot.MouseLeftButtonUp += OnPlotClicked;
}
/// <summary>The session whose points a click landed on (<see cref="TrendPoint.SessionId"/>).</summary>
public event EventHandler<SessionClickedEventArgs>? SessionClicked;
public ScottPlot.Plot ScottPlot => Plot.Plot;
public int DrawnPoints { get; private set; }
@@ -20,9 +35,20 @@ public partial class TrendChart : UserControl
/// <summary>How many of <see cref="DrawnPoints"/> were drawn hollow (a part of their session).</summary>
public int HollowPoints { get; private set; }
public void Show(IReadOnlyList<TrendPoint> points, IReadOnlyList<HardwareChange> changes, string metricLabel)
/// <summary>How many lines were drawn against the right axis (a second unit).</summary>
public int RightAxisLines { get; private set; }
/// <summary>One metric — what the Trend drew before beta.11.</summary>
public void Show(IReadOnlyList<TrendPoint> points, IReadOnlyList<HardwareChange> changes, string metricLabel) =>
Show([new TrendLine(metricLabel, metricLabel, points)], changes);
/// <summary>
/// Every line in <paramref name="lines"/>: the first line's unit on the left axis, the first other unit on the right,
/// and a line in any further unit is not drawn (the selector allows two).
/// </summary>
public void Show(IReadOnlyList<TrendLine> lines, IReadOnlyList<HardwareChange> changes)
{
ArgumentNullException.ThrowIfNull(points);
ArgumentNullException.ThrowIfNull(lines);
ArgumentNullException.ThrowIfNull(changes);
ScottPlot.Plot plot = Plot.Plot;
plot.Clear();
@@ -31,31 +57,36 @@ public partial class TrendChart : UserControl
plot.Axes.DateTimeTicksBottom();
ChartTheme.Apply(plot);
plot.XLabel(Strings.Trend_Axis_Date);
plot.YLabel(metricLabel);
DrawnPoints = points.Count;
HollowPoints = points.Count(static t => t.SettingsChangedMidSession);
if (points.Count > 0)
{
ChartPalette p = ChartTheme.Current;
double[] xs = [.. points.Select(static t => t.At.LocalDateTime.ToOADate())];
double[] ys = [.. points.Select(static t => t.Value)];
Scatter line = plot.Add.Scatter(xs, ys, p.Native);
line.LineWidth = 2;
line.MarkerSize = 7;
line.LegendText = metricLabel;
string? left = lines.Count > 0 ? lines[0].Unit : null;
string? right = lines.Select(static l => l.Unit).FirstOrDefault(u => !string.Equals(u, left, StringComparison.Ordinal));
plot.YLabel(left ?? string.Empty);
plot.Axes.Right.Label.Text = right ?? string.Empty;
// A point that describes part of its session (settings changed, or a steady state) is drawn hollow over its
// filled one: the line still passes through it, and it cannot be read as the session's own number.
TrendPoint[] partial = [.. points.Where(static t => t.SettingsChangedMidSession)];
if (partial.Length > 0)
ChartPalette p = ChartTheme.Current;
Color[] palette = [p.Native, p.Displayed, p.Percentile, p.Sensor, p.SensorSecondary, p.Stutter, p.Histogram, p.Segment];
var drawn = new List<TrendPoint>();
int hollow = 0;
int onRight = 0;
for (int i = 0; i < lines.Count; i++)
{
TrendLine line = lines[i];
bool isRight = right is not null && string.Equals(line.Unit, right, StringComparison.Ordinal);
if (line.Points.Count == 0 || (!isRight && !string.Equals(line.Unit, left, StringComparison.Ordinal)))
{
double[] hx = [.. partial.Select(static t => t.At.LocalDateTime.ToOADate())];
double[] hy = [.. partial.Select(static t => t.Value)];
Scatter hollow = plot.Add.ScatterPoints(hx, hy, p.Data);
hollow.MarkerSize = 6;
hollow.MarkerShape = MarkerShape.FilledCircle;
continue;
}
hollow += AddLine(plot, line, palette[i % palette.Length], p.Data, isRight);
onRight += isRight ? 1 : 0;
drawn.AddRange(line.Points);
}
_all = [.. drawn];
DrawnPoints = drawn.Count;
HollowPoints = hollow;
RightAxisLines = onRight;
if (drawn.Count > 0)
{
foreach (HardwareChange change in TrendSeriesBuilder.MergedByDay(changes))
{
VerticalLine marker = plot.Add.VerticalLine(change.At.LocalDateTime.ToOADate(), 1, p.StutterPso, LinePattern.Dashed);
@@ -70,4 +101,67 @@ public partial class TrendChart : UserControl
Plot.Refresh();
}
/// <summary>One line, its hollow points, against the left or the right axis; how many were hollow.</summary>
private static int AddLine(ScottPlot.Plot plot, TrendLine line, Color color, Color hollowColor, bool isRight)
{
double[] xs = [.. line.Points.Select(static t => t.At.LocalDateTime.ToOADate())];
double[] ys = [.. line.Points.Select(static t => t.Value)];
Scatter scatter = plot.Add.Scatter(xs, ys, color);
scatter.LineWidth = 2;
scatter.MarkerSize = 7;
scatter.LegendText = isRight ? line.Label + " ▸" : line.Label;
if (isRight)
{
scatter.Axes.YAxis = plot.Axes.Right;
}
// A point that describes part of its session (settings changed, or a steady state) is drawn hollow over its filled
// one: the line still passes through it, and it cannot be read as the session's own number.
TrendPoint[] partial = [.. line.Points.Where(static t => t.SettingsChangedMidSession)];
if (partial.Length > 0)
{
double[] hx = [.. partial.Select(static t => t.At.LocalDateTime.ToOADate())];
double[] hy = [.. partial.Select(static t => t.Value)];
Scatter dots = plot.Add.ScatterPoints(hx, hy, hollowColor);
dots.MarkerSize = 6;
dots.MarkerShape = MarkerShape.FilledCircle;
if (isRight)
{
dots.Axes.YAxis = plot.Axes.Right;
}
}
return partial.Length;
}
/// <summary>The session whose points are nearest the click along the date axis, if any is within <see cref="_clickReach"/>.</summary>
private void OnPlotClicked(object sender, MouseButtonEventArgs e)
{
if (_all.Length == 0 || SessionClicked is null)
{
return;
}
System.Windows.Point at = e.GetPosition(Plot);
float scale = Plot.DisplayScale;
double clickX = at.X * scale;
ScottPlot.Plot plot = Plot.Plot;
TrendPoint? nearest = null;
double best = double.MaxValue;
foreach (TrendPoint point in _all)
{
double distance = Math.Abs(plot.GetPixel(new Coordinates(point.At.LocalDateTime.ToOADate(), 0)).X - clickX);
if (distance < best)
{
best = distance;
nearest = point;
}
}
if (nearest is { } hit && best <= _clickReach * scale)
{
SessionClicked.Invoke(this, new SessionClickedEventArgs(hit.SessionId));
}
}
}
+10
View File
@@ -0,0 +1,10 @@
namespace FrameLedger.App.Charts;
/// <summary>
/// One metric's line on a trend (beta.11, owner decision D39: several metrics at once): its label, the unit that decides
/// which axis it is drawn against, and its points (one per session, oldest first).
/// </summary>
/// <param name="Label">The metric, as the legend names it.</param>
/// <param name="Unit">The axis label every line in the same unit shares.</param>
/// <param name="Points">The sessions that have the metric.</param>
public sealed record TrendLine(string Label, string Unit, IReadOnlyList<TrendPoint> Points);
@@ -42,6 +42,44 @@ public static class TrendSeriesBuilder
return points;
}
/// <summary>
/// The axis a metric is drawn against (beta.11, D39): frame rates share one, temperatures, loads and shares, power,
/// memory and the factor each have their own — two of them at most on one chart.
/// </summary>
public static string UnitOf(TrendMetric metric) => metric switch
{
TrendMetric.PresentedFps or TrendMetric.NativeFps or TrendMetric.Displayed or TrendMetric.P1Low or TrendMetric.P01Low => Strings.Trend_Unit_Fps,
TrendMetric.MaxGpuTemp or TrendMetric.MaxCpuTemp => Strings.Trend_Unit_Celsius,
TrendMetric.AvgGpuPower => Strings.Trend_Unit_Watts,
TrendMetric.MaxVramProcess or TrendMetric.AvgRam => Strings.Trend_Unit_Megabytes,
TrendMetric.FgFactor => Strings.Trend_Unit_Factor,
_ => Strings.Trend_Unit_Percent,
};
/// <summary>
/// The Sessions tab's overview (beta.11, D39): every hooked session's rate and lows on one chart — Presented FPS where
/// no generated frame was counted, Native and Displayed where frame generation was measured (rule 6: never one inflated
/// number), and the 1% and 0.1% lows — partial sessions included and drawn hollow.
/// </summary>
public static IReadOnlyList<TrendLine> Overview(IReadOnlyList<SessionRow> rows)
{
ArgumentNullException.ThrowIfNull(rows);
(TrendMetric Metric, string Label)[] metrics =
[
(TrendMetric.PresentedFps, Strings.Trend_Metric_PresentedFps),
(TrendMetric.NativeFps, Strings.Trend_Metric_NativeFps),
(TrendMetric.Displayed, Strings.Trend_Metric_Displayed),
(TrendMetric.P1Low, Strings.Trend_Metric_P1Low),
(TrendMetric.P01Low, Strings.Trend_Metric_P01Low),
];
// Native and Displayed only where frames were generated: on a session that counted none, Native is the Presented rate
// already drawn, and a second line on the same points reads as a second measurement.
HashSet<long> generated = [.. rows.Where(static r => FpsPresentation.FromRow(r).Kind == FpsReadoutKind.Generated).Select(static r => r.Id)];
return [.. metrics.Select(m => new TrendLine(m.Label, Strings.Trend_Unit_Fps,
[.. Points(rows, m.Metric, includeMidSessionChanges: true).Where(p => m.Metric is not (TrendMetric.NativeFps or TrendMetric.Displayed) || generated.Contains(p.SessionId))]))
.Where(static l => l.Points.Count > 0)];
}
/// <summary>How many sessions FR-6.4 leaves out at the default setting.</summary>
public static int ExcludedCount(IReadOnlyList<SessionRow> rows) => ExcludedCount(rows, TrendMetric.PresentedFps);
@@ -215,6 +215,18 @@
<ui:TextBlock Appearance="Secondary" TextWrapping="Wrap"
Text="{x:Static vm:GameDetailViewModel.SessionsEmptyText}"
Visibility="{Binding ViewModel.SessionsEmpty, Converter={StaticResource BoolToVis}}" />
<!-- beta.11 (D39): every hooked session's rate and lows at a glance; a click selects the session below. -->
<StackPanel Visibility="{Binding ViewModel.OverviewVisible, Converter={StaticResource BoolToVis}}">
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static vm:GameDetailViewModel.OverviewHeader}" />
<ui:TextBlock Appearance="Tertiary" TextWrapping="Wrap" Text="{x:Static vm:GameDetailViewModel.OverviewNote}" />
<charts:TrendChart x:Name="Overview" Height="220" MinHeight="200" Margin="0,4,0,8" />
</StackPanel>
<!-- beta.11 (D40): the game, its settings and its consent stay; the confirmation says how many go. -->
<StackPanel Margin="0,0,0,8" Orientation="Horizontal" HorizontalAlignment="Right"
Visibility="{Binding ViewModel.SessionsEmpty, Converter={StaticResource InverseBoolToVis}}">
<ui:Button Appearance="Secondary" Command="{Binding ViewModel.DeleteAllSessionsCommand}"
Content="{x:Static vm:GameDetailViewModel.DeleteAllSessionsText}" Icon="{ui:SymbolIcon Delete24}" />
</StackPanel>
<DataGrid x:Name="SessionsGrid" AutoGenerateColumns="False" CanUserAddRows="False" IsReadOnly="True" HeadersVisibility="Column"
ItemsSource="{Binding ViewModel.Sessions}" SelectionMode="Extended" MouseDoubleClick="OnSessionDoubleClick"
SelectedItem="{Binding ViewModel.SelectedSession, Mode=TwoWay}">
@@ -323,6 +335,21 @@
<CheckBox Margin="16,0,0,0" VerticalAlignment="Center" Content="{x:Static vm:GameDetailViewModel.IncludeMidSessionText}"
IsChecked="{Binding ViewModel.IncludeMidSession}" />
</StackPanel>
<!-- beta.11 (D39): more metrics on the same chart; a second unit is drawn against the right axis, a third cannot be ticked. -->
<ui:TextBlock Margin="0,10,0,0" Appearance="Secondary" Text="{x:Static vm:GameDetailViewModel.TrendExtrasLabel}" />
<ItemsControl ItemsSource="{Binding ViewModel.TrendExtras}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate DataType="{x:Type vm:TrendMetricOptionViewModel}">
<CheckBox Margin="0,4,14,0" Content="{Binding Label}" IsChecked="{Binding IsSelected, Mode=TwoWay}" IsEnabled="{Binding IsEnabled}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<ui:TextBlock Margin="0,4,0,0" Appearance="Tertiary" TextWrapping="Wrap" Text="{x:Static vm:GameDetailViewModel.TrendExtrasNote}" />
<ui:TextBlock Margin="0,6,0,0" Appearance="Tertiary" Text="{Binding ViewModel.TrendExcludedText}"
Visibility="{Binding ViewModel.TrendExcludedText, Converter={StaticResource NullToCollapsed}}" />
<ui:TextBlock Margin="0,6,0,0" Appearance="Tertiary" TextWrapping="Wrap" Text="{x:Static vm:GameDetailViewModel.TrendAverageNote}" />
@@ -14,6 +14,7 @@ public partial class GameDetailPage : INavigableView<GameDetailViewModel>
InitializeComponent();
ViewModel.SelectionPresented += OnSelectionPresented;
ViewModel.TrendPresented += OnTrendPresented;
Overview.SessionClicked += OnOverviewClicked;
// The view model starts loading before this page exists, and a load that finished first raised its events to
// nobody: the Trend tab was blank on every first open (beta.8). Draw what it holds now; a later load redraws.
OnTrendPresented(this, EventArgs.Empty);
@@ -23,6 +24,7 @@ public partial class GameDetailPage : INavigableView<GameDetailViewModel>
{
ViewModel.SelectionPresented -= OnSelectionPresented;
ViewModel.TrendPresented -= OnTrendPresented;
Overview.SessionClicked -= OnOverviewClicked;
ViewModel.Detach();
};
}
@@ -37,7 +39,22 @@ public partial class GameDetailPage : INavigableView<GameDetailViewModel>
Latency.Show(ViewModel.SelectedSeries, ViewModel.SelectedSession?.Row.LatencyAvgUs, ViewModel.SelectedSession?.Row.LatencyP95Us);
}
private void OnTrendPresented(object? sender, EventArgs e) => Trend.Show(ViewModel.TrendPoints, ViewModel.HardwareChanges, ViewModel.TrendMetricText);
/// <summary>The Trend tab's lines (beta.11: several metrics at once) and the Sessions tab's overview, from one rebuild.</summary>
private void OnTrendPresented(object? sender, EventArgs e)
{
Trend.Show(ViewModel.TrendLines, ViewModel.HardwareChanges);
Overview.Show(ViewModel.OverviewLines, ViewModel.HardwareChanges);
}
/// <summary>beta.11 (D39): a session picked on the overview is selected in the grid below it, and scrolled to.</summary>
private void OnOverviewClicked(object? sender, Charts.SessionClickedEventArgs e)
{
ViewModel.SelectSession(e.SessionId);
if (ViewModel.SelectedSession is { } session)
{
SessionsGrid.ScrollIntoView(session);
}
}
private void OnSessionDoubleClick(object sender, MouseButtonEventArgs e)
{
+18 -15
View File
@@ -28,11 +28,10 @@
<ui:TextBlock Appearance="Secondary" Text="{x:Static res:Strings.Settings_KillSwitch_Body}" TextWrapping="Wrap" />
</ui:CardExpander>
<ui:CardExpander Margin="0,8,0,0" IsExpanded="True" Icon="{ui:SymbolIcon Games24}" Header="{x:Static res:Strings.Settings_HookedGames_Label}">
<!-- beta.11 (owner request 2026-10-03: no row without a control): shown only while a game has hooking on, each with its Turn off. -->
<ui:CardExpander Margin="0,8,0,0" IsExpanded="True" Icon="{ui:SymbolIcon Games24}" Header="{x:Static res:Strings.Settings_HookedGames_Label}"
Visibility="{Binding ViewModel.HasHookedGames, Converter={StaticResource BoolToVis}}">
<StackPanel>
<ui:TextBlock Appearance="Secondary"
Text="{x:Static res:Strings.Settings_HookedGames_Empty}"
Visibility="{Binding ViewModel.HookedGames.Count, Converter={StaticResource ZeroToVisible}}" />
<ItemsControl ItemsSource="{Binding ViewModel.HookedGames}">
<ItemsControl.ItemTemplate>
<DataTemplate>
@@ -214,23 +213,28 @@
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_Background_Label}" IsChecked="{Binding ViewModel.BackgroundCapture, Mode=TwoWay}" />
</ui:CardControl>
<!-- Agent: elevation is optional and no tier needs it; the logon task arrives with the tray build. -->
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Agent_Header}" />
<ui:CardExpander Margin="0,4,0,0" Icon="{ui:SymbolIcon Person24}">
<ui:CardExpander.Header>
<!-- beta.11 (owner request 2026-10-03: no row without a control): Data - Delete all sessions (D40). -->
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Data_Header}" />
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon Delete24}">
<ui:CardControl.Header>
<StackPanel>
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_Agent_Elevation_Label}" />
<ui:TextBlock Appearance="Secondary" Text="{Binding ViewModel.ElevationText}" />
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_DeleteSessions_Label}" />
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Appearance="Secondary" Text="{x:Static res:Strings.Settings_DeleteSessions_Body}" TextWrapping="Wrap" />
</StackPanel>
</ui:CardExpander.Header>
<ui:TextBlock Appearance="Secondary" Text="{x:Static res:Strings.Settings_Agent_Elevation_Body}" TextWrapping="Wrap" />
</ui:CardExpander>
</ui:CardControl.Header>
<ui:Button Appearance="Secondary" Command="{Binding ViewModel.DeleteAllSessionsCommand}" Content="{x:Static res:Strings.Settings_DeleteSessions_Button}" />
</ui:CardControl>
<!-- Agent: elevation is optional and no tier needs it. beta.11: the elevation line is the admin mode's own status, not a row of its own. -->
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Agent_Header}" />
<!-- beta.10, the admin mode (D34): off by default; on shows the disclosure, and Windows asks at every Agent start. -->
<ui:CardControl Margin="0,8,0,0" Icon="{ui:SymbolIcon Shield24}">
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon Shield24}">
<ui:CardControl.Header>
<StackPanel>
<ui:TextBlock FontTypography="BodyStrong" Text="{x:Static res:Strings.Settings_Agent_RunElevated_Label}" />
<ui:TextBlock MaxWidth="560" HorizontalAlignment="Left" Appearance="Secondary" Text="{x:Static res:Strings.Settings_Agent_RunElevated_Body}" TextWrapping="Wrap" />
<ui:TextBlock Margin="0,4,0,0" FontTypography="BodyStrong" Text="{Binding ViewModel.ElevationText}" TextWrapping="Wrap"
ToolTip="{x:Static res:Strings.Settings_Agent_Elevation_Body}" />
</StackPanel>
</ui:CardControl.Header>
<ui:ToggleSwitch AutomationProperties.Name="{x:Static res:Strings.Settings_Agent_RunElevated_Label}" IsChecked="{Binding ViewModel.RunElevated, Mode=TwoWay}" />
@@ -278,7 +282,6 @@
SelectedValue="{Binding ViewModel.SelectedLanguage, Mode=TwoWay}"
SelectedValuePath="Value" />
</ui:CardControl>
<ui:TextBlock Margin="0,6,0,0" Appearance="Secondary" Text="{x:Static vm:SettingsViewModel.LanguageNote}" TextWrapping="Wrap" />
<ui:TextBlock FontTypography="Subtitle" Margin="0,20,0,8" Text="{x:Static res:Strings.Settings_Window_Header}" />
<ui:CardControl Margin="0,4,0,0" Icon="{ui:SymbolIcon Power24}">
@@ -27,4 +27,21 @@ public sealed class Confirmations : IConfirmations
_ => RemoveGameChoice.Cancel,
};
}
/// <summary>beta.11 (D40): the one destructive button, in the danger colour; closing the box or Cancel deletes nothing.</summary>
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
public async Task<bool> DeleteSessionsAsync(string? gameName, long sessions, CancellationToken ct = default)
{
var box = new MessageBox
{
Title = gameName is null
? Strings.DeleteSessions_AllTitle
: string.Format(CultureInfo.CurrentCulture, Strings.DeleteSessions_GameTitle_Format, gameName),
Content = string.Format(CultureInfo.CurrentCulture, gameName is null ? Strings.DeleteSessions_AllBody_Format : Strings.DeleteSessions_GameBody_Format, sessions),
PrimaryButtonText = Strings.DeleteSessions_Delete,
PrimaryButtonAppearance = ControlAppearance.Danger,
CloseButtonText = Strings.Common_Cancel,
};
return await box.ShowDialogAsync(cancellationToken: ct).ConfigureAwait(true) == MessageBoxResult.Primary;
}
}
@@ -4,4 +4,10 @@ namespace FrameLedger.App.Services;
public interface IConfirmations
{
Task<RemoveGameChoice> RemoveGameAsync(string gameName, CancellationToken ct = default);
/// <summary>
/// beta.11 (D40): delete every session of <paramref name="gameName"/>'s game — or of every game when it is null —
/// <paramref name="sessions"/> of them; true only on the explicit delete button.
/// </summary>
Task<bool> DeleteSessionsAsync(string? gameName, long sessions, CancellationToken ct = default);
}
@@ -0,0 +1,12 @@
namespace FrameLedger.App.Services;
/// <summary>
/// The session summary windows that are open (beta.11, owner decision D40). After Delete all sessions a window left open
/// would show a session that is gone, and a note written from it would go to whichever session reuses its id (the table has
/// no AUTOINCREMENT).
/// </summary>
public interface ISessionWindows
{
/// <summary>Closes every open summary window whose session is no longer in the ledger.</summary>
Task CloseDeletedAsync(CancellationToken ct = default);
}
@@ -0,0 +1,83 @@
using FrameLedger.Application.Persistence;
using FrameLedger.Infrastructure.Ipc;
using FrameLedger.Shared.Ipc;
using Serilog;
namespace FrameLedger.App.Services;
/// <summary>
/// Delete all sessions (beta.11, owner decision D40), of one game from its page or of every game from Settings ▸ Data. The
/// sessions are the Agent's rows (<c>06_DATA_MODEL</c> §Writer ownership), so the App asks it over the pipe, as Tools ▸
/// Database maintenance asks for the retention sweep; the Agent refuses while a session it would delete under is being
/// recorded. The confirmation is the caller's to ask first. After a delete it forgets what is gone, for both callers: File ▸
/// Export's selection when it named a deleted session, and the summary windows open on one — session ids are reused once
/// the newest is gone (no AUTOINCREMENT), so either would otherwise act on whichever session takes the id next.
/// </summary>
public sealed class SessionDeletion
{
private readonly IAgentRequests _agent;
private readonly ISessionRepository? _sessions;
private readonly SessionSelection? _selection;
private readonly ISessionWindows? _windows;
public SessionDeletion(IAgentRequests agent, ISessionRepository? sessions = null, SessionSelection? selection = null, ISessionWindows? windows = null)
{
_agent = agent ?? throw new ArgumentNullException(nameof(agent));
_sessions = sessions;
_selection = selection;
_windows = windows;
}
/// <summary>Every session of <paramref name="gameId"/>, or of every game when it is null.</summary>
public async Task<SessionDeletionResult> DeleteAsync(long? gameId, CancellationToken ct = default)
{
if (!_agent.IsConnected)
{
return new(SessionDeletionOutcome.AgentUnavailable);
}
try
{
IpcEnvelope envelope = await _agent.RequestAsync(IpcMessageType.DeleteSessions, new DeleteSessionsRequest(gameId), ct).ConfigureAwait(true);
DeleteSessionsAck ack = IpcCodec.Payload<DeleteSessionsAck>(envelope) ?? throw new InvalidOperationException("DeleteSessions answered without a payload");
Log.Information("sessions: deleted {Sessions} session(s) of {Games} game(s) ({Scope})", ack.Sessions, ack.Games, gameId is null ? "every game" : "game " + gameId);
await ForgetDeletedAsync(ct).ConfigureAwait(true);
return new(SessionDeletionOutcome.Deleted, ack.Games, ack.Sessions);
}
catch (IpcRequestException ex) when (string.Equals(ex.Code, IpcErrorCode.SessionRunning, StringComparison.Ordinal))
{
return new(SessionDeletionOutcome.SessionRunning);
}
catch (IpcRequestException ex) when (string.Equals(ex.Code, IpcErrorCode.UnknownType, StringComparison.Ordinal))
{
Log.Warning("sessions: the Agent does not know DeleteSessions ({Message})", ex.Message);
return new(SessionDeletionOutcome.AgentTooOld);
}
catch (Exception ex) when (ex is IpcRequestException or InvalidOperationException or TimeoutException)
{
Log.Warning("sessions: DeleteSessions failed ({Message})", ex.Message);
return new(SessionDeletionOutcome.Failed, Detail: ex.Message);
}
}
/// <summary>The delete happened: what still names a deleted session lets go of it. A failure here is logged, not the delete's.</summary>
private async Task ForgetDeletedAsync(CancellationToken ct)
{
try
{
if (_sessions is not null && _selection?.SessionId is long selected && await _sessions.FindByIdAsync(selected, ct).ConfigureAwait(true) is null)
{
_selection.Set(null);
}
if (_windows is not null)
{
await _windows.CloseDeletedAsync(ct).ConfigureAwait(true);
}
}
catch (Exception ex) when (ex is not OutOfMemoryException and not OperationCanceledException)
{
Log.Warning(ex, "sessions: the deleted sessions' selection and windows were not all let go of");
}
}
}
@@ -0,0 +1,20 @@
namespace FrameLedger.App.Services;
/// <summary>How a <c>DeleteSessions</c> ask ended (beta.11, D40).</summary>
public enum SessionDeletionOutcome
{
/// <summary>The Agent deleted them; the counts say how many.</summary>
Deleted,
/// <summary>A session it would delete under is being recorded: nothing was deleted.</summary>
SessionRunning,
/// <summary>The capture agent is not connected: nothing was asked.</summary>
AgentUnavailable,
/// <summary>The Agent does not know the request (an older build): nothing was deleted.</summary>
AgentTooOld,
/// <summary>Anything else; the detail says what.</summary>
Failed,
}
@@ -0,0 +1,19 @@
using System.Globalization;
namespace FrameLedger.App.Services;
/// <summary>What a <c>DeleteSessions</c> ask did (beta.11, D40), and the sentence to tell the user.</summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
public sealed record SessionDeletionResult(SessionDeletionOutcome Outcome, int Games = 0, int Sessions = 0, string? Detail = null)
{
public bool Succeeded => Outcome == SessionDeletionOutcome.Deleted;
public string Message => Outcome switch
{
SessionDeletionOutcome.Deleted => string.Format(CultureInfo.CurrentCulture, Strings.DeleteSessions_Done_Format, Sessions, Games),
SessionDeletionOutcome.SessionRunning => Strings.DeleteSessions_Running,
SessionDeletionOutcome.AgentUnavailable => Strings.DeleteSessions_NoAgent,
SessionDeletionOutcome.AgentTooOld => Strings.DeleteSessions_AgentTooOld,
_ => Detail ?? Strings.Common_NotAvailable,
};
}
@@ -10,15 +10,18 @@ namespace FrameLedger.App.Services;
/// <summary>
/// Builds a summary window per open: the view model's override prompt is bound to THAT window's dialog host,
/// which is why the window is composed here rather than resolved whole from DI. The load runs after
/// <c>Show()</c> so the window appears at once and fills in.
/// <c>Show()</c> so the window appears at once and fills in. It keeps the windows it opened, so that Delete all sessions
/// can close the ones whose session is gone (<see cref="ISessionWindows"/>, beta.11).
/// </summary>
public sealed class SessionSummaryOpener : ISessionSummaryOpener
public sealed class SessionSummaryOpener : ISessionSummaryOpener, ISessionWindows
{
private readonly IServiceProvider _services;
private readonly ShellHost _shell;
private readonly SessionSelection _selection;
private readonly List<(long SessionId, SessionSummaryWindow Window)> _open = [];
public SessionSummaryOpener(IServiceProvider services, ShellHost shell, SessionSelection selection)
{
_services = services ?? throw new ArgumentNullException(nameof(services));
@@ -43,10 +46,26 @@ public sealed class SessionSummaryOpener : ISessionSummaryOpener
{
Owner = _shell.Current,
};
(long, SessionSummaryWindow) open = (sessionId, window);
_open.Add(open);
window.Closed += (_, _) => _open.Remove(open);
window.Show();
_ = LoadAsync(viewModel, sessionId);
}
public async Task CloseDeletedAsync(CancellationToken ct = default)
{
ISessionRepository sessions = _services.GetRequiredService<ISessionRepository>();
foreach ((long SessionId, SessionSummaryWindow Window) open in _open.ToArray())
{
// Still open after the read: the user may have closed it meanwhile, and a closed window is not closed twice.
if (await sessions.FindByIdAsync(open.SessionId, ct).ConfigureAwait(true) is null && _open.Contains(open))
{
open.Window.Close();
}
}
}
private static async Task LoadAsync(SessionSummaryViewModel viewModel, long sessionId)
{
try
+72 -6
View File
@@ -183,6 +183,15 @@ public static class Strings
nameof(Dashboard_Totals_Games),
nameof(Dashboard_Totals_Playtime),
nameof(Dashboard_Totals_ThisWeek),
nameof(DeleteSessions_AgentTooOld),
nameof(DeleteSessions_AllBody_Format),
nameof(DeleteSessions_AllTitle),
nameof(DeleteSessions_Delete),
nameof(DeleteSessions_Done_Format),
nameof(DeleteSessions_GameBody_Format),
nameof(DeleteSessions_GameTitle_Format),
nameof(DeleteSessions_NoAgent),
nameof(DeleteSessions_Running),
nameof(Diag_Written_Format),
nameof(Display_Buffer_Format),
nameof(Display_BufferEffect_Format),
@@ -365,6 +374,7 @@ public static class Strings
nameof(GameDetail_AntiCheat_Header),
nameof(GameDetail_Back),
nameof(GameDetail_ChangeExe),
nameof(GameDetail_DeleteSessions),
nameof(GameDetail_Details_Architecture),
nameof(GameDetail_Details_Engine),
nameof(GameDetail_Details_EngineVersion),
@@ -403,6 +413,8 @@ public static class Strings
nameof(GameDetail_Measured_Header),
nameof(GameDetail_Measured_NotHooked),
nameof(GameDetail_NotFound),
nameof(GameDetail_Overview_Header),
nameof(GameDetail_Overview_Note),
nameof(GameDetail_Recording_Body),
nameof(GameDetail_Recording_Header),
nameof(GameDetail_Recording_Off),
@@ -688,6 +700,10 @@ public static class Strings
nameof(Settings_Capture_Header),
nameof(Settings_Channel_Beta),
nameof(Settings_Channel_Stable),
nameof(Settings_Data_Header),
nameof(Settings_DeleteSessions_Body),
nameof(Settings_DeleteSessions_Button),
nameof(Settings_DeleteSessions_Label),
nameof(Settings_Exceptions_Body),
nameof(Settings_Exceptions_Checking),
nameof(Settings_Exceptions_Empty),
@@ -702,7 +718,6 @@ public static class Strings
nameof(Settings_Header),
nameof(Settings_HideAntiCheatHooking_Body),
nameof(Settings_HideAntiCheatHooking_Label),
nameof(Settings_HookedGames_Empty),
nameof(Settings_HookedGames_Label),
nameof(Settings_HookedGames_Revoke),
nameof(Settings_Interval_Body),
@@ -713,7 +728,6 @@ public static class Strings
nameof(Settings_KillSwitch_Off),
nameof(Settings_KillSwitch_On),
nameof(Settings_Language_Label),
nameof(Settings_Language_Note),
nameof(Settings_Legal_Header),
nameof(Settings_Legal_Reopen),
nameof(Settings_LogDebug_Body),
@@ -847,6 +861,8 @@ public static class Strings
nameof(Trend_Empty),
nameof(Trend_Empty_Format),
nameof(Trend_Excluded_Format),
nameof(Trend_Extras_Label),
nameof(Trend_Extras_Note),
nameof(Trend_IncludeMidSession),
nameof(Trend_Metric_Average),
nameof(Trend_Metric_AvgCpuLoad),
@@ -867,6 +883,12 @@ public static class Strings
nameof(Trend_Metric_P1Low),
nameof(Trend_Metric_PresentedFps),
nameof(Trend_Partial_Note),
nameof(Trend_Unit_Celsius),
nameof(Trend_Unit_Factor),
nameof(Trend_Unit_Fps),
nameof(Trend_Unit_Megabytes),
nameof(Trend_Unit_Percent),
nameof(Trend_Unit_Watts),
nameof(Uninstall_DataFolder_Body),
nameof(Uninstall_DataFolder_Title),
nameof(Update_AgentStillRunning),
@@ -1214,6 +1236,24 @@ public static class Strings
public static string Dashboard_Totals_ThisWeek => ResourceManager.GetString(nameof(Dashboard_Totals_ThisWeek), Culture) ?? nameof(Dashboard_Totals_ThisWeek);
public static string DeleteSessions_AgentTooOld => ResourceManager.GetString(nameof(DeleteSessions_AgentTooOld), Culture) ?? nameof(DeleteSessions_AgentTooOld);
public static string DeleteSessions_AllBody_Format => ResourceManager.GetString(nameof(DeleteSessions_AllBody_Format), Culture) ?? nameof(DeleteSessions_AllBody_Format);
public static string DeleteSessions_AllTitle => ResourceManager.GetString(nameof(DeleteSessions_AllTitle), Culture) ?? nameof(DeleteSessions_AllTitle);
public static string DeleteSessions_Delete => ResourceManager.GetString(nameof(DeleteSessions_Delete), Culture) ?? nameof(DeleteSessions_Delete);
public static string DeleteSessions_Done_Format => ResourceManager.GetString(nameof(DeleteSessions_Done_Format), Culture) ?? nameof(DeleteSessions_Done_Format);
public static string DeleteSessions_GameBody_Format => ResourceManager.GetString(nameof(DeleteSessions_GameBody_Format), Culture) ?? nameof(DeleteSessions_GameBody_Format);
public static string DeleteSessions_GameTitle_Format => ResourceManager.GetString(nameof(DeleteSessions_GameTitle_Format), Culture) ?? nameof(DeleteSessions_GameTitle_Format);
public static string DeleteSessions_NoAgent => ResourceManager.GetString(nameof(DeleteSessions_NoAgent), Culture) ?? nameof(DeleteSessions_NoAgent);
public static string DeleteSessions_Running => ResourceManager.GetString(nameof(DeleteSessions_Running), Culture) ?? nameof(DeleteSessions_Running);
public static string Diag_Written_Format => ResourceManager.GetString(nameof(Diag_Written_Format), Culture) ?? nameof(Diag_Written_Format);
public static string Display_Buffer_Format => ResourceManager.GetString(nameof(Display_Buffer_Format), Culture) ?? nameof(Display_Buffer_Format);
@@ -1578,6 +1618,8 @@ public static class Strings
public static string GameDetail_ChangeExe => ResourceManager.GetString(nameof(GameDetail_ChangeExe), Culture) ?? nameof(GameDetail_ChangeExe);
public static string GameDetail_DeleteSessions => ResourceManager.GetString(nameof(GameDetail_DeleteSessions), Culture) ?? nameof(GameDetail_DeleteSessions);
public static string GameDetail_Details_Architecture => ResourceManager.GetString(nameof(GameDetail_Details_Architecture), Culture) ?? nameof(GameDetail_Details_Architecture);
public static string GameDetail_Details_Engine => ResourceManager.GetString(nameof(GameDetail_Details_Engine), Culture) ?? nameof(GameDetail_Details_Engine);
@@ -1654,6 +1696,10 @@ public static class Strings
public static string GameDetail_NotFound => ResourceManager.GetString(nameof(GameDetail_NotFound), Culture) ?? nameof(GameDetail_NotFound);
public static string GameDetail_Overview_Header => ResourceManager.GetString(nameof(GameDetail_Overview_Header), Culture) ?? nameof(GameDetail_Overview_Header);
public static string GameDetail_Overview_Note => ResourceManager.GetString(nameof(GameDetail_Overview_Note), Culture) ?? nameof(GameDetail_Overview_Note);
public static string GameDetail_Recording_Body => ResourceManager.GetString(nameof(GameDetail_Recording_Body), Culture) ?? nameof(GameDetail_Recording_Body);
public static string GameDetail_Recording_Header => ResourceManager.GetString(nameof(GameDetail_Recording_Header), Culture) ?? nameof(GameDetail_Recording_Header);
@@ -2224,6 +2270,14 @@ public static class Strings
public static string Settings_Channel_Stable => ResourceManager.GetString(nameof(Settings_Channel_Stable), Culture) ?? nameof(Settings_Channel_Stable);
public static string Settings_Data_Header => ResourceManager.GetString(nameof(Settings_Data_Header), Culture) ?? nameof(Settings_Data_Header);
public static string Settings_DeleteSessions_Body => ResourceManager.GetString(nameof(Settings_DeleteSessions_Body), Culture) ?? nameof(Settings_DeleteSessions_Body);
public static string Settings_DeleteSessions_Button => ResourceManager.GetString(nameof(Settings_DeleteSessions_Button), Culture) ?? nameof(Settings_DeleteSessions_Button);
public static string Settings_DeleteSessions_Label => ResourceManager.GetString(nameof(Settings_DeleteSessions_Label), Culture) ?? nameof(Settings_DeleteSessions_Label);
public static string Settings_Exceptions_Body => ResourceManager.GetString(nameof(Settings_Exceptions_Body), Culture) ?? nameof(Settings_Exceptions_Body);
public static string Settings_Exceptions_Checking => ResourceManager.GetString(nameof(Settings_Exceptions_Checking), Culture) ?? nameof(Settings_Exceptions_Checking);
@@ -2252,8 +2306,6 @@ public static class Strings
public static string Settings_HideAntiCheatHooking_Label => ResourceManager.GetString(nameof(Settings_HideAntiCheatHooking_Label), Culture) ?? nameof(Settings_HideAntiCheatHooking_Label);
public static string Settings_HookedGames_Empty => ResourceManager.GetString(nameof(Settings_HookedGames_Empty), Culture) ?? nameof(Settings_HookedGames_Empty);
public static string Settings_HookedGames_Label => ResourceManager.GetString(nameof(Settings_HookedGames_Label), Culture) ?? nameof(Settings_HookedGames_Label);
public static string Settings_HookedGames_Revoke => ResourceManager.GetString(nameof(Settings_HookedGames_Revoke), Culture) ?? nameof(Settings_HookedGames_Revoke);
@@ -2274,8 +2326,6 @@ public static class Strings
public static string Settings_Language_Label => ResourceManager.GetString(nameof(Settings_Language_Label), Culture) ?? nameof(Settings_Language_Label);
public static string Settings_Language_Note => ResourceManager.GetString(nameof(Settings_Language_Note), Culture) ?? nameof(Settings_Language_Note);
public static string Settings_Legal_Header => ResourceManager.GetString(nameof(Settings_Legal_Header), Culture) ?? nameof(Settings_Legal_Header);
public static string Settings_Legal_Reopen => ResourceManager.GetString(nameof(Settings_Legal_Reopen), Culture) ?? nameof(Settings_Legal_Reopen);
@@ -2542,6 +2592,10 @@ public static class Strings
public static string Trend_Excluded_Format => ResourceManager.GetString(nameof(Trend_Excluded_Format), Culture) ?? nameof(Trend_Excluded_Format);
public static string Trend_Extras_Label => ResourceManager.GetString(nameof(Trend_Extras_Label), Culture) ?? nameof(Trend_Extras_Label);
public static string Trend_Extras_Note => ResourceManager.GetString(nameof(Trend_Extras_Note), Culture) ?? nameof(Trend_Extras_Note);
public static string Trend_IncludeMidSession => ResourceManager.GetString(nameof(Trend_IncludeMidSession), Culture) ?? nameof(Trend_IncludeMidSession);
public static string Trend_Metric_Average => ResourceManager.GetString(nameof(Trend_Metric_Average), Culture) ?? nameof(Trend_Metric_Average);
@@ -2582,6 +2636,18 @@ public static class Strings
public static string Trend_Partial_Note => ResourceManager.GetString(nameof(Trend_Partial_Note), Culture) ?? nameof(Trend_Partial_Note);
public static string Trend_Unit_Celsius => ResourceManager.GetString(nameof(Trend_Unit_Celsius), Culture) ?? nameof(Trend_Unit_Celsius);
public static string Trend_Unit_Factor => ResourceManager.GetString(nameof(Trend_Unit_Factor), Culture) ?? nameof(Trend_Unit_Factor);
public static string Trend_Unit_Fps => ResourceManager.GetString(nameof(Trend_Unit_Fps), Culture) ?? nameof(Trend_Unit_Fps);
public static string Trend_Unit_Megabytes => ResourceManager.GetString(nameof(Trend_Unit_Megabytes), Culture) ?? nameof(Trend_Unit_Megabytes);
public static string Trend_Unit_Percent => ResourceManager.GetString(nameof(Trend_Unit_Percent), Culture) ?? nameof(Trend_Unit_Percent);
public static string Trend_Unit_Watts => ResourceManager.GetString(nameof(Trend_Unit_Watts), Culture) ?? nameof(Trend_Unit_Watts);
public static string Uninstall_DataFolder_Body => ResourceManager.GetString(nameof(Uninstall_DataFolder_Body), Culture) ?? nameof(Uninstall_DataFolder_Body);
public static string Uninstall_DataFolder_Title => ResourceManager.GetString(nameof(Uninstall_DataFolder_Title), Culture) ?? nameof(Uninstall_DataFolder_Title);
+97 -9
View File
@@ -409,10 +409,6 @@
<value>言語</value>
<comment>review</comment>
</data>
<data name="Settings_Language_Note" xml:space="preserve">
<value>すぐに適用されます。ウィンドウは新しい言語で再構築されます。</value>
<comment>review</comment>
</data>
<data name="Settings_Theme_Dark" xml:space="preserve">
<value>ダーク</value>
<comment>review</comment>
@@ -981,6 +977,54 @@
<value>セッション</value>
<comment>review</comment>
</data>
<data name="GameDetail_DeleteSessions" xml:space="preserve">
<value>すべてのセッションを削除…</value>
<comment>review</comment>
</data>
<data name="GameDetail_Overview_Header" xml:space="preserve">
<value>セッションの概要</value>
<comment>review</comment>
</data>
<data name="GameDetail_Overview_Note" xml:space="preserve">
<value>フックした各セッションのフレームレートと Low 値(古い順)。フレーム生成が計測されたセッションでは Native と Displayed を描画します。白抜きの点はセッションの一部を表します。点をクリックすると下の一覧でそのセッションを選択します。</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_GameTitle_Format" xml:space="preserve">
<value>{0} のすべてのセッションを削除しますか?</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_AllTitle" xml:space="preserve">
<value>すべてのゲームのすべてのセッションを削除しますか?</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_GameBody_Format" xml:space="preserve">
<value>{0} 件のセッションを、フレームとセンサーのデータやメモとともに削除します。ゲーム、その設定、フックへの同意は残ります。元に戻すことはできません。</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_AllBody_Format" xml:space="preserve">
<value>すべてのゲームの {0} 件のセッションを、フレームとセンサーのデータやメモとともに削除します。ライブラリー、設定、フックへの同意はすべて残ります。元に戻すことはできません。</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_Delete" xml:space="preserve">
<value>セッションを削除</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_Done_Format" xml:space="preserve">
<value>{1} 件のゲームの {0} 件のセッションを削除しました。</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_Running" xml:space="preserve">
<value>セッションを記録中のため、何も削除していません。停止するか終了するのを待ってから、もう一度お試しください。</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_NoAgent" xml:space="preserve">
<value>キャプチャエージェントが接続されていないため、何も削除していません。</value>
<comment>review</comment>
</data>
<data name="DeleteSessions_AgentTooOld" xml:space="preserve">
<value>キャプチャエージェントがこの要求にまだ対応していません。再起動してからもう一度お試しください。何も削除していません。</value>
<comment>review</comment>
</data>
<data name="GameDetail_Tab_Trend" xml:space="preserve">
<value>傾向</value>
<comment>review</comment>
@@ -1709,6 +1753,38 @@
<value>指標</value>
<comment>review</comment>
</data>
<data name="Trend_Extras_Label" xml:space="preserve">
<value>あわせて表示</value>
<comment>review</comment>
</data>
<data name="Trend_Extras_Note" xml:space="preserve">
<value>単位は同時に2つまでです。2つ目の単位は右側の軸に描画されます(凡例に ▸ で表示)。</value>
<comment>review</comment>
</data>
<data name="Trend_Unit_Fps" xml:space="preserve">
<value>FPS</value>
<comment>review</comment>
</data>
<data name="Trend_Unit_Celsius" xml:space="preserve">
<value>°C</value>
<comment>review</comment>
</data>
<data name="Trend_Unit_Percent" xml:space="preserve">
<value>%</value>
<comment>review</comment>
</data>
<data name="Trend_Unit_Watts" xml:space="preserve">
<value>W</value>
<comment>review</comment>
</data>
<data name="Trend_Unit_Megabytes" xml:space="preserve">
<value>MB</value>
<comment>review</comment>
</data>
<data name="Trend_Unit_Factor" xml:space="preserve">
<value>×(フレーム生成)</value>
<comment>review</comment>
</data>
<data name="Trend_Metric_MaxGpuTemp" xml:space="preserve">
<value>GPU 最高 °C</value>
<comment>review</comment>
@@ -1881,10 +1957,6 @@
<value>安定版</value>
<comment>review</comment>
</data>
<data name="Settings_HookedGames_Empty" xml:space="preserve">
<value>フックが有効なゲームはありません。</value>
<comment>review</comment>
</data>
<data name="Settings_HookedGames_Label" xml:space="preserve">
<value>フック有効なゲーム</value>
<comment>review</comment>
@@ -1965,6 +2037,22 @@
<value>記録</value>
<comment>review</comment>
</data>
<data name="Settings_Data_Header" xml:space="preserve">
<value>データ</value>
<comment>review</comment>
</data>
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
<value>すべてのセッションを削除</value>
<comment>review</comment>
</data>
<data name="Settings_DeleteSessions_Body" xml:space="preserve">
<value>すべてのゲームのすべてのセッションを、フレームとセンサーのデータやメモとともに削除します。ライブラリー、設定、各ゲームのフックへの同意は残ります。元に戻すことはできません。</value>
<comment>review</comment>
</data>
<data name="Settings_DeleteSessions_Button" xml:space="preserve">
<value>すべてのセッションを削除…</value>
<comment>review</comment>
</data>
<data name="Settings_Privacy_Header" xml:space="preserve">
<value>プライバシー</value>
<comment>review</comment>
@@ -2410,7 +2498,7 @@
<comment>review</comment>
</data>
<data name="Maintenance_Sweep_Unlimited" xml:space="preserve">
<value>保持は無制限に設定されています (設定 ▸ キャプチャ)。整理するものはありません。</value>
<value>保持は無制限に設定されています (設定 ▸ 記録)。整理するものはありません。</value>
<comment>review</comment>
</data>
<data name="Maintenance_Sweep_NoAgent" xml:space="preserve">
+73 -7
View File
@@ -312,9 +312,6 @@
<data name="Settings_Language_Label" xml:space="preserve">
<value>Language</value>
</data>
<data name="Settings_Language_Note" xml:space="preserve">
<value>Applies at once; the window is rebuilt in the new language.</value>
</data>
<data name="Settings_Theme_Dark" xml:space="preserve">
<value>Dark</value>
</data>
@@ -741,6 +738,42 @@
<data name="GameDetail_Tab_Sessions" xml:space="preserve">
<value>Sessions</value>
</data>
<data name="GameDetail_DeleteSessions" xml:space="preserve">
<value>Delete all sessions…</value>
</data>
<data name="GameDetail_Overview_Header" xml:space="preserve">
<value>Sessions at a glance</value>
</data>
<data name="GameDetail_Overview_Note" xml:space="preserve">
<value>Each hooked session's frame rate and lows, oldest first. Native and Displayed are drawn where frame generation was measured; a hollow point describes part of its session. Click a point to select its session below.</value>
</data>
<data name="DeleteSessions_GameTitle_Format" xml:space="preserve">
<value>Delete every session of {0}?</value>
</data>
<data name="DeleteSessions_AllTitle" xml:space="preserve">
<value>Delete every session of every game?</value>
</data>
<data name="DeleteSessions_GameBody_Format" xml:space="preserve">
<value>{0} session(s), with their frame and sensor data and their notes, are deleted. The game, its settings and its hooking consent stay. This cannot be undone.</value>
</data>
<data name="DeleteSessions_AllBody_Format" xml:space="preserve">
<value>{0} session(s) of every game, with their frame and sensor data and their notes, are deleted. The library, your settings and every hooking consent stay. This cannot be undone.</value>
</data>
<data name="DeleteSessions_Delete" xml:space="preserve">
<value>Delete sessions</value>
</data>
<data name="DeleteSessions_Done_Format" xml:space="preserve">
<value>Deleted {0} session(s) of {1} game(s).</value>
</data>
<data name="DeleteSessions_Running" xml:space="preserve">
<value>A session is being recorded, so nothing was deleted. Stop it or let it end, then try again.</value>
</data>
<data name="DeleteSessions_NoAgent" xml:space="preserve">
<value>The capture agent is not connected, so nothing was deleted.</value>
</data>
<data name="DeleteSessions_AgentTooOld" xml:space="preserve">
<value>The capture agent does not know this request yet; restart it and try again. Nothing was deleted.</value>
</data>
<data name="GameDetail_Tab_Trend" xml:space="preserve">
<value>Trend</value>
</data>
@@ -1287,6 +1320,30 @@
<data name="Trend_Metric_Label" xml:space="preserve">
<value>Metric</value>
</data>
<data name="Trend_Extras_Label" xml:space="preserve">
<value>Also draw</value>
</data>
<data name="Trend_Extras_Note" xml:space="preserve">
<value>Up to two units at once: a second unit is drawn against the right axis (marked ▸ in the legend).</value>
</data>
<data name="Trend_Unit_Fps" xml:space="preserve">
<value>FPS</value>
</data>
<data name="Trend_Unit_Celsius" xml:space="preserve">
<value>°C</value>
</data>
<data name="Trend_Unit_Percent" xml:space="preserve">
<value>%</value>
</data>
<data name="Trend_Unit_Watts" xml:space="preserve">
<value>W</value>
</data>
<data name="Trend_Unit_Megabytes" xml:space="preserve">
<value>MB</value>
</data>
<data name="Trend_Unit_Factor" xml:space="preserve">
<value>× (frame generation)</value>
</data>
<data name="Trend_Metric_MaxGpuTemp" xml:space="preserve">
<value>Max GPU °C</value>
</data>
@@ -1416,9 +1473,6 @@
<data name="Settings_Channel_Stable" xml:space="preserve">
<value>Stable</value>
</data>
<data name="Settings_HookedGames_Empty" xml:space="preserve">
<value>No game has hooking on.</value>
</data>
<data name="Settings_HookedGames_Label" xml:space="preserve">
<value>Games with hooking on</value>
</data>
@@ -1479,6 +1533,18 @@
<data name="Settings_Policy_Header" xml:space="preserve">
<value>Recording</value>
</data>
<data name="Settings_Data_Header" xml:space="preserve">
<value>Data</value>
</data>
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
<value>Delete all sessions</value>
</data>
<data name="Settings_DeleteSessions_Body" xml:space="preserve">
<value>Every session of every game, with its frame and sensor data and its notes. The library, your settings and each game's hooking consent stay. It cannot be undone.</value>
</data>
<data name="Settings_DeleteSessions_Button" xml:space="preserve">
<value>Delete all sessions…</value>
</data>
<data name="Settings_Privacy_Header" xml:space="preserve">
<value>Privacy</value>
</data>
@@ -1813,7 +1879,7 @@
<value>Sweep…</value>
</data>
<data name="Maintenance_Sweep_Unlimited" xml:space="preserve">
<value>Retention is unlimited (Settings ▸ Capture), so there is nothing to sweep.</value>
<value>Retention is unlimited (Settings ▸ Recording), so there is nothing to sweep.</value>
</data>
<data name="Maintenance_Sweep_NoAgent" xml:space="preserve">
<value>The Agent is not connected. The raw data is the Agent's to remove; start it and try again.</value>
+73 -7
View File
@@ -307,9 +307,6 @@
<data name="Settings_Language_Label" xml:space="preserve">
<value>Ngôn ngữ</value>
</data>
<data name="Settings_Language_Note" xml:space="preserve">
<value>Áp dụng ngay; cửa sổ được dựng lại bằng ngôn ngữ mới.</value>
</data>
<data name="Settings_Theme_Dark" xml:space="preserve">
<value>Tối</value>
</data>
@@ -736,6 +733,42 @@
<data name="GameDetail_Tab_Sessions" xml:space="preserve">
<value>Phiên chơi</value>
</data>
<data name="GameDetail_DeleteSessions" xml:space="preserve">
<value>Xoá mọi phiên…</value>
</data>
<data name="GameDetail_Overview_Header" xml:space="preserve">
<value>Tổng quan các phiên</value>
</data>
<data name="GameDetail_Overview_Note" xml:space="preserve">
<value>Tốc độ khung hình và các mức thấp của mỗi phiên có hook, cũ nhất trước. Native và Displayed được vẽ ở phiên đo được frame generation; điểm rỗng mô tả một phần phiên. Bấm vào một điểm để chọn phiên đó bên dưới.</value>
</data>
<data name="DeleteSessions_GameTitle_Format" xml:space="preserve">
<value>Xoá mọi phiên của {0}?</value>
</data>
<data name="DeleteSessions_AllTitle" xml:space="preserve">
<value>Xoá mọi phiên của mọi game?</value>
</data>
<data name="DeleteSessions_GameBody_Format" xml:space="preserve">
<value>{0} phiên, kèm dữ liệu frame, cảm biến và ghi chú, sẽ bị xoá. Game, cài đặt và consent hooking của nó vẫn giữ nguyên. Không thể hoàn tác.</value>
</data>
<data name="DeleteSessions_AllBody_Format" xml:space="preserve">
<value>{0} phiên của mọi game, kèm dữ liệu frame, cảm biến và ghi chú, sẽ bị xoá. Thư viện, cài đặt và mọi consent hooking vẫn giữ nguyên. Không thể hoàn tác.</value>
</data>
<data name="DeleteSessions_Delete" xml:space="preserve">
<value>Xoá phiên</value>
</data>
<data name="DeleteSessions_Done_Format" xml:space="preserve">
<value>Đã xoá {0} phiên của {1} game.</value>
</data>
<data name="DeleteSessions_Running" xml:space="preserve">
<value>Đang ghi một phiên nên chưa xoá gì. Hãy dừng hoặc chờ phiên kết thúc rồi thử lại.</value>
</data>
<data name="DeleteSessions_NoAgent" xml:space="preserve">
<value>Agent ghi chưa kết nối nên chưa xoá gì.</value>
</data>
<data name="DeleteSessions_AgentTooOld" xml:space="preserve">
<value>Agent ghi chưa hỗ trợ yêu cầu này; hãy khởi động lại rồi thử lại. Chưa xoá gì.</value>
</data>
<data name="GameDetail_Tab_Trend" xml:space="preserve">
<value>Xu hướng</value>
</data>
@@ -1282,6 +1315,30 @@
<data name="Trend_Metric_Label" xml:space="preserve">
<value>Chỉ số</value>
</data>
<data name="Trend_Extras_Label" xml:space="preserve">
<value>Vẽ thêm</value>
</data>
<data name="Trend_Extras_Note" xml:space="preserve">
<value>Tối đa hai đơn vị cùng lúc: đơn vị thứ hai được vẽ theo trục bên phải (đánh dấu ▸ trong chú thích).</value>
</data>
<data name="Trend_Unit_Fps" xml:space="preserve">
<value>FPS</value>
</data>
<data name="Trend_Unit_Celsius" xml:space="preserve">
<value>°C</value>
</data>
<data name="Trend_Unit_Percent" xml:space="preserve">
<value>%</value>
</data>
<data name="Trend_Unit_Watts" xml:space="preserve">
<value>W</value>
</data>
<data name="Trend_Unit_Megabytes" xml:space="preserve">
<value>MB</value>
</data>
<data name="Trend_Unit_Factor" xml:space="preserve">
<value>× (frame generation)</value>
</data>
<data name="Trend_Metric_MaxGpuTemp" xml:space="preserve">
<value>GPU tối đa °C</value>
</data>
@@ -1411,9 +1468,6 @@
<data name="Settings_Channel_Stable" xml:space="preserve">
<value>Ổn định</value>
</data>
<data name="Settings_HookedGames_Empty" xml:space="preserve">
<value>Chưa có game nào bật hooking.</value>
</data>
<data name="Settings_HookedGames_Label" xml:space="preserve">
<value>Game đang bật hooking</value>
</data>
@@ -1474,6 +1528,18 @@
<data name="Settings_Policy_Header" xml:space="preserve">
<value>Ghi phiên</value>
</data>
<data name="Settings_Data_Header" xml:space="preserve">
<value>Dữ liệu</value>
</data>
<data name="Settings_DeleteSessions_Label" xml:space="preserve">
<value>Xoá mọi phiên</value>
</data>
<data name="Settings_DeleteSessions_Body" xml:space="preserve">
<value>Mọi phiên của mọi game, kèm dữ liệu frame, cảm biến và ghi chú. Thư viện, cài đặt và consent hooking của từng game vẫn giữ nguyên. Không thể hoàn tác.</value>
</data>
<data name="Settings_DeleteSessions_Button" xml:space="preserve">
<value>Xoá mọi phiên…</value>
</data>
<data name="Settings_Privacy_Header" xml:space="preserve">
<value>Quyền riêng tư</value>
</data>
@@ -1808,7 +1874,7 @@
<value>Dọn dẹp…</value>
</data>
<data name="Maintenance_Sweep_Unlimited" xml:space="preserve">
<value>Lưu giữ đang là không giới hạn (Cài đặt ▸ Ghi), nên không có gì để dọn.</value>
<value>Lưu giữ đang là không giới hạn (Cài đặt ▸ Ghi phiên), nên không có gì để dọn.</value>
</data>
<data name="Maintenance_Sweep_NoAgent" xml:space="preserve">
<value>Agent chưa kết nối. Dữ liệu thô do Agent xoá; hãy khởi động Agent rồi thử lại.</value>
@@ -43,6 +43,7 @@ public sealed partial class GameDetailViewModel : ObservableObject
private readonly SessionSelection _selection;
private readonly RegisteredSettings? _settings;
private readonly AntiCheatExceptions? _exceptions;
private readonly SessionDeletion? _deletion;
private readonly long? _gameId;
// ui.hide_anticheat_hooking (2026-09-25), read at each load; on until the settings say otherwise, as its default is.
@@ -196,14 +197,19 @@ public sealed partial class GameDetailViewModel : ObservableObject
[ObservableProperty]
private bool _trendEmpty = true;
/// <summary>beta.11 (D39): whether the Sessions tab's overview has anything to draw.</summary>
[ObservableProperty]
private bool _overviewVisible;
[ObservableProperty]
private string _trendExcludedText = string.Empty;
public GameDetailViewModel(GameLibrary library, GameSelection selection, HookingConsent consent, IPageNavigator navigator,
IConfirmations confirmations, IEditGamePrompt edit, IMessageStrip strip, ISessionSummaryOpener summaries,
SessionSeriesLoader loader, IHardwareSnapshotRepository hardware, SessionSelection sessionSelection, IGamePicker picker,
RegisteredSettings? settings = null, IAgentLink? agent = null, AntiCheatExceptions? exceptions = null)
RegisteredSettings? settings = null, IAgentLink? agent = null, AntiCheatExceptions? exceptions = null, SessionDeletion? deletion = null)
{
_deletion = deletion;
_exceptions = exceptions;
_settings = settings;
_agent = agent;
@@ -345,6 +351,28 @@ public sealed partial class GameDetailViewModel : ObservableObject
public IReadOnlyList<TrendPoint> TrendPoints { get; private set; } = [];
/// <summary>
/// beta.11 (D39): what the Trend draws — the selected metric, then every metric ticked beside it. One line alone keeps
/// its own name on the axis, as before; several are labelled by unit, a second unit on the right.
/// </summary>
public IReadOnlyList<TrendLine> TrendLines { get; private set; } = [];
/// <summary>beta.11 (D39): the metrics that can be drawn beside the selected one, ticked by the user.</summary>
public ObservableCollection<TrendMetricOptionViewModel> TrendExtras { get; } = [];
/// <summary>beta.11 (D39): the Sessions tab's overview — every hooked session's rate and lows (<see cref="TrendSeriesBuilder.Overview"/>).</summary>
public IReadOnlyList<TrendLine> OverviewLines { get; private set; } = [];
public static string TrendExtrasLabel => Strings.Trend_Extras_Label;
public static string TrendExtrasNote => Strings.Trend_Extras_Note;
public static string OverviewHeader => Strings.GameDetail_Overview_Header;
public static string OverviewNote => Strings.GameDetail_Overview_Note;
public static string DeleteAllSessionsText => Strings.GameDetail_DeleteSessions;
public IReadOnlyList<HardwareChange> HardwareChanges { get; private set; } = [];
public string TrendMetricText => TrendMetrics.First(c => c.Value == TrendMetric).Label;
@@ -526,12 +554,92 @@ public sealed partial class GameDetailViewModel : ObservableObject
TrendPoints = TrendSeriesBuilder.Points(_detail.Sessions, TrendMetric, IncludeMidSession);
int excluded = IncludeMidSession ? 0 : TrendSeriesBuilder.ExcludedCount(_detail.Sessions, TrendMetric);
TrendExcludedText = excluded > 0 ? string.Format(CultureInfo.CurrentCulture, Strings.Trend_Excluded_Format, excluded) : string.Empty;
TrendEmpty = TrendPoints.Count == 0;
TrendLines = BuildTrendLines();
TrendEmpty = TrendLines.All(static l => l.Points.Count == 0);
TrendEmptyMessage = string.Format(CultureInfo.CurrentCulture, Strings.Trend_Empty_Format, TrendMetricText);
OverviewLines = TrendSeriesBuilder.Overview(_detail.Sessions);
OverviewVisible = OverviewLines.Count > 0;
OnPropertyChanged(nameof(TrendMetricText));
TrendPresented?.Invoke(this, EventArgs.Empty);
}
/// <summary>
/// beta.11 (D39): the selected metric's line, then each ticked metric's — and the options' state: the selected metric
/// is not offered beside itself, and once two units are on the chart a metric in a third cannot be ticked. A metric
/// ticked in a third unit — the selected one changed to a unit neither ticked unit shares — is unticked: the chart
/// draws two units, and a box left ticked would name a line that is not there.
/// </summary>
private List<TrendLine> BuildTrendLines()
{
if (TrendExtras.Count == 0)
{
foreach (Choice<TrendMetric> choice in TrendMetrics)
{
var option = new TrendMetricOptionViewModel(choice.Value, choice.Label, TrendSeriesBuilder.UnitOf(choice.Value));
option.PropertyChanged += OnTrendExtraChanged;
TrendExtras.Add(option);
}
}
_rebuildingExtras = true;
try
{
string primaryUnit = TrendSeriesBuilder.UnitOf(TrendMetric);
string? secondUnit = null;
foreach (TrendMetricOptionViewModel option in TrendExtras.Where(o => o.IsSelected))
{
if (option.Metric == TrendMetric)
{
option.IsSelected = false;
}
else if (!string.Equals(option.Unit, primaryUnit, StringComparison.Ordinal))
{
secondUnit ??= option.Unit;
option.IsSelected = string.Equals(option.Unit, secondUnit, StringComparison.Ordinal);
}
}
TrendMetricOptionViewModel[] ticked = [.. TrendExtras.Where(static o => o.IsSelected)];
HashSet<string> units = [primaryUnit, .. ticked.Select(static o => o.Unit)];
foreach (TrendMetricOptionViewModel option in TrendExtras)
{
option.IsEnabled = option.Metric != TrendMetric && (option.IsSelected || units.Count < 2 || units.Contains(option.Unit));
}
if (ticked.Length == 0)
{
return [new TrendLine(TrendMetricText, TrendMetricText, TrendPoints)];
}
List<TrendLine> lines = [new TrendLine(TrendMetricText, primaryUnit, TrendPoints)];
lines.AddRange(ticked.Select(o => new TrendLine(o.Label, o.Unit, TrendSeriesBuilder.Points(_detail!.Sessions, o.Metric, IncludeMidSession))));
return lines;
}
finally
{
_rebuildingExtras = false;
}
}
private bool _rebuildingExtras;
private void OnTrendExtraChanged(object? sender, System.ComponentModel.PropertyChangedEventArgs e)
{
if (!_rebuildingExtras && string.Equals(e.PropertyName, nameof(TrendMetricOptionViewModel.IsSelected), StringComparison.Ordinal))
{
RebuildTrendPoints();
}
}
/// <summary>beta.11 (D39): a click on the Sessions tab's overview selects that session in the grid.</summary>
public void SelectSession(long sessionId)
{
if (Sessions.FirstOrDefault(s => s.Row.Id == sessionId) is { } session)
{
SelectedSession = session;
}
}
[RelayCommand]
private void Back() => _navigator.Navigate<GamesPage>();
@@ -567,6 +675,10 @@ public sealed partial class GameDetailViewModel : ObservableObject
[RelayCommand]
private Task RemoveAsync() => RunAsync(RemoveCoreAsync);
/// <summary>beta.11 (D40): every session of this game, after the confirmation; the game, its settings and its consent stay.</summary>
[RelayCommand]
private Task DeleteAllSessionsAsync() => RunAsync(DeleteAllSessionsCoreAsync);
[RelayCommand]
private Task ChangeExecutableAsync() => RunAsync(ChangeExecutableCoreAsync);
@@ -694,6 +806,27 @@ public sealed partial class GameDetailViewModel : ObservableObject
await LoadAsync().ConfigureAwait(true);
}
private async Task DeleteAllSessionsCoreAsync()
{
if (Game is null || Sessions.Count == 0 || !await _confirmations.DeleteSessionsAsync(Game.Name, Sessions.Count).ConfigureAwait(true))
{
return;
}
SessionDeletionResult result = _deletion is null
? new(SessionDeletionOutcome.AgentUnavailable)
: await _deletion.DeleteAsync(Game.Id).ConfigureAwait(true);
if (!result.Succeeded)
{
_strip.Warn(Game.Name, result.Message);
return;
}
// SessionDeletion has let go of File ▸ Export's selection and the summary windows of what is gone (ids are reused).
_strip.Success(Game.Name, result.Message);
await LoadAsync().ConfigureAwait(true);
}
private async Task RemoveCoreAsync()
{
if (Game is null)
@@ -37,6 +37,9 @@ public sealed partial class SettingsViewModel : ObservableObject
private readonly IAgentLink _agent;
private readonly IRunAtLogon _runAtLogon;
private readonly IMessageStrip _strip;
private readonly IConfirmations? _confirmations;
private readonly SessionDeletion? _deletion;
private long _sessionTotal;
private readonly IMaintenanceState _maintenance;
private readonly IAgentTool _tool;
private readonly WindowClosePolicy _closePolicy;
@@ -147,8 +150,14 @@ public sealed partial class SettingsViewModel : ObservableObject
IFirstRunFlow firstRun,
AntiCheatExceptions? exceptions = null,
IAgentAdminPrompt? adminPrompt = null,
Func<bool>? agentHeld = null)
Func<bool>? agentHeld = null,
IConfirmations? confirmations = null,
SessionDeletion? deletion = null)
{
// beta.11 (D40): Settings ▸ Data's Delete all sessions — its confirmation and its request; a composition without them
// (a test) deletes nothing.
_confirmations = confirmations;
_deletion = deletion;
// The admin mode's disclosure (a composition without it — a test — cannot turn the mode on), and the probe of the
// data folder's instance lock the restart waits on (a test's own).
_adminPrompt = adminPrompt;
@@ -181,7 +190,6 @@ public sealed partial class SettingsViewModel : ObservableObject
public static string LanguageLabel => Strings.Settings_Language_Label;
public static string LanguageNote => Strings.Settings_Language_Note;
public static IReadOnlyList<Choice<AppTheme>> Themes { get; } =
[
@@ -215,6 +223,9 @@ public sealed partial class SettingsViewModel : ObservableObject
public ObservableCollection<HookedGameViewModel> HookedGames { get; } = [];
/// <summary>beta.11: the "Games with hooking on" card is shown only while it lists a game (a row with no control is not shown).</summary>
public bool HasHookedGames => HookedGames.Count > 0;
/// <summary>
/// D33: the games the user-mode exception concerns — in force, eligible, or held back only by the session count. The rest
/// of the blocked games say why not on their own pages.
@@ -513,6 +524,8 @@ public sealed partial class SettingsViewModel : ObservableObject
}
PresentExceptions(cards);
OnPropertyChanged(nameof(HasHookedGames));
_sessionTotal = cards.Sum(static c => c.Summary?.SessionCount ?? 0);
Shared.Ipc.HelloAck? hello = _agent.Hello;
ElevationText = ElevationTextOf(_agent.State, hello);
@@ -624,6 +637,33 @@ public sealed partial class SettingsViewModel : ObservableObject
[RelayCommand]
private Task RefreshExceptionsAsync() => RefreshAsync();
/// <summary>
/// beta.11 (D40): every session of every game, after the confirmation, through the Agent; the library, the settings and
/// every consent stay.
/// </summary>
[RelayCommand]
private async Task DeleteAllSessionsAsync()
{
if (_confirmations is null || !await _confirmations.DeleteSessionsAsync(null, _sessionTotal).ConfigureAwait(true))
{
return;
}
SessionDeletionResult result = _deletion is null
? new(SessionDeletionOutcome.AgentUnavailable)
: await _deletion.DeleteAsync(null).ConfigureAwait(true);
if (result.Succeeded)
{
_strip.Success(Strings.Settings_DeleteSessions_Label, result.Message);
}
else
{
_strip.Warn(Strings.Settings_DeleteSessions_Label, result.Message);
}
await RefreshCoreAsync().ConfigureAwait(true);
}
private async Task RevokeAsync(HookedGameViewModel game)
{
HookingConsentResult result = await _consent.DisableAsync(game.GameId).ConfigureAwait(true);
@@ -0,0 +1,31 @@
using CommunityToolkit.Mvvm.ComponentModel;
using FrameLedger.App.Charts;
namespace FrameLedger.App.ViewModels;
/// <summary>
/// One metric the Trend can draw beside the selected one (beta.11, owner decision D39: several metrics at once). Disabled
/// when it is the selected metric itself, or when two units are already on the chart and it is in neither.
/// </summary>
public sealed partial class TrendMetricOptionViewModel : ObservableObject
{
[ObservableProperty]
private bool _isSelected;
[ObservableProperty]
private bool _isEnabled = true;
public TrendMetricOptionViewModel(TrendMetric metric, string label, string unit)
{
Metric = metric;
Label = label ?? throw new ArgumentNullException(nameof(label));
Unit = unit ?? throw new ArgumentNullException(nameof(unit));
}
public TrendMetric Metric { get; }
public string Label { get; }
/// <summary>The axis it is drawn against (<see cref="TrendSeriesBuilder.UnitOf"/>).</summary>
public string Unit { get; }
}
@@ -37,6 +37,7 @@ public sealed class AgentCommandHandler
private readonly TimeProvider _clock;
private readonly VkLayerReconciler? _layer;
private readonly Func<CancellationToken, ValueTask<SweepRetentionAck>>? _sweepRetention;
private readonly ISessionRepository? _deleteSessions;
private readonly ExecutableRelocator? _relocator;
private readonly IExecutableArchitectureSource? _architecture;
private readonly AntiCheatExceptionCommands? _exceptions;
@@ -69,8 +70,10 @@ public sealed class AgentCommandHandler
CaptureOrchestrator orchestrator, CapturePause pause, IAgentLifetime lifetime, Func<CancellationToken, ValueTask<string>> updateRules,
string? disclosureVersion = null, TimeProvider? clock = null, VkLayerReconciler? layer = null,
Func<CancellationToken, ValueTask<SweepRetentionAck>>? sweepRetention = null, ExecutableRelocator? relocator = null,
IExecutableArchitectureSource? architecture = null, AntiCheatExceptionCommands? exceptions = null)
IExecutableArchitectureSource? architecture = null, AntiCheatExceptionCommands? exceptions = null, ISessionRepository? deleteSessions = null)
{
// beta.11 (D40): DeleteSessions — composed under --serve over the Agent's own repository; absent, not answered (UnknownType).
_deleteSessions = deleteSessions;
// D33: the user-mode exception's collaborators — its option, its evidence, its disclosure version. Absent, no
// exception applies to SetHookEnabled and SetAntiCheatException is not answered (UnknownType).
_exceptions = exceptions;
@@ -117,10 +120,34 @@ public sealed class AgentCommandHandler
IpcMessageType.SetAntiCheatException when _exceptions is not null => await SetAntiCheatExceptionAsync(request, _exceptions, ct).ConfigureAwait(false),
IpcMessageType.SweepRetention when _sweepRetention is not null =>
IpcCodec.Encode(IpcMessageType.SweepRetentionAck, request.Id, await _sweepRetention(ct).ConfigureAwait(false)),
IpcMessageType.DeleteSessions when _deleteSessions is not null => await DeleteSessionsAsync(request, _deleteSessions, ct).ConfigureAwait(false),
_ => null,
};
}
/// <summary>
/// beta.11 (owner decision D40): every session of one game, or of every game — never while a session it would delete
/// under is being recorded (that session would land after the delete, and a summary the App opened could point at a
/// reused id). The rows are the Agent's (<c>06_DATA_MODEL</c> §Writer ownership), so the Agent deletes them.
/// </summary>
private async ValueTask<byte[]> DeleteSessionsAsync(IpcEnvelope request, ISessionRepository sessions, CancellationToken ct)
{
DeleteSessionsRequest? payload = IpcCodec.Payload<DeleteSessionsRequest>(request);
if (payload is null)
{
return Malformed(request, "DeleteSessions carries no payload");
}
bool running = payload.GameId is { } one ? _orchestrator.IsRecording(one) : _orchestrator.IsRecordingAny();
if (running)
{
return Error(request, IpcErrorCode.SessionRunning, "a session is being recorded; nothing was deleted — stop it or let it end, then try again");
}
RetentionSweepResult deleted = await sessions.DeleteSessionsAsync(payload.GameId, ct).ConfigureAwait(false);
return IpcCodec.Encode(IpcMessageType.DeleteSessionsAck, request.Id, new DeleteSessionsAck(payload.GameId, deleted.Games, deleted.Sessions));
}
/// <summary>
/// Identity only (<c>07_IPC</c>: "carries no hooking state"): every entry's row is ensured, hooking off when new.
/// Nothing is removed — removing a game is the App's FR-1.4 (with its "keep the sessions?" question), never a
@@ -59,6 +59,13 @@ public interface ISessionRepository
/// </summary>
ValueTask<RetentionSweepResult> SweepRetentionAllAsync(int keep, CancellationToken ct = default);
/// <summary>
/// beta.11 (owner decision D40): delete every session of <paramref name="gameId"/>, or of every game when it is null, in
/// one transaction — segments, frame and sensor series and annotations cascade with them (schema 0001's foreign keys).
/// Nothing about the games, their consent or the settings is touched. The Agent's to call (§Writer ownership).
/// </summary>
ValueTask<RetentionSweepResult> DeleteSessionsAsync(long? gameId, CancellationToken ct = default);
ValueTask<FrameBlobs?> FindFramesAsync(long sessionId, CancellationToken ct = default);
/// <summary>The session's segments in frame order (the ribbon, <c>08_UI</c> §Session summary).</summary>
@@ -104,6 +104,15 @@ public sealed class CaptureOrchestrator
}
}
/// <summary>Whether any session started here is still running — what deleting every session waits for (beta.11).</summary>
public bool IsRecordingAny()
{
lock (_table)
{
return _running.Values.Any(static r => !r.Task.IsCompleted);
}
}
/// <summary>Poll until cancelled, then wait for every running session to finalize.</summary>
public async Task RunAsync(CancellationToken ct)
{
@@ -217,6 +217,20 @@ public sealed class SqliteSessionRepository : ISessionRepository
}, ct);
}
/// <summary>
/// beta.11 (D40): one transaction — count what goes, then delete; <c>PRAGMA foreign_keys = ON</c> (LedgerDatabase) lets
/// segments, frame and sensor series and annotations go with their sessions.
/// </summary>
public ValueTask<RetentionSweepResult> DeleteSessionsAsync(long? gameId, CancellationToken ct = default) =>
_db.WriteAsync(async (c, tx, token) =>
{
const string scope = "FROM sessions WHERE (@gameId IS NULL OR game_id = @gameId)";
long games = await c.ExecuteScalarAsync<long>(new CommandDefinition("SELECT COUNT(DISTINCT game_id) " + scope, new { gameId }, tx,
cancellationToken: token)).ConfigureAwait(false);
int sessions = await c.ExecuteAsync(new CommandDefinition("DELETE " + scope, new { gameId }, tx, cancellationToken: token)).ConfigureAwait(false);
return new RetentionSweepResult(checked((int)games), sessions);
}, ct);
public ValueTask<FrameBlobs?> FindFramesAsync(long sessionId, CancellationToken ct = default) =>
_db.ReadAsync((c, token) => SqliteReaders.ReadOneAsync(
c, new CommandDefinition(_selectFrames, new { sessionId }, cancellationToken: token), ReadFrames), ct);
@@ -52,6 +52,8 @@ namespace FrameLedger.Shared.Ipc;
[JsonSerializable(typeof(ShutdownAck))]
[JsonSerializable(typeof(SweepRetentionRequest))]
[JsonSerializable(typeof(SweepRetentionAck))]
[JsonSerializable(typeof(DeleteSessionsRequest))]
[JsonSerializable(typeof(DeleteSessionsAck))]
public sealed partial class IpcJsonContext : JsonSerializerContext
{
}
+20
View File
@@ -57,6 +57,13 @@ public static class IpcMessageType
public const string SweepRetention = "SweepRetention";
public const string SweepRetentionAck = "SweepRetentionAck";
/// <summary>
/// beta.11 (owner decision D40): delete every session of one game, or of every game — the Agent's rows (§Writer
/// ownership), deleted by the Agent, refused while a session it would delete under is still being recorded.
/// </summary>
public const string DeleteSessions = "DeleteSessions";
public const string DeleteSessionsAck = "DeleteSessionsAck";
public const string SessionStarted = "SessionStarted";
public const string SessionProgress = "SessionProgress";
@@ -96,6 +103,9 @@ public static class IpcErrorCode
/// <summary>D33: <c>SetAntiCheatException true</c> while <c>hooking.usermode_ac_exceptions</c> is off — nothing is granted.</summary>
public const string ExceptionsOff = "ExceptionsOff";
/// <summary>beta.11: <c>DeleteSessions</c> while a session of that game (or of any game, for all) is being recorded — nothing is deleted.</summary>
public const string SessionRunning = "SessionRunning";
}
/// <summary>Codes a <see cref="CaptureErrorEvent"/> carries (<c>07_IPC</c> §Messages, <c>CaptureError</c>).</summary>
@@ -362,3 +372,13 @@ public sealed record SweepRetentionRequest;
/// series were removed. Aggregates and segments are never touched.
/// </summary>
public sealed record SweepRetentionAck(int Keep, int Games, int Sessions);
/// <summary>
/// <c>DeleteSessions</c> (beta.11, D40): every session of <see cref="GameId"/>, or of every game when it is null — with
/// their segments, frame and sensor series and annotations (they cascade). The library, the settings and every consent
/// stay. Refused with <c>Error SessionRunning</c> while such a session is being recorded.
/// </summary>
public sealed record DeleteSessionsRequest(long? GameId);
/// <summary>What was deleted: the sessions, and how many games they belonged to.</summary>
public sealed record DeleteSessionsAck(long? GameId, int Games, int Sessions);
@@ -66,9 +66,17 @@ public sealed class GameDetailViewModelTests
public void GoBack() => Pages.Add("back");
}
private sealed class FakeConfirmations(RemoveGameChoice choice) : IConfirmations
private sealed class FakeConfirmations(RemoveGameChoice choice, bool deleteSessions = false) : IConfirmations
{
public List<(string? Game, long Sessions)> DeleteAsked { get; } = [];
public Task<RemoveGameChoice> RemoveGameAsync(string gameName, CancellationToken ct = default) => Task.FromResult(choice);
public Task<bool> DeleteSessionsAsync(string? gameName, long sessions, CancellationToken ct = default)
{
DeleteAsked.Add((gameName, sessions));
return Task.FromResult(deleteSessions);
}
}
private sealed class FakeEdit(GameMetadata? answer) : IEditGamePrompt
@@ -72,6 +72,8 @@ public sealed class PagesLoadTests
private sealed class NoConfirm : IConfirmations
{
public Task<bool> DeleteSessionsAsync(string? gameName, long sessions, CancellationToken ct = default) => Task.FromResult(false);
public Task<RemoveGameChoice> RemoveGameAsync(string gameName, CancellationToken ct = default) => Task.FromResult(RemoveGameChoice.Cancel);
}
@@ -0,0 +1,273 @@
using FluentAssertions;
using FrameLedger.App.Charts;
using FrameLedger.App.Services;
using FrameLedger.App.ViewModels;
using FrameLedger.Application.Persistence;
using FrameLedger.Infrastructure.Ipc;
using FrameLedger.Shared.Ipc;
namespace FrameLedger.App.Tests;
/// <summary>
/// beta.11: Delete all sessions (owner decision D40) through the Agent, from the game page; and the charts across a game's
/// sessions (D39) — the Sessions tab's overview, and the Trend's second metric and second unit.
/// </summary>
[Collection(StringsCultureCollection.Name)]
public sealed class SessionDeletionAndOverviewTests
{
private static CancellationToken Ct => TestContext.Current.CancellationToken;
/// <summary>An Agent that answers DeleteSessions as scripted, and records what it was asked.</summary>
private sealed class ScriptedAgent : IAgentRequests
{
public HelloAck? Hello => null;
public bool IsConnected { get; set; } = true;
public List<DeleteSessionsRequest> Asked { get; } = [];
public Func<DeleteSessionsRequest, Task<IpcEnvelope>> Answer { get; set; } = static r =>
Task.FromResult(IpcCodec.Decode(IpcCodec.Encode(IpcMessageType.DeleteSessionsAck, "1", new DeleteSessionsAck(r.GameId, 1, 2))));
public Task<IpcEnvelope> RequestAsync<TRequest>(string type, TRequest payload, CancellationToken ct = default)
where TRequest : class
{
type.Should().Be(IpcMessageType.DeleteSessions);
var request = (DeleteSessionsRequest)(object)payload;
Asked.Add(request);
return Answer(request);
}
}
private sealed class Confirm(bool yes) : IConfirmations
{
public List<(string? Game, long Sessions)> Asked { get; } = [];
public Task<RemoveGameChoice> RemoveGameAsync(string gameName, CancellationToken ct = default) => Task.FromResult(RemoveGameChoice.Cancel);
public Task<bool> DeleteSessionsAsync(string? gameName, long sessions, CancellationToken ct = default)
{
Asked.Add((gameName, sessions));
return Task.FromResult(yes);
}
}
private sealed class Strip : IMessageStrip
{
public List<string> Lines { get; } = [];
public void Info(string title, string body) => Lines.Add("info:" + body);
public void Success(string title, string body) => Lines.Add("success:" + body);
public void Warn(string title, string body) => Lines.Add("warn:" + body);
}
private sealed class Nav : IPageNavigator
{
public void Navigate<TPage>()
where TPage : class
{
}
public void GoBack()
{
}
}
private sealed class NoEdit : IEditGamePrompt
{
public Task<GameMetadata?> EditAsync(GameMetadata current, string? provenanceJson, CancellationToken ct = default) => Task.FromResult<GameMetadata?>(null);
}
private sealed class NoSummaries : ISessionSummaryOpener
{
public void Open(long sessionId)
{
}
}
private sealed class NoPicker : IGamePicker
{
public string? PickExecutable() => null;
}
/// <summary>The summary windows, counting how often they were asked to close the deleted sessions' ones.</summary>
private sealed class Windows : ISessionWindows
{
public int Asked { get; private set; }
public Task CloseDeletedAsync(CancellationToken ct = default)
{
Asked++;
return Task.CompletedTask;
}
}
/// <summary>The scripted Agent deletes for real, as the Agent's repository would.</summary>
private static Func<DeleteSessionsRequest, Task<IpcEnvelope>> DeletesFrom(ScratchLedger s) => async r =>
{
RetentionSweepResult gone = await s.Sessions.DeleteSessionsAsync(r.GameId, Ct).ConfigureAwait(false);
return IpcCodec.Decode(IpcCodec.Encode(IpcMessageType.DeleteSessionsAck, "1", new DeleteSessionsAck(r.GameId, gone.Games, gone.Sessions)));
};
private sealed class NoPrompt : IConsentPrompt
{
public Task<bool> ShowAsync(string gameName, CancellationToken ct = default) => Task.FromResult(false);
}
private static async Task<GameDetailViewModel> PageAsync(ScratchLedger s, long gameId, IConfirmations confirm, SessionDeletion? deletion, IMessageStrip strip,
SessionSelection? selection = null)
{
var vm = new GameDetailViewModel(s.Library, new GameSelection { GameId = gameId }, new HookingConsent(new ScriptedAgent(), new NoPrompt()), new Nav(),
confirm, new NoEdit(), strip, new NoSummaries(), new SessionSeriesLoader(s.Sessions),
new Infrastructure.Persistence.SqliteHardwareSnapshotRepository(s.Db), selection ?? new SessionSelection(), new NoPicker(), deletion: deletion);
Task pending = vm.Pending;
await pending.ConfigureAwait(false);
return vm;
}
[Fact]
public async Task TheRequestSaysWhatTheAgentDidOrWhyNothingWasDeleted()
{
var agent = new ScriptedAgent();
var deletion = new SessionDeletion(agent);
SessionDeletionResult done = await deletion.DeleteAsync(7, Ct);
done.Should().Be(new SessionDeletionResult(SessionDeletionOutcome.Deleted, 1, 2));
done.Message.Should().Contain("2");
agent.Asked.Should().Equal(new DeleteSessionsRequest(7));
agent.Answer = static _ => throw new IpcRequestException(IpcErrorCode.SessionRunning, "running");
(await deletion.DeleteAsync(null, Ct)).Outcome.Should().Be(SessionDeletionOutcome.SessionRunning);
agent.Answer = static _ => throw new IpcRequestException(IpcErrorCode.UnknownType, "older agent");
(await deletion.DeleteAsync(null, Ct)).Outcome.Should().Be(SessionDeletionOutcome.AgentTooOld);
agent.IsConnected = false;
(await deletion.DeleteAsync(null, Ct)).Outcome.Should().Be(SessionDeletionOutcome.AgentUnavailable);
agent.Asked.Should().HaveCount(3, "nothing is asked of an Agent that is not there");
}
/// <summary>
/// The game page asks first and deletes nothing on a no; on a yes the Agent deletes, the page says so, reloads empty, and
/// File ▸ Export no longer points at a session that is gone.
/// </summary>
[Fact]
public async Task TheGamePageAsksThenTheAgentDeletesAndThePageReloads()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow game = await s.GameAsync("Alpha");
long first = await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-2));
await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddHours(-1));
var strip = new Strip();
var agent = new ScriptedAgent();
GameDetailViewModel no = await PageAsync(s, game.Id, new Confirm(false), new SessionDeletion(agent), strip);
await no.DeleteAllSessionsCommand.ExecuteAsync(null);
agent.Asked.Should().BeEmpty("a no deletes nothing");
no.Sessions.Should().HaveCount(2);
agent.Answer = DeletesFrom(s);
var confirm = new Confirm(true);
var selection = new SessionSelection();
selection.Set(first);
GameDetailViewModel yes = await PageAsync(s, game.Id, confirm, new SessionDeletion(agent, s.Sessions, selection), strip, selection);
await yes.DeleteAllSessionsCommand.ExecuteAsync(null);
confirm.Asked.Should().Equal(("Alpha", 2L));
agent.Asked.Should().Equal(new DeleteSessionsRequest(game.Id));
yes.Sessions.Should().BeEmpty();
yes.SessionsEmpty.Should().BeTrue();
strip.Lines.Should().ContainSingle(static l => l.StartsWith("success:", StringComparison.Ordinal));
selection.SessionId.Should().BeNull("an id that is gone can be reused by the next session");
}
/// <summary>
/// After a delete — from the game page or from Settings — SessionDeletion lets go of what still names a deleted session:
/// File ▸ Export's selection (a session that is still there stays selected) and the summary windows. A refused delete
/// touches neither.
/// </summary>
[Fact]
public async Task AfterADeleteWhatNamedADeletedSessionLetsGoOfIt()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow alpha = await s.GameAsync("Alpha");
GameRow beta = await s.GameAsync("Beta");
long gone = await s.SessionAsync(alpha.Id, DateTimeOffset.UtcNow.AddHours(-2));
long kept = await s.SessionAsync(beta.Id, DateTimeOffset.UtcNow.AddHours(-1));
var agent = new ScriptedAgent { Answer = DeletesFrom(s) };
var selection = new SessionSelection();
var windows = new Windows();
var deletion = new SessionDeletion(agent, s.Sessions, selection, windows);
selection.Set(gone);
(await deletion.DeleteAsync(alpha.Id, Ct)).Outcome.Should().Be(SessionDeletionOutcome.Deleted);
selection.SessionId.Should().BeNull("Export would otherwise name a session that is gone, or the next one to take its id");
windows.Asked.Should().Be(1, "the summary windows close the deleted sessions' ones");
selection.Set(kept);
(await deletion.DeleteAsync(alpha.Id, Ct)).Outcome.Should().Be(SessionDeletionOutcome.Deleted);
selection.SessionId.Should().Be(kept, "the other game's session is still there");
windows.Asked.Should().Be(2);
agent.Answer = static _ => throw new IpcRequestException(IpcErrorCode.SessionRunning, "running");
(await deletion.DeleteAsync(null, Ct)).Outcome.Should().Be(SessionDeletionOutcome.SessionRunning);
selection.SessionId.Should().Be(kept, "nothing was deleted");
windows.Asked.Should().Be(2, "nothing was deleted");
}
/// <summary>
/// D39: the overview draws every hooked session's rate and lows; the Trend draws a ticked metric beside the selected
/// one, a second unit on the right, and offers no third unit.
/// </summary>
[Fact]
public async Task TheOverviewAndTheTrendDrawSeveralMetricsTwoUnitsAtMost()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow game = await s.GameAsync("Alpha");
await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddDays(-2), native: 60);
await s.SessionAsync(game.Id, DateTimeOffset.UtcNow.AddDays(-1), native: 70);
GameDetailViewModel vm = await PageAsync(s, game.Id, new Confirm(false), null, new Strip());
vm.OverviewVisible.Should().BeTrue();
vm.OverviewLines.Should().NotBeEmpty().And.OnlyContain(static l => l.Unit == Strings.Trend_Unit_Fps && l.Points.Count == 2);
vm.OverviewLines.Select(static l => l.Label).Should().NotContain(Strings.Trend_Metric_NativeFps,
"no session generated frames, so Native would only repeat the Presented line");
vm.TrendLines.Should().ContainSingle("only the selected metric until another is ticked");
TrendMetricOptionViewModel selected = vm.TrendExtras.Single(o => o.Metric == vm.TrendMetric);
selected.IsEnabled.Should().BeFalse("the selected metric is not offered beside itself");
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.MaxGpuTemp).IsSelected = true;
vm.TrendLines.Should().HaveCount(2);
vm.TrendLines[1].Unit.Should().Be(Strings.Trend_Unit_Celsius);
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.AvgGpuPower).IsEnabled.Should().BeFalse("watts would be a third unit");
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.P1Low).IsEnabled.Should().BeTrue("a frame rate is the first unit");
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.MaxCpuTemp).IsEnabled.Should().BeTrue("°C is already on the chart");
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.MaxGpuTemp).IsSelected = false;
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.AvgGpuPower).IsEnabled.Should().BeTrue("back to one unit");
// °C and a frame rate ticked, then the selected metric changed to watts: one of the two ticked units goes, so the
// boxes name exactly the lines the chart draws.
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.MaxGpuTemp).IsSelected = true;
vm.TrendExtras.Single(static o => o.Metric == TrendMetric.P1Low).IsSelected = true;
vm.TrendLines.Select(static l => l.Unit).Distinct(StringComparer.Ordinal).Should().HaveCount(2);
vm.TrendMetric = TrendMetric.AvgGpuPower;
vm.TrendLines.Select(static l => l.Unit).Distinct(StringComparer.Ordinal).Should().HaveCount(2, "the chart draws two units");
vm.TrendLines[0].Unit.Should().Be(TrendSeriesBuilder.UnitOf(TrendMetric.AvgGpuPower));
vm.TrendExtras.Count(static o => o.IsSelected).Should().Be(vm.TrendLines.Count - 1, "every ticked box has its line");
}
[Theory]
[InlineData(TrendMetric.PresentedFps, "FPS")]
[InlineData(TrendMetric.P01Low, "FPS")]
[InlineData(TrendMetric.MaxGpuTemp, "°C")]
[InlineData(TrendMetric.AvgGpuLoad, "%")]
[InlineData(TrendMetric.DisplayBorderlessShare, "%")]
[InlineData(TrendMetric.AvgGpuPower, "W")]
[InlineData(TrendMetric.AvgRam, "MB")]
public void EachMetricHasItsUnit(TrendMetric metric, string unit) => TrendSeriesBuilder.UnitOf(metric).Should().StartWith(unit);
}
@@ -128,7 +128,7 @@ public sealed class SettingsViewModelTests
}
private static async Task<Harness> OpenAsync(ScratchLedger s, FakeAgentLink? agent = null, FakeRun? run = null, FakeMaintenance? maintenance = null, FakeTool? tool = null,
IAgentAdminPrompt? adminPrompt = null)
IAgentAdminPrompt? adminPrompt = null, IConfirmations? confirmations = null, SessionDeletion? deletion = null)
{
maintenance ??= new FakeMaintenance();
tool ??= new FakeTool();
@@ -144,12 +144,71 @@ public sealed class SettingsViewModelTests
var shell = new ShellHost(new ServiceCollection().BuildServiceProvider(), null!, null!, closePolicy);
// The instance-lock probe is the test's (never the real folder's): no Agent holds it, so a restart never waits.
var vm = new SettingsViewModel(appearance, new NoTheme(), shell, settings, s.Library, new HookingConsent(agent, new NoPrompt()), agent, run, strip, maintenance, tool, closePolicy, firstRun,
adminPrompt: adminPrompt, agentHeld: static () => false);
adminPrompt: adminPrompt, agentHeld: static () => false, confirmations: confirmations, deletion: deletion);
Task pending = vm.Pending;
await pending.ConfigureAwait(false);
return new Harness { Ledger = s, Settings = settings, Agent = agent, Run = run, Strip = strip, Vm = vm, Maintenance = maintenance, Tool = tool, ClosePolicy = closePolicy, FirstRun = firstRun };
}
/// <summary>beta.11 (D40): Settings ▸ Data asks with the total, deletes nothing on a no, and deletes every game's through the Agent on a yes.</summary>
[Fact]
public async Task DeleteAllSessionsAsksWithTheTotalThenGoesThroughTheAgent()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow alpha = await s.GameAsync("Alpha");
GameRow bravo = await s.GameAsync("Bravo");
await s.SessionAsync(alpha.Id, DateTimeOffset.UtcNow.AddHours(-2));
await s.SessionAsync(bravo.Id, DateTimeOffset.UtcNow.AddHours(-1));
var confirm = new DeleteConfirm();
var agent = new DeletingAgent(s);
Harness h = await OpenAsync(s, confirmations: confirm, deletion: new SessionDeletion(agent));
await h.Vm.DeleteAllSessionsCommand.ExecuteAsync(null);
confirm.Asked.Should().Equal(((string?)null, 2L));
agent.Asked.Should().BeEmpty("a no deletes nothing");
confirm.Answer = true;
await h.Vm.DeleteAllSessionsCommand.ExecuteAsync(null);
agent.Asked.Should().Equal(new DeleteSessionsRequest(null));
(await s.Sessions.SummariseByGameAsync(Ct)).Should().BeEmpty();
(await s.Games.ListAsync(Ct)).Should().HaveCount(2, "the library stays");
h.Vm.HasHookedGames.Should().BeFalse("no game has hooking on, so that card is not shown");
}
private sealed class DeleteConfirm : IConfirmations
{
public bool Answer { get; set; }
public List<(string? Game, long Sessions)> Asked { get; } = [];
public Task<RemoveGameChoice> RemoveGameAsync(string gameName, CancellationToken ct = default) => Task.FromResult(RemoveGameChoice.Cancel);
public Task<bool> DeleteSessionsAsync(string? gameName, long sessions, CancellationToken ct = default)
{
Asked.Add((gameName, sessions));
return Task.FromResult(Answer);
}
}
/// <summary>An Agent that deletes in the scratch ledger as the real one does in its own.</summary>
private sealed class DeletingAgent(ScratchLedger s) : IAgentRequests
{
public HelloAck? Hello => null;
public bool IsConnected => true;
public List<DeleteSessionsRequest> Asked { get; } = [];
public async Task<IpcEnvelope> RequestAsync<TRequest>(string type, TRequest payload, CancellationToken ct = default)
where TRequest : class
{
var request = (DeleteSessionsRequest)(object)payload;
Asked.Add(request);
RetentionSweepResult gone = await s.Sessions.DeleteSessionsAsync(request.GameId, ct).ConfigureAwait(false);
return IpcCodec.Decode(IpcCodec.Encode(IpcMessageType.DeleteSessionsAck, "1", new DeleteSessionsAck(request.GameId, gone.Games, gone.Sessions)));
}
}
[Fact]
public async Task LoadsTheRegistrysEffectiveValuesAndWritesNothing()
{
@@ -183,7 +183,7 @@ public sealed class AgentCommandHandlerTests : IAsyncDisposable
var handler = new AgentCommandHandler(games, consent, guard, identity, orchestrator, pause, lifetime,
_ => { h.RulesUpdates++; return ValueTask.FromResult("AlreadyCurrent"); },
disclosureVersion, new FakeClock(), sweepRetention: sweep, architecture: architecture,
exceptions: exceptions ? new AntiCheatExceptionCommands(option, _exceptionDisclosure) : null);
exceptions: exceptions ? new AntiCheatExceptionCommands(option, _exceptionDisclosure) : null, deleteSessions: sessions);
h = new Harness
{
Handler = handler,
@@ -438,6 +438,47 @@ public sealed class AgentCommandHandlerTests : IAsyncDisposable
payload.Reason.Should().NotBeNullOrEmpty();
}
/// <summary>
/// beta.11 (owner decision D40): DeleteSessions deletes the Agent's own rows — one game's, or every game's — and answers
/// the counts; a request with no payload is malformed; and nothing runs here, so nothing is refused for a recording.
/// </summary>
[Fact]
public async Task DeleteSessionsDeletesTheAgentsRowsAndAnswersTheCounts()
{
Harness h = await BuildAsync().ConfigureAwait(true);
long game = h.Games.Rows[_exe].Id;
foreach (long owner in new[] { game, game, game + 1 })
{
h.Sessions.Stored.Add(new FinalizedSession
{
Row = new SessionRow
{
SessionGuid = Guid.NewGuid(),
GameId = owner,
SnapshotId = 1,
StartedAt = DateTimeOffset.UnixEpoch,
EndedAt = DateTimeOffset.UnixEpoch.AddMinutes(1),
QpcEpoch = 0,
QpcFrequency = 1,
Tier = Domain.Sessions.CaptureTier.Hooked,
Mode = Domain.Sessions.CaptureMode.Attach,
ExitStatus = Domain.Sessions.ExitStatus.Normal,
}
});
}
IpcEnvelope one = await AskAsync(h.Handler, IpcMessageType.DeleteSessions, new DeleteSessionsRequest(game)).ConfigureAwait(true);
IpcCodec.Payload<DeleteSessionsAck>(one).Should().Be(new DeleteSessionsAck(game, 1, 2));
h.Sessions.Stored.Should().ContainSingle().Which.Row.GameId.Should().Be(game + 1);
IpcEnvelope all = await AskAsync(h.Handler, IpcMessageType.DeleteSessions, new DeleteSessionsRequest(null)).ConfigureAwait(true);
IpcCodec.Payload<DeleteSessionsAck>(all).Should().Be(new DeleteSessionsAck(null, 1, 1));
h.Sessions.Stored.Should().BeEmpty();
IpcEnvelope malformed = await AskAsync(h.Handler, IpcMessageType.DeleteSessions).ConfigureAwait(true);
IpcCodec.Payload<ErrorAck>(malformed)!.Code.Should().Be(IpcErrorCode.Malformed);
}
[Fact]
public async Task LaunchGameIsTheOrchestratorsAnswer()
{
@@ -91,6 +91,19 @@ internal sealed class FakeSessionRepository : ISessionRepository
public ValueTask<long> CountSinceAsync(DateTimeOffset since, CancellationToken ct = default) =>
ValueTask.FromResult((long)Stored.Count(s => s.Row.StartedAt >= since));
/// <summary>beta.11 (D40): every session of the game, or of every game, leaves the store.</summary>
public ValueTask<RetentionSweepResult> DeleteSessionsAsync(long? gameId, CancellationToken ct = default)
{
List<FinalizedSession> gone = [.. Stored.Where(s => gameId is null || s.Row.GameId == gameId)];
int games = gone.Select(static s => s.Row.GameId).Distinct().Count();
foreach (FinalizedSession session in gone)
{
Stored.Remove(session);
}
return ValueTask.FromResult(new RetentionSweepResult(games, gone.Count));
}
/// <summary>D38: each game's successful sessions under its grant in force, as the tests say; a game not named has none.</summary>
public Dictionary<long, int> SuccessfulUnderGrant { get; } = [];
@@ -432,6 +432,7 @@ public sealed class CaptureOrchestratorTests
recorder.Requests.Should().ContainSingle("one session per executable, whatever id its entry has now");
o.IsRecording(original.Id).Should().BeTrue();
o.IsRecordingAny().Should().BeTrue("beta.11: what deleting every session waits for");
log.Should().Contain(l => l.Contains("one at a time", StringComparison.Ordinal));
}
@@ -394,6 +394,45 @@ public sealed class SqliteSessionRepositoryTests
accepted.AcceptedAt.Should().Be(DateTimeOffset.FromUnixTimeMilliseconds(1_700_000_000_000));
}
/// <summary>
/// beta.11 (owner decision D40): Delete all sessions — one game's, then every game's — takes their segments, frame and
/// sensor series with them (they cascade), leaves the other game's sessions until asked, and never a games row.
/// </summary>
[Fact]
public async Task DeletingSessionsTakesTheirSeriesAndLeavesTheGames()
{
await using LedgerFixture f = await LedgerFixture.OpenAsync();
(long gameId, long snapshotId) = await SeedAsync(f);
long other = (await new SqliteGameRepository(f.Db).EnsureAsync(new() { ExePath = @"C:\Games\Other\other.exe", SizeBytes = 1, MtimeUnixMs = 1 }, "O", Ct)).Id;
var repo = new SqliteSessionRepository(f.Db);
foreach (long owner in new[] { gameId, gameId, other })
{
await repo.InsertFinalizedAsync(new FinalizedSession
{
Row = Row(owner, snapshotId),
Segments = [new SegmentRow { SwapchainId = 1, StartFrame = 0, EndFrame = 9 }],
Frames = Frames(10),
Sensors = [new SensorBlob { Series = "gpu_temp", Hz = 1, Codec = SeriesCodec.Tag, Data = SeriesCodec.EncodeFloat32([60f]) }],
}, Ct);
}
(await repo.DeleteSessionsAsync(gameId, Ct)).Should().Be(new RetentionSweepResult(1, 2));
(await repo.ListByGameAsync(gameId, 10, Ct)).Should().BeEmpty();
(await repo.ListByGameAsync(other, 10, Ct)).Should().ContainSingle("only the game asked for");
(await CountAsync(f, "frame_blobs")).Should().Be(1, "the series went with their sessions");
(await CountAsync(f, "sensor_blobs")).Should().Be(1);
(await CountAsync(f, "session_segments")).Should().Be(1);
(await repo.DeleteSessionsAsync(null, Ct)).Should().Be(new RetentionSweepResult(1, 1));
(await CountAsync(f, "sessions")).Should().Be(0);
(await CountAsync(f, "frame_blobs")).Should().Be(0);
(await CountAsync(f, "games")).Should().Be(2, "the library stays");
(await repo.DeleteSessionsAsync(null, Ct)).Should().Be(new RetentionSweepResult(0, 0));
}
private static Task<long> CountAsync(LedgerFixture f, string table) =>
f.Db.ReadAsync((c, ct) => c.ExecuteScalarAsync<long>(new CommandDefinition("SELECT COUNT(*) FROM " + table, cancellationToken: ct)), Ct).AsTask();
/// <summary>
/// D38 (owner decision 2026-10-03): a grant's trial counts its own sessions — hooked under that family, from the grant on,
/// frames recorded, <c>normal</c> — and nothing else: a crash, a safety unhook, a degraded or Tier-2 session, one that