we (web engine): Experimental web browser project to understand the limits of Claude

Implement navigation history stack #158

open opened by pierrelf.com

Description#

Implement a session history stack that tracks visited pages and allows back/forward traversal. This is the internal data structure that powers both the History API and the browser chrome back/forward buttons.

Requirements#

Session History#

  • Maintain an ordered list of session history entries
  • Each entry stores: URL, document state (or ability to reconstruct), scroll position (x, y), serialized state data (for pushState), document title
  • Track the current entry index (position in the list)
  • Navigating to a new page pushes a new entry after the current position (discarding any forward entries)
  • Maximum history size limit (e.g., 50 entries) to prevent unbounded memory growth

Traversal#

  • traverse_back() — move to previous entry, reload document if needed
  • traverse_forward() — move to next entry, reload document if needed
  • traverse_to(delta) — move by delta steps (negative = back, positive = forward)
  • Same-document navigations (pushState, fragment changes) don't require full page reload on traversal

Integration Points#

  • Link click navigation should push a new history entry
  • location.replace() should replace (not push) the current entry
  • Form submission should push a new history entry
  • Fragment navigation should push a new history entry

Acceptance Criteria#

  • Navigating to a new page creates a new history entry
  • Back traversal returns to the previous page
  • Forward traversal returns to the page you came back from
  • Navigating from the middle of the stack discards forward entries
  • Scroll position is saved and restored on traversal
  • History size is bounded
  • Unit tests for stack operations (push, traverse back/forward, truncation)
sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:meotu43t6usg4qdwzenk4s2t/sh.tangled.repo.issue/3mii3nth3kh27