Skip to content

fix: persist deselected account state across chain switches (OK-51089)#10552

Closed
PatrickChoo wants to merge 1 commit intoOneKeyHQ:xfrom
PatrickChoo:fix/OK-51089-manage-account-deselect-persist
Closed

fix: persist deselected account state across chain switches (OK-51089)#10552
PatrickChoo wants to merge 1 commit intoOneKeyHQ:xfrom
PatrickChoo:fix/OK-51089-manage-account-deselect-persist

Conversation

@PatrickChoo
Copy link
Copy Markdown
Collaborator

@PatrickChoo PatrickChoo commented Mar 9, 2026

Summary

  • Fix manage accounts page losing "delete" account selections when switching chains
  • Previously, deselectedExistingIndexes was reset on network/deriveType change while normalSelectedIndexes (add selections) was preserved
  • Now both add and delete selections persist across chain switches, aligned behavior

Test plan

  • Open manage accounts page
  • Check some accounts to add and uncheck some existing accounts (mark for deletion)
  • Switch to a different chain
  • Verify both add selections and delete selections are preserved
  • Confirm the final operation works correctly with persisted selections

Jira: OK-51089


Open with Devin

@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Mar 9, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 10 additional findings.

Open in Devin Review

chatgpt-codex-connector[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 9 additional findings.

Open in Devin Review

Minnzen
Minnzen previously approved these changes Mar 9, 2026
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch 2 times, most recently from 285aece to 908fa72 Compare March 10, 2026 06:46
chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@socket-security
Copy link
Copy Markdown

socket-security Bot commented Mar 10, 2026

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch from e7f4e12 to ec027e3 Compare March 12, 2026 16:29
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

devin-ai-integration[bot]

This comment was marked as resolved.

@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch from ec027e3 to fe1556e Compare March 12, 2026 17:22
devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch from 5678e12 to b814804 Compare March 16, 2026 11:50
devin-ai-integration[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

1 similar comment
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch from 754683c to 3abb947 Compare March 25, 2026 12:17
@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

devin-ai-integration[bot]

This comment was marked as resolved.

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Repo admins can enable using credits for code reviews in their settings.

@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch from 8c07fef to a6bd976 Compare March 26, 2026 04:55
devin-ai-integration[bot]

This comment was marked as resolved.

Cache deselection state per network+deriveType so switching chains
preserves selections without risking stale account deletion.
@PatrickChoo PatrickChoo force-pushed the fix/OK-51089-manage-account-deselect-persist branch from a6bd976 to 887480f Compare March 26, 2026 05:04
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 42 additional findings in Devin Review.

Open in Devin Review

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 Stale closure in headerRight causes saveDeselectionToCache to save outdated deselection state on derive type switch

saveDeselectionToCache (line 340) closes over deselectedExistingIndexes state and is listed in its useCallback deps (line 350). However, headerRight's useCallback (line 519) does NOT include saveDeselectionToCache in its dependency array (lines 610-619). When a user deselects accounts and then switches derive type, the onChange handler at line 562 calls a stale saveDeselectionToCache that captured the old (empty) deselectedExistingIndexes — the user's deselections are silently lost and cannot be restored when switching back. This directly breaks the PR's intended feature of persisting deselection state across derive type switches.

Triggering flow
  1. User is on networkA with deriveTypeA, headerRight is created.
  2. User deselects some existing accounts → deselectedExistingIndexes updates → saveDeselectionToCache is recreated.
  3. headerRight is NOT recreated because saveDeselectionToCache is not in its dependency array.
  4. User switches to deriveTypeB → onChange fires with the stale saveDeselectionToCache from step 1.
  5. Stale saveDeselectionToCache saves {} (empty) to cache key networkA__deriveTypeA.
  6. User switches back to deriveTypeA → empty state is restored, deselections are gone.

(Refers to lines 610-619)

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@PatrickChoo
Copy link
Copy Markdown
Collaborator Author

Closing: PR had too many unrelated changes mixed in. Reopening as a clean PR with only the OK-51089 fix.

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.

4 participants