Compare commits

...
Author SHA1 Message Date
semmelrindeandClaude Opus 5.5 2d1d568718 Report a bug: keep the typed answers when the draft is closed or opened again (#7189) (#7194)
* claim: #7189

* Report a bug: keep the typed answers when the draft is closed or opened again (#7189)

Opening the report again (Help > Report an Issue... on macOS, ui.help report,
a crash's Report...) while the draft has typed answers now keeps that draft
and focuses it; an untouched draft still gives way to the new context.

Close draft and the header close button keep the typed summary and answers.
The next draft offers "Restore what you typed before", which fills its empty
fields; the offer goes once used or once the new draft gets answers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Report a bug: a draft handed to GitHub is not kept or offered back

Once Continue on GitHub has the text, closing the draft no longer keeps
its answers for the next report, and a new report replaces it: offering
the filed text again invited a second issue. Answers are offered back
only to a draft that opened empty, not into a crash or failed-command
draft. A kept draft says how to report the new problem when a crash's
Report… or a dialog's Create Issue… brings one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Locales: Arabic and Hebrew for the new strings

ar and he are complete catalogs on main now (#3458): every new message
needs them. The pending-messages test compares right-to-left messages in
display order once #7532 lands (#7527).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Locales: Vietnamese for the new strings

Vietnamese became a complete catalog on main (#5823), so every new English
message needs it too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-27 14:16:18 +00:00
3 changed files with 231 additions and 0 deletions

No files matched your search

@@ -0,0 +1,30 @@
{
"en": {
"Close this draft to report the new problem.": "Close this draft to report the new problem.",
"Restore what you typed before": "Restore what you typed before"
},
"ar": {
"Close this draft to report the new problem.": "أغلق هذه المسودة للإبلاغ عن المشكلة الجديدة.",
"Restore what you typed before": "استعادة ما كتبته سابقًا"
},
"de": {
"Close this draft to report the new problem.": "Schließe diesen Entwurf, um das neue Problem zu melden.",
"Restore what you typed before": "Vorherige Eingaben wiederherstellen"
},
"he": {
"Close this draft to report the new problem.": "סגור את הטיוטה הזו כדי לדווח על הבעיה החדשה.",
"Restore what you typed before": "שחזור מה שהקלדת קודם"
},
"ja": {
"Close this draft to report the new problem.": "新しい問題を報告するには、この下書きを閉じてください。",
"Restore what you typed before": "前回の入力を復元"
},
"vi": {
"Close this draft to report the new problem.": "Hãy đóng bản nháp này để báo cáo sự cố mới.",
"Restore what you typed before": "Khôi phục nội dung bạn đã nhập trước đó"
},
"zh": {
"Close this draft to report the new problem.": "关闭此草稿以报告新问题。",
"Restore what you typed before": "恢复之前输入的内容"
}
}
+185
View File
@@ -111,6 +111,9 @@ pub struct ReportState {
/// The report's field that had focus when a capture hid it.
refocus: Option<egui::Id>,
cad_focus: Option<egui::Id>,
/// What was typed into the last draft closed with answers, offered to the next draft until
/// it is taken back or that draft gets answers of its own (#7189).
earlier: Option<Answers>,
}
/// How long a screenshot waits for a preview being computed before it shows it unfinished.
@@ -142,10 +145,17 @@ pub struct Draft {
focus_requested: bool,
missing_description: bool,
opened_github: bool,
/// The answers as the draft opened: a crash or a failed command fills some in.
opened_with: Answers,
}
/// A draft's summary and its three answers, in that order: what someone types.
#[derive(Default)]
struct Answers([String; 4]);
impl Draft {
fn new(title: String, body: String, source_signature: u64) -> Self {
let opened_with = Answers([title.clone(), String::new(), String::new(), String::new()]);
Self {
title,
title_prefix: String::new(),
@@ -160,6 +170,44 @@ impl Draft {
focus_requested: false,
missing_description: false,
opened_github: false,
opened_with,
}
}
fn answers(&self) -> [&String; 4] {
[&self.title, &self.description, &self.steps, &self.expected]
}
/// Whether anything was typed: an answer differs from what the draft opened with.
fn typed(&self) -> bool {
self.answers().into_iter().zip(&self.opened_with.0).any(|(now, opened)| now != opened)
}
/// The answers typed, to keep when the draft closes (the others left empty); `None` when
/// nothing was.
fn typed_answers(&self) -> Option<Answers> {
let mut typed = Answers::default();
for ((kept, now), opened) in typed.0.iter_mut().zip(self.answers()).zip(&self.opened_with.0) {
if now != opened {
kept.clone_from(now);
}
}
typed.0.iter().any(|kept| !kept.is_empty()).then_some(typed)
}
/// Whether `earlier` has an answer for a field still empty here. Only a draft that opened
/// empty offers it: a crash or a failed command is a problem of its own.
fn restorable(&self, earlier: &Answers) -> bool {
self.opened_with.0.iter().all(String::is_empty)
&& self.answers().into_iter().zip(&earlier.0).any(|(now, kept)| now.is_empty() && !kept.is_empty())
}
/// Puts `earlier` back into the fields still empty.
fn restore(&mut self, earlier: Answers) {
for (now, kept) in [&mut self.title, &mut self.description, &mut self.steps, &mut self.expected].into_iter().zip(earlier.0) {
if now.is_empty() {
*now = kept;
}
}
}
@@ -547,11 +595,28 @@ pub fn crash_draft(report: &serde_json::Value) -> Draft {
let mut draft = Draft::new(title, body, 0);
draft.description =
limited(&format!("{what}{}.", command.map(|c| format!(" while running `{}`", limited(c, 160))).unwrap_or_default()), MAX_ANSWER);
draft.opened_with = Answers(draft.answers().map(String::clone));
draft
}
/// A draft with typed answers is never replaced: opening the report again shows it, with its
/// description focused (#7189). An untouched draft, or one already handed to GitHub, gives way to
/// the new context. When the new report has context of its own (a crash, a failed command), the
/// kept draft says how to report it.
fn keep_typed(app: &mut SolveApp, new_context: bool) -> bool {
let Some(draft) = app.issue_report.draft.as_mut().filter(|draft| draft.typed() && !draft.opened_github) else { return false };
draft.focus_requested = false;
if new_context {
draft.note = "Close this draft to report the new problem.".into();
}
true
}
/// Open a reviewed draft for a crash report (no screenshot: the view shows nothing of it).
pub fn begin_crash(app: &mut SolveApp, ctx: &egui::Context, report: &serde_json::Value) {
if keep_typed(app, true) {
return;
}
if app.issue_report.draft.is_none() {
app.issue_report.cad_focus = ctx.memory(|m| m.focused());
}
@@ -588,6 +653,9 @@ pub fn draft_url(title: &str, body: &str) -> (String, bool) {
}
pub fn begin(app: &mut SolveApp, ctx: &egui::Context, dialog: Option<&dialogs::Dialog>, error: Option<&str>) {
if keep_typed(app, dialog.is_some() || error.is_some()) {
return;
}
if app.issue_report.draft.is_none() {
app.issue_report.cad_focus = ctx.memory(|m| m.focused());
}
@@ -865,6 +933,13 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
crate::drag_snap::clear();
crate::gizmo::cancel(ctx, egui::Id::new("sc_move_triad"));
crate::gizmo::cancel(ctx, egui::Id::new("sc_occ_triad"));
// What was typed outlives the draft: the next one offers it back. Not once it went to
// GitHub: the issue has it, and offering it again invites a second one.
if !draft.opened_github
&& let Some(typed) = draft.typed_answers()
{
app.issue_report.earlier = Some(typed);
}
if let Some(focus) = app.issue_report.cad_focus.take() {
ctx.memory_mut(|m| m.request_focus(focus));
}
@@ -1220,6 +1295,116 @@ mod tests {
assert_eq!(before, (app.session.doc.to_json(), app.session.undo.len(), app.session.redo.len(), app.cam));
}
/// Report an Issue… (the macOS Help menu, `ui.help report`) or a crash's Report… while a
/// draft has answers shows that draft, not an empty one (#7189).
#[test]
fn issue_report_opened_again_keeps_the_typed_draft() {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
h.call("ui.help", json!({"item":"report"}));
let token = h.app.issue_report.pending.as_ref().unwrap().token;
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(4);
h.step(&json!({"text":"The fillet preview vanished"})).unwrap();
for reopen in ["help", "crash"] {
h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("issue_report_steps")));
h.frames(1);
if reopen == "help" {
h.call("ui.help", json!({"item":"report"}));
} else {
begin_crash(&mut h.app, &h.ctx, &json!({"kind":"command_panic","message":"boom"}));
}
h.frames(2);
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert_eq!(draft.description, "The fillet preview vanished", "{reopen}");
assert!(draft.image.is_some() && !pending(&h.app), "{reopen}: the draft stays as it was, screenshot included");
assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("issue_report_body")), "{reopen}: and is brought into view");
}
}
/// Close draft and the header ✕ keep what was typed: the next draft offers it back, until it
/// is taken or that draft gets answers of its own (#7189).
#[test]
fn issue_report_closed_answers_are_offered_to_the_next_draft() {
let open = |h: &mut crate::scenario::Harness| {
h.call("ui.help", json!({"item":"report"}));
let token = h.app.issue_report.pending.as_ref().unwrap().token;
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(4);
};
for close in [json!({"widget":"Close draft"}), json!({"click":{"handle":"dialog:close"}})] {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
open(&mut h);
assert!(h.widget("Restore what you typed before").is_none(), "nothing to restore yet");
h.step(&json!({"text":"The fillet preview vanished"})).unwrap();
h.ctx.memory_mut(|m| m.request_focus(egui::Id::new("issue_report_steps")));
h.frames(1);
h.step(&json!({"text":"Fillet the top edge"})).unwrap();
h.step(&close).unwrap();
assert!(h.app.issue_report.draft.is_none(), "{close}");
open(&mut h);
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert!(draft.description.is_empty() && draft.steps.is_empty(), "a new draft starts empty");
h.step(&json!({"widget":"Restore what you typed before"})).unwrap();
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert_eq!([draft.description.as_str(), draft.steps.as_str()], ["The fillet preview vanished", "Fillet the top edge"], "{close}");
assert!(h.widget("Restore what you typed before").is_none(), "the offer is gone once used");
// Restored answers are typed answers: closing keeps them again, until the next draft
// gets answers of its own.
h.step(&close).unwrap();
open(&mut h);
assert!(h.widget("Restore what you typed before").is_some());
h.step(&json!({"text":"Another problem"})).unwrap();
h.frames(1);
assert!(h.widget("Restore what you typed before").is_none(), "typing in the new draft drops the offer");
h.step(&close).unwrap();
open(&mut h);
h.step(&json!({"widget":"Restore what you typed before"})).unwrap();
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert_eq!([draft.description.as_str(), draft.steps.as_str()], ["Another problem", ""]);
}
}
/// A kept draft says how to report the new problem a crash brings. Once it went to GitHub it
/// is neither kept nor offered back: the issue has its text (#7189).
#[test]
fn issue_report_draft_handed_to_github_gives_way() {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
h.call("ui.help", json!({"item":"report"}));
let token = h.app.issue_report.pending.as_ref().unwrap().token;
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(4);
h.step(&json!({"text":"The fillet preview vanished"})).unwrap();
let crash = json!({"kind":"command_panic","message":"boom"});
begin_crash(&mut h.app, &h.ctx, &crash);
h.frames(2);
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert_eq!(draft.description, "The fillet preview vanished");
assert_eq!(draft.note, "Close this draft to report the new problem.");
assert!(h.widget("Close this draft to report the new problem.").is_some());
click_commands(&mut h, "Continue on GitHub");
assert!(h.app.issue_report.draft.as_ref().unwrap().opened_github);
begin_crash(&mut h.app, &h.ctx, &crash);
h.frames(2);
assert_ne!(h.app.issue_report.draft.as_ref().unwrap().description, "The fillet preview vanished", "the crash gets its own draft");
// Closed after GitHub has it, nothing is offered to the next draft.
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
h.call("ui.help", json!({"item":"report"}));
let token = h.app.issue_report.pending.as_ref().unwrap().token;
receive(&mut h.app, token, Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
h.frames(4);
h.step(&json!({"text":"The fillet preview vanished"})).unwrap();
click_commands(&mut h, "Continue on GitHub");
h.step(&json!({"widget":"Close draft"})).unwrap();
assert!(h.app.issue_report.draft.is_none() && h.app.issue_report.earlier.is_none());
h.call("ui.help", json!({"item":"report"}));
h.frames(4);
assert!(h.widget("Restore what you typed before").is_none());
}
#[test]
fn issue_report_selected_and_recent_sketch_geometry_is_not_exported() {
let mut app = app();
+16
View File
@@ -83,6 +83,21 @@ fn screenshot(app: &mut SolveApp, draft: &mut Draft, ui: &mut Ui) -> bool {
retake
}
/// Offers back what was typed into the last draft closed with answers, until it is taken or
/// this draft gets answers of its own (#7189).
fn restore(app: &mut SolveApp, draft: &mut Draft, ui: &mut Ui) {
let Some(earlier) = app.issue_report.earlier.as_ref() else { return };
if draft.typed() {
app.issue_report.earlier = None;
} else if draft.restorable(earlier)
&& ui_kit::button(ui, tr_label("Restore what you typed before"), ui_kit::Button::Normal).clicked()
&& let Some(earlier) = app.issue_report.earlier.take()
{
draft.restore(earlier);
draft.opened_github = false;
}
}
/// Returns whether to retake the screenshot and whether the user closed the form.
pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -> (bool, bool) {
let mut retake = false;
@@ -147,6 +162,7 @@ pub(super) fn show(app: &mut SolveApp, draft: &mut Draft, ctx: &egui::Context) -
draft.opened_github = false;
}
super::truncate(&mut draft.title, 160);
restore(app, draft, ui);
let response = answer(ui, "What happened?", "Describe the problem you saw", &mut draft.description, "issue_report_body", 3);
if response.changed() {
draft.opened_github = false;