Skip to content

fix(redis): guard string key Refresh and crumb navigation against unsaved edits - #933

Merged
ZhuchkaTriplesix merged 1 commit into
devfrom
issue/873-redis-refresh-dirty-guard
Sep 24, 2026
Merged

ZhuchkaTriplesix merged 1 commit into
devfrom
issue/873-redis-refresh-dirty-guard

Conversation

@ZhuchkaTriplesix

Copy link
Copy Markdown
Member

Summary

Prevents data loss when the user edits a Redis string key value and then clicks Refresh or navigates away via the breadcrumb trail without saving.

Changes

redis_key_editor.dart

  • Added _savedStringText to track the server-loaded string value.
  • Added _isStringDirty getter — true only for editable string keys when the controller text differs from _savedStringText.
  • Added _confirmDiscardStringEdits() — shows an 'Unsaved changes' dialog and returns true only when safe to proceed.
  • Introduced RedisKeyEditorController (public) with a canNavigateAway() method so the parent widget can query dirty-state without touching private state.
  • Added optional controller parameter to RedisKeyEditor; the state attaches/detaches in initState/dispose.
  • Wrapped the Refresh button's onTap with the discard guard.

redis_explorer_view.dart

  • Added RedisKeyEditorController? _keyEditorController to _RedisExplorerViewState.
  • _navigateToKeys() is now async and calls controller.canNavigateAway() before clearing navigation state.
  • _onCrumbTap uses unawaited(_navigateToKeys()) so the async guard works.
  • _navigateToKey and _onKeyRenamed create a fresh controller on each key selection.

Tests

4 new cases in test/features/redis/redis_key_editor_test.dart:

  • Refresh proceeds silently when value is unedited.
  • Refresh shows discard dialog when value is dirty; Cancel blocks reload, Discard allows it.
  • canNavigateAway() returns true when clean.
  • canNavigateAway() shows dialog when dirty; Cancel → false, Discard → true.

Closes #873

…aved edits

Add _savedStringText to track the server-loaded value and _isStringDirty
to detect unsaved edits in the string TextField. Wrap the Refresh button
with _confirmDiscardStringEdits() so the user is prompted before their
changes are thrown away.

Introduce RedisKeyEditorController with canNavigateAway() so that
RedisExplorerView can guard crumb/back navigation in the same way.
_navigateToKeys() now awaits the controller before clearing the selected key.

Tests: 4 new cases in redis_key_editor_test.dart covering clean/dirty
Refresh and clean/dirty canNavigateAway().

Closes #873
@github-actions github-actions Bot added bug Something isn't working frontend Theme parser epic label: frontend ux User experience, keyboard shortcuts and interactions labels Sep 24, 2026
@github-actions github-actions Bot added this to the 0.4.18 milestone Sep 24, 2026
@ZhuchkaTriplesix
ZhuchkaTriplesix merged commit 3024f5f into dev Sep 24, 2026
4 checks passed
@ZhuchkaTriplesix
ZhuchkaTriplesix deleted the issue/873-redis-refresh-dirty-guard branch September 28, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working frontend Theme parser epic label: frontend ux User experience, keyboard shortcuts and interactions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant