Skip to content

Improve "Recover Files" UI (related issues #4130, #5513)#5805

Open
dacap wants to merge 1 commit into
aseprite:betafrom
dacap:recover-active-session
Open

Improve "Recover Files" UI (related issues #4130, #5513)#5805
dacap wants to merge 1 commit into
aseprite:betafrom
dacap:recover-active-session

Conversation

@dacap
Copy link
Copy Markdown
Member

@dacap dacap commented May 11, 2026

This PR adds the "Active Session" in the "Recover Files" tab:

image

When we close a sprite:

image

When a version of the sprite is fully backed up in disk and we close the sprite we can see both versions (the one closed still in memory with undo info, and the backed up sprite in disk):

image

After the file in memory is freed only the backed up data is displayed:

image

* Show "Active Session" with closed docs (in memory) and backups (in disk)
* Show all sessions in date order (crashed and correcly closed)
Copy link
Copy Markdown
Collaborator

@aseprite-bot aseprite-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-tidy made some suggestions

Comment thread src/app/closed_docs.cpp
ASSERT(doc->context() == nullptr);

ClosedDoc closedDoc = { doc, base::current_tick() };
ObjectId docId = doc->id();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'docId' of type 'ObjectId' (aka 'unsigned int') can be declared 'const' [misc-const-correctness]

Suggested change
ObjectId docId = doc->id();
ObjectId const docId = doc->id();

Comment thread src/app/closed_docs.cpp
std::unique_lock<std::mutex> lock(m_mutex);
m_docs.insert(m_docs.begin(), std::move(closedDoc));
{
std::unique_lock<std::mutex> lock(m_mutex);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'lock' of type 'std::unique_lockstd::mutex' can be declared 'const' [misc-const-correctness]

Suggested change
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<std::mutex> const lock(m_mutex);

Comment thread src/app/closed_docs.cpp
{
Doc* doc = nullptr;
{
std::unique_lock<std::mutex> lock(m_mutex);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'lock' of type 'std::unique_lockstd::mutex' can be declared 'const' [misc-const-correctness]

Suggested change
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<std::mutex> const lock(m_mutex);

Comment thread src/app/closed_docs.cpp
{
std::vector<crash::DocumentInfo> infos;
{
std::unique_lock<std::mutex> lock(m_mutex);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'lock' of type 'std::unique_lockstd::mutex' can be declared 'const' [misc-const-correctness]

Suggested change
std::unique_lock<std::mutex> lock(m_mutex);
std::unique_lock<std::mutex> const lock(m_mutex);

Comment thread src/app/closed_docs.h
bool hasClosedDocs();
void addClosedDoc(Doc* doc);
Doc* reopenLastClosedDoc();
Doc* reopenClosedDocById(const doc::ObjectId docId);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'docId' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]

Suggested change
Doc* reopenClosedDocById(const doc::ObjectId docId);
Doc* reopenClosedDocById(doc::ObjectId docId);

{
DATAVIEW_TRACE("DATAVIEW: onNewClosedDoc", (int)docId);

int i = parent()->getChildIndex(this);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'i' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int i = parent()->getChildIndex(this);
int const i = parent()->getChildIndex(this);

updateNoClosedDocVisibility();
}

void onArchiveClosedDoc(doc::ObjectId docId, const bool backedup) override
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: parameter 'backedup' is unused [misc-unused-parameters]

Suggested change
void onArchiveClosedDoc(doc::ObjectId docId, const bool backedup) override
void onArchiveClosedDoc(doc::ObjectId docId, const bool /*backedup*/) override


onReopenClosedDoc(docId);

int index = clearBackups(parent());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'index' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int index = clearBackups(parent());
int const index = clearBackups(parent());

int countItemsInThisSection()
{
int itemsInThisSection = 0;
int n = int(parent()->children().size());
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: variable 'n' of type 'int' can be declared 'const' [misc-const-correctness]

Suggested change
int n = int(parent()->children().size());
int const n = int(parent()->children().size());

}

void DataRecoveryView::onOpen()
WidgetsList DataRecoveryView::selectedItems()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

warning: method 'selectedItems' can be made static [readability-convert-member-functions-to-static]

src/app/ui/data_recovery_view.h:58:

-   ui::WidgetsList selectedItems();
+   static ui::WidgetsList selectedItems();

@dacap dacap assigned Gasparoken and unassigned Gasparoken May 11, 2026
@Gasparoken
Copy link
Copy Markdown
Member

Perfect! It works great, I like it.

The only note is: "in memory" implies that the sprite is still in RAM, which is correct, but perhaps it would be better to report "undo history" or "w/undo history" or "can undo" to express the advantages of "in memory".

@Gasparoken Gasparoken assigned dacap and unassigned Gasparoken May 12, 2026
@dacap
Copy link
Copy Markdown
Member Author

dacap commented May 12, 2026

The only note is: "in memory" implies that the sprite is still in RAM, which is correct, but perhaps it would be better to report "undo history" or "w/undo history" or "can undo" to express the advantages of "in memory".

I thought something similar, but I'm as #3718 is planned, the idea is that after that all backups (even the one in disk) will contain the undo information.

@dacap
Copy link
Copy Markdown
Member Author

dacap commented May 12, 2026

One thing I don't like is when both versions appear: the one in memory (with undo) and the one in disk (without undo, at the moment). So probably just hiding the one in disk while we have the one in memory would be enough to avoid confusion to the user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants