Skip to content

feat(v1): replace downward route with browser-style directory history #36

Closed

Description

@benbenbang

Delivery

Implemented in #54 and released in 0.4.0. This changes the public navigation semantics; regenerate and reload shell integration after upgrading.

Motivation

The current downward route is created only by the configured up ticker and is cleared by successful builtin navigation. That means home and previous-directory navigation lose useful context:

~/Git/project $ cd
~             $ cd v
# expected: ~/Git/project

A browser-style model should remember the location being left for every successful wrapper-controlled navigation.

Proposed behavior

  • keep a bounded, shell-local stack of previously visited directories
  • record navigation through cd, cd ~, cd -, direct paths, raw mode, aliases, mounts, Git shortcuts, zoxide, and the worktree picker
  • record only successful moves whose destination differs from the current directory
  • never observe or record explicit builtin cd, which remains the escape hatch
  • make one v return to the previous navigation entry, even across unrelated directories or volumes
  • make repeated down tickers consume that many history entries atomically
  • treat each character in repeated up navigation as a step: ^^^ records each traversed parent so vvv can retrace it
  • do not push the directory being left while consuming history, avoiding immediate loops
  • preserve history after failed navigation

Examples

~/Git/project/src $ cd ^^^
~                 $ cd vvv
~/Git/project/src

~/Git/project $ cd
~             $ cd v
~/Git/project

~/one $ cd /tmp/two
/tmp/two $ cd v
~/one

Cross-shell requirements

  • identical behavior in Bash, Zsh, Nushell, and PowerShell
  • preserve paths containing spaces and platform-native path syntax
  • preserve non-UTF-8 Unix paths wherever the shell permits them
  • keep the history bounded to prevent unbounded shell state
  • generated integration owns the history; it is not persisted between shell sessions

Compatibility and documentation

  • replace the single CJ_INTERNAL_DOWN_ROUTE model or provide a compatible transition
  • regenerate integration after upgrading
  • document v as browser-style back history rather than only descendant traversal
  • update exact error messages for empty and exhausted history

Acceptance criteria

  • unit tests cover stack push, multi-pop, failed/no-op navigation, and exhaustion
  • external integration tests cover every supported shell when available
  • tests cover home, cd -, unrelated paths, aliases/mounts, zoxide, worktree picker, and repeated ^/v
  • Windows cross-compilation and platform CI remain green

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions