Skip to content

Show unsaved entry changes in entry list#13338

Open
anansutiawan wants to merge 6 commits into
keepassxreboot:developfrom
anansutiawan:fix/1162-unsaved-entry-indicator
Open

Show unsaved entry changes in entry list#13338
anansutiawan wants to merge 6 commits into
keepassxreboot:developfrom
anansutiawan:fix/1162-unsaved-entry-indicator

Conversation

@anansutiawan
Copy link
Copy Markdown

Fixes #1162

Shows entries with unsaved local changes in italics when autosave after every change is disabled. The model compares entry modification timestamps with the current database file timestamp only while the database is dirty, so the indicator clears after save and is suppressed when autosave-after-every-change is enabled.

Generative AI disclosure: The majority of this patch was prepared with OpenAI Codex.

Screenshots

Not included; visual change is font styling only.

Testing strategy

  • Added TestEntryModel::testUnsavedEntryFont() coverage for unsaved-entry italic styling, autosave suppression, and clean-database clearing.
  • Ran git diff --check.
  • Not run locally: CMake build, unit test binary, or clang-format. cmake and clang-format are not available in this workspace PATH.

Type of change

  • New feature (change that adds functionality)

@varjolintu varjolintu added the pr: ai-assisted Pull request contains significant contributions by generative AI label May 13, 2026
anansutiawan and others added 3 commits May 19, 2026 18:08
Remove unnecessary code from EntryModel and place the hasUnsavedChanges into Entry itself.

Add default search

Add tooltip
Testing out using a modified visual indicator on the entry icon
@droidmonkey droidmonkey force-pushed the fix/1162-unsaved-entry-indicator branch from 171fa14 to 7b5f1a3 Compare May 20, 2026 00:27
@droidmonkey droidmonkey self-requested a review May 20, 2026 00:28
@droidmonkey droidmonkey added pr: new feature Pull request adds a new feature user interface labels May 20, 2026
@droidmonkey droidmonkey added this to the v2.8.0 milestone May 20, 2026
@droidmonkey
Copy link
Copy Markdown
Member

I cleaned up the code since there was a lot of extra calls to data updates that are unnecessary. Qt refreshes the data constantly and we already refresh the whole list when an entry is modified.

I am playing around with a badge indicator and tooltip in addition to the italic text.

image

One thing that gives me pause on this PR is that we constantly (like hundreds of times) check the on-disk file modified information which can be VERY expensive, especially for networked files. We will have to adjust this to use cached information before merging or some other smarter way to indicate an entry was modified but not yet saved.

@droidmonkey droidmonkey marked this pull request as draft May 20, 2026 00:32
@anansutiawan
Copy link
Copy Markdown
Author

Thanks for taking a pass on the UI.

I pushed 78f692d to address the expensive file-stat concern. Database now caches the saved file modification time when the file path changes or the database is marked clean, and Entry::hasUnsavedChanges() uses that cached value instead of constructing QFileInfo from the entry model/icon/search hot paths. I also kept the AutoSaveAfterEveryChange guard so autosave mode does not show the unsaved indicator.

Local validation available in this workspace:

git diff --check

I still cannot run CMake, the unit binary, or clang-format locally because those tools are not available in this PATH.

@droidmonkey
Copy link
Copy Markdown
Member

droidmonkey commented May 20, 2026

I also kept the AutoSaveAfterEveryChange guard so autosave mode does not show the unsaved indicator.

I removed that for a reason because it is not desired. Auto save doesnt mean the database is actually saved to disk. Saves can error out leaving the database unsaved and still modified.

@anansutiawan
Copy link
Copy Markdown
Author

Thanks, that makes sense. I pushed d8ce861 to remove the AutoSaveAfterEveryChange suppression from Entry::hasUnsavedChanges(), so the indicator now still reflects a dirty database if autosave fails or leaves changes unsaved. I also updated the EntryModel regression test to expect the italic indicator while autosave is enabled and the database remains modified.\n\nLocal validation available here: git diff --check. CMake, the unit binary, and clang-format are still unavailable in this workspace PATH.

@anansutiawan anansutiawan marked this pull request as ready for review May 22, 2026 05:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: ai-assisted Pull request contains significant contributions by generative AI pr: new feature Pull request adds a new feature user interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Provide a visual indication for entries that contain unsaved changes [$5]

3 participants