-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add a recovery path for autosaved documents that don't open successfully #4157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Keavon
wants to merge
1
commit into
master
Choose a base branch
from
autosave-recovery
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
editor/src/messages/dialog/simple_dialogs/failed_to_load_documents_dialog.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| use crate::messages::layout::utility_types::widget_prelude::*; | ||
| use crate::messages::prelude::*; | ||
|
|
||
| /// A dialog shown after startup when one or more autosaved documents fail to deserialize. | ||
| /// Offers the user a chance to download the raw content (so the data isn't lost), discard the failed | ||
| /// documents, or dismiss the dialog (keeping the autosave for a later session, when the deserialization | ||
| /// bug may be fixed in a future release). | ||
| pub struct FailedToLoadDocumentsDialog { | ||
| pub failed_document_names: Vec<String>, | ||
| } | ||
|
|
||
| impl DialogLayoutHolder for FailedToLoadDocumentsDialog { | ||
| const ICON: &'static str = "Warning"; | ||
| const TITLE: &'static str = "Failed to Open Documents"; | ||
|
|
||
| fn layout_buttons(&self) -> Layout { | ||
| let widgets = vec![ | ||
| TextButton::new("Download") | ||
| .emphasized(true) | ||
| .tooltip_description("Save the raw document data to disk so it can be recovered later.") | ||
| .on_update(|_| { | ||
| DialogMessage::CloseAndThen { | ||
| followups: vec![PortfolioMessage::DownloadFailedToLoadDocuments.into()], | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| TextButton::new("Discard") | ||
| .tooltip_description("Permanently delete the autosaved data for these documents.") | ||
| .on_update(|_| { | ||
| DialogMessage::CloseAndThen { | ||
| followups: vec![PortfolioMessage::DiscardFailedToLoadDocuments.into()], | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| TextButton::new("Dismiss") | ||
| .tooltip_description("Close this dialog. The autosaved data is kept and this dialog will reappear on next launch.") | ||
| .on_update(|_| FrontendMessage::DialogClose.into()) | ||
| .widget_instance(), | ||
| ]; | ||
|
|
||
| Layout(vec![LayoutGroup::row(widgets)]) | ||
| } | ||
| } | ||
|
|
||
| impl LayoutHolder for FailedToLoadDocumentsDialog { | ||
| fn layout(&self) -> Layout { | ||
| let count = self.failed_document_names.len(); | ||
| let header = format!("{count} document{} couldn't be reopened.", if count == 1 { "" } else { "s" }); | ||
| let list = "• ".to_string() + &self.failed_document_names.join("\n• "); | ||
| let plural_s = if count == 1 { "" } else { "s" }; | ||
| let plural_it_them = if count == 1 { "it" } else { "them" }; | ||
|
|
||
| Layout(vec![ | ||
| LayoutGroup::row(vec![TextLabel::new(header).bold(true).multiline(true).widget_instance()]), | ||
| LayoutGroup::row(vec![ | ||
| TextLabel::new(format!( | ||
| "Sorry about that!\n\ | ||
| This shouldn't happen, and we'd like to help.\n\ | ||
| \n\ | ||
| Click \"Download\" to save a copy of the affected file{plural_s},\n\ | ||
| then please share {plural_it_them} with us so we can investigate:" | ||
| )) | ||
| .multiline(true) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextButton::new("Ask on Discord") | ||
| .icon("Volunteer") | ||
| .flush(true) | ||
| .on_update(|_| { | ||
| FrontendMessage::TriggerVisitLink { | ||
| url: "https://discord.graphite.art".into(), | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextButton::new("Report on GitHub") | ||
| .icon("Bug") | ||
| .flush(true) | ||
| .on_update(|_| { | ||
| FrontendMessage::TriggerVisitLink { | ||
| url: "https://github.com/GraphiteEditor/Graphite/issues/new".into(), | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextLabel::new( | ||
| "In the meantime, you can keep working in the\n\ | ||
| previous version of Graphite:", | ||
| ) | ||
| .multiline(true) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextButton::new("Sept. 2025 Release") | ||
| .icon("GraphiteLogo") | ||
| .flush(true) | ||
| .on_update(|_| { | ||
| FrontendMessage::TriggerVisitLink { | ||
| url: "https://57130155.graphite.pages.dev/".into(), | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![TextLabel::new(format!("Affected document{plural_s}:\n{list}")).multiline(true).widget_instance()]), | ||
| ]) | ||
| } | ||
| } |
90 changes: 90 additions & 0 deletions
90
editor/src/messages/dialog/simple_dialogs/failed_to_open_document_dialog.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| use crate::messages::layout::utility_types::widget_prelude::*; | ||
| use crate::messages::prelude::*; | ||
|
|
||
| /// A dialog shown when a manually opened document fails to deserialize. Mirrors the recovery affordances | ||
| /// of [`super::FailedToLoadDocumentsDialog`] (offering Discord/GitHub/previous-version links) but for | ||
| /// the single-file, user-initiated open case, where the file is already on the user's disk and there's | ||
| /// nothing to download or discard. | ||
| pub struct FailedToOpenDocumentDialog { | ||
| /// Display name of the file the user tried to open; used in the dialog header. Falls back to a | ||
| /// generic phrase when empty. | ||
| pub document_name: String, | ||
| } | ||
|
|
||
| impl DialogLayoutHolder for FailedToOpenDocumentDialog { | ||
| const ICON: &'static str = "Warning"; | ||
| const TITLE: &'static str = "Failed to Open Document"; | ||
|
|
||
| fn layout_buttons(&self) -> Layout { | ||
| let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DialogClose.into()).widget_instance()]; | ||
| Layout(vec![LayoutGroup::row(widgets)]) | ||
| } | ||
| } | ||
|
|
||
| impl LayoutHolder for FailedToOpenDocumentDialog { | ||
| fn layout(&self) -> Layout { | ||
| let header = if self.document_name.trim().is_empty() { | ||
| "The document couldn't be opened.".to_string() | ||
| } else { | ||
| format!("\"{}\" couldn't be opened.", self.document_name) | ||
| }; | ||
|
|
||
| Layout(vec![ | ||
| LayoutGroup::row(vec![TextLabel::new(header).bold(true).multiline(true).widget_instance()]), | ||
| LayoutGroup::row(vec![ | ||
| TextLabel::new( | ||
| "Sorry about that!\n\ | ||
| This shouldn't happen, and we'd like to help.\n\ | ||
| \n\ | ||
| Please share the file with us so we can investigate:", | ||
| ) | ||
| .multiline(true) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextButton::new("Ask on Discord") | ||
| .icon("Volunteer") | ||
| .flush(true) | ||
| .on_update(|_| { | ||
| FrontendMessage::TriggerVisitLink { | ||
| url: "https://discord.graphite.art".into(), | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextButton::new("Report on GitHub") | ||
| .icon("Bug") | ||
| .flush(true) | ||
| .on_update(|_| { | ||
| FrontendMessage::TriggerVisitLink { | ||
| url: "https://github.com/GraphiteEditor/Graphite/issues/new".into(), | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextLabel::new( | ||
| "In the meantime, you can keep working in the\n\ | ||
| previous version of Graphite:", | ||
| ) | ||
| .multiline(true) | ||
| .widget_instance(), | ||
| ]), | ||
| LayoutGroup::row(vec![ | ||
| TextButton::new("Sept. 2025 Release") | ||
| .icon("GraphiteLogo") | ||
| .flush(true) | ||
| .on_update(|_| { | ||
| FrontendMessage::TriggerVisitLink { | ||
| url: "https://57130155.graphite.pages.dev/".into(), | ||
| } | ||
| .into() | ||
| }) | ||
| .widget_instance(), | ||
| ]), | ||
| ]) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P1: Validate or sanitize recovered document filenames before transporting them as raw
Strings. As written, a crafted document name can escape the selected recovery folder when the desktop wrapper later doesfolder.join(filename).Prompt for AI agents