Skip to content

refactor(renderer): share path head elision - #19938

Merged
AmethystLiang merged 1 commit into
mainfrom
palette-path-head-elision
Sep 11, 2026
Merged

AmethystLiang merged 1 commit into
mainfrom
palette-path-head-elision

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​83 $\color{#cf222e}{\Huge{\mathbf{−}}}$​15 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​68
Prod 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62 $\color{#cf222e}{\Huge{\mathbf{−}}}$​17 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​45

ELI5

Move the existing “keep the useful end of a long path visible” behavior into one reusable renderer helper.

What Changed

  • Added a shared path-head elision helper with POSIX and Windows path support.
  • Preserved and rebased highlight ranges when a matched path segment moves into the visible tail.
  • Migrated the New Workspace project picker to the shared helper.
  • Added focused coverage for deep paths, shallow paths, separators, and matched segments.

Why

The Cmd+J layout work needs the same path treatment as New Workspace. Keeping that behavior in one helper avoids duplicating path parsing and keeps cross-platform handling consistent.

Linked Issue

N/A — no linked issue was provided.

Visual Proof

N/A — this is an extraction/refactor with no intentional layout change in the New Workspace picker.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Validated with:

  • 20 focused tests across the path-elision and New Workspace matching/row suites
  • pnpm tc:web
  • commit hooks
  • pnpm run check:code-quality:changed (run on the complete two-commit stack; 0 new findings)

Platform coverage: automated cases include POSIX and Windows paths. The renderer-only change does not alter execution, SSH, or remote wire behavior.

AI Disclosure

Review

Please review the range math around matches that extend the preserved tail.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

This is PR 1 of 2. The Cmd+J layout PR is stacked on this branch and should merge second.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (targeted tests, pnpm tc:web, commit hooks, and changed-code quality passed; full suite/build left to CI)

@coderabbitai

coderabbitai Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 79e7bd20-1e67-40f7-b609-221d63555ff0

📥 Commits

Reviewing files that changed from the base of the PR and between fb85f88 and fad48ab.

📒 Files selected for processing (6)
  • src/renderer/src/components/new-workspace/ProjectComboboxRow.test.tsx
  • src/renderer/src/components/new-workspace/ProjectComboboxRow.tsx
  • src/renderer/src/components/new-workspace/project-combobox-matching.test.ts
  • src/renderer/src/components/new-workspace/project-combobox-matching.ts
  • src/renderer/src/lib/path-head-elision.test.ts
  • src/renderer/src/lib/path-head-elision.ts
💤 Files with no reviewable changes (1)
  • src/renderer/src/components/new-workspace/project-combobox-matching.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The change adds splitPathHeadForElision with POSIX and Windows path support, match range rebasing, and focused tests. ProjectOptionDetail uses the helper and highlights matched text in the preserved tail. The previous splitDetailForElision helper and its tests are removed.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 5 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise, specific, and accurately describes the main change: sharing path head elision in the renderer.
Description check ✅ Passed The description follows the required template and clearly explains the change, motivation, testing, visual proof, and compatibility considerations. The Linked Issue section contains N/A despite the te…
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

A renderer-only refactor that extracts the New Workspace picker's head-elision into a shared helper so the stacked Cmd+J layout PR can reuse it, and in doing so fixes a highlight-on-elide gap.

  • Shared helper — splitPathHeadForElision replaces the inline splitDetailForElision, adds Windows separator support via isWindowsAbsolutePathLike, and keeps the two-segment tail.
  • Highlight survival — matched single-char ranges are re-based into the elided tail and rendered through MatchedText, instead of being dropped when a path elides.
  • Callers migrated — ProjectOptionDetail consumes the shared helper; the old function and its tests are removed with no dangling references.
  • Coverage — exact-equality tests for POSIX/Windows paths, backslash-in-segment, shallow/deep paths, and matched-segment tail extension.

I traced the range math the description flags: after the findLast adjustment tailStart is always <= the earliest match (and so <= every range start), which makes range.start - tailStart non-negative; the segment-spans-tail and match-sits-in-head cases are pinned by toEqual/toBeNull assertions rather than loose checks.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@AmethystLiang
AmethystLiang merged commit ae72912 into main Sep 11, 2026
29 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.

1 participant