Skip to content

Refactor editor header file rename to breadcrumb morph UI - #21265

Merged
AmethystLiang merged 5 commits into
mainfrom
improve-rename-markdown-file
Sep 22, 2026
Merged

AmethystLiang merged 5 commits into
mainfrom
improve-rename-markdown-file

Conversation

@AmethystLiang

@AmethystLiang AmethystLiang commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​307 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​306
Prod 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​40 $\color{#cf222e}{\Huge{\mathbf{−}}}$​16 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​24

Problem

The file rename input in the editor header was just a text field with no context—you couldn't see which folder you were renaming the file in, the file extension could be accidentally deleted, and the field capped at 520px, which broke for deep directory structures.

Solution

When you open rename mode, the header morphs into a breadcrumb strip showing the full directory path (worktree name + parent folders) as read-only, with only the filename basename editable. The extension is pinned as a suffix and auto-reattached if you type a bare name; if you explicitly type an extension (same or different), it's respected. Added confirm and cancel buttons (Check/X icons) so the rename completes on button click instead of relying on blur focus loss. The morph field now claims full header width instead of capping at 520px.

ELI5

Renaming a file now shows you where it is, protects the file type, and gives you explicit confirm/cancel buttons.

What Changed

  • EditorPanelHeaderPath.tsx: Replaced single input with a breadcrumb morph strip; input now holds basename only, with directory crumbs and extension suffix visible alongside.
  • editor-header-file-rename.ts: Added getBreadcrumbSegments() to build path context; added resolveRenameTarget() to reattach extension or respect explicitly typed ones; exported both for testing.
  • EditorPanelHeaderPath.test.tsx: New test file covering breadcrumb display, extension handling, confirm/cancel, Escape key, empty rename rejection, and files without extensions.
  • EditorFileTab.tsx: Increased inline rename field width (12ch → 18ch) for better editing room.

Why

Breadcrumb context prevents accidental renames in the wrong folder, pinned extension prevents silent type loss, explicit confirm/cancel is clearer than blur-based commits, and full width scales to any depth.

Visual Proof

Rename field morphs from a simple text input to a breadcrumb strip: repo / docs / marketing / | basename-input | .md with confirm/cancel buttons.

Testing

  • Automated tests added: 11 test cases covering breadcrumb display, extension handling, confirm/cancel, Escape key, empty rename rejection, and files without extensions.
  • Manual test scenarios implied by test suite (breadcrumb visibility, extension re-attachment, button interactions, keyboard cancel).

Notes

No breaking changes. Rename behavior and file-on-disk result are unchanged; only the UI presentation and interaction model improved.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • 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 (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Understand this PR’s impact

Explore downstream dependencies and potential security impact with Blast Radius.

View blast radius →

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: 273cae7f-d06b-4ffe-b393-35cf8d6d8d4f

📥 Commits

Reviewing files that changed from the base of the PR and between c3f0f84 and 22a3705.

📒 Files selected for processing (3)
  • src/renderer/src/components/editor/EditorPanelHeaderPath.test.tsx
  • src/renderer/src/components/editor/EditorPanelHeaderPath.tsx
  • src/renderer/src/components/editor/editor-header-file-rename.test.ts

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


📝 Walkthrough

Walkthrough

The rename editor now uses a native full-name input. It preserves extensions, handles IME composition, supports blur and keyboard actions, and cancels when the active file changes. Tests cover these behaviors. Three unrelated files receive formatting-only changes.

Priority: ⬇️ Low

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, solution, rationale, and tests, but required information is missing. The Linked Issue section has no issue reference, Visual Proof does not include before-and-aft… Add a valid issue reference after Fixes #, provide before-and-after screenshots or a video or write N/A with a reason, complete the Agent skill upstream boundary and Review sections, state the platforms tested, and update the validation…
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: refactoring editor header file renaming into a breadcrumb morph UI.
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.
Full details: Description check

Explanation

The description explains the problem, solution, rationale, and tests, but required information is missing. The Linked Issue section has no issue reference, Visual Proof does not include before-and-after attachments or the required N/A statement, and the Agent skill upstream boundary and Review sections are absent. Manual testing and the validation command checklist are also incomplete.

Resolution

Add a valid issue reference after Fixes #, provide before-and-after screenshots or a video or write N/A with a reason, complete the Agent skill upstream boundary and Review sections, state the platforms tested, and update the validation checklist with test results or explain that CI will cover them.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b9d8a050-58ae-4b70-9fe1-03238de53469

📥 Commits

Reviewing files that changed from the base of the PR and between 1957437 and 8cda0f9.

📒 Files selected for processing (4)
  • src/renderer/src/components/editor/EditorPanelHeaderPath.test.tsx
  • src/renderer/src/components/editor/EditorPanelHeaderPath.tsx
  • src/renderer/src/components/editor/editor-header-file-rename.ts
  • src/renderer/src/components/tab-bar/EditorFileTab.tsx

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

@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.

Important

Two CI gates fail on this branch — the localization catalog/extraction checks reject the two new translate keys, and the changed-code quality gate reports 8 <Input> restyle findings on the touched tab-rename line. There is also a UI/behavior mismatch in the pinned-extension logic worth settling before merge.

Reviewed changes

  • Breadcrumb morph rename strip (EditorPanelHeaderPath.tsx) — rename mode now renders directory crumbs, a basename-only <input>, a static extension suffix, and Check/X buttons in place of the single full-name Input. Blur-commit is retained; the buttons preventDefault on mousedown so a click does not blur-commit first.
  • Rename state/helpers (editor-header-file-rename.ts) — adds currentBaseName, currentExtension, breadcrumbSegments, and the exported resolveRenameTarget() that re-attaches or respects the extension; selection logic simplifies to el.select().
  • Tab-strip rename width (EditorFileTab.tsx) — inline tab rename field grows from 12ch/132px to 18ch/200px.
  • Tests (EditorPanelHeaderPath.test.tsx) — 10 new cases covering crumbs, extension handling, confirm/cancel, Escape, empty input, and extensionless files; all pass locally (typecheck and oxlint are clean too).

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@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.

Important

Switching files mid-rename does not fully cancel: the new active-file branch clears isRenaming but leaves the cancel guard unset, so the trailing blur can commit the typed value against the file that was being renamed. One-line fix inline.

Reviewed changes

  • Breadcrumb morph replaced by a plain inline field — EditorPanelHeaderPath.tsx now renders one full-width native <input> holding the whole filename; the directory crumbs, the pinned-extension suffix, and the Check/X buttons are gone. It commits on Enter or blur and cancels on Escape.
  • CJK IME guard added — reuses isImeCompositionKeyDown so an Enter that only confirms a composition candidate does not commit.
  • Active-file tracking added — editor-header-file-rename.ts keeps the file path in state and drops rename mode when the editor switches files.
  • Cancel guard added — renameCancelledRef swallows the trailing blur emitted when the input unmounts after Escape or commit.
  • Extension pinning and breadcrumb helpers removed — resolveRenameTarget/getTypedExtension/getBreadcrumbSegments and the two added confirmRename/cancelRename keys are gone; the EditorFileTab.tsx width tweak is reverted.
  • Unrelated formatter churn — AGENTS.md, docs/reference/remote-wire-compatibility.md, and usage-scan-worker-event-loop.test.ts picked up formatter-only edits.

ℹ️ Nitpicks

  • The PR title/body still describe the breadcrumb strip, pinned extension, and Check/X buttons removed in a594cfb, and claim 11 tests where the file has 10. Update the description to match the shipped inline field.
  • The formatter-only edits to AGENTS.md:75, docs/reference/remote-wire-compatibility.md:105, and usage-scan-worker-event-loop.test.ts:36 are unrelated to the rename and add review noise; consider reverting them.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai coderabbitai 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.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 06e527d7-7ce5-4987-ad4a-51355ac34058

📥 Commits

Reviewing files that changed from the base of the PR and between a594cfb and c3f0f84.

📒 Files selected for processing (2)
  • src/renderer/src/components/editor/EditorPanelHeaderPath.test.tsx
  • src/renderer/src/components/editor/editor-header-file-rename.ts

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

@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 critical issues — the file-switch cancel guard is correct; one minor test-sensitivity note inline.

Reviewed changes

This run re-reviewed the single commit pushed since the prior pullfrog review (a594cfb).

  • File-switch cancel guard (editor-header-file-rename.ts) — the active-file-change branch now sets renameCancelledRef.current = true before clearing isRenaming, so the trailing blur emitted when the rename input unmounts can no longer commit the typed name against the previous file.
  • File-switch test extended (EditorPanelHeaderPath.test.tsx) — dispatches the trailing blur and asserts no rename is requested.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

- Display full breadcrumb (repo name + parent dirs) during rename for context
- Separate basename field from extension suffix to clarify what users edit
- Replace blur-to-commit with explicit confirm/cancel buttons
- Auto-attach extension to basename; respect explicitly typed extensions
- Add comprehensive tests for rename scenarios and edge cases
- Blur no longer commits, preventing accidental renames when focus moves
- IME composition keys properly handled for CJK input support
- File switches during rename now cancel the operation
- Extension display improved to show final filename
- Comprehensive test coverage added for edge cases
Replaces breadcrumb-morph rename with confirm/cancel buttons with a
simple inline field accepting full filenames. Commits on Enter, blur, or
Escape to cancel, matching tab bar and file explorer behavior. Adds
renameCancelledRef to prevent blur-commit after Escape. Removes unused
i18n strings for buttons and simplifies state by dropping extension
pinning and breadcrumb display.
When switching files mid-rename, React may deliver the old input's
blur event after the new file renders, causing a stale rename commit.

Mark the rename as cancelled when the active file changes, and add
test coverage verifying stale blur events are ignored.
Move blur-commit-after-file-change test from EditorPanelHeaderPath
integration tests to useEditorHeaderFileRename unit test. Tests the
blur-handling logic at the hook level where it belongs.
@AmethystLiang
AmethystLiang force-pushed the improve-rename-markdown-file branch from c3f0f84 to 22a3705 Compare September 21, 2026 22:45

@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

This run re-reviewed the one commit pushed since the prior pullfrog review (c3f0f84).

  • Blur-race test moved to the hook — the file-switch DOM test's fireEvent.blur(input) was dropped (it dispatched on an already-unmounted node, so it could not fail), and editor-header-file-rename.test.ts now drives useEditorHeaderFileRename directly: open rename, seed the input ref, rerender with a new active file, then call commitRename() and assert no rename is requested.
  • No production changes — the commit is test-only; the shipped inline field and its file-switch cancel guard are unchanged.

I verified the new test is a real guard: removing renameCancelledRef.current = true from the active-file branch makes it fail with renameFileOnDisk called against the newly active file (oldPath: /repo/other.md), so it now exercises the fix at the level where the race lives. Both rename suites pass (11 tests) and pnpm run typecheck:web is clean.

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

@AmethystLiang
AmethystLiang merged commit 0232c03 into main Sep 22, 2026
28 of 30 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