Skip to content

pickbrain branch support#5

Open
eiderman wants to merge 10 commits intomasterfrom
eider/pickbrain-branch-support
Open

pickbrain branch support#5
eiderman wants to merge 10 commits intomasterfrom
eider/pickbrain-branch-support

Conversation

@eiderman
Copy link
Copy Markdown
Contributor

@eiderman eiderman commented Apr 17, 2026

Pickbrain was close but didn't quite match my workflow since it is often branch based. This adds 1 flags

  • --branch X when used alone, it will filter the conversations by branch and allow a normal pickbrain search. Because a branch is picked, it will also try to check out that branch in the cwd. --branch . is for the current branch
  • Inside the conversation picker / (or ctrl-F) allows a witchcraft search to further narrow the options (also works in the standard pickbrain UI)
  • Fixed a bug where we rescanned the entire conversation to find the cwd which made restarting very slow.

Lots of unit tests.

Claude Code: read per-entry gitBranch (last wins per interaction) and
authoritative cwd from JSONL entries instead of lossy directory name
decoding. Store both in metadata.

Codex: detect branch changes from git checkout/switch in exec command
output, overriding the initial session_meta branch. Add comments for
non-obvious ordering semantics and a TODO for locale assumptions.

Includes tests for branch extraction, session parsing, sanitization,
cwd extraction, and project name decoding.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eiderman eiderman requested a review from jacobgorm April 17, 2026 17:34
Resume picker (--resume): find sessions by git branch or project
directory. Presents a TUI picker when multiple sessions match. Checks
for dirty working tree before switching branches.

Semantic search: both TUIs use witchcraft for / search instead of
substring matching. Results update live as the user types (3+ chars).
The resume picker lazy-loads the embedder only when search is first
used, avoiding model load delay on startup.

Carries cwd through BranchSession so launch_resume no longer reads
the entire JSONL file. Integrates upstream --exclude and --since
filters into the unified build_sql_filter.

Includes tests for SQL filter construction, search result dedup,
format_date, and parse_range.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@eiderman eiderman force-pushed the eider/pickbrain-branch-support branch from 2db1fab to 7cad98b Compare April 17, 2026 17:42
eiderman and others added 4 commits April 17, 2026 10:46
Replaces (session_id, path, cwd, source, branch, project) tuples with
the existing BranchSession struct throughout search_tui, confirm_resume,
resume_session, and launch_resume. No behavior change.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- `--branch .` resolves to current git branch
- With --branch: search/pick resumes with git checkout
- Without --branch: search resumes without checkout (branches are
  short-lived; old conversations shouldn't try dead branches)
- Remove resume_for_branch, resume_for_project, find_sessions_for_project
  (dead after --resume removal)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Only attempt git checkout when running interactively (stderr is a
terminal) and after a y/N prompt. Prevents unintended side effects
when pickbrain is invoked as a skill or in a pipeline.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
} else {
eprintln!("Usage: pickbrain [--branch NAME|.] [--session UUID] [--exclude UUID,...] [--since 24h|7d|2w] <query>");
eprintln!(" pickbrain --branch NAME|.");
eprintln!("Usage: pickbrain [--branch NAME|.] [--session UUID] [--exclude UUID,...] [--since 24h|7d|2w] [query]");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets ask Claude to split this into N extra-indented alpha-sorted sub-lines, perhaps with comments

eiderman and others added 4 commits April 17, 2026 12:27
Byte-slicing into a multi-byte character (e.g. em dash) caused a panic.
Use floor_char_boundary to find a safe cut point.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Both TUIs now:
- Exit search mode on arrow up/down (falling through to navigation)
- Highlight the search bar (bg) when in search mode
- Remove list highlight when search bar is focused
- Esc and Enter both accept current search results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Esc cancels the search and restores previous results. Enter and arrow
keys accept and exit. Help text leads with ⏎ since that's the
intuitive action most users will try first.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Arrow down was falling through to navigation, advancing past item 1.
Now exits search with continue so the highlight lands on the current
selection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants