Skip to content
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
581 changes: 581 additions & 0 deletions crates/ui-egui/src/bug_report.rs

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions crates/ui-egui/src/control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ pub fn handle(app: &mut LightcraftApp, ctx: &egui::Context, req: &ControlRequest
| crate::state::Dialog::SaveEffect { .. }
| crate::state::Dialog::CaptureTime { .. }
| crate::state::Dialog::LensDatabase { .. }
| crate::state::Dialog::ReportBug { .. }
| crate::state::Dialog::TextPrompt { .. }
))
|| (r.is_ok() && crate::panels::dialogs::keeps_open(app, &d))
Expand Down
6 changes: 6 additions & 0 deletions crates/ui-egui/src/dialogs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ pub fn show(app: &mut LightcraftApp, ctx: &egui::Context, blocked: bool) {
Dialog::Welcome { .. } => 460.0,
Dialog::LensDatabase { .. } => 440.0,
Dialog::ManageEffects { .. } => 560.0,
Dialog::ReportBug { .. } => 560.0,
_ => 380.0,
})
.show(ctx, |ui| {
Expand Down Expand Up @@ -455,6 +456,7 @@ fn dialog_title(app: &LightcraftApp, dlg: &Dialog) -> String {
Dialog::NewSmartAlbum { .. } => "Create Smart Album",
Dialog::AllMetadata { .. } => "All Metadata",
Dialog::SystemInfo { .. } => "System Info",
Dialog::ReportBug { .. } => "Report a Bug",
Dialog::DenoiseModel { .. } => "AI Denoise Model",
Dialog::FaceModel { info, .. } if info["download"].is_string() => "Download Face Model",
Dialog::FaceModel { .. } => "Add Face Model",
Expand Down Expand Up @@ -606,6 +608,7 @@ fn fixed_ok_label(app: &LightcraftApp, dlg: &Dialog, informational: bool) -> &'s
d @ Dialog::LightroomDestination { .. } => crate::lightroom_destination::ok_label(d),
Dialog::Welcome { .. } => "",
Dialog::LensDatabase { .. } => "Download",
Dialog::ReportBug { .. } => "Create Report",
Dialog::SynchronizeFolder { .. } if informational => "Close",
Dialog::SynchronizeFolder { .. } => "Synchronize",
Dialog::RenamePerson { from, to, .. } if person_rename_plan(&app.session.catalog, from, to).needs_merge => "Merge",
Expand Down Expand Up @@ -733,6 +736,8 @@ fn confirmed(app: &mut LightcraftApp, ctx: &egui::Context, dlg: &mut Dialog) ->
| Dialog::SaveEffect { .. }
| Dialog::CaptureTime { .. }
| Dialog::LensDatabase { .. }
// a report that can't be written or opened keeps what was typed (#1128 review)
| Dialog::ReportBug { .. }
) =>
{
app.toast(ctx, e)
Expand Down Expand Up @@ -2086,6 +2091,7 @@ fn dialog_content(app: &mut LightcraftApp, ui: &mut egui::Ui, t: &Tokens, body_m
Dialog::FaceModel { info, accepted, .. } => crate::panels::faces::model_dialog(app, ui, t, info, accepted),
Dialog::LightroomResult { .. } => lightroom_result_body(ui, dlg),
Dialog::SystemInfo { .. } => system_info_body(ui, t, dlg),
Dialog::ReportBug { opts, rows, logs } => crate::bug_report::dialog_body(ui, t, opts, rows, logs),
Dialog::AllMetadata { .. } => all_metadata_body(ui, t, dlg),
Dialog::SmartRules { .. } => smart_rules_body(app, ui, t, dlg),
Dialog::NewSmartAlbum { .. } => new_smart_album_body(app, ui, t, confirm, dlg),
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/dialogs/confirm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub fn confirm_dialog(app: &mut LightcraftApp, dlg: &Dialog) -> Result<serde_jso
Dialog::DenoiseModel { info, accepted } => crate::panels::denoise::install(app, info, *accepted),
Dialog::FaceModel { path, info, accepted } => crate::panels::faces::install(app, path, info, *accepted),
Dialog::AllMetadata { .. } | Dialog::SystemInfo { .. } | Dialog::WhatsNew | Dialog::Welcome { .. } => Ok(serde_json::Value::Null),
Dialog::ReportBug { opts, rows, logs } => crate::bug_report::create(app, opts, rows, logs),
Dialog::Cull { reject_below, pick_best, burst_gap, similarity } => {
app.ui.cull_burst = Some((*burst_gap, *similarity));
app.run("photo.analyze", cull_params(*reject_below, *pick_best, *burst_gap, *similarity))
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub const UPDATE_APP: craft_update::app::App = craft_update::app::App {
};

pub mod brush_live;
pub mod bug_report;
pub mod canvas_keys;
mod command_error;
pub mod control;
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/menus/menubar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ const LAYOUT: &[(&str, &[&str])] = &[
&[
"app.discord",
"app.feedback",
"app.reportBug",
"---",
"app.website",
"app.github",
Expand Down
40 changes: 2 additions & 38 deletions crates/ui-egui/src/menus/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ fn ui_commands_10(app: &mut LightcraftApp, ctx: &egui::Context, id: &str, p: &Va
Ok(json!({"text": crate::panels::dialogs::WHATS_NEW}))
}
"app.systemInfo" => app_system_info_command(app, p),
"app.reportBug" => crate::bug_report::command(app, p),
"app.shortcuts" => {
app.ui.dialog = Some(Dialog::Shortcuts);
Ok(Value::Null)
Expand Down Expand Up @@ -1674,44 +1675,7 @@ fn dialog_smart_album_command(app: &mut LightcraftApp, _id: &str, p: &Value) ->

/// The `app.systemInfo` command.
fn app_system_info_command(app: &mut LightcraftApp, p: &Value) -> Result<Value, String> {
let info = app.session.execute("library.info", &json!({})).unwrap_or_default();
let gpu = (lightcraft_engine::gpu::ready() && lightcraft_engine::gpu::available()).then(lightcraft_engine::gpu::adapter_name).flatten();
let mb = |b: u64| format!("{:.0} MB", b as f64 / (1u64 << 20) as f64);
let mut rows = vec![
("Version".to_string(), env!("CARGO_PKG_VERSION").to_string()),
("System".to_string(), format!("{} ({})", std::env::consts::OS, std::env::consts::ARCH)),
("CPU threads".to_string(), std::thread::available_parallelism().map(|n| n.get().to_string()).unwrap_or_else(|_| "?".into())),
(
"GPU".to_string(),
gpu.unwrap_or_else(|| match lightcraft_engine::gpu::unavailable_reason() {
Some(why) => crate::i18n::tr_format!("none (CPU rendering): {why}", why = why),
None => "none (CPU rendering)".into(),
}),
),
("GPU rendering".to_string(), if app.ui.settings.gpu { "on".into() } else { "off".into() }),
("Memory budget".to_string(), mb(lightcraft_engine::memory::default_budget() as u64)),
(
"Preview size".to_string(),
match app.ui.settings.preview_limit {
0 => "automatic".to_string(),
n => format!("{n} px"),
},
),
("Photos".to_string(), info["photos"].to_string()),
("Albums".to_string(), info["albums"].to_string()),
];
if let Some(dir) = info["dir"].as_str().or(info["path"].as_str()) {
rows.push(("Library".into(), dir.to_string()));
}
rows.push(("Frame time".into(), format!("{:.1} ms ({:.0} fps)", app.perf.frame_ms, app.perf.fps)));
rows.push((
"Frame update".into(),
format!("{:.1} ms (logic {:.1} ms; slowest {:.0} ms)", app.perf.update_ms, app.perf.logic_ms, app.perf.max_update_ms),
));
rows.push(("Last loupe render".into(), format!("{:.0} ms", app.renderer.last_main_ms)));
if let Some(f) = lightcraft_engine::gpu::last_fallback() {
rows.push(("Last GPU fallback".into(), f));
}
let rows = crate::bug_report::system_rows(app);
let r = json!(rows.iter().map(|(k, v)| json!({"label": k, "value": v})).collect::<Vec<_>>());
if p.get("open").and_then(Value::as_bool).unwrap_or(true) {
app.ui.dialog = Some(Dialog::SystemInfo { rows });
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/menus/ui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ pub const UI_COMMANDS: &[UiCommand] = &[
("app.about", "About LightCraft", None, "Help"),
("app.checkForUpdates", "Check for Updates…", None, "Help"),
("app.systemInfo", "System Info…", None, "Help"),
("app.reportBug", "Report a Bug…", None, "Help"),
("app.openLogFolder", "Open Log Folder", None, "Help"),
// the frame-rate display (`frame_rate`): a debugging aid, never saved
("view.frameRate", "Frame Rate", None, "Help>Debug"),
Expand Down
7 changes: 7 additions & 0 deletions crates/ui-egui/src/state/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ pub enum Dialog {
SystemInfo {
rows: Vec<(String, String)>,
},
/// Help ▸ Report a Bug… (#1015): the choices, and the logs found when it opened.
ReportBug {
opts: crate::bug_report::ReportOptions,
/// The System Info rows when it opened: what the preview shows is what the report holds.
rows: Vec<(String, String)>,
logs: Vec<crate::bug_report::LogInfo>,
},
/// Every metadata field of a photo's file (`photo.allMetadata`), filtered by `search`.
AllMetadata {
title: String,
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ mod quit_unsaved;
mod rating;
mod recheck;
mod rename_person;
mod report_bug;
mod rules_editor;
mod sam_setup;
mod scan_probes;
Expand Down
153 changes: 153 additions & 0 deletions crates/ui-egui/src/tests/report_bug.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
//! #1015: Help ▸ Report a Bug… writes a report file next to the logs, shows it in the file manager
//! and opens a pre-filled GitHub issue. Nothing is sent; personal paths and photo names are hidden by
//! default.

use crate::headless::Headless;
use crate::{LightcraftApp, Services};
use serde_json::json;
use std::sync::{Arc, Mutex};
use std::time::Duration;

const T: Duration = Duration::from_secs(20);
const SETTLE: Duration = Duration::from_secs(60);

/// A log folder with this run's log and the one before, which name a photo under the home folder.
fn log_dir(tag: &str) -> (std::path::PathBuf, String) {
let dir = std::env::temp_dir().join(format!("lc-report-bug-{tag}-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&dir);
std::fs::create_dir_all(&dir).unwrap();
let home = crate::bug_report::home_dir().unwrap_or_else(|| "/home/someone".into());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
let current = dir.join("lightcraft.log");
std::fs::write(&current, format!("10:00 INFO start\n10:01 WARN import: {home}/Pictures/Ann birthday.CR2: no preview\n")).unwrap();
std::fs::write(dir.join("lightcraft.1.log"), "09:00 ERROR the run before\n").unwrap();
(dir, current.to_string_lossy().to_string())
}

/// The demo app with a log file, recording what it reveals and which links it opens.
fn app(log_file: Option<String>) -> (Headless, Arc<Mutex<Vec<String>>>, Arc<Mutex<Vec<String>>>) {
let (revealed, opened) = (Arc::new(Mutex::new(Vec::new())), Arc::new(Mutex::new(Vec::new())));
let (r, o) = (revealed.clone(), opened.clone());
let services = Services {
png: None,
log_file,
reveal: Some(Box::new(move |p: &str| {
r.lock().unwrap().push(p.to_string());
Ok(())
})),
open_url: Some(Box::new(move |u: &str| {
o.lock().unwrap().push(u.to_string());
Ok(())
})),
..Default::default()
};
let mut h = Headless::new(LightcraftApp::new(lightcraft_engine::Session::with_demo(), services), [1300.0, 900.0], 1.0);
h.settle(SETTLE);
(h, revealed, opened)
}

fn has(h: &Headless, id: &str) -> bool {
h.app.widgets.iter().any(|(w, _)| w == id)
}

#[test]
fn the_report_file_and_the_issue_hold_what_was_chosen() {
let (dir, log) = log_dir("create");
let (mut h, revealed, opened) = app(Some(log));
let r = h.request("engine.execute", json!({"command": "app.reportBug", "params": {"create": true, "what": "Export hangs at 90 %"}}), T);
assert_eq!(r["ok"], true, "{r}");
let path = r["result"]["path"].as_str().expect("a report file").to_string();
assert!(path.starts_with(&dir.to_string_lossy().to_string()) && path.ends_with(".txt"), "{path}");
let text = std::fs::read_to_string(&path).unwrap();
assert!(text.contains("Export hangs at 90 %") && text.contains("Version: ") && text.contains("== lightcraft.log =="), "{text}");
// this run's log only, with the home folder and the photo's name hidden
assert!(!text.contains("lightcraft.1.log") && !text.contains("the run before"), "{text}");
assert!(!text.contains("Ann birthday"), "{text}");
// the home folder becomes `~` only where there is one to find (CI runners may have none)
if crate::bug_report::home_dir().is_some() {
assert!(text.contains("~/Pictures/<photo>.CR2"), "{text}");
}
assert_eq!(*revealed.lock().unwrap(), vec![path.clone()]);
let url = opened.lock().unwrap().last().cloned().expect("the issue opened");
assert!(
url.starts_with("https://github.com/storytold/lightcraft/issues/new?title=Bug%3A%20Export%20hangs")
&& url.len() <= crate::bug_report::MAX_URL,
"{url}"
);
assert!(!url.contains("birthday"), "{url}");

// the previous run's log too, names shown when asked
let r = h.request("engine.execute", json!({"command": "app.reportBug", "params": {"create": true, "previousLogs": true, "private": false}}), T);
let text = std::fs::read_to_string(r["result"]["path"].as_str().unwrap()).unwrap();
assert!(text.contains("== lightcraft.1.log ==") && text.contains("the run before") && text.contains("Ann birthday.CR2"), "{text}");
assert_eq!(r["result"]["logs"], json!(["lightcraft.log", "lightcraft.1.log"]));
let _ = std::fs::remove_dir_all(&dir);
}

#[test]
fn the_dialog_previews_the_issue_and_creates_the_report() {
let (dir, log) = log_dir("dialog");
let (mut h, revealed, opened) = app(Some(log));
let r = h.request("ui.menu.invoke", json!({"id": "app.reportBug"}), T);
assert_eq!(r["ok"], true, "{r}");
h.step();
h.step();
assert!(matches!(h.app.ui.dialog, Some(crate::state::Dialog::ReportBug { .. })));
for id in
["field:reportBugWhat", "check:reportBugPrivate", "check:reportBugPrevious", "button:reportBugCopy", "button:dialogCancel", "button:dialogOk"]
{
assert!(has(&h, id), "no {id}");
}
let text = h.painted_text().join("\n");
assert!(text.contains("Create Report") && text.contains("### What happened") && text.contains("lightcraft.log"), "{text}");
// the preview hides what the report hides
assert!(text.contains("<photo>.CR2") && !text.contains("Ann birthday"), "{text}");
let r = h.request("ui.clickWidget", json!({"id": "button:dialogOk"}), T);
assert_eq!(r["ok"], true, "{r}");
h.step();
assert!(h.app.ui.dialog.is_none(), "Create Report closes the dialog");
assert_eq!(revealed.lock().unwrap().len(), 1);
assert_eq!(opened.lock().unwrap().len(), 1);
let _ = std::fs::remove_dir_all(&dir);
}

#[test]
fn without_a_log_the_issue_holds_the_system_info_only() {
let (mut h, revealed, opened) = app(None);
let r = h.request("engine.execute", json!({"command": "app.reportBug", "params": {"create": true}}), T);
assert_eq!(r["ok"], true, "{r}");
assert!(r["result"]["path"].is_null(), "{r}");
assert!(revealed.lock().unwrap().is_empty());
let url = opened.lock().unwrap().last().cloned().expect("the issue opened");
assert!(url.contains("title=Bug%20report") && url.contains("Version%3A%20"), "{url}");
let r = h.request("ui.menu.invoke", json!({"id": "app.reportBug"}), T);
assert_eq!(r["ok"], true, "{r}");
h.step();
h.step();
assert!(!has(&h, "check:reportBugPrevious"), "no previous logs to offer");
assert!(h.painted_text().join("\n").contains("keeps no log"));
}

/// A report that can't be written keeps the dialog, and what was typed, open with the error, through
/// the control channel as through its button (#1128 review).
#[test]
#[cfg(unix)]
fn a_report_that_cant_be_written_keeps_the_dialog() {
use std::os::unix::fs::PermissionsExt;
let (dir, log) = log_dir("unwritable");
let (mut h, _, opened) = app(Some(log));
let r = h.request("ui.menu.invoke", json!({"id": "app.reportBug"}), T);
assert_eq!(r["ok"], true, "{r}");
if let Some(crate::state::Dialog::ReportBug { opts, .. }) = h.app.ui.dialog.as_mut() {
opts.what = "Export hangs".into();
}
std::fs::set_permissions(&dir, std::fs::Permissions::from_mode(0o555)).unwrap();
let r = h.request("ui.dialog.confirm", json!({}), T);
std::fs::set_permissions(&dir, std::fs::Permissions::from_mode(0o755)).unwrap();
assert_eq!(r["ok"], false, "the report file can't be written: {r}");
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
match &h.app.ui.dialog {
Some(crate::state::Dialog::ReportBug { opts, .. }) => assert_eq!(opts.what, "Export hangs", "what was typed is kept"),
other => panic!("the dialog closed: {other:?}"),
}
assert!(opened.lock().unwrap().is_empty(), "no issue opened for a report that wasn't made");
let _ = std::fs::remove_dir_all(&dir);
}
2 changes: 2 additions & 0 deletions docs/parity-checklist.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ visible menu bar yet: the menu model is only exposed through the control channel
| MENU-HELP-WHATSNEW | What's new | P2 | ✅ | `cmd:app.whatsNew` | |
| MENU-HELP-SHORTCUTS | Keyboard shortcuts | P1 | ✅ | `cmd:app.shortcuts` | |
| MENU-HELP-FEEDBACK | Send feedback | P2 | ✅ | `cmd:app.feedback` | opens a new issue on the project's GitHub |
| MENU-HELP-REPORTBUG | Report a bug | P2 | ✅ | `cmd:app.reportBug`, `crates/ui-egui/src/bug_report.rs` | an extra (issue #1015): Help ▸ Report a Bug… previews, then writes `lightcraft-report-<time>.txt` next to the logs (what happened, the System Info rows, this run's log and optionally the two before) and reveals it, and opens a new GitHub issue pre-filled with the same and the end of the log (link ≤ 8,000 characters); the home folder and photo file names are hidden by default; nothing is sent. Not yet: an offer after a crash, a duplicate search, reporting without a GitHub account |
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
| MENU-HELP-LOGFOLDER | Open log folder | P2 | ✅ | `cmd:app.openLogFolder` | an extra (the reference app has no such item): Help ▸ Open Log Folder reveals `logs/lightcraft.log` in the system file manager (Finder, Explorer, or the folder on Linux); off on the web and in `--memory` sessions, which keep no log (issue #260) |
| MENU-HELP-SYSINFO | System info | P2 | ✅ | `cmd:app.systemInfo`, `cmd:library.info` | Help ▸ System Info…: version, OS, CPU threads, GPU, memory budget, preview size, library, timings; Copy to Clipboard; one Close button, like About (#782); JSON for agents (`open: false`) |
| MENU-CTX-GRID | Photo context menu | P0 | ✅ | `crates/ui-egui/src/panels/grid.rs` (`context_menu`) | rate, flag, label, add to / remove from album, rename, virtual copy, version, stack, copy / paste / paste selected, reset, merge, rotate, show in Finder, export / export with preset, set as album cover (in an album), delete (restore / delete permanently in Recently Deleted) |
Expand Down Expand Up @@ -909,6 +910,7 @@ Latin stays upright. Advanced Japanese composition remains open. Regression cove
| 2026-10-14 | patch | LR-MASK-BRUSH: ⇧-click with the brush draws a straight stroke from where the last stroke ended, tapering when the brush changed in between (`cmd:mask.brushStroke` `connect`); status unchanged |
| 2026-10-14 | minor | LR-VIEW-ZOOM 🟡 → ✅: soft proofing gets zoom windows (mask overlays already had them; row text corrected), 1:1 pixels tested equal to the full-size export, slider-drag latency at 1:1 measured on Linux |
| 2026-10-14 | patch | LR-IMP-LOCAL: browsing a folder from the sidebar records it as browsed, as `library.browse` does, so its untouched photos aren't forgotten while in use; status unchanged (✅) |
| 2026-10-14 | minor | MENU-HELP-REPORTBUG: Help ▸ Report a Bug… writes a report file and opens a pre-filled issue (issue #1015) |
| 2026-10-13 | patch | LR-VIEW-COMPARE, LRC-LIB-COMPARE: ⌘/Ctrl- and Shift-clicks on the filmstrip in Compare change the selection as in the grid; the two photos shown stay selected and the active photo is unchanged (#187); statuses unchanged |
| 2026-10-13 | minor | KEYC-SELECTONLYACTIVE: Edit → Select Only Active Photo (⌘⇧D) lands as a new row; status 🟡 (headless-tested, native macOS menu path unverified) |
| 2026-10-13 | patch | LRC-LIB-CATALOG-IMPORT: a catalog whose tables are all still in its `-wal` file (main file schema format 0) opens instead of failing as an unsupported schema format; status unchanged |
Expand Down
Loading
Loading