Put the log and the crash records in one file, and show it before writing it
NFR-OPS-1 asks for a diagnostics bundle — the log, the schema version, the GPU and driver, the app version — "with an explicit preview-and-consent step before anything leaves the device". The log and the crash records have existed since August; what did not exist was any way to hand them over that was not `adb pull` and a knowledge of where the state directory is, which on the tablet the requirement was written for is nobody. Nothing here sends anything, and that is the design rather than a gap: crash.rs already says why a transport built ahead of the consent is the shape of thing that gets switched on by default. The bundle writes one text file to a place the user can find, so that they can attach it. That is the moment it leaves, and it is theirs. So the consent guards the write, not a send. Preparing gathers everything into memory and shows what would be written — each section, its size, what was taken out, and where the file would go — and only the second press puts bytes on disk. A user who reads the preview and presses the other button has changed nothing anywhere. The gathered bundle is held between the presses so what is saved is exactly what was shown, not a second gathering that differs by whatever was logged while they were reading. One text file rather than an archive, because a `.txt` opens wherever the user is sitting and pastes into an issue, and because the preview can then be the file rather than a summary of it. Every line goes through the blunter of the two redactions on the way in, whatever the sink already did to it: the log's own rule keeps paths, since a path read over `adb` is context, but a file meant to be attached to a public report by someone who may not read it first is held to the crash record's rule instead. The About page's graphics line gains the driver, which the requirement names and the adapter has always reported. And docs/outstanding.md is corrected on both OPS requirements: it said crash reporting was a log::error! hook and NFR-OPS-1 had nothing behind it, and neither had been true since 2026-08-30.
This commit is contained in:
@@ -1192,6 +1192,79 @@ pub fn run(paths: Vec<PathBuf>) -> Result<()> {
|
||||
None => window.set_backend("NO GPU".into()),
|
||||
}
|
||||
|
||||
// TRACES: NFR-OPS-1
|
||||
// The diagnostics bundle, wired as the two presses the requirement
|
||||
// describes. Preparing gathers the log and the crash records into memory
|
||||
// and shows what would be written; saving writes it; discarding drops it
|
||||
// and writes nothing. The gathered bundle is held between the presses so
|
||||
// that what is saved is exactly what was shown — a bundle gathered again
|
||||
// at save time could differ from its own preview by whatever was logged
|
||||
// while the user was reading.
|
||||
{
|
||||
use dr_plat::diagnostics::bundle::{Bundle, Facts};
|
||||
let facts = Facts {
|
||||
app_version: env!("CARGO_PKG_VERSION").to_string(),
|
||||
schema_version: dr_catalog::schema::SCHEMA_VERSION,
|
||||
graphics: match &gpu {
|
||||
Some(ctx) => format!(
|
||||
"{} ({:?}), {}",
|
||||
ctx.adapter_name(),
|
||||
ctx.backend(),
|
||||
ctx.driver()
|
||||
),
|
||||
None => "no GPU".to_string(),
|
||||
},
|
||||
};
|
||||
let pending: Rc<RefCell<Option<Bundle>>> = Rc::new(RefCell::new(None));
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let pending = pending.clone();
|
||||
window.on_diagnostics_prepare(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let bundle = Bundle::gather(&facts);
|
||||
w.set_diagnostics_preview(
|
||||
bundle
|
||||
.preview(&dr_plat::diagnostics::bundle::default_dir())
|
||||
.into(),
|
||||
);
|
||||
w.set_diagnostics_result("".into());
|
||||
*pending.borrow_mut() = Some(bundle);
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
let pending = pending.clone();
|
||||
window.on_diagnostics_save(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
let Some(bundle) = pending.borrow_mut().take() else {
|
||||
return;
|
||||
};
|
||||
let dir = dr_plat::diagnostics::bundle::default_dir();
|
||||
let result = match bundle.write_to(&dir) {
|
||||
Ok(path) => {
|
||||
log::info!("diagnostics bundle written: {}", path.display());
|
||||
format!("Saved as {}", path.display())
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("diagnostics bundle not written: {e}");
|
||||
format!("Could not save the bundle to {}: {e}", dir.display())
|
||||
}
|
||||
};
|
||||
w.set_diagnostics_preview("".into());
|
||||
w.set_diagnostics_result(result.into());
|
||||
});
|
||||
}
|
||||
{
|
||||
let weak = window.as_weak();
|
||||
window.on_diagnostics_discard(move || {
|
||||
let Some(w) = weak.upgrade() else { return };
|
||||
*pending.borrow_mut() = None;
|
||||
w.set_diagnostics_preview("".into());
|
||||
w.set_diagnostics_result("".into());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Every background job reports here, and this draws the bar across the top
|
||||
// of the shell and fills the settings page's list. Built before the
|
||||
// controllers because they take a handle to it: a job that starts during
|
||||
|
||||
@@ -69,6 +69,14 @@ export component AppWindow inherits Window {
|
||||
/// Set from `CARGO_PKG_VERSION`, so the About line cannot disagree with
|
||||
/// the binary it is part of.
|
||||
in property <string> app-version: "unknown";
|
||||
/// TRACES: NFR-OPS-1
|
||||
/// The diagnostics bundle's preview and the last save's outcome — see
|
||||
/// `SettingsPage`, which is the only reader.
|
||||
in property <string> diagnostics-preview;
|
||||
in property <string> diagnostics-result;
|
||||
callback diagnostics-prepare();
|
||||
callback diagnostics-save();
|
||||
callback diagnostics-discard();
|
||||
|
||||
// Current image, for the status strip and empty state.
|
||||
in property <string> filename: "";
|
||||
@@ -1363,6 +1371,13 @@ in property <bool> panel-visible: true;
|
||||
thumbnail-library() => { root.library-thumbnail-all(); }
|
||||
index-faces() => { root.identity-index(); }
|
||||
|
||||
// TRACES: NFR-OPS-1
|
||||
diagnostics-preview: root.diagnostics-preview;
|
||||
diagnostics-result: root.diagnostics-result;
|
||||
diagnostics-prepare() => { root.diagnostics-prepare(); }
|
||||
diagnostics-save() => { root.diagnostics-save(); }
|
||||
diagnostics-discard() => { root.diagnostics-discard(); }
|
||||
|
||||
close() => { root.settings-close(); }
|
||||
reset-defaults() => { root.settings-reset(); }
|
||||
}
|
||||
|
||||
@@ -136,6 +136,17 @@ export component SettingsPage inherits Rectangle {
|
||||
in property <string> layout-class;
|
||||
in property <string> app-version;
|
||||
|
||||
/// TRACES: NFR-OPS-1
|
||||
/// The diagnostics bundle, in its two states. `diagnostics-preview` is
|
||||
/// empty until the user asks for one; while it is not, the panel shows
|
||||
/// what would be written and offers the write. `diagnostics-result` is
|
||||
/// what the last save said — a path, or why it failed.
|
||||
in property <string> diagnostics-preview;
|
||||
in property <string> diagnostics-result;
|
||||
callback diagnostics-prepare();
|
||||
callback diagnostics-save();
|
||||
callback diagnostics-discard();
|
||||
|
||||
/// TRACES: FR-DSP-8
|
||||
/// The display showing the canvas, and the colour it is being given.
|
||||
///
|
||||
@@ -900,6 +911,71 @@ export component SettingsPage inherits Rectangle {
|
||||
}
|
||||
}
|
||||
|
||||
// --- diagnostics -----------------------------------------
|
||||
//
|
||||
// TRACES: NFR-OPS-1
|
||||
// Two presses, never one. The first gathers and shows; the
|
||||
// second writes. The requirement asks for a preview-and-
|
||||
// consent step before anything leaves the device, and a
|
||||
// single button that gathered and saved would be the step
|
||||
// skipped under the name of convenience. Nothing is sent by
|
||||
// either press — the file is for the user to attach.
|
||||
Rectangle {
|
||||
width: content.column;
|
||||
height: diagnostics.preferred-height;
|
||||
|
||||
diagnostics := Panel {
|
||||
width: 100%;
|
||||
spacing: Theme.gap;
|
||||
|
||||
PanelHeading { text: "DIAGNOSTICS"; }
|
||||
|
||||
Caption {
|
||||
text: "The log, any crash records, and the facts "
|
||||
+ "above, as one text file to attach to a bug "
|
||||
+ "report. Credentials and file paths are "
|
||||
+ "removed first, and you see what is in it "
|
||||
+ "before anything is written.";
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
if root.diagnostics-preview == "": Rectangle {
|
||||
height: Theme.control-height;
|
||||
|
||||
Button {
|
||||
x: 0;
|
||||
text: "Show what a bundle would contain";
|
||||
clicked => { root.diagnostics-prepare(); }
|
||||
}
|
||||
}
|
||||
|
||||
if root.diagnostics-preview != "": Value {
|
||||
text: root.diagnostics-preview;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
if root.diagnostics-preview != "": HorizontalLayout {
|
||||
spacing: Theme.gap;
|
||||
alignment: start;
|
||||
|
||||
Button {
|
||||
text: "Save the bundle";
|
||||
clicked => { root.diagnostics-save(); }
|
||||
}
|
||||
|
||||
Button {
|
||||
text: "Don't";
|
||||
clicked => { root.diagnostics-discard(); }
|
||||
}
|
||||
}
|
||||
|
||||
if root.diagnostics-result != "": Caption {
|
||||
text: root.diagnostics-result;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// --- naming and destination ------------------------------
|
||||
//
|
||||
// Its own panel rather than more of the export one: format and
|
||||
|
||||
Reference in New Issue
Block a user