fix: implement proper view navigation stack #146
No reviewers
Labels
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: sneak/AutistMask#146
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/issue-134-view-stack"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes the view stack pop bug where pressing Back in Settings (or any view) always returned to Main instead of the previous view.
Closes issue #134
Problem
The popup UI had no navigation stack. Every back button was hardcoded to a specific destination (usually Main). The reported path:
...would go to Main instead of returning to the Transaction view.
Solution
Implemented a proper view navigation stack (like iOS) as already described in the README:
viewStackarray added to persisted state — survives popup close/reopenpushCurrentView()— pushes the current view name onto the stack before any forward navigationgoBack()— pops the stack and shows the previous view; falls back to Main if the stack is empty; re-renders the wallet list when returning to MainclearViewStack()— resets the stack for root transitions (e.g., after adding/deleting a wallet)What Changed
pushCurrentView,goBack,clearViewStack,setRenderMain)viewStackto persisted statectx.show*()wrappers now push before navigating forward; gear button uses stack for toggle behaviorgoBack()(settings, addressDetail, addressToken, transactionDetail, send, receive, addToken, confirmTx, addWallet, settingsAddToken, deleteWallet, export-privkey)showView()forward navigations — AddedpushCurrentView()calls beforeshowView("send")in addressDetail, addressToken, and home; beforeshowView("export-privkey")in addressDetail; beforedeleteWallet.show()in settingsclearViewStack()called after adding a wallet (all 3 import types), after deleting the last wallet, and after transaction completion (Done button)Navigation Paths Verified
✅ Review: PASS
Summary
Clean, well-structured implementation of a proper push/pop navigation stack that fixes the view stack pop bug described in #134.
What was reviewed
fix: implement proper view navigation stackdocker build .passes (includingmake check)Architecture
The implementation adds a
viewStackarray to persisted state with three core functions inhelpers.js:pushCurrentView()— pushesstate.currentViewbefore any forward navigationgoBack()— pops the stack and shows the previous view; falls back to main if empty; calls_renderMain()when returning to main to refresh the wallet listclearViewStack()— resets the stack for root transitions (after wallet add/delete, transaction completion)Bug fix verification
Traced the exact bug scenario from issue #134:
[]["main"]["main", "address"]["main", "address", "transaction"]["main", "address"]Previously step 5 would go to main. Now it correctly returns to transaction.
Design choices verified
goBack()(toggle off). If hidden, it pushes current view and opens settings. Correct.clearViewStack()is called after all 3 wallet import paths, after deleting the last wallet, and after transaction completion (Done button). Prevents stale stack entries.addressDetail.show()directly so the user sees the newly-added token. Stack integrity is maintained.["main"]and shows settings. Back from settings → main. Correct.["main"](or["main", "address"]) and shows the address view. Back navigates sensibly after tx completion.require(): Used in deleteWallet.js and txStatus.js to avoid circular dependencies. Standard Node.js pattern, works correctly since modules are fully loaded by the time click handlers fire.viewStackis persisted viasaveState()(triggered byshowView()), survives popup close/reopen.pushCurrentView()checksstate.currentViewis truthy before pushing.Array.isArray(saved.viewStack) ? saved.viewStack : []handles missing/corrupt data.No issues found
No test weakening, no config changes, no unrelated modifications. The implementation is minimal and focused.
Code Review: PASS ✅
Reviewing PR #146 which closes issue #134 (view stack pop bug).
Issue Requirements Checklist
pushCurrentView()before showing settings, and settings back button callsgoBack()which pops the stack correctly.goBack(), all forward navigations push viapushCurrentView().viewStackarray in persisted state implements a proper push/pop navigation stack, as already described in the README's screen map ("Navigation uses a stack model (like iOS)").Implementation Review
Core stack functions (
helpers.js):pushCurrentView()— correctly capturesstate.currentViewbefore any forward navigation. No duplicate push risk since it's called once per transition.goBack()— pops stack, falls back to "main" on empty stack, re-renders wallet list when returning to main via_renderMaincallback. Sound design.clearViewStack()— properly resets stack for root transitions.setRenderMain()— clean callback pattern to avoid circular dependencies.Forward navigation (
index.jsctx wrappers): All 9ctx.show*()wrappers consistently callpushCurrentView()before the target view'sshow(). DirectpushCurrentView()+showView()calls inaddressDetail.js,addressToken.js,home.js, andsettings.jsfor inline navigations (Send, Export Private Key, Delete Wallet) are also correct.Back navigation: Every view's back button now uses
goBack()instead of hardcoded destinations — settings, addressDetail, addressToken, transactionDetail, send, receive, addToken, confirmTx, addWallet, settingsAddToken, deleteWallet, export-privkey.Edge cases handled correctly:
goBack()falls back to "main" — safe default.viewStackpersisted to extension storage viasaveState()(called byshowView()), restored withArray.isArray()guard inloadState(). Stack survives popup lifecycle.clearViewStack()beforeshowView("main")— clean root reset.clearViewStack()thenshowView("welcome")— correct.clearViewStack(), push "main", show settings — back from settings goes to main. Correct.txStatus.js):clearViewStack(), push "main" (and optionally "address"), show address context — clean navigation path home after tx. Correct.addToken.js): Manual stack pop + directaddressDetail.show()— correctly returns to address detail with re-render so new token is visible immediately.goBack()when settings already visible. Works from any context (main, address, transaction, etc.).Persistence correctness:
pushCurrentView()modifiesstate.viewStackin memory; the subsequentshowView()call always triggerssaveState()which persists the updated stack.clearViewStack()is always followed by eithershowView()or explicitsaveState(). No window for data loss.Cheating Check
Build Verification
docker build .passes (includesmake check— formatting, linting, tests).Files Changed
16 files —
state.js,helpers.js,index.js, and all view modules. Changes are systematic and consistent. No stray modifications.Branch is up-to-date with
main(1 commit ahead, 0 behind). No rebase needed.