feat: add browser-like back/forward navigation history#183
Conversation
Tracks note navigation in a history stack so you can move back and forward between previously visited notes, mimicing standard browser behaviour. I've chosen Cmd+[ and Cmd+] as keyboard shortcuts for back/forward because that's what Safari uses. I considered using Cmd+left and Cmd+right to match Chrome, but that clashed with editor shortcuts to jump to the start of the line. I've added toolbar back/forward buttons with arrow icons, next to the sidebar toggle, and enable/disable them if the stack has no pages left. I've tried to make sure the stack keeps up with any changes (e.g. when notes or folders are renamed or deleted) so the history doesn't point at non-existent pages. Returning to the default "What's on your mind?" page will clear the history entirely as it is essentially a reset. All of that did complicate the commit a lot more than I'd originally hoped/expected, sorry about that! To copy web browser behaviour, if you click on a link that discards any forward history. I'm ignoring any external URL clicks as that just got confusing to include. Signed-off-by: Dale Lane <dale.lane@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds browser-style back/forward navigation history to the notes app. ChangesNote Navigation History
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@erictli Thanks so much for sharing scratch - I find it super useful. I feel a little weird offering an unsolicited feature, so obviously it's entirely fine if you're not interested and prefer to close this without review. I'm happy using this as a feature in my private fork. |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/context/NotesContext.tsx`:
- Around line 173-179: The selectNote flow in NotesContext pushes the note ID
into navigation history before verifying the note loads successfully. Update the
selectNote callback to await loadNoteById(id) first and only call setNav with
navPush afterward, matching the goBack/goForward behavior so failed loads do not
leave broken entries in history.
In `@src/lib/shortcuts.ts`:
- Around line 26-28: The shortcuts list currently advertises a “Go to note”
binding for mod+G, but there is no matching handler in the global shortcut
logic. Either remove the `Go to note` entry from `shortcuts.ts` or implement the
`g` branch in `App.tsx`’s shortcut handler so it triggers the intended note
navigation action, keeping the documented shortcut and runtime behavior aligned.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 93d851a8-1395-4bd9-8aa5-ad5e92c1d259
📒 Files selected for processing (4)
src/App.tsxsrc/components/editor/Editor.tsxsrc/context/NotesContext.tsxsrc/lib/shortcuts.ts
This was a git commit mixup - I've got a go-to-note feature in a separate branch, and hadn't spotted that I left the shortcut in this branch. Signed-off-by: Dale Lane <dale.lane@gmail.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Tracks note navigation in a history stack so you can move back and forward between previously visited notes, mimicing standard browser behaviour.
I've chosen Cmd+[ and Cmd+] as keyboard shortcuts for back/forward because that's what Safari uses. I considered using Cmd+left and Cmd+right to match Chrome, but that clashed with editor shortcuts to jump to the start of the line.
I've added toolbar back/forward buttons with arrow icons, next to the sidebar toggle, and enable/disable them if the stack has no pages left.
I've tried to make sure the stack keeps up with any changes (e.g. when notes or folders are renamed or deleted) so the history doesn't point at non-existent pages. Returning to the default "What's on your mind?" page will clear the history entirely as it is essentially a reset. All of that did complicate the commit a lot more than I'd originally hoped/expected, sorry about that!
To copy web browser behaviour, if you click on a link that discards any forward history. I'm ignoring any external URL clicks as that just got confusing to include.
Summary by CodeRabbit
New Features
Bug Fixes