Skip to content

refactor(ui): reuse pathLeaf instead of local basename copies - #152

Merged
danielss-dev merged 2 commits into
mainfrom
developements/dedupe-path-leaf-1995
Oct 22, 2026
Merged

danielss-dev merged 2 commits into
mainfrom
developements/dedupe-path-leaf-1995

Conversation

@danielss-dev

@danielss-dev danielss-dev commented Oct 17, 2026 •

Copy link
Copy Markdown
Owner

Problem

The same last-path-segment helper was copy-pasted in three UI files, while pathLeaf already existed:

  • ui/src/App.tsx — local basename via split(/[\\/]/).filter(Boolean)
  • ui/src/views/Review.tsx — local basename via split(/[\\/]/).filter(Boolean).pop() ?? p
  • ui/src/views/Commits.tsx — the same split/filter/pop inline on the two "Back to" labels
  • Shared helper already at ui/src/lib/repoIdentity.ts (pathLeaf)

After filter(Boolean), [\\/] and pathLeaf's [\\/]+ are equivalent.

Solution

Delete the local copies and call pathLeaf. No new helper, no rename sweep.

Left alone on purpose: FileView.tsx basename only splits on / (git-relative paths); plugin-local copies (HeroiView, Quick Notes, Agent Session Recap) to keep this change small.

Merged current main (eddbe24) in. The only conflict was the Commits.tsx import: keep pathLeaf and main's t import from i18n. Undo focus gating (data-git-undo-surface) and drag-and-drop (data-git-index) stay as they are on main.

Files

  • ui/src/App.tsx
  • ui/src/views/Review.tsx
  • ui/src/views/Commits.tsx
  • ui/src/lib/repoIdentity.test.ts

Tests run

pnpm --filter ./ui exec tsc --noEmit
→ exit 0

pnpm --filter ./ui test
→ Test Files  114 passed (114)
   Tests      733 passed (733)
   includes gitUndoBindingAllowed (keys.test.ts), gitDrag, and pathLeaf

No Rust delta versus main; CI Rust (ubuntu + macos) and clippy passed on the merge head.

Risks

Display-only (progress subject, toast, icon-dialog fallback, review feedback repo name, "Back to …" bars). Empty/separator-only strings still return the original input, pinned by the pathLeaf tests.

Open in Web Open in Cursor 

App, Review, and Commits each inlined the same last-segment helper.
Call the existing pathLeaf from repoIdentity and pin it against the
deleted split/filter algorithm.

Co-authored-by: Daniels <danielss-dev@users.noreply.github.com>
@danielss-dev
danielss-dev marked this pull request as ready for review October 22, 2026 16:23
…path-leaf-1995

Keep main's i18n import and the undo/drag graph behavior in Commits.tsx.
Re-apply pathLeaf only for the two "Back to" labels.

Co-authored-by: Daniels <danielss-dev@users.noreply.github.com>
@danielss-dev
danielss-dev merged commit 14c5a8c into main Oct 22, 2026
5 checks passed
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