From 3a4ac943404ffa73eaf08043d77375b938754e61 Mon Sep 17 00:00:00 2001 From: Jack Platten Date: Tue, 20 Oct 2026 19:15:18 -0700 Subject: [PATCH] feat(jj): show only the nearest ancestor bookmark for new installs (#112) * feat(jj): only show the nearest ancestor bookmark by default In a stack, every bookmarked ancestor between @ and trunk was listed, so the prompt grew with the stack. Add tide_jj_ancestor_bookmark_limit (default 1; 0 shows all) to cap how many ancestor bookmarks are shown, nearest first. Skipped bookmarks also skip their depth lookup, which saves a jj fork per bookmark when the ahead-path contains a merge. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PVbQM4XyH5HLzapJWmWTU1 * feat(jj): limit ancestor bookmarks only for new installs Rather than changing the code default, which would change every existing prompt on update, set tide_jj_ancestor_bookmark_limit 1 in the configure configs. New installs and `tide configure` show only the nearest ancestor bookmark, while setups without the variable keep showing them all. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PVbQM4XyH5HLzapJWmWTU1 * feat(jj): ignore an ancestor bookmark limit that isn't a whole number Same check as for the length settings: anything other than a whole number falls back to showing every ancestor bookmark instead of making `test` error from the background render. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01PVbQM4XyH5HLzapJWmWTU1 --------- Co-authored-by: Claude --- functions/_tide_internal_vcs_jj.fish | 17 ++++++++++- functions/tide/configure/configs/classic.fish | 1 + .../configure/configs/classic_16color.fish | 1 + functions/tide/configure/configs/lean.fish | 1 + .../tide/configure/configs/lean_16color.fish | 1 + functions/tide/configure/configs/rainbow.fish | 1 + .../configure/configs/rainbow_16color.fish | 1 + tests/_tide_item_vcs.test.fish | 30 +++++++++++++++++++ 8 files changed, 52 insertions(+), 1 deletion(-) diff --git a/functions/_tide_internal_vcs_jj.fish b/functions/_tide_internal_vcs_jj.fish index 197e6de..fd7e9fe 100644 --- a/functions/_tide_internal_vcs_jj.fish +++ b/functions/_tide_internal_vcs_jj.fish @@ -111,6 +111,13 @@ if(self.contained_in("::trunk() & ~::@"), # instead of erroring from the background render. string match -qr '^\d+$' -- "$tide_jj_bookmark_length" && set bm_length $tide_jj_bookmark_length + # In a stack, every bookmarked ancestor down to trunk is listed, so + # tide_jj_ancestor_bookmark_limit can cap it to the nearest ones. New + # installs get 1 through the configs; unset (or 0) shows them all, so + # existing setups don't change. + set -l ancestor_bm_limit 0 + string match -qr '^\d+$' -- "$tide_jj_ancestor_bookmark_limit" && set ancestor_bm_limit $tide_jj_ancestor_bookmark_limit + set -l info "" set -l has_conflict 0 set -l has_immutable 0 @@ -212,7 +219,12 @@ if(self.contained_in("::trunk() & ~::@"), set info "$cid_color$parts[1]$reset$at_bookmarks$workspace_label $bold_brblue$parts[5]$reset$conflict_label $status_color$st$reset$divergent_label$desc_label" else if test $nparts -eq 2 - # Ancestor with bookmarks: change_id, bookmarks + # Ancestor with bookmarks: change_id, bookmarks. jj lists nearer + # ancestors first, so once the limit is hit the rest are skipped + # (which also skips their depth lookups below). + if test $ancestor_bm_limit -gt 0; and test (count $display_bookmarks) -ge $ancestor_bm_limit + continue + end set -l cid $parts[1] set -l depth "" if test $has_merge -eq 1 @@ -231,6 +243,9 @@ if(self.contained_in("::trunk() & ~::@"), end for bookmark in (string split ',' -- $parts[2]) set bookmark (string trim -- $bookmark) + if test $ancestor_bm_limit -gt 0; and test (count $display_bookmarks) -ge $ancestor_bm_limit + break + end if test -n "$bookmark" if test $bm_length -gt 0; and test (string length -- $bookmark) -gt $bm_length set bookmark (string sub -l $bm_length -- $bookmark)"…" diff --git a/functions/tide/configure/configs/classic.fish b/functions/tide/configure/configs/classic.fish index 802c865..8cb6f6d 100644 --- a/functions/tide/configure/configs/classic.fish +++ b/functions/tide/configure/configs/classic.fish @@ -49,6 +49,7 @@ tide_java_color ED8B00 tide_jj_color $_tide_color_green tide_jj_bg_color 444444 tide_jj_show_description false +tide_jj_ancestor_bookmark_limit 1 tide_jobs_bg_color 444444 tide_jobs_color $_tide_color_dark_green tide_jobs_number_threshold 1000 diff --git a/functions/tide/configure/configs/classic_16color.fish b/functions/tide/configure/configs/classic_16color.fish index b0c4ee4..f29f5ce 100644 --- a/functions/tide/configure/configs/classic_16color.fish +++ b/functions/tide/configure/configs/classic_16color.fish @@ -42,6 +42,7 @@ tide_java_color yellow tide_jj_color brgreen tide_jj_bg_color black tide_jj_show_description false +tide_jj_ancestor_bookmark_limit 1 tide_jobs_bg_color black tide_jobs_color green tide_kubectl_bg_color black diff --git a/functions/tide/configure/configs/lean.fish b/functions/tide/configure/configs/lean.fish index 127815a..29e6c00 100644 --- a/functions/tide/configure/configs/lean.fish +++ b/functions/tide/configure/configs/lean.fish @@ -49,6 +49,7 @@ tide_java_color ED8B00 tide_jj_color $_tide_color_green tide_jj_bg_color normal tide_jj_show_description false +tide_jj_ancestor_bookmark_limit 1 tide_jobs_bg_color normal tide_jobs_color $_tide_color_dark_green tide_jobs_number_threshold 1000 diff --git a/functions/tide/configure/configs/lean_16color.fish b/functions/tide/configure/configs/lean_16color.fish index 0dc6a37..d11d49d 100644 --- a/functions/tide/configure/configs/lean_16color.fish +++ b/functions/tide/configure/configs/lean_16color.fish @@ -42,6 +42,7 @@ tide_java_color yellow tide_jj_bg_color normal tide_jj_color brgreen tide_jj_show_description false +tide_jj_ancestor_bookmark_limit 1 tide_jobs_bg_color normal tide_jobs_color green tide_kubectl_bg_color normal diff --git a/functions/tide/configure/configs/rainbow.fish b/functions/tide/configure/configs/rainbow.fish index d7a130b..bb475d7 100644 --- a/functions/tide/configure/configs/rainbow.fish +++ b/functions/tide/configure/configs/rainbow.fish @@ -52,6 +52,7 @@ tide_jobs_number_threshold 1000 tide_jj_color 000000 tide_jj_bg_color 4E9A06 tide_jj_show_description false +tide_jj_ancestor_bookmark_limit 1 tide_kubectl_bg_color 326CE5 tide_kubectl_color 000000 tide_left_prompt_frame_enabled true diff --git a/functions/tide/configure/configs/rainbow_16color.fish b/functions/tide/configure/configs/rainbow_16color.fish index 7ab529e..e01428d 100644 --- a/functions/tide/configure/configs/rainbow_16color.fish +++ b/functions/tide/configure/configs/rainbow_16color.fish @@ -44,6 +44,7 @@ tide_jobs_color green tide_jj_bg_color green tide_jj_color black tide_jj_show_description false +tide_jj_ancestor_bookmark_limit 1 tide_kubectl_bg_color blue tide_kubectl_color black tide_nix_shell_bg_color brblue diff --git a/tests/_tide_item_vcs.test.fish b/tests/_tide_item_vcs.test.fish index 91c80be..ed72b21 100644 --- a/tests/_tide_item_vcs.test.fish +++ b/tests/_tide_item_vcs.test.fish @@ -189,6 +189,36 @@ set -g tide_jj_bookmark_length _vcs_item # CHECK: (@ xyz999 this-is-a-very-long-at-b… def999 * desc feature/abc-123-some-ver…↑1 ↑2) set -e tide_jj_bookmark_length +# -------- jj ancestor bookmark limit -------- +# Only the nearest tide_jj_ancestor_bookmark_limit ancestor bookmarks are +# shown (unset or 0 shows all; new installs get 1 through the configs). Here +# @ has a bookmarked parent ("near"), then an unbookmarked commit, then a +# commit with two bookmarks. +set -l configs $tests_dir/../functions/tide/configure/configs/*.fish +for config in $configs + string match -q 'tide_jj_ancestor_bookmark_limit 1' <$config && echo $config +end | count +# CHECK: 6 + +mkdir -p $dir/jj-stack-repo/.jj +printf '#!/bin/sh\ncmd="$*"\ncase "$cmd" in\n *"workspace list"*) printf "default\\n" ;;\n *"log"*) printf "xyz999\\t.\\t.\\tdefault\\tdef999\\t*\\tfalse\\tdesc\\nanc111\\tnear\\n\\nanc333\\tfar1,far2\\n" ;;\n *) exit 0 ;;\nesac\n' >$dir/bin/jj +cd $dir/jj-stack-repo +# A setup from before the option existed has no variable, and keeps them all +set -q tide_jj_ancestor_bookmark_limit && set -l saved_bm_limit $tide_jj_ancestor_bookmark_limit +set -e -U tide_jj_ancestor_bookmark_limit +_vcs_item # CHECK: (@ xyz999 def999 * desc near↑1 far1↑3 far2↑3 ↑4) +set -g tide_jj_ancestor_bookmark_limit 1 +_vcs_item # CHECK: (@ xyz999 def999 * desc near↑1 ↑4) +set -g tide_jj_ancestor_bookmark_limit 2 +_vcs_item # CHECK: (@ xyz999 def999 * desc near↑1 far1↑3 ↑4) +set -g tide_jj_ancestor_bookmark_limit 0 +_vcs_item # CHECK: (@ xyz999 def999 * desc near↑1 far1↑3 far2↑3 ↑4) +# A value that isn't a whole number is ignored rather than erroring +set -g tide_jj_ancestor_bookmark_limit abc +_vcs_item # CHECK: (@ xyz999 def999 * desc near↑1 far1↑3 far2↑3 ↑4) +set -e tide_jj_ancestor_bookmark_limit +set -q saved_bm_limit[1] && set -U tide_jj_ancestor_bookmark_limit $saved_bm_limit + set -g tide_jj_description_length abc set -g tide_jj_show_description true mkdir -p $dir/jj-longdesc-repo/.jj -- knotmirror 0.0.1