Bug report: clarify the form and retain margins on resize (#2244) (#2246)

* claim: #2244

* fix(ui): guide bug reports with a bounded, labelled form

* fix(ui): export bug reports after processing current-frame edits

---------

Co-authored-by: bherbruck <brennen.herbruck@gmail.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
takuto-NA
2026-10-21 21:49:11 +00:00
committed by GitHub
parent c54b711345
commit 4ab3a85323
6 changed files with 520 additions and 147 deletions
+19
View File
@@ -28,6 +28,7 @@
"Also deletes": "Also deletes",
"Angle 2": "Angle 2",
"Animate": "Animate",
"App/system information and command settings are included. Review private details before sharing.": "App/system information and command settings are included. Review private details before sharing.",
"Appearance name": "Appearance name",
"Applied Radius": "Applied Radius",
"Apply To": "Apply To",
@@ -83,6 +84,7 @@
"Contact": "Contact",
"Contact Sets": "Contact Sets",
"Contact sets": "Contact sets",
"Continue on GitHub": "Continue on GitHub",
"Continuity": "Continuity",
"Copy Error Message": "Copy Error Message",
"Copy Warning Message": "Copy Warning Message",
@@ -111,6 +113,8 @@
"Delete the set": "Delete the set",
"Density": "Density",
"Dependents": "Dependents",
"Describe the problem you saw": "Describe the problem you saw",
"Describe what happened before continuing.": "Describe what happened before continuing.",
"Designs you open or save appear here.": "Designs you open or save appear here.",
"Determined by To Object. Choose Angle to edit the angular extent.": "Determined by To Object. Choose Angle to edit the angular extent.",
"Direction": "Direction",
@@ -128,6 +132,7 @@
"Enabled": "Enabled",
"End bulge": "End bulge",
"End continuity": "End continuity",
"Expected result (optional)": "Expected result (optional)",
"Explode": "Explode",
"Explode Text": "Explode Text",
"Export Animation…": "Export Animation…",
@@ -245,6 +250,8 @@
"Open GitHub draft": "Open GitHub draft",
"Open local libraries in the desktop app. You can export this design's library here.": "Open local libraries in the desktop app. You can export this design's library here.",
"Open-source parametric 3D CAD in Rust. Licensed MIT OR Apache-2.0.": "Open-source parametric 3D CAD in Rust. Licensed MIT OR Apache-2.0.",
"Opens your browser and copies the report text for you to paste into GitHub.": "Opens your browser and copies the report text for you to paste into GitHub.",
"Opens your browser. Review and submit your report on GitHub.": "Opens your browser. Review and submit your report on GitHub.",
"Operator": "Operator",
"Other side": "Other side",
"Other surface (mutual trim)": "Other surface (mutual trim)",
@@ -294,6 +301,8 @@
"Remove the track": "Remove the track",
"Remove this point": "Remove this point",
"Report a bug — review a screenshot and open a GitHub draft": "Report a bug — review a screenshot and open a GitHub draft",
"Report text copied. Paste it into GitHub and submit your report there.": "Report text copied. Paste it into GitHub and submit your report there.",
"Reports are public. A GitHub account is required.": "Reports are public. A GitHub account is required.",
"Reset Toolbar": "Reset Toolbar",
"Resize Part": "Resize Part",
"Restore View": "Restore View",
@@ -308,6 +317,7 @@
"Revert Pos.": "Revert Pos.",
"Revert Position": "Revert Position",
"Review the report and screenshot before opening GitHub.": "Review the report and screenshot before opening GitHub.",
"Review your report on GitHub and click Submit new issue to publish it.": "Review your report on GitHub and click Submit new issue to publish it.",
"Rim Edge": "Rim Edge",
"Roll History Marker Here": "Roll History Marker Here",
"Round": "Round",
@@ -318,10 +328,12 @@
"SURFACE QUALITY": "SURFACE QUALITY",
"Save Rule": "Save Rule",
"Save View": "Save View",
"Save screenshot…": "Save screenshot…",
"Save the study as an animated GIF, seen as the viewport shows it": "Save the study as an animated GIF, seen as the viewport shows it",
"Saved preview. Geometry is being checked before editing.": "Saved preview. Geometry is being checked before editing.",
"Scale factor": "Scale factor",
"Scene": "Scene",
"Screenshot (optional)": "Screenshot (optional)",
"Search": "Search",
"Search commands": "Search commands",
"Search this library": "Search this library",
@@ -356,10 +368,12 @@
"Start continuity": "Start continuity",
"Step": "Step",
"Steps": "Steps",
"Steps to reproduce (optional)": "Steps to reproduce (optional)",
"Stitch the kept pieces": "Stitch the kept pieces",
"Stitch to both bodies": "Stitch to both bodies",
"Study": "Study",
"Style": "Style",
"Summary": "Summary",
"Suppressed": "Suppressed",
"Surface": "Surface",
"Swap Ends": "Swap Ends",
@@ -368,6 +382,7 @@
"Tangent Chain": "Tangent Chain",
"Tap drill diameter": "Tap drill diameter",
"Tear": "Tear",
"Technical details": "Technical details",
"The dashed sketch is a saved plane guide. Select a new face to repair the attachment.": "The dashed sketch is a saved plane guide. Select a new face to repair the attachment.",
"The saved author occurrence is missing. Select a valid author placement before rebinding.": "The saved author occurrence is missing. Select a valid author placement before rebinding.",
"Then": "Then",
@@ -379,6 +394,7 @@
"This child is shared. Deleting it removes it from every copy of its parent.": "This child is shared. Deleting it removes it from every copy of its parent.",
"This child is shared. Position changes apply to every copy of its parent.": "This child is shared. Position changes apply to every copy of its parent.",
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.",
"This image is not attached to GitHub yet. Copy or save it, then attach it on GitHub.": "This image is not attached to GitHub yet. Copy or save it, then attach it on GitHub.",
"To Offset": "To Offset",
"To edges": "To edges",
"Tolerance": "Tolerance",
@@ -404,6 +420,9 @@
"Wall": "Wall",
"Wall Location": "Wall Location",
"Wall Thickness": "Wall Thickness",
"What did you do just before the problem? A short list is enough": "What did you do just before the problem? A short list is enough",
"What did you expect to see?": "What did you expect to see?",
"What happened?": "What happened?",
"When": "When",
"Width": "Width",
"Will fail": "Will fail",
+19
View File
@@ -28,6 +28,7 @@
"Also deletes": "同時に削除される要素:",
"Angle 2": "角度 2",
"Animate": "アニメーション",
"App/system information and command settings are included. Review private details before sharing.": "アプリ・システム情報とコマンド設定が含まれます。共有前に非公開の情報を確認してください。",
"Appearance name": "外観名",
"Applied Radius": "適用半径",
"Apply To": "適用先",
@@ -83,6 +84,7 @@
"Contact": "接触",
"Contact Sets": "接触セット",
"Contact sets": "接触セット",
"Continue on GitHub": "GitHubで続ける",
"Continuity": "連続性",
"Copy Error Message": "エラーメッセージをコピー",
"Copy Warning Message": "警告メッセージをコピー",
@@ -111,6 +113,8 @@
"Delete the set": "セットを削除",
"Density": "密度",
"Dependents": "依存先",
"Describe the problem you saw": "発生した問題を説明してください",
"Describe what happened before continuing.": "続ける前に、何が起きたか記入してください。",
"Designs you open or save appear here.": "開いたデザインや保存したデザインがここに表示されます。",
"Determined by To Object. Choose Angle to edit the angular extent.": "「対象オブジェクトまで」により決定されます。角度範囲を編集するには「角度」を選択してください。",
"Direction": "方向",
@@ -128,6 +132,7 @@
"Enabled": "有効",
"End bulge": "終了側の膨らみ",
"End continuity": "終了側の連続性",
"Expected result (optional)": "期待した結果(任意)",
"Explode": "分解",
"Explode Text": "テキストを分解",
"Export Animation…": "アニメーションをエクスポート…",
@@ -245,6 +250,8 @@
"Open GitHub draft": "GitHubの下書きを開く",
"Open local libraries in the desktop app. You can export this design's library here.": "ローカルライブラリはデスクトップアプリで開いてください。このデザインのライブラリはここで書き出せます。",
"Open-source parametric 3D CAD in Rust. Licensed MIT OR Apache-2.0.": "Rust製オープンソース・パラメトリック3D CAD。ライセンス: MIT または Apache-2.0。",
"Opens your browser and copies the report text for you to paste into GitHub.": "ブラウザーを開き、GitHubに貼り付ける報告本文をコピーします。",
"Opens your browser. Review and submit your report on GitHub.": "ブラウザーを開きます。GitHubで内容を確認して投稿してください。",
"Operator": "演算子",
"Other side": "反対側",
"Other surface (mutual trim)": "相手のサーフェス(相互トリム)",
@@ -294,6 +301,8 @@
"Remove the track": "トラックを削除",
"Remove this point": "この点を削除",
"Report a bug — review a screenshot and open a GitHub draft": "バグを報告 — スクリーンショットを確認してGitHub下書きを作成",
"Report text copied. Paste it into GitHub and submit your report there.": "報告本文をコピーしました。GitHubに貼り付けて投稿してください。",
"Reports are public. A GitHub account is required.": "報告は公開されます。GitHubアカウントが必要です。",
"Reset Toolbar": "ツールバーをリセット",
"Resize Part": "部品サイズ変更",
"Restore View": "ビューを復元",
@@ -308,6 +317,7 @@
"Revert Pos.": "位置を復元",
"Revert Position": "位置を元に戻す",
"Review the report and screenshot before opening GitHub.": "GitHubを開く前にレポートとスクリーンショットを確認してください。",
"Review your report on GitHub and click Submit new issue to publish it.": "GitHubで内容を確認し、Submit new issueをクリックすると公開されます。",
"Rim Edge": "リムエッジ",
"Roll History Marker Here": "履歴マーカーをここに移動",
"Round": "丸め",
@@ -318,10 +328,12 @@
"SURFACE QUALITY": "サーフェス品質",
"Save Rule": "ルールを保存",
"Save View": "ビューを保存",
"Save screenshot…": "スクリーンショットを保存…",
"Save the study as an animated GIF, seen as the viewport shows it": "ビューポートの表示どおりにスタディをアニメーション GIF として保存",
"Saved preview. Geometry is being checked before editing.": "保存済みのプレビューです。編集前にジオメトリを検証しています。",
"Scale factor": "尺度係数",
"Scene": "シーン",
"Screenshot (optional)": "スクリーンショット(任意)",
"Search": "検索",
"Search commands": "コマンドを検索",
"Search this library": "このライブラリを検索",
@@ -356,10 +368,12 @@
"Start continuity": "開始側の連続性",
"Step": "ステップ",
"Steps": "ステップ数",
"Steps to reproduce (optional)": "再現手順(任意)",
"Stitch the kept pieces": "残した部分をステッチ",
"Stitch to both bodies": "両方のボディにステッチ",
"Study": "スタディ",
"Style": "スタイル",
"Summary": "概要",
"Suppressed": "抑制",
"Surface": "サーフェス",
"Swap Ends": "端点を入れ替え",
@@ -368,6 +382,7 @@
"Tangent Chain": "正接チェーン",
"Tap drill diameter": "タップ下穴径",
"Tear": "引き裂き",
"Technical details": "技術情報",
"The dashed sketch is a saved plane guide. Select a new face to repair the attachment.": "破線のスケッチは保存された平面ガイドです。新しい面を選択してアタッチメントを修復してください。",
"The saved author occurrence is missing. Select a valid author placement before rebinding.": "保存された作成元のオカレンスが見つかりません。再バインドする前に有効な作成元配置を選択してください。",
"Then": "次を実行 (Then)",
@@ -379,6 +394,7 @@
"This child is shared. Deleting it removes it from every copy of its parent.": "この子要素は共有されています。削除すると親のすべてのコピーから削除されます。",
"This child is shared. Position changes apply to every copy of its parent.": "この子要素は共有されています。位置の変更は親のすべてのコピーに適用されます。",
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "この面は安定したアタッチメントを提供できません。別の面を選択するか、固定平面を明示的に使用してください。",
"This image is not attached to GitHub yet. Copy or save it, then attach it on GitHub.": "この画像はまだGitHubに添付されていません。コピーまたは保存し、GitHubで添付してください。",
"To Offset": "オフセットまで",
"To edges": "終了側エッジ",
"Tolerance": "公差",
@@ -404,6 +420,9 @@
"Wall": "肉厚",
"Wall Location": "壁の位置",
"Wall Thickness": "壁の厚さ",
"What did you do just before the problem? A short list is enough": "問題の直前に行った操作を簡単に記入してください",
"What did you expect to see?": "どのような結果を期待していましたか?",
"What happened?": "何が起きましたか?",
"When": "条件 (When)",
"Width": "幅",
"Will fail": "失敗します",
+19
View File
@@ -28,6 +28,7 @@
"Also deletes": "同时删除",
"Angle 2": "角度 2",
"Animate": "动画",
"App/system information and command settings are included. Review private details before sharing.": "报告包含应用和系统信息以及命令设置。共享前请检查私人信息。",
"Appearance name": "外观名称",
"Applied Radius": "应用半径",
"Apply To": "应用于",
@@ -83,6 +84,7 @@
"Contact": "接触",
"Contact Sets": "接触集",
"Contact sets": "接触集",
"Continue on GitHub": "在GitHub中继续",
"Continuity": "连续性",
"Copy Error Message": "复制错误消息",
"Copy Warning Message": "复制警告消息",
@@ -111,6 +113,8 @@
"Delete the set": "删除此集合",
"Density": "密度",
"Dependents": "依赖项",
"Describe the problem you saw": "请描述您遇到的问题",
"Describe what happened before continuing.": "继续之前,请描述发生了什么。",
"Designs you open or save appear here.": "你打开或保存的设计会显示在此处。",
"Determined by To Object. Choose Angle to edit the angular extent.": "由“到对象”确定。选择“角度”可编辑角度范围。",
"Direction": "方向",
@@ -128,6 +132,7 @@
"Enabled": "已启用",
"End bulge": "终止鼓度",
"End continuity": "终止连续性",
"Expected result (optional)": "预期结果(可选)",
"Explode": "爆炸",
"Explode Text": "分解文字",
"Export Animation…": "导出动画…",
@@ -245,6 +250,8 @@
"Open GitHub draft": "打开 GitHub 草稿",
"Open local libraries in the desktop app. You can export this design's library here.": "请在桌面应用中打开本地库。您可以在此导出当前设计的库。",
"Open-source parametric 3D CAD in Rust. Licensed MIT OR Apache-2.0.": "使用 Rust 编写的开源参数化 3D CAD。基于 MIT OR Apache-2.0 许可。",
"Opens your browser and copies the report text for you to paste into GitHub.": "打开浏览器,并复制报告文本以便粘贴到GitHub。",
"Opens your browser. Review and submit your report on GitHub.": "打开浏览器。请在GitHub中检查并提交报告。",
"Operator": "运算符",
"Other side": "另一侧",
"Other surface (mutual trim)": "另一曲面(相互修剪)",
@@ -294,6 +301,8 @@
"Remove the track": "移除轨迹",
"Remove this point": "移除此点",
"Report a bug — review a screenshot and open a GitHub draft": "报告缺陷 — 复核截图并开启 GitHub 草稿",
"Report text copied. Paste it into GitHub and submit your report there.": "报告文本已复制。请在GitHub中粘贴并提交。",
"Reports are public. A GitHub account is required.": "报告将公开发布。您需要GitHub账户。",
"Reset Toolbar": "重置工具栏",
"Resize Part": "调整零件大小",
"Restore View": "恢复视图",
@@ -308,6 +317,7 @@
"Revert Pos.": "还原位置",
"Revert Position": "恢复位置",
"Review the report and screenshot before opening GitHub.": "打开 GitHub 前请审阅报告和截图。",
"Review your report on GitHub and click Submit new issue to publish it.": "请在GitHub中检查报告,然后点击Submit new issue发布。",
"Rim Edge": "轮缘边",
"Roll History Marker Here": "将历史标记滚动到此处",
"Round": "圆角",
@@ -318,10 +328,12 @@
"SURFACE QUALITY": "曲面质量",
"Save Rule": "保存规则",
"Save View": "保存视图",
"Save screenshot…": "保存屏幕截图…",
"Save the study as an animated GIF, seen as the viewport shows it": "按视口中的显示将研究保存为动画 GIF",
"Saved preview. Geometry is being checked before editing.": "已保存预览。编辑前正在检查几何。",
"Scale factor": "比例因子",
"Scene": "场景",
"Screenshot (optional)": "屏幕截图(可选)",
"Search": "搜索",
"Search commands": "搜索命令",
"Search this library": "搜索此库",
@@ -356,10 +368,12 @@
"Start continuity": "起始连续性",
"Step": "步骤",
"Steps": "步数",
"Steps to reproduce (optional)": "重现步骤(可选)",
"Stitch the kept pieces": "缝合保留的部分",
"Stitch to both bodies": "缝合到两个实体",
"Study": "研究",
"Style": "样式",
"Summary": "摘要",
"Suppressed": "已抑制",
"Surface": "曲面",
"Swap Ends": "交换端点",
@@ -368,6 +382,7 @@
"Tangent Chain": "相切链",
"Tap drill diameter": "攻丝底孔直径",
"Tear": "撕裂",
"Technical details": "技术详情",
"The dashed sketch is a saved plane guide. Select a new face to repair the attachment.": "虚线草图是已保存的平面引导。选择一个新面以修复附着。",
"The saved author occurrence is missing. Select a valid author placement before rebinding.": "保存的作者实例缺失。重新绑定前请选择有效的作者放置。",
"Then": "操作",
@@ -379,6 +394,7 @@
"This child is shared. Deleting it removes it from every copy of its parent.": "此子项是共享的。删除它会从其父项的每个副本中移除。",
"This child is shared. Position changes apply to every copy of its parent.": "此子项是共享的。位置更改会应用到其父项的每个副本。",
"This face cannot provide a durable attachment. Choose another face or explicitly use a fixed plane.": "此面无法提供持久附着。请选择其他面或显式使用固定平面。",
"This image is not attached to GitHub yet. Copy or save it, then attach it on GitHub.": "此图片尚未附加到GitHub。请复制或保存图片,然后在GitHub中附加。",
"To Offset": "偏移",
"To edges": "终止边",
"Tolerance": "公差",
@@ -404,6 +420,9 @@
"Wall": "壁厚",
"Wall Location": "壁位置",
"Wall Thickness": "壁厚度",
"What did you do just before the problem? A short list is enough": "问题发生前您进行了哪些操作?简要列出即可",
"What did you expect to see?": "您期望看到什么结果?",
"What happened?": "发生了什么?",
"When": "条件",
"Width": "宽度",
"Will fail": "将失败",
+247 -147
View File
@@ -4,11 +4,16 @@ use std::fmt::Write as _;
use std::hash::{Hash, Hasher};
use std::sync::Arc;
use egui::{ColorImage, TextureHandle, vec2};
use egui::{ColorImage, TextureHandle};
use crate::{SolveApp, dialogs, help, ui_kit};
use crate::{SolveApp, dialogs, help};
mod form;
const MAX_ANSWER: usize = 2000;
const MAX_BODY: usize = 24_000;
// Room for all three answers and the original bounded diagnostic context.
const MAX_REPORT: usize = 32_000;
const MAX_IMAGE_PIXELS: usize = 16_000_000;
const ISSUE_URL: &str = "https://github.com/tangency-labs/solidcraft/issues/new";
@@ -96,11 +101,64 @@ pub struct ReportState {
pub struct Draft {
pub title: String,
/// Collected technical context, separately reviewable and editable.
pub body: String,
description: String,
steps: String,
expected: String,
image: Option<Arc<ColorImage>>,
texture: Option<TextureHandle>,
pub note: String,
source_signature: u64,
focus_requested: bool,
missing_description: bool,
opened_github: bool,
}
impl Draft {
fn new(title: String, body: String, source_signature: u64) -> Self {
Self {
title,
body,
description: String::new(),
steps: String::new(),
expected: String::new(),
image: None,
texture: None,
note: String::new(),
source_signature,
focus_requested: false,
missing_description: false,
opened_github: false,
}
}
fn report_title(&self) -> String {
if self.title.trim().is_empty() {
limited(self.description.trim().lines().next().unwrap_or_default(), 160)
} else {
limited(&self.title, 160)
}
}
fn report_body(&self) -> String {
let answer = |text: &str| if text.trim().is_empty() { "Not provided".to_string() } else { limited(text, MAX_ANSWER) };
let mut report = format!(
"## Actual behavior\n{}\n\n## Reproduction\n{}\n\n## Expected behavior\n{}\n\n",
answer(&self.description),
answer(&self.steps),
answer(&self.expected)
);
let room = MAX_REPORT.saturating_sub(report.len());
if self.body.len() <= room {
report.push_str(&self.body);
} else {
let marker = "\n[technical details truncated]\n";
report.push_str(&limited(&self.body, room.saturating_sub(marker.len())));
report.push_str(marker);
}
report
}
}
struct Pending {
@@ -270,14 +328,14 @@ pub fn draft_for(app: &SolveApp, dialog: Option<&dialogs::Dialog>, error: Option
context.push_str(&format!("Feature error: {}\n", debug(&e, 1000)));
}
}
let actual = error.map(|e| debug(&e, 4000)).unwrap_or_else(|| "Describe the unexpected result shown in the view.".into());
let actual = error.map(|e| debug(&e, 4000)).unwrap_or_else(|| "No command error was recorded.".into());
let image_state = if error.is_some() {
"A failed preview may display the last valid geometry; that geometry is not evidence that the failed operation succeeded."
} else {
"Describe what looks wrong in the current result."
"The screenshot shows the current view."
};
let mut body = format!(
"## Expected behavior\nDescribe the intended result.\n\n## Actual behavior\n{actual}\n\n{image_state}\n\n## Reproduction\nDescribe the steps or a small public-safe example.\n\n## Settings and selection\n{context}\n## Environment\n{}\nRevision: {}\nCamera: {}\n\n## Visual context\nAttach the reviewed screenshot or a short example showing the problem.\n",
"## Operation context\n{actual}\n\n{image_state}\n\n## Settings and selection\n{context}\n## Environment\n{}\nRevision: {}\nCamera: {}\n\n## Visual context\nAttach the reviewed screenshot or a short example showing the problem.\n",
block(&debug(&help::diagnostics(app), 2000)),
app.session.revision,
block(&debug(&app.cam, 1500))
@@ -288,7 +346,7 @@ pub fn draft_for(app: &SolveApp, dialog: Option<&dialogs::Dialog>, error: Option
}
let mut title = format!("{label}: {}", if error.is_some() { "operation failed" } else { "unexpected result" });
truncate(&mut title, 160);
Draft { title, body, image: None, texture: None, note: String::new(), source_signature: source_signature(app, dialog) }
Draft::new(title, body, source_signature(app, dialog))
}
/// A draft from a crash report (`solidcraft_engine::crash`): what happened, where, the command
@@ -357,7 +415,10 @@ pub fn crash_draft(report: &serde_json::Value) -> Draft {
}
let mut title = format!("Crash: {}", s("message").lines().next().unwrap_or_default());
truncate(&mut title, 160);
Draft { title, body, image: None, texture: None, note: String::new(), source_signature: 0 }
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
}
/// Open a reviewed draft for a crash report (no screenshot: the view shows nothing of it).
@@ -509,122 +570,8 @@ pub fn show(app: &mut SolveApp, ctx: &egui::Context) {
return;
}
let Some(mut draft) = app.issue_report.draft.take() else { return };
let mut retake = false;
let t = crate::theme::Tokens::get();
let screen = ctx.content_rect();
let cards = ((screen.width() - 2.0 * t.space_16) / t.form_card_width).clamp(0.5, 2.6);
// The card's own header, footer and margins come on top of the scrolling body.
let chrome = ui_kit::header_height() + t.form_footer_height + 6.0 * t.space_8;
let scroll = (screen.height() - 2.0 * t.space_16 - chrome).clamp(60.0, 640.0);
let mut link = None;
let (closed, action) = ui_kit::Window::new(egui::Id::new("sc_issue_report"), "bug_report", crate::i18n::tr_label("Create Issue — review draft"))
.cards(cards)
.fields()
.keep_open_on_escape()
.actions(crate::i18n::tr_label("Open GitHub draft"), crate::i18n::tr_label("Close draft"), Some(crate::i18n::tr_label("Copy report")))
.show(ctx, true, |ui| {
// Only the review scrolls: the submission actions stay in the footer even when a
// screenshot or a long report needs more room.
egui::ScrollArea::vertical().id_salt("issue-report-review").max_height(scroll).auto_shrink([false, true]).show(ui, |ui| {
ui_kit::text(
ui,
crate::i18n::tr_label("Review the report and screenshot before opening GitHub."),
ui_kit::Text::Report("review", false),
);
ui.horizontal_wrapped(|ui| {
retake = ui_kit::button(ui, crate::i18n::tr_label("Retake screenshot"), ui_kit::Button::Normal).clicked();
if ui_kit::button(ui, "Copy screenshot", ui_kit::Button::Enabled(draft.image.is_some())).clicked()
&& let Some(image) = draft.image.as_ref()
{
ctx.copy_image((**image).clone());
draft.note = crate::i18n::tr("issue.note_image_copied").into();
}
if ui_kit::button(
ui,
crate::i18n::tr("issue.save_screenshot"),
ui_kit::Button::Enabled(draft.image.is_some() && app.services.pick_save.is_some()),
)
.clicked()
&& let Some(image) = draft.image.clone()
{
app.pick_save(&format!("solidcraft-issue-{}.png", app.shot_token), &["png"], move |app, path| {
let Some(path) = path else { return };
let result = crate::control::save_screenshot(&image, Some(&path));
if let Some(draft) = app.issue_report.draft.as_mut() {
draft.note = if result.get("ok").and_then(serde_json::Value::as_bool) == Some(true) {
crate::i18n::tr("issue.note_saved").into()
} else {
crate::i18n::format("issue.note_save_failed", &[("error", &debug(&result.get("error"), 1000))])
};
}
});
}
if ui_kit::button(ui, "Remove screenshot", ui_kit::Button::Enabled(draft.image.is_some())).clicked() {
draft.image = None;
draft.texture = None;
draft.note = crate::i18n::tr("issue.note_removed").into();
}
});
ui_kit::cell_editor(ui, egui::Id::new("issue_report_title"), &mut draft.title, "Issue title", false);
egui::ScrollArea::vertical().id_salt("issue-report-body").max_height((screen.height() * 0.35).clamp(72.0, 240.0)).show(ui, |ui| {
ui_kit::text_area(ui, crate::i18n::tr("issue.body_label"), egui::Id::new("issue_report_body"), &mut draft.body, 5, MAX_BODY);
});
truncate(&mut draft.title, 160);
truncate(&mut draft.body, MAX_BODY);
ui_kit::text(ui, crate::i18n::tr_label("Remove private design details or paths before sharing."), ui_kit::Text::Note("private"));
if !draft.note.is_empty() {
ui_kit::text(ui, &draft.note, ui_kit::Text::Note("note"));
}
if let Some(image) = draft.image.as_ref() {
let texture =
draft.texture.get_or_insert_with(|| ctx.load_texture("issue-report-frame", image.clone(), egui::TextureOptions::LINEAR));
ui.add(
egui::Image::new(&*texture)
.max_size(vec2(ui.available_width(), (screen.height() * 0.25).clamp(60.0, 220.0)))
.maintain_aspect_ratio(true),
);
}
ui_kit::divider(ui, "send");
ui_kit::text(ui, crate::i18n::tr_label("Send your report on GitHub"), ui_kit::Text::Report("send", false));
let (url, copy_needed) = draft_url(&draft.title, &draft.body);
link = Some((url, copy_needed));
ui_kit::text(
ui,
crate::i18n::tr_label(if copy_needed {
"1. Open GitHub draft below, then paste the report copied to your clipboard."
} else {
"1. Open GitHub draft below. Your title and report will be filled in."
}),
ui_kit::Text::Report("step1", false),
);
ui_kit::text(
ui,
crate::i18n::tr_label("2. Attach your screenshot: copy and paste it, or save and upload the PNG."),
ui_kit::Text::Report("step2", false),
);
ui_kit::text(
ui,
crate::i18n::tr_label("3. Click Submit new issue on GitHub to send your report."),
ui_kit::Text::Report("step3", false),
);
});
});
let open = !(closed || action == ui_kit::Action::Cancel);
match (action, link) {
(ui_kit::Action::Ok, Some((url, copy_needed))) => {
if copy_needed {
ctx.copy_text(draft.body.clone());
}
ctx.open_url(egui::OpenUrl::new_tab(url));
draft.note = crate::i18n::tr(if copy_needed { "issue.note_opened_copied" } else { "issue.note_opened" }).into();
}
(ui_kit::Action::Apply, _) => {
ctx.copy_text(draft.body.clone());
draft.note = crate::i18n::tr("issue.note_report_copied").into();
}
_ => {}
}
if open {
let (retake, close) = form::show(app, &mut draft, ctx);
if !close {
app.issue_report.draft = Some(draft);
if retake {
let dialog = app.dialog.clone();
@@ -672,6 +619,137 @@ mod tests {
dialog.inputs.get_mut(1).unwrap().items = vec![Sel::Body { name: "Cutter".into() }];
}
fn click_commands(h: &mut crate::scenario::Harness, label: &str) -> Vec<egui::OutputCommand> {
let [x, y] = h.widget(label).unwrap();
assert_eq!(h.call("ui.move", json!({"x":x,"y":y}))["ok"], true);
let (request, _reply) = crate::control::ControlRequest::new("ui.click", json!({"x":x,"y":y}));
assert!(matches!(crate::control::handle(&mut h.app, &h.ctx, &request), crate::control::Outcome::Done(value) if value["ok"] == true));
let mut commands = Vec::new();
for _ in 0..12 {
h.frame();
commands.extend(h.output.commands.clone());
}
commands
}
#[test]
fn issue_report_form_separates_user_answers_from_technical_context() {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
h.app.issue_report.draft = Some(draft_for(&h.app, None, None));
h.frames(4);
for label in ["What happened?", "Steps to reproduce (optional)", "Expected result (optional)", "Technical details", "Continue on GitHub"] {
assert!(h.widget(label).is_some(), "missing report form control: {label}");
}
assert!(h.widget("Describe the intended result.").is_none(), "Markdown instructions must not be editable answers");
}
#[test]
fn issue_report_answers_preserve_the_reviewed_context_within_the_export_budget() {
let mut draft = draft_for(&app(), None, None);
draft.description = "a".repeat(MAX_ANSWER);
draft.steps = "b".repeat(MAX_ANSWER);
draft.expected = "c".repeat(MAX_ANSWER);
draft.body = format!("{}END_CONTEXT", "d".repeat(MAX_BODY - 11));
let report = draft.report_body();
assert!(report.len() <= MAX_REPORT && report.ends_with(&draft.body));
for answer in [&draft.description, &draft.steps, &draft.expected] {
assert!(report.contains(answer));
}
draft.description = "現象🚀".repeat(MAX_REPORT);
draft.body = "調査🚀".repeat(MAX_REPORT);
let bounded = draft.report_body();
assert!(bounded.len() <= MAX_REPORT && bounded.ends_with("[technical details truncated]\n"));
}
#[test]
fn issue_report_requires_an_answer_before_browser_handoff_without_changing_the_design() {
for (size, scale) in [([1600, 1000], 1.0), ([640, 480], 2.0)] {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
h.app.preferences.ui_scale = scale;
h.call("ui.resize", json!({"width":size[0],"height":size[1]}));
h.app.issue_report.draft = Some(draft_for(&h.app, None, None));
h.frames(16);
let before = (h.app.session.doc.to_json(), h.app.session.revision, h.app.session.undo.len());
let commands = click_commands(&mut h, "Continue on GitHub");
assert!(!commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(_))));
assert!(h.app.issue_report.draft.as_ref().unwrap().missing_description);
assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("issue_report_body")));
h.step(&json!({"text":"The preview disappeared"})).unwrap();
let commands = click_commands(&mut h, "Continue on GitHub");
assert!(commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(url) if url.url.starts_with(ISSUE_URL))));
assert!(h.app.issue_report.draft.as_ref().unwrap().description.contains("The preview disappeared"));
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.revision, h.app.session.undo.len()));
}
}
#[test]
fn issue_report_handoff_includes_edits_from_the_click_frame() {
for field in ["issue_report_body", "issue_report_title", "issue_report_steps", "issue_report_expected", "issue_report_technical"] {
for clipboard in [false, true] {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
let mut draft = Draft::new("Previous summary".into(), "Private diagnostic details".into(), 0);
if field != "issue_report_body" {
draft.description = "Previously reviewed problem".into();
}
if clipboard {
draft.steps = "Reproduction context. ".repeat(100);
}
h.app.issue_report.draft = Some(draft);
h.frames(16);
if field == "issue_report_technical" {
h.call("ui.scroll", json!({"x":800,"y":600,"delta":-1000}));
h.step(&json!({"widget":"Technical details"})).unwrap();
h.call("ui.scroll", json!({"x":800,"y":600,"delta":-1000}));
}
h.ctx.memory_mut(|m| m.request_focus(egui::Id::new(field)));
h.frames(1);
let [x, y] = h.widget("Continue on GitHub").unwrap();
let pos = egui::pos2(x as f32, y as f32);
let modifiers = egui::Modifiers { ctrl: true, command: true, ..Default::default() };
let raw = egui::RawInput {
screen_rect: Some(h.ctx.content_rect()),
focused: true,
events: vec![
egui::Event::Key { key: egui::Key::A, physical_key: None, pressed: true, repeat: false, modifiers },
egui::Event::Paste("Latest reviewed content".into()),
egui::Event::PointerMoved(pos),
egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: true, modifiers: Default::default() },
egui::Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed: false, modifiers: Default::default() },
],
..Default::default()
};
let app = &mut h.app;
let mut output = h.ctx.run_ui(raw, |ui| {
app.logic(ui.ctx());
app.ui(ui);
});
let draft = h.app.issue_report.draft.as_ref().unwrap();
let edited = match field {
"issue_report_body" => &draft.description,
"issue_report_title" => &draft.title,
"issue_report_steps" => &draft.steps,
"issue_report_expected" => &draft.expected,
_ => &draft.body,
};
assert_eq!(edited, "Latest reviewed content", "{field}, clipboard={clipboard}");
let body = draft.report_body();
let (url, copy_needed) = draft_url(&draft.report_title(), &body);
assert!(
output.platform_output.commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(u) if u.url == url)),
"handoff must use this frame's edits: {field}, clipboard={clipboard}"
);
if copy_needed {
assert!(output.platform_output.commands.iter().any(|c| matches!(c, egui::OutputCommand::CopyText(text) if text == &body)));
}
output.textures_delta.clear();
assert!(draft.opened_github && !draft.missing_description);
}
}
}
#[test]
fn crash_draft_marks_later_detection_without_losing_native_evidence() {
let message =
@@ -749,7 +827,7 @@ mod tests {
let ctx = crate::fonts::test_context();
help::run(&mut app, &ctx, "report");
let draft = app.issue_report.draft.as_ref().unwrap();
assert!(draft.body.contains("Describe the unexpected result"));
assert!(draft.description.is_empty(), "user answers start empty, without template instructions");
assert!(draft.body.contains(help::COMMIT));
assert!(draft.body.contains("combine") && draft.body.contains("keep_tools") && draft.body.contains("Cutter"));
assert!(pending(&app), "Help must request real evidence, not just copy generic text");
@@ -801,27 +879,49 @@ mod tests {
h.app.home.open = false;
let mut draft = draft_for(&h.app, None, None);
draft.body = "Reviewed context 🚀 &labels=private\n".repeat(120);
let reviewed = draft.body.clone();
draft.description = "The preview disappeared after clicking Extrude.".into();
draft.steps = "1. Select a face\n2. Start Extrude".into();
draft.expected = "A preview of the extrusion".into();
draft.image = Some(Arc::new(ColorImage::new([2, 2], vec![egui::Color32::GREEN; 4])));
let reviewed = draft.report_body();
h.app.issue_report.draft = Some(draft);
h.frames(4);
assert!(h.widget("1. Open GitHub draft below, then paste the report copied to your clipboard.").is_some());
assert!(h.widget("3. Click Submit new issue on GitHub to send your report.").is_some());
let [x, y] = h.widget("Open GitHub draft").unwrap();
assert_eq!(h.call("ui.move", json!({"x":x,"y":y}))["ok"], true);
let (request, _reply) = crate::control::ControlRequest::new("ui.click", json!({"x":x,"y":y}));
assert!(matches!(crate::control::handle(&mut h.app, &h.ctx, &request), crate::control::Outcome::Done(value) if value["ok"] == true));
let mut commands = Vec::new();
for _ in 0..12 {
h.frame();
commands.extend(h.output.commands.clone());
}
h.frames(16);
assert!(h.widget("Opens your browser and copies the report text for you to paste into GitHub.").is_some());
assert!(h.widget("Reports are public. A GitHub account is required.").is_some());
let commands = click_commands(&mut h, "Continue on GitHub");
assert!(commands.iter().any(|c| matches!(c, egui::OutputCommand::CopyText(text) if text == &reviewed)), "commands: {commands:?}");
assert!(
commands.iter().any(|c| matches!(c, egui::OutputCommand::OpenUrl(url) if url.url.starts_with(ISSUE_URL) && !url.url.contains("&body=")))
);
assert_eq!(h.app.issue_report.draft.as_ref().unwrap().body, reviewed);
assert!(h.app.issue_report.draft.as_ref().unwrap().note.starts_with("Report copied. Paste into the GitHub draft"));
assert!(h.app.issue_report.draft.as_ref().unwrap().note.contains("Submit new issue"));
assert_eq!(h.app.issue_report.draft.as_ref().unwrap().report_body(), reviewed);
assert!(h.app.issue_report.draft.as_ref().unwrap().opened_github);
click_commands(&mut h, "Copy screenshot");
assert!(!h.app.issue_report.draft.as_ref().unwrap().opened_github, "copying an image replaces the report text on the clipboard");
assert!(h.widget("Opens your browser and copies the report text for you to paste into GitHub.").is_some());
click_commands(&mut h, "Continue on GitHub");
click_commands(&mut h, "Remove screenshot");
assert!(h.app.issue_report.draft.as_ref().unwrap().image.is_none());
assert!(h.widget("Screenshot removed from this draft.").is_some());
assert!(h.widget("Report text copied. Paste it into GitHub and submit your report there.").is_some());
}
#[test]
fn issue_report_blank_summary_uses_the_export_title_for_clipboard_guidance() {
let mut h = crate::scenario::Harness::new();
h.app.home.open = false;
let mut draft = draft_for(&h.app, None, None);
draft.title.clear();
draft.description = "d".repeat(160);
draft.body = "x".repeat(1500);
let reviewed = draft.report_body();
assert!(!draft_url("", &reviewed).1, "the fallback title must be what crosses the URL limit");
assert!(draft_url(&draft.report_title(), &reviewed).1);
h.app.issue_report.draft = Some(draft);
h.frames(16);
assert!(h.widget("Opens your browser and copies the report text for you to paste into GitHub.").is_some());
let commands = click_commands(&mut h, "Continue on GitHub");
assert!(commands.iter().any(|c| matches!(c, egui::OutputCommand::CopyText(text) if text == &reviewed)));
assert!(h.widget("Report text copied. Paste it into GitHub and submit your report there.").is_some());
}
#[test]
@@ -843,8 +943,8 @@ mod tests {
let idle = rect(&h);
assert!((idle.width() - settled.width()).abs() < 1.0, "size={size:?}: {settled:?} grew to {idle:?}");
assert!(idle.width() <= 790.0, "report must retain its width limit: {idle:?}");
assert!(h.ctx.content_rect().contains_rect(idle), "size={size:?} scale={scale}: window must fit: {idle:?}");
for label in ["Copy screenshot", "Save screenshot…", "Open GitHub draft", "Copy report", "Close draft"] {
assert!(h.ctx.content_rect().shrink(8.0).contains_rect(idle), "size={size:?} scale={scale}: retain an outer margin: {idle:?}");
for label in ["Continue on GitHub", "Close draft"] {
let [x, y] = h.widget(label).unwrap();
assert!(idle.contains(egui::pos2(x as f32, y as f32)), "{label} must stay visible: {idle:?}, {x}, {y}");
}
@@ -873,7 +973,7 @@ mod tests {
h.ctx.memory_mut(|m| m.surrender_focus(id));
}
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert!(draft.title.contains("edited-report-marker") && draft.body.contains("edited-report-marker"));
assert!(draft.title.contains("edited-report-marker") && draft.description.contains("edited-report-marker"));
for key in [json!({"key":"Enter"}), json!({"key":"Escape"}), json!({"key":"Z","cmd":true})] {
h.step(&key).unwrap();
assert!(h.app.dialog.is_some() && h.app.issue_report.draft.is_some());
@@ -913,7 +1013,7 @@ mod tests {
assert!(h.widget("Pending CAD text").is_some(), "report keys must not apply, edit or cancel the Text editor");
}
let draft = h.app.issue_report.draft.as_ref().unwrap();
assert!(draft.title.contains("report-only-marker") && draft.body.contains("report-only-marker"));
assert!(draft.title.contains("report-only-marker") && draft.description.contains("report-only-marker"));
h.step(&json!({"widget":"Close draft"})).unwrap();
assert!(h.app.issue_report.draft.is_none());
h.frames(2);
@@ -968,7 +1068,7 @@ mod tests {
h.app.home.open = false;
h.app.run("sketch.create", json!({"plane":"XY"})).unwrap();
h.app.run("sketch.line", json!({"points":[[0,0],[20,0]],"id":"line"})).unwrap();
h.frames(3);
h.frames(16);
let at = h.call("ui.at", json!({"sketch":[0,0]}));
let p = egui::pos2(at["result"][0].as_f64().unwrap() as f32, at["result"][1].as_f64().unwrap() as f32);
h.app.synthetic.push(egui::Event::PointerMoved(p));
@@ -999,7 +1099,7 @@ mod tests {
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision));
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(3);
h.frames(16);
h.step(&json!({"widget":"Close draft"})).unwrap();
assert!(h.app.viewport.point_drag.is_none());
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision));
@@ -1034,7 +1134,7 @@ mod tests {
h.step(&json!({"key":"Escape"})).unwrap();
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.redo.len(), h.app.session.revision));
assert!(crate::dim_view::editing() && h.widget("30 mm").is_some());
assert!(h.app.issue_report.draft.as_ref().unwrap().body.contains("Typing here describes"));
assert!(h.app.issue_report.draft.as_ref().unwrap().description.contains("Typing here describes"));
h.step(&json!({"widget":"Close draft"})).unwrap();
h.frames(2);
assert_eq!(h.ctx.memory(|m| m.focused()), Some(egui::Id::new("sc_dim_edit")));
+214
View File
@@ -0,0 +1,214 @@
//! The reviewed report form. User answers stay separate from collected diagnostics.
use egui::{Id, Ui, vec2};
use super::{Draft, MAX_ANSWER, MAX_BODY, draft_url};
use crate::{SolveApp, i18n::tr_label, ui_kit};
const ALL_GUIDANCE: [&str; 4] = [
"Report text copied. Paste it into GitHub and submit your report there.",
"Review your report on GitHub and click Submit new issue to publish it.",
"Opens your browser and copies the report text for you to paste into GitHub.",
"Opens your browser. Review and submit your report on GitHub.",
];
fn answer(ui: &mut Ui, label: &str, hint: &str, text: &mut String, id: &str, rows: usize) -> egui::Response {
ui_kit::text(ui, tr_label(label), ui_kit::Text::Heading(label));
ui_kit::text(ui, tr_label(hint), ui_kit::Text::Note(hint));
let response = ui_kit::text_area(ui, tr_label(label), Id::new(id), text, rows, MAX_ANSWER);
crate::scenario::publish_handle(id, response.rect.center());
super::truncate(text, MAX_ANSWER);
response
}
fn screenshot_actions(app: &mut SolveApp, draft: &mut Draft, ui: &mut Ui) -> bool {
let mut retake = false;
ui.horizontal_wrapped(|ui| {
retake = ui_kit::button(ui, tr_label("Retake screenshot"), ui_kit::Button::Normal).clicked();
if ui_kit::button(ui, tr_label("Remove screenshot"), ui_kit::Button::Enabled(draft.image.is_some())).clicked() {
draft.image = None;
draft.texture = None;
draft.note = "Screenshot removed from this draft.".into();
}
});
if draft.image.is_some() {
ui.horizontal_wrapped(|ui| {
if ui_kit::button(ui, tr_label("Copy screenshot"), ui_kit::Button::Normal).clicked()
&& let Some(image) = draft.image.as_ref()
{
ui.ctx().copy_image((**image).clone());
draft.opened_github = false;
draft.note = "Paste the image into the GitHub draft, or save the PNG if image copying is unavailable.".into();
}
if ui_kit::button(ui, tr_label("Save screenshot…"), ui_kit::Button::Enabled(app.services.pick_save.is_some())).clicked()
&& let Some(image) = draft.image.clone()
{
app.pick_save(&format!("solidcraft-issue-{}.png", app.shot_token), &["png"], move |app, path| {
let Some(path) = path else { return };
let result = crate::control::save_screenshot(&image, Some(&path));
if let Some(draft) = app.issue_report.draft.as_mut() {
draft.note = if result.get("ok").and_then(serde_json::Value::as_bool) == Some(true) {
"Screenshot saved. Attach the PNG in the GitHub draft.".into()
} else {
format!("Could not save screenshot: {}", super::debug(&result.get("error"), 1000))
};
}
});
}
});
}
if !draft.note.is_empty() {
ui_kit::text(ui, tr_label(&draft.note), ui_kit::Text::Note("note"));
}
retake
}
fn screenshot(app: &mut SolveApp, draft: &mut Draft, ui: &mut Ui) -> bool {
ui_kit::text(ui, tr_label("Screenshot (optional)"), ui_kit::Text::Heading("Screenshot (optional)"));
let preview = draft.image.as_ref().map(|image| {
draft.texture.get_or_insert_with(|| ui.ctx().load_texture("issue-report-frame", image.clone(), egui::TextureOptions::LINEAR)).clone()
});
let mut retake = false;
let guidance = |ui: &mut Ui| {
ui_kit::text(
ui,
tr_label("This image is not attached to GitHub yet. Copy or save it, then attach it on GitHub."),
ui_kit::Text::Note("screenshot"),
);
};
if let Some(texture) = preview {
ui.add(egui::Image::new(&texture).max_size(vec2(ui.available_width(), 130.0)).maintain_aspect_ratio(true));
guidance(ui);
}
retake |= screenshot_actions(app, draft, ui);
retake
}
/// 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;
let t = crate::theme::Tokens::get();
let screen = ctx.content_rect();
let cards = ((screen.width() - 2.0 * t.space_16) / t.form_card_width).clamp(0.5, 2.6);
let (closed, action) = ui_kit::Window::new(Id::new("sc_issue_report"), "bug_report", tr_label("Report a bug"))
.cards(cards)
.anchor(egui::Align2::CENTER_TOP, vec2(0.0, t.space_16))
.fields()
.keep_open_on_escape()
.actions(tr_label("Continue on GitHub"), tr_label("Close draft"), Some(tr_label("Copy report")))
.show(ctx, true, |ui| {
// The card's own header, footer and margins come on top of the scrolling body.
let chrome = ui_kit::header_height() + t.form_footer_height + 6.0 * t.space_8;
let scroll = (screen.height() - 2.0 * t.space_16 - chrome).clamp(60.0, 640.0);
// Sized outright, not from what is left: a card that fits its content grows frame by
// frame otherwise, and the footer moves under a click.
ui.allocate_ui(vec2(ui.available_width(), scroll), |ui| {
egui::ScrollArea::vertical()
.id_salt("issue-report-review")
.max_height(scroll)
.min_scrolled_height(scroll)
.auto_shrink([false, false])
.show(ui, |ui| {
let body = draft.report_body();
let (_, copy_needed) = draft_url(&draft.report_title(), &body);
let guidance = if draft.opened_github {
if copy_needed {
"Report text copied. Paste it into GitHub and submit your report there."
} else {
"Review your report on GitHub and click Submit new issue to publish it."
}
} else if copy_needed {
"Opens your browser and copies the report text for you to paste into GitHub."
} else {
"Opens your browser. Review and submit your report on GitHub."
};
// Reserve the tallest wording, so the card (and its footer) keeps its height as the
// guidance changes under a click.
let width = ui.available_width();
let font = egui::FontId::proportional(t.font_small);
let tallest = ALL_GUIDANCE
.iter()
.map(|g| ui.painter().layout(tr_label(g).to_string(), font.clone(), t.form_dim, width).size().y)
.fold(0.0_f32, f32::max);
ui.allocate_ui(vec2(width, tallest), |ui| {
ui_kit::text(ui, tr_label(guidance), ui_kit::Text::Note("guidance"));
});
ui_kit::text(ui, tr_label("Reports are public. A GitHub account is required."), ui_kit::Text::Note("public"));
ui_kit::divider(ui, "report");
ui_kit::text(ui, tr_label("Summary"), ui_kit::Text::Heading("Summary"));
let response = ui_kit::bounded_cell_editor(ui, Id::new("issue_report_title"), &mut draft.title, "", false, 160);
if response.changed() {
draft.opened_github = false;
}
super::truncate(&mut draft.title, 160);
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;
}
crate::scenario::publish_rect("report:description", response.rect);
if !draft.focus_requested || draft.missing_description {
response.scroll_to_me(Some(egui::Align::Center));
response.request_focus();
draft.focus_requested = true;
}
if draft.missing_description {
if draft.description.trim().is_empty() {
ui_kit::text(ui, tr_label("Describe what happened before continuing."), ui_kit::Text::Error("description"));
} else {
draft.missing_description = false;
}
}
let steps = answer(
ui,
"Steps to reproduce (optional)",
"What did you do just before the problem? A short list is enough",
&mut draft.steps,
"issue_report_steps",
2,
);
let expected =
answer(ui, "Expected result (optional)", "What did you expect to see?", &mut draft.expected, "issue_report_expected", 2);
if steps.changed() || expected.changed() {
draft.opened_github = false;
}
retake = screenshot(app, draft, ui);
ui_kit::text(
ui,
tr_label("App/system information and command settings are included. Review private details before sharing."),
ui_kit::Text::Note("private"),
);
ui_kit::section(ui, "issue-report-technical", "Technical details", false, |ui| {
let response =
ui_kit::text_area(ui, tr_label("Technical details"), Id::new("issue_report_technical"), &mut draft.body, 8, MAX_BODY);
if response.changed() {
draft.opened_github = false;
}
super::truncate(&mut draft.body, MAX_BODY);
});
});
});
});
// TextEdit applies this frame's events while it is drawn. Export only after every editor
// has processed its input, including diagnostic redactions.
match action {
ui_kit::Action::Ok => {
draft.missing_description = draft.description.trim().is_empty();
if !draft.missing_description {
let body = draft.report_body();
let (url, copy_needed) = draft_url(&draft.report_title(), &body);
if copy_needed {
ctx.copy_text(body);
}
ctx.open_url(egui::OpenUrl::new_tab(url));
draft.opened_github = true;
ctx.request_repaint();
}
}
ui_kit::Action::Apply => {
ctx.copy_text(draft.report_body());
draft.note = "Report copied. Paste it into the GitHub draft if needed.".into();
}
_ => {}
}
(retake, closed || action == ui_kit::Action::Cancel)
}
+2
View File
@@ -2252,6 +2252,8 @@ mod header_report_tests {
assert!(crate::issue_report::pending(&h.app));
assert_eq!(before, (h.app.session.doc.to_json(), h.app.session.undo.len(), h.app.session.revision));
captured_frame(&mut h);
// The report card takes a few frames to reach its full height.
h.frames(16);
// Existing review content scrolls vertically when the window is narrow.
if width < 700.0 {
let [x, y] = h.widget("Close draft").unwrap();