Compare commits

...
Author SHA1 Message Date
poli0981andClaude Opus 5 351c30895e feat(app): the bug report's last optional item, the last session's summary when ticked
10_LOGGING's bug report step 2 listed "last session metadata + aggregates JSON (never raw blobs by default)" beside
the crash dump, and the privacy policy promises both only when ticked. The Optional items dialog now shows a
checkbox for each item that exists: the crash dump, and the newest session in the ledger (LastSessionSummary),
labelled with its game and start time. Ticked, the zip gains session.json, File > Export's own JSON (metadata,
aggregates, segments, hardware) without the user's notes and tags, passed through LogRedactor because it names the
executable. No frame or sensor series. With neither item there is no question.

CrashDumpChoice became BugBundleOptions, and IBugReportPreview.AskCrashDumpAsync became AskOptionsAsync with a
BugBundleOffer. Two strings in en/vi/ja.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-15 21:23:05 +07:00
24 changed files with 359 additions and 98 deletions

No files matched your search

+10
View File
@@ -21,6 +21,16 @@ under a `## [x.y.z] - date` heading in the same commit that bumps `VERSION`, the
### Added
- **The bug report's last optional item: the last session's summary, when ticked (2026-09-15).** `10_LOGGING` §Bug
report flow step 2 listed "last session metadata + aggregates JSON (never raw blobs by default)" beside the crash
dump, and `legal/PRIVACY_POLICY.md` §3 promises both only when ticked. The Optional items dialog PR-9 added now shows
a box for each item that exists: the crash dump, and the newest session in the ledger (`LastSessionSummary`) labelled
with its game and start time. Ticked, the zip gains `session.json`, File ▸ Export's own JSON (metadata, aggregates,
segments, hardware) without the user's notes and tags, passed through `LogRedactor` because it names the executable;
no frame or sensor series. With neither item there is no question. `CrashDumpChoice` became `BugBundleOptions`, and
`IBugReportPreview.AskCrashDumpAsync` became `AskOptionsAsync(BugBundleOffer)`. Two strings (en/vi/ja). Tests:
`LastSessionSummaryTests`, `BugReportFlowTests`, `BugBundleOptionsViewModelTests`, `PagesLoadTests`. Docs:
`10_LOGGING` §Bug report flow step 2.
- **P4 PR-9 — the crash dialog, the minidump in both processes, and the crash dump as the bug report's opt-in
(2026-09-15).** `10_LOGGING` §Crash handling specified Fatal → `MiniDumpWriteDump` → a dialog offering the bug report
→ exit code 1; only the Fatal line existed, and `Crash_Title` / `Crash_Body` were translated for a dialog nothing
+16 -5
View File
@@ -91,7 +91,7 @@ Tails the active files (shared read), level filter, text search, pause autoscrol
> summary as Markdown** puts `sysinfo.json`'s twelve keys on the clipboard as a table. Both behind ports
> (`IBugReportPreview`, `IUrlOpener`, `IClipboard`) so `BugReportFlowTests` pins the exact URL without a browser.
> ~~Still open from this list: the **crash dialog and the minidump** (§Crash handling, step 1's third entry point)
> and the optional session-metadata / dump checkboxes of step 2.~~ PR-9 below; the session-metadata checkbox is open.
> and the optional session-metadata / dump checkboxes of step 2.~~ PR-9 below, and the session-metadata checkbox after it (2026-09-15).
>
> **The log copies are redacted since 2026-09-15.** `App/Services/LogRedactor` is what the list's "redacted copies"
> and `legal/PRIVACY_POLICY.md` §3 promised: in every `logs/` and `overlay/` entry the name in each
@@ -114,10 +114,21 @@ Tails the active files (shared read), level filter, text search, pause autoscrol
> settings. Continue with the box clear writes the bundle without it; ticked, `crashdumps/<name>.dmp` goes in;
> Cancel writes nothing. `WriteAsync` refuses a dump from anywhere but that directory, before the zip is created. It
> is a dialog before the save rather than a box on step 3's preview because the preview lists a zip that is already
> written. The crash dialog (§Crash handling) is step 1's third entry point. Still open: the session-metadata
> checkbox. Tests: `BugBundleBuilderTests` (only when passed, only from the directory, the newest of the week),
> `BugReportFlowTests` (no dump no question; left clear, ticked, cancelled), `BugBundleOptionsViewModelTests`,
> `PagesLoadTests`.
> written. The crash dialog (§Crash handling) is step 1's third entry point. ~~Still open: the session-metadata
> checkbox.~~ Built the same day, below. Tests: `BugBundleBuilderTests` (only when passed, only from the directory,
> the newest of the week), `BugReportFlowTests` (no dump no question; left clear, ticked, cancelled),
> `BugBundleOptionsViewModelTests`, `PagesLoadTests`.
>
> **The last session's checkbox built 2026-09-15**, which completes this list's optional items. The same **Optional
> items** dialog carries a second box when the ledger holds a session: the newest one (`App/Services/LastSessionSummary`),
> labelled with its game and local start time, with a line saying what the file holds. Ticked, the bundle gains
> `session.json`: File ▸ Export's own JSON (`SessionExporter.Document` — metadata, aggregates, segments, hardware)
> **without the user's notes and tags**, and passed through `LogRedactor` like a log because it names the executable.
> No frame or sensor series, which is the list's "never raw blobs". The dialog now appears when either item exists and
> not at all when neither does; the port's answer is `BugBundleOptions` (closed, or which boxes were ticked) where
> PR-9's was `CrashDumpChoice`. Tests: `LastSessionSummaryTests` (the newest session, no notes or tags, nothing for an
> empty ledger), `BugReportFlowTests` (left clear, and ticked with a profile path redacted in the zip),
> `BugBundleOptionsViewModelTests` (every box clear, an absent item cannot be included), `PagesLoadTests`.
3. **Preview step:** the dialog lists every file included and lets the user open the zip before continuing. Nothing is ever sent automatically.
4. "Open GitHub issue" → launches browser to
`https://github.com/poli0981/frameledger/issues/new?template=bug_report.yml&title=[Bug]%20&labels=bug&app_version=…&os=…`
+1
View File
@@ -287,6 +287,7 @@ public partial class App : System.Windows.Application
services.AddSingleton<IUrlOpener, ShellUrlOpener>();
services.AddSingleton<IClipboard, WpfClipboard>();
services.AddSingleton<IBugReportPreview, BugReportPreviewPrompt>();
services.AddSingleton<LastSessionSummary>();
services.AddSingleton<BugReportFlow>();
services.AddSingleton<SessionSelection>();
services.AddSingleton<SessionExportService>();
@@ -9,13 +9,19 @@
mc:Ignorable="d"
MinWidth="480">
<!--
10_LOGGING §Bug report flow step 2's optional item (P4 PR-9): the crash dump goes in only when it is ticked
(legal/PRIVACY_POLICY.md §3). The box starts clear, and its label and the line under it say how large the dump is
and what it can hold before anyone ticks it.
10_LOGGING §Bug report flow step 2's optional items: the crash dump (P4 PR-9) and the last session's summary each go
in only when ticked (legal/PRIVACY_POLICY.md §3). Only the items there are get a box; every box starts clear, and
the line under it says what the item holds before anyone ticks it.
-->
<StackPanel>
<ui:TextBlock TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.Intro}" />
<CheckBox Margin="0,12,0,0" IsChecked="{Binding IncludeCrashDump}" Content="{Binding DumpLabel}" />
<ui:TextBlock Margin="28,4,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.DumpDetail}" />
<StackPanel Visibility="{Binding HasCrashDump, Converter={StaticResource BoolToVis}}">
<CheckBox Margin="0,12,0,0" IsChecked="{Binding IncludeCrashDump}" Content="{Binding DumpLabel}" />
<ui:TextBlock Margin="28,4,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.DumpDetail}" />
</StackPanel>
<StackPanel Visibility="{Binding HasLastSession, Converter={StaticResource BoolToVis}}">
<CheckBox Margin="0,12,0,0" IsChecked="{Binding IncludeLastSession}" Content="{Binding SessionLabel}" />
<ui:TextBlock Margin="28,4,0,0" Appearance="Secondary" TextWrapping="Wrap" Text="{x:Static vm:BugBundleOptionsViewModel.SessionDetail}" />
</StackPanel>
</StackPanel>
</UserControl>
@@ -63,9 +63,10 @@ public sealed class BugBundleBuilder
/// <summary>
/// Writes the zip at <paramref name="path"/>; returns the entry names written. <paramref name="crashDump"/> goes in only
/// when the caller passes one, which is the user's tick (P4 PR-9), and only from the crash dump directory.
/// when the caller passes one, which is the user's tick (P4 PR-9), and only from the crash dump directory;
/// <paramref name="lastSessionJson"/> likewise, as <c>session.json</c> with the user names in its paths replaced.
/// </summary>
public async Task<IReadOnlyList<string>> WriteAsync(string path, HelloAck? agent, CrashDumpInfo? crashDump = null, CancellationToken ct = default)
public async Task<IReadOnlyList<string>> WriteAsync(string path, HelloAck? agent, CrashDumpInfo? crashDump = null, byte[]? lastSessionJson = null, CancellationToken ct = default)
{
ArgumentException.ThrowIfNullOrWhiteSpace(path);
if (crashDump is not null && !IsOurDump(crashDump.Path))
@@ -96,6 +97,12 @@ public sealed class BugBundleBuilder
AddFile(zip, crashDump.Path, "crashdumps/" + Path.GetFileName(crashDump.Path), written);
}
// The other optional item: the last session's summary the user ticked, redacted like a log (it names the executable).
if (lastSessionJson is not null)
{
AddBytes(zip, "session.json", _redactor.Redact(lastSessionJson), written);
}
AddText(zip, "sysinfo.json", SysInfo(agent), written);
AddText(zip, "settings.json", await SettingsJsonAsync(ct).ConfigureAwait(false), written);
return written;
@@ -137,10 +144,14 @@ public sealed class BugBundleBuilder
bytes = buffer.ToArray();
}
byte[] redacted = _redactor.Redact(bytes);
AddBytes(zip, entryName, _redactor.Redact(bytes), written);
}
private static void AddBytes(ZipArchive zip, string entryName, byte[] bytes, List<string> written)
{
ZipArchiveEntry entry = zip.CreateEntry(entryName, CompressionLevel.Optimal);
using Stream target = entry.Open();
target.Write(redacted, 0, redacted.Length);
target.Write(bytes, 0, bytes.Length);
written.Add(entryName);
}
@@ -0,0 +1,11 @@
namespace FrameLedger.App.Services;
/// <summary>
/// The optional items a bug report can offer (<c>10_LOGGING</c> §Bug report flow step 2), each null when there is none:
/// the newest crash dump of the last seven days (P4 PR-9) and the last session's summary.
/// </summary>
public sealed record BugBundleOffer(CrashDumpInfo? CrashDump, LastSessionInfo? LastSession)
{
/// <summary>Nothing to offer, so no question is asked.</summary>
public bool IsEmpty => CrashDump is null && LastSession is null;
}
@@ -0,0 +1,14 @@
namespace FrameLedger.App.Services;
/// <summary>
/// The answer to the optional items (<c>legal/PRIVACY_POLICY.md</c> §3: included only when ticked): the dialog closed, or
/// which boxes were ticked. Every box starts clear.
/// </summary>
public sealed record BugBundleOptions(bool Cancelled, bool IncludeCrashDump, bool IncludeLastSession)
{
/// <summary>The dialog was closed: no bundle is written.</summary>
public static BugBundleOptions Cancel { get; } = new(Cancelled: true, IncludeCrashDump: false, IncludeLastSession: false);
/// <summary>Continue with every box clear, and what an empty offer means.</summary>
public static BugBundleOptions NothingTicked { get; } = new(Cancelled: false, IncludeCrashDump: false, IncludeLastSession: false);
}
+24 -12
View File
@@ -7,7 +7,7 @@ namespace FrameLedger.App.Services;
/// <summary>
/// <c>10_LOGGING</c> §Bug report flow, steps 2–4 in one place (P4 PR-3), reached from Help ▸ Report a bug, the Logs
/// page's button and the crash dialog (P4 PR-9): a recent crash dump offered as a checkbox that starts clear, the zip
/// page's button and the crash dialog (P4 PR-9): a recent crash dump and the last session offered as checkboxes that start clear, the zip
/// where the user says (step 2, <see cref="BugBundleBuilder"/>), the preview listing every entry (step 3), then either
/// the GitHub issue form with the two short fields prefilled or the environment summary on the clipboard as Markdown
/// (step 4). Nothing is ever sent automatically; the zip is dragged in by hand.
@@ -23,8 +23,9 @@ public sealed class BugReportFlow
private readonly IClipboard _clipboard;
private readonly IMessageStrip _strip;
private readonly TimeProvider _clock;
private readonly LastSessionSummary? _lastSession;
public BugReportFlow(BugBundleBuilder bundles, IFileSaver saver, IAgentRequests agent, IBugReportPreview preview, IUrlOpener urls, IClipboard clipboard, IMessageStrip strip, TimeProvider? clock = null)
public BugReportFlow(BugBundleBuilder bundles, IFileSaver saver, IAgentRequests agent, IBugReportPreview preview, IUrlOpener urls, IClipboard clipboard, IMessageStrip strip, TimeProvider? clock = null, LastSessionSummary? lastSession = null)
{
_bundles = bundles ?? throw new ArgumentNullException(nameof(bundles));
_saver = saver ?? throw new ArgumentNullException(nameof(saver));
@@ -34,13 +35,14 @@ public sealed class BugReportFlow
_clipboard = clipboard ?? throw new ArgumentNullException(nameof(clipboard));
_strip = strip ?? throw new ArgumentNullException(nameof(strip));
_clock = clock ?? TimeProvider.System;
_lastSession = lastSession;
}
/// <summary>The whole flow; the outcome says how far it went, for the tests and the caller's log.</summary>
public async Task<BugReportOutcome> RunAsync(CancellationToken ct = default)
{
DateTimeOffset now = _clock.GetUtcNow();
(bool cancelled, CrashDumpInfo? dump) = await ChooseCrashDumpAsync(ct).ConfigureAwait(true);
(bool cancelled, CrashDumpInfo? dump, byte[]? sessionJson) = await ChooseOptionalItemsAsync(ct).ConfigureAwait(true);
if (cancelled)
{
return new BugReportOutcome(null, BugReportChoice.Close, Written: false);
@@ -56,7 +58,7 @@ public sealed class BugReportFlow
IReadOnlyList<string> entries;
try
{
entries = await _bundles.WriteAsync(path, hello, dump, ct).ConfigureAwait(true);
entries = await _bundles.WriteAsync(path, hello, dump, sessionJson, ct).ConfigureAwait(true);
}
catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
{
@@ -91,18 +93,28 @@ public sealed class BugReportFlow
}
/// <summary>
/// Step 2's optional item (P4 PR-9): a crash dump of the last seven days is offered before the save dialog, in a
/// checkbox that starts clear. No dump, no question; the dump comes back only when it was ticked.
/// Step 2's optional items, offered before the save dialog, each in a checkbox that starts clear: a crash dump of the
/// last seven days (P4 PR-9) and the last session's summary. Nothing to offer, no question; an item comes back only
/// when it was ticked.
/// </summary>
private async Task<(bool Cancelled, CrashDumpInfo? Dump)> ChooseCrashDumpAsync(CancellationToken ct)
private async Task<(bool Cancelled, CrashDumpInfo? Dump, byte[]? SessionJson)> ChooseOptionalItemsAsync(CancellationToken ct)
{
CrashDumpInfo? dump = _bundles.LatestCrashDump();
if (dump is null)
LastSessionInfo? session = _lastSession is null ? null : await _lastSession.FindAsync(ct).ConfigureAwait(true);
var offer = new BugBundleOffer(_bundles.LatestCrashDump(), session);
if (offer.IsEmpty)
{
return (false, null);
return (false, null, null);
}
CrashDumpChoice answer = await _preview.AskCrashDumpAsync(dump, ct).ConfigureAwait(true);
return (answer == CrashDumpChoice.Cancel, answer == CrashDumpChoice.Include ? dump : null);
BugBundleOptions options = await _preview.AskOptionsAsync(offer, ct).ConfigureAwait(true);
if (options.Cancelled)
{
return (true, null, null);
}
byte[]? json = options.IncludeLastSession && session is not null && _lastSession is not null
? await _lastSession.JsonAsync(session.SessionId, ct).ConfigureAwait(true)
: null;
return (false, options.IncludeCrashDump ? offer.CrashDump : null, json);
}
}
@@ -7,7 +7,7 @@ namespace FrameLedger.App.Services;
/// <summary>
/// The bug report's dialogs in WPF UI: step 3's <c>ContentDialog</c> listing the zip's entries, whose primary button is
/// step 4 and whose secondary is the clipboard fallback; and step 2's optional crash dump, a checkbox (P4 PR-9).
/// step 4 and whose secondary is the clipboard fallback; and step 2's optional items, a checkbox each.
/// </summary>
public sealed class BugReportPreviewPrompt : IBugReportPreview
{
@@ -38,10 +38,10 @@ public sealed class BugReportPreviewPrompt : IBugReportPreview
};
}
public async Task<CrashDumpChoice> AskCrashDumpAsync(CrashDumpInfo dump, CancellationToken ct = default)
public async Task<BugBundleOptions> AskOptionsAsync(BugBundleOffer offer, CancellationToken ct = default)
{
ArgumentNullException.ThrowIfNull(dump);
var viewModel = new BugBundleOptionsViewModel(dump);
ArgumentNullException.ThrowIfNull(offer);
var viewModel = new BugBundleOptionsViewModel(offer);
var dialog = new ContentDialog
{
Title = BugBundleOptionsViewModel.Title,
@@ -53,6 +53,6 @@ public sealed class BugReportPreviewPrompt : IBugReportPreview
};
ContentDialogResult result = await _dialogs.ShowAsync(dialog, ct).ConfigureAwait(true);
return viewModel.Choice(result == ContentDialogResult.Primary);
return viewModel.Options(result == ContentDialogResult.Primary);
}
}
@@ -1,14 +0,0 @@
namespace FrameLedger.App.Services;
/// <summary>The answer to the bug report's optional crash dump (P4 PR-9, <c>10_LOGGING</c> §Bug report flow step 2).</summary>
public enum CrashDumpChoice
{
/// <summary>The dialog was closed: no bundle is written.</summary>
Cancel,
/// <summary>Continue without the dump: the checkbox was left clear, which is how it starts.</summary>
LeaveOut,
/// <summary>Continue with the dump: the user ticked it.</summary>
Include,
}
@@ -7,8 +7,8 @@ public interface IBugReportPreview
Task<BugReportChoice> ShowAsync(BugReportPreviewModel model, CancellationToken ct = default);
/// <summary>
/// Step 2's optional item (P4 PR-9): the crash dump's checkbox, clear until the user ticks it
/// (<c>legal/PRIVACY_POLICY.md</c> §3). Closing the dialog is <see cref="CrashDumpChoice.Cancel"/>.
/// Step 2's optional items: a checkbox for each item <paramref name="offer"/> has, clear until the user ticks it
/// (<c>legal/PRIVACY_POLICY.md</c> §3). Closing the dialog is <see cref="BugBundleOptions.Cancel"/>.
/// </summary>
Task<CrashDumpChoice> AskCrashDumpAsync(CrashDumpInfo dump, CancellationToken ct = default);
Task<BugBundleOptions> AskOptionsAsync(BugBundleOffer offer, CancellationToken ct = default);
}
@@ -0,0 +1,4 @@
namespace FrameLedger.App.Services;
/// <summary>The newest session in the ledger, as the bug report offers it: which one, of what, and when.</summary>
public sealed record LastSessionInfo(long SessionId, string Game, DateTimeOffset StartedAt);
@@ -0,0 +1,56 @@
using System.IO;
using FrameLedger.Application.Persistence;
using FrameLedger.Domain.Sessions;
namespace FrameLedger.App.Services;
/// <summary>
/// Step 2's other optional item, "last session metadata + aggregates JSON (never raw blobs by default)"
/// (<c>10_LOGGING</c> §Bug report flow): the newest session in the ledger, written as the same <c>session.json</c> File ▸
/// Export writes (<see cref="SessionExporter.Document"/>: metadata, aggregates, segments, hardware) but without the
/// user's notes and tags, which are theirs and are not a diagnosis. No frame or sensor series.
/// </summary>
public sealed class LastSessionSummary
{
private readonly ISessionRepository _sessions;
private readonly IGameRepository _games;
private readonly IHardwareSnapshotRepository _hardware;
public LastSessionSummary(ISessionRepository sessions, IGameRepository games, IHardwareSnapshotRepository hardware)
{
_sessions = sessions ?? throw new ArgumentNullException(nameof(sessions));
_games = games ?? throw new ArgumentNullException(nameof(games));
_hardware = hardware ?? throw new ArgumentNullException(nameof(hardware));
}
/// <summary>The newest session and its game, or null when the ledger has none.</summary>
public async Task<LastSessionInfo?> FindAsync(CancellationToken ct = default)
{
IReadOnlyList<SessionRow> recent = await _sessions.ListRecentAsync(1, ct).ConfigureAwait(false);
if (recent.Count == 0)
{
return null;
}
SessionRow row = recent[0];
GameRow? game = await _games.FindByIdAsync(row.GameId, ct).ConfigureAwait(false);
return game is null ? null : new LastSessionInfo(row.Id, game.Name, row.StartedAt);
}
/// <summary>The session's <c>session.json</c> bytes without notes or tags, or null when it is gone.</summary>
public async Task<byte[]?> JsonAsync(long sessionId, CancellationToken ct = default)
{
SessionRow? row = await _sessions.FindByIdAsync(sessionId, ct).ConfigureAwait(false);
GameRow? game = row is null ? null : await _games.FindByIdAsync(row.GameId, ct).ConfigureAwait(false);
if (row is null || game is null)
{
return null;
}
IReadOnlyList<SegmentRow> segments = await _sessions.FindSegmentsAsync(sessionId, ct).ConfigureAwait(false);
HardwareSnapshot? snapshot = await _hardware.FindAsync(row.SnapshotId, ct).ConfigureAwait(false);
using var buffer = new MemoryStream();
SessionExporter.WriteJson(buffer, SessionExporter.Document(row, game, snapshot, segments, annotation: null));
return buffer.ToArray();
}
}
+6
View File
@@ -56,6 +56,8 @@ public static class Strings
nameof(BugReport_Options_Dump_Detail),
nameof(BugReport_Options_Dump_Format),
nameof(BugReport_Options_Intro),
nameof(BugReport_Options_Session_Detail),
nameof(BugReport_Options_Session_Format),
nameof(BugReport_Options_Title),
nameof(BugReport_Preview_Drag),
nameof(BugReport_Preview_Intro_Format),
@@ -642,6 +644,10 @@ public static class Strings
public static string BugReport_Options_Intro => ResourceManager.GetString(nameof(BugReport_Options_Intro), Culture) ?? nameof(BugReport_Options_Intro);
public static string BugReport_Options_Session_Detail => ResourceManager.GetString(nameof(BugReport_Options_Session_Detail), Culture) ?? nameof(BugReport_Options_Session_Detail);
public static string BugReport_Options_Session_Format => ResourceManager.GetString(nameof(BugReport_Options_Session_Format), Culture) ?? nameof(BugReport_Options_Session_Format);
public static string BugReport_Options_Title => ResourceManager.GetString(nameof(BugReport_Options_Title), Culture) ?? nameof(BugReport_Options_Title);
public static string BugReport_Preview_Drag => ResourceManager.GetString(nameof(BugReport_Preview_Drag), Culture) ?? nameof(BugReport_Preview_Drag);
+8
View File
@@ -2233,6 +2233,14 @@
<value>クラッシュ時の FrameLedger 自身のメモリのスナップショットです。原因の特定に役立ちますが、この PC のファイルパス、ゲーム名、設定が含まれる場合があります。</value>
<comment>review</comment>
</data>
<data name="BugReport_Options_Session_Format" xml:space="preserve">
<value>直近のセッション: {0}、{1}</value>
<comment>review</comment>
</data>
<data name="BugReport_Options_Session_Detail" xml:space="preserve">
<value>session.json: ゲームの名前と実行ファイルのパス、キャプチャ方法、設定と統計、この PC の CPU と GPU。フレームごとのデータ、メモやタグは含まれません。パス内のユーザー名は置き換えられます。</value>
<comment>review</comment>
</data>
<data name="BugReport_Options_Continue" xml:space="preserve">
<value>続行</value>
<comment>review</comment>
+6
View File
@@ -1682,6 +1682,12 @@ Open the bug report now? It shows you every file in the zip, sends nothing by it
<data name="BugReport_Options_Dump_Detail" xml:space="preserve">
<value>A snapshot of FrameLedger's own memory when it crashed. It helps find the cause, and it can contain file paths, game names and settings from this PC.</value>
</data>
<data name="BugReport_Options_Session_Format" xml:space="preserve">
<value>The last session: {0}, {1}</value>
</data>
<data name="BugReport_Options_Session_Detail" xml:space="preserve">
<value>session.json: the game's name and executable path, how it was captured, its settings and statistics, and this PC's CPU and GPU. No frame data, and not your notes or tags. User names in paths are replaced.</value>
</data>
<data name="BugReport_Options_Continue" xml:space="preserve">
<value>Continue</value>
</data>
+6
View File
@@ -1677,6 +1677,12 @@ Mở báo cáo lỗi ngay bây giờ? Báo cáo cho bạn xem mọi tệp trong
<data name="BugReport_Options_Dump_Detail" xml:space="preserve">
<value>Ảnh chụp bộ nhớ của chính FrameLedger lúc bị lỗi. Nó giúp tìm nguyên nhân, và có thể chứa đường dẫn tệp, tên game và cài đặt trên máy này.</value>
</data>
<data name="BugReport_Options_Session_Format" xml:space="preserve">
<value>Phiên gần nhất: {0}, {1}</value>
</data>
<data name="BugReport_Options_Session_Detail" xml:space="preserve">
<value>session.json: tên game và đường dẫn tệp chạy, cách ghi, các thiết lập và thống kê, cùng CPU và GPU của máy này. Không có dữ liệu từng khung hình, không có ghi chú hay thẻ của bạn. Tên người dùng trong đường dẫn được thay thế.</value>
</data>
<data name="BugReport_Options_Continue" xml:space="preserve">
<value>Tiếp tục</value>
</data>
@@ -6,24 +6,41 @@ using FrameLedger.App.Services;
namespace FrameLedger.App.ViewModels;
/// <summary>
/// The bug report's optional crash dump (P4 PR-9, <c>10_LOGGING</c> §Bug report flow step 2): one checkbox, clear until the
/// user ticks it (<c>legal/PRIVACY_POLICY.md</c> §3), labelled with the dump's time and size, and a line saying what a
/// dump can hold.
/// The bug report's optional items (<c>10_LOGGING</c> §Bug report flow step 2): a checkbox for each item there is — the
/// crash dump (P4 PR-9) and the last session's summary — each clear until the user ticks it
/// (<c>legal/PRIVACY_POLICY.md</c> §3), each with a line saying what it holds.
/// </summary>
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format string is a resource that follows the UI culture, which changes at runtime")]
[SuppressMessage("Performance", "CA1863:Use 'CompositeFormat'", Justification = "the format strings are resources that follow the UI culture, which changes at runtime")]
public sealed partial class BugBundleOptionsViewModel : ObservableObject
{
[ObservableProperty]
private bool _includeCrashDump;
public BugBundleOptionsViewModel(CrashDumpInfo dump)
[ObservableProperty]
private bool _includeLastSession;
public BugBundleOptionsViewModel(BugBundleOffer offer)
{
ArgumentNullException.ThrowIfNull(dump);
DumpLabel = string.Format(
CultureInfo.CurrentCulture,
Strings.BugReport_Options_Dump_Format,
dump.WrittenAt.ToLocalTime().ToString("g", CultureInfo.CurrentCulture),
dump.Bytes / (1024.0 * 1024.0));
ArgumentNullException.ThrowIfNull(offer);
HasCrashDump = offer.CrashDump is not null;
HasLastSession = offer.LastSession is not null;
if (offer.CrashDump is { } dump)
{
DumpLabel = string.Format(
CultureInfo.CurrentCulture,
Strings.BugReport_Options_Dump_Format,
dump.WrittenAt.ToLocalTime().ToString("g", CultureInfo.CurrentCulture),
dump.Bytes / (1024.0 * 1024.0));
}
if (offer.LastSession is { } session)
{
SessionLabel = string.Format(
CultureInfo.CurrentCulture,
Strings.BugReport_Options_Session_Format,
session.Game,
session.StartedAt.ToLocalTime().ToString("g", CultureInfo.CurrentCulture));
}
}
public static string Title => Strings.BugReport_Options_Title;
@@ -32,17 +49,20 @@ public sealed partial class BugBundleOptionsViewModel : ObservableObject
public static string DumpDetail => Strings.BugReport_Options_Dump_Detail;
/// <summary>The checkbox's text: the dump's local time and its size in MB.</summary>
public string DumpLabel { get; }
public static string SessionDetail => Strings.BugReport_Options_Session_Detail;
public bool HasCrashDump { get; }
public bool HasLastSession { get; }
/// <summary>The crash dump's checkbox text: its local time and size in MB; empty when there is no dump.</summary>
public string DumpLabel { get; } = string.Empty;
/// <summary>The last session's checkbox text: the game and the local start time; empty when there is no session.</summary>
public string SessionLabel { get; } = string.Empty;
/// <summary>The answer, once the dialog closed: <paramref name="continued"/> is its primary button.</summary>
public CrashDumpChoice Choice(bool continued)
{
if (!continued)
{
return CrashDumpChoice.Cancel;
}
return IncludeCrashDump ? CrashDumpChoice.Include : CrashDumpChoice.LeaveOut;
}
public BugBundleOptions Options(bool continued) => continued
? new BugBundleOptions(Cancelled: false, IncludeCrashDump: HasCrashDump && IncludeCrashDump, IncludeLastSession: HasLastSession && IncludeLastSession)
: BugBundleOptions.Cancel;
}
@@ -122,13 +122,13 @@ public sealed class BugBundleBuilderTests : IDisposable
latest.Bytes.Should().Be(3000);
IReadOnlyList<string> without = await builder.WriteAsync(Path.Combine(_dir, "without.zip"), agent: null, ct: Ct);
IReadOnlyList<string> with = await builder.WriteAsync(Path.Combine(_dir, "with.zip"), agent: null, latest, Ct);
IReadOnlyList<string> with = await builder.WriteAsync(Path.Combine(_dir, "with.zip"), agent: null, latest, ct: Ct);
without.Should().NotContain(static e => e.StartsWith("crashdumps/", StringComparison.Ordinal), "a dump goes in only when the user ticked it");
with.Should().Contain("crashdumps/ui-20260915-100000-42.dmp");
string foreign = Path.Combine(_dir, "game.dmp");
await File.WriteAllTextAsync(foreign, "MDMP", Ct);
Func<Task> outside = () => builder.WriteAsync(Path.Combine(_dir, "foreign.zip"), agent: null, latest with { Path = foreign }, Ct);
Func<Task> outside = () => builder.WriteAsync(Path.Combine(_dir, "foreign.zip"), agent: null, latest with { Path = foreign }, ct: Ct);
await outside.Should().ThrowAsync<ArgumentException>("the bundle never carries a file from outside the dump directory");
File.Exists(Path.Combine(_dir, "foreign.zip")).Should().BeFalse("refused before the zip is created");
}
@@ -6,22 +6,42 @@ using FrameLedger.App.ViewModels;
namespace FrameLedger.App.Tests;
/// <summary>
/// The bug report's optional crash dump (P4 PR-9): the box starts clear (<c>legal/PRIVACY_POLICY.md</c> §3, only when
/// ticked), closing the dialog never includes it, and the label carries the dump's size.
/// The bug report's optional items: every box starts clear (<c>legal/PRIVACY_POLICY.md</c> §3, only when ticked), only an
/// item that exists can be included, closing the dialog includes nothing, and each label says what and how big.
/// </summary>
public sealed class BugBundleOptionsViewModelTests
{
private static readonly CrashDumpInfo _dump = new(@"C:\data\crashdumps\ui-1.dmp", new DateTimeOffset(2026, 9, 15, 1, 2, 3, TimeSpan.Zero), 1536 * 1024);
private static readonly LastSessionInfo _session = new(42, "Title", new DateTimeOffset(2026, 9, 15, 3, 4, 5, TimeSpan.Zero));
[Fact]
public void TheBoxStartsClearAndOnlyATickAndContinueIncludesTheDump()
public void EveryBoxStartsClearAndOnlyATickAndContinueIncludesAnItem()
{
var vm = new BugBundleOptionsViewModel(new CrashDumpInfo(@"C:\data\crashdumps\ui-1.dmp", new DateTimeOffset(2026, 9, 15, 1, 2, 3, TimeSpan.Zero), 1536 * 1024));
var vm = new BugBundleOptionsViewModel(new BugBundleOffer(_dump, _session));
vm.IncludeCrashDump.Should().BeFalse();
vm.Choice(continued: true).Should().Be(CrashDumpChoice.LeaveOut);
vm.Choice(continued: false).Should().Be(CrashDumpChoice.Cancel);
vm.IncludeLastSession.Should().BeFalse();
vm.Options(continued: true).Should().Be(BugBundleOptions.NothingTicked);
vm.Options(continued: false).Should().Be(BugBundleOptions.Cancel);
vm.IncludeCrashDump = true;
vm.Choice(continued: true).Should().Be(CrashDumpChoice.Include);
vm.Choice(continued: false).Should().Be(CrashDumpChoice.Cancel, "closing the dialog never includes the dump");
vm.Options(continued: true).Should().Be(new BugBundleOptions(Cancelled: false, IncludeCrashDump: true, IncludeLastSession: false));
vm.IncludeLastSession = true;
vm.Options(continued: true).Should().Be(new BugBundleOptions(Cancelled: false, IncludeCrashDump: true, IncludeLastSession: true));
vm.Options(continued: false).Should().Be(BugBundleOptions.Cancel, "closing the dialog never includes anything");
vm.DumpLabel.Should().Contain(string.Format(CultureInfo.CurrentCulture, "{0:0.0}", 1.5), "the size is in the label, in MB");
vm.SessionLabel.Should().Contain("Title");
}
[Fact]
public void AnItemThereIsNoneOfHasNoBoxAndCannotBeIncluded()
{
var vm = new BugBundleOptionsViewModel(new BugBundleOffer(CrashDump: null, _session));
vm.HasCrashDump.Should().BeFalse();
vm.HasLastSession.Should().BeTrue();
vm.DumpLabel.Should().BeEmpty();
vm.IncludeCrashDump = true;
vm.Options(continued: true).IncludeCrashDump.Should().BeFalse("there is no dump to include");
new BugBundleOffer(null, null).IsEmpty.Should().BeTrue();
}
}
@@ -2,6 +2,7 @@ using System.IO;
using System.IO.Compression;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.Application.Persistence;
using FrameLedger.Application.Settings;
using FrameLedger.Infrastructure.Persistence;
using FrameLedger.Shared.Ipc;
@@ -41,17 +42,18 @@ public sealed class BugReportFlowTests : IDisposable
private sealed record Harness(BugReportFlow Flow, ClosePreview Preview, NoUrlOpener Urls, NoClipboard Clipboard, RecordingStrip Strip, string Zip);
private async Task<Harness> BuildAsync(ScratchLedger s, BugReportChoice choice, bool cancel = false, CrashDumpChoice dumpChoice = CrashDumpChoice.LeaveOut)
private async Task<Harness> BuildAsync(ScratchLedger s, BugReportChoice choice, bool cancel = false, BugBundleOptions? options = null)
{
await File.WriteAllTextAsync(Path.Combine(_dir, "ui-20260914.log"), "[12:00:00.000 INF] hello\n", Ct).ConfigureAwait(false);
var builder = new BugBundleBuilder(_dir, new RegisteredSettings(new SqliteSettingsStore(s.Db)), crashDumpDirectory: Path.Combine(_dir, "crashdumps"));
string zip = Path.Combine(_dir, "bundle.zip");
var preview = new ClosePreview(choice, dumpChoice);
var preview = new ClosePreview(choice, options);
var urls = new NoUrlOpener();
var clipboard = new NoClipboard();
var strip = new RecordingStrip();
var agent = new FakeAgentLink { Hello = new HelloAck("9.9.9", IpcProtocol.Version, 4, false, "build-z", false, "l1", false, "consent-dialog/1") };
return new Harness(new BugReportFlow(builder, new PathSaver(cancel ? null : zip), agent, preview, urls, clipboard, strip), preview, urls, clipboard, strip, zip);
var lastSession = new LastSessionSummary(s.Sessions, s.Games, new SqliteHardwareSnapshotRepository(s.Db));
return new Harness(new BugReportFlow(builder, new PathSaver(cancel ? null : zip), agent, preview, urls, clipboard, strip, lastSession: lastSession), preview, urls, clipboard, strip, zip);
}
[Fact]
@@ -77,22 +79,22 @@ public sealed class BugReportFlowTests : IDisposable
.And.Contain("&os=Windows%20", "the form's field ids are app-version and os, hyphenated");
h.Clipboard.Texts.Should().BeEmpty();
h.Strip.Shown.Should().BeEmpty("the browser opened; there is nothing to say");
h.Preview.DumpsOffered.Should().BeEmpty("no crash dump, no question");
h.Preview.Offers.Should().BeEmpty("no crash dump and no session: no question");
}
[Theory]
[InlineData(CrashDumpChoice.LeaveOut, false)]
[InlineData(CrashDumpChoice.Include, true)]
public async Task ARecentCrashDumpIsOfferedAndGoesInOnlyWhenTicked(CrashDumpChoice answer, bool included)
[InlineData(false)]
[InlineData(true)]
public async Task ARecentCrashDumpIsOfferedAndGoesInOnlyWhenTicked(bool included)
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
string dump = WriteDump();
Harness h = await BuildAsync(s, BugReportChoice.Close, dumpChoice: answer);
Harness h = await BuildAsync(s, BugReportChoice.Close, options: new BugBundleOptions(Cancelled: false, IncludeCrashDump: included, IncludeLastSession: false));
BugReportOutcome o = await h.Flow.RunAsync(Ct);
o.Written.Should().BeTrue();
h.Preview.DumpsOffered.Should().ContainSingle().Which.Path.Should().Be(dump);
h.Preview.Offers.Should().ContainSingle().Which.CrashDump!.Path.Should().Be(dump);
IReadOnlyList<string> entries = h.Preview.Shown.Should().ContainSingle().Subject.Entries;
string entry = "crashdumps/" + Path.GetFileName(dump);
if (included)
@@ -110,7 +112,7 @@ public sealed class BugReportFlowTests : IDisposable
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
WriteDump();
Harness h = await BuildAsync(s, BugReportChoice.OpenIssue, dumpChoice: CrashDumpChoice.Cancel);
Harness h = await BuildAsync(s, BugReportChoice.OpenIssue, options: BugBundleOptions.Cancel);
BugReportOutcome o = await h.Flow.RunAsync(Ct);
@@ -121,6 +123,36 @@ public sealed class BugReportFlowTests : IDisposable
h.Urls.Opened.Should().BeEmpty();
}
[Theory]
[InlineData(false)]
[InlineData(true)]
public async Task TheLastSessionIsOfferedAndGoesInOnlyWhenTickedWithItsPathsRedacted(bool included)
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
GameRow game = await s.GameAsync("Title", @"C:\Users\tester\Games\Title\title.exe");
long id = await s.SessionAsync(game.Id, new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero));
Harness h = await BuildAsync(s, BugReportChoice.Close, options: new BugBundleOptions(Cancelled: false, IncludeCrashDump: false, IncludeLastSession: included));
BugReportOutcome o = await h.Flow.RunAsync(Ct);
o.Written.Should().BeTrue();
BugBundleOffer offer = h.Preview.Offers.Should().ContainSingle().Subject;
offer.CrashDump.Should().BeNull();
offer.LastSession.Should().Be(new LastSessionInfo(id, "Title", new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero)));
IReadOnlyList<string> entries = h.Preview.Shown.Should().ContainSingle().Subject.Entries;
if (!included)
{
entries.Should().NotContain("session.json", "the box starts clear and was left so");
return;
}
entries.Should().Contain("session.json");
using ZipArchive archive = await ZipFile.OpenReadAsync(h.Zip, Ct);
using var reader = new StreamReader(await archive.GetEntry("session.json")!.OpenAsync(Ct));
string json = await reader.ReadToEndAsync(Ct);
json.Should().Contain("Title").And.NotContain("tester", "a path in the summary is redacted like a log");
}
private string WriteDump()
{
string dumps = Path.Combine(_dir, "crashdumps");
+7 -6
View File
@@ -4,13 +4,14 @@ namespace FrameLedger.App.Tests;
/// <summary>
/// The bug report flow's three ports, scripted (P4 PR-3): a preview that answers what the test says, a browser and a
/// clipboard that record. The crash dump question (P4 PR-9) answers <paramref name="dumpChoice"/> and records each offer.
/// clipboard that record. The optional items' question answers <paramref name="options"/> (nothing ticked by default) and
/// records each offer.
/// </summary>
internal sealed class ClosePreview(BugReportChoice choice = BugReportChoice.Close, CrashDumpChoice dumpChoice = CrashDumpChoice.LeaveOut) : IBugReportPreview
internal sealed class ClosePreview(BugReportChoice choice = BugReportChoice.Close, BugBundleOptions? options = null) : IBugReportPreview
{
public List<BugReportPreviewModel> Shown { get; } = [];
public List<CrashDumpInfo> DumpsOffered { get; } = [];
public List<BugBundleOffer> Offers { get; } = [];
public Task<BugReportChoice> ShowAsync(BugReportPreviewModel model, CancellationToken ct = default)
{
@@ -18,9 +19,9 @@ internal sealed class ClosePreview(BugReportChoice choice = BugReportChoice.Clos
return Task.FromResult(choice);
}
public Task<CrashDumpChoice> AskCrashDumpAsync(CrashDumpInfo dump, CancellationToken ct = default)
public Task<BugBundleOptions> AskOptionsAsync(BugBundleOffer offer, CancellationToken ct = default)
{
DumpsOffered.Add(dump);
return Task.FromResult(dumpChoice);
Offers.Add(offer);
return Task.FromResult(options ?? BugBundleOptions.NothingTicked);
}
}
@@ -0,0 +1,40 @@
using System.Text.Json;
using FluentAssertions;
using FrameLedger.App.Services;
using FrameLedger.Application.Persistence;
using FrameLedger.Infrastructure.Persistence;
namespace FrameLedger.App.Tests;
/// <summary>
/// The last session's summary (<c>10_LOGGING</c> §Bug report flow step 2): the newest session, as File ▸ Export's
/// <c>session.json</c> without the user's notes and tags; nothing when the ledger has no session.
/// </summary>
public sealed class LastSessionSummaryTests
{
private static CancellationToken Ct => TestContext.Current.CancellationToken;
[Fact]
public async Task TheNewestSessionIsOfferedAndWrittenWithoutNotesOrTags()
{
await using ScratchLedger s = await ScratchLedger.OpenAsync();
var summary = new LastSessionSummary(s.Sessions, s.Games, new SqliteHardwareSnapshotRepository(s.Db));
(await summary.FindAsync(Ct)).Should().BeNull("an empty ledger offers nothing");
GameRow older = await s.GameAsync("Older");
GameRow newer = await s.GameAsync("Newer");
await s.SessionAsync(older.Id, new DateTimeOffset(2026, 9, 1, 10, 0, 0, TimeSpan.Zero));
long id = await s.SessionAsync(newer.Id, new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero));
await s.Annotations.UpsertAsync(new SessionAnnotation { SessionId = id, Notes = "private note", Tags = ["mine"] }, Ct);
LastSessionInfo? info = await summary.FindAsync(Ct);
byte[]? json = await summary.JsonAsync(id, Ct);
info.Should().Be(new LastSessionInfo(id, "Newer", new DateTimeOffset(2026, 9, 14, 10, 0, 0, TimeSpan.Zero)));
json.Should().NotBeNull();
using JsonDocument doc = JsonDocument.Parse(json!);
doc.RootElement.GetProperty("game").GetString().Should().Be("Newer");
System.Text.Encoding.UTF8.GetString(json!).Should().NotContain("private note").And.NotContain("mine");
(await summary.JsonAsync(id + 1000, Ct)).Should().BeNull("a session that is gone writes nothing");
}
}
@@ -267,11 +267,11 @@ public sealed class PagesLoadTests
public Task<bool> ConfirmSweepAsync(int keep, CancellationToken ct = default) => Task.FromResult(false);
}
/// <summary>The bug report's optional crash dump (P4 PR-9) under the real dictionaries: the checkbox and both texts bind.</summary>
/// <summary>The bug report's optional items under the real dictionaries: both checkboxes, their texts, the visibility converter.</summary>
[Fact]
public async Task TheBundleOptionsDialogLoads()
{
var vm = new BugBundleOptionsViewModel(new CrashDumpInfo(@"C:\data\crashdumps\ui-20260915-010203-42.dmp", DateTimeOffset.UtcNow, 2 * 1024 * 1024));
var vm = new BugBundleOptionsViewModel(new BugBundleOffer(new CrashDumpInfo(@"C:\data\crashdumps\ui-20260915-010203-42.dmp", DateTimeOffset.UtcNow, 2 * 1024 * 1024), new LastSessionInfo(1, "Title", DateTimeOffset.UtcNow)));
double width = await OnStaAsync(() =>
{