Skip to content

fix: polish tab strip context interactions#150

Open
Star-sumi wants to merge 2 commits into
OlaProeis:masterfrom
Star-sumi:fix/tab-strip-context-polish
Open

fix: polish tab strip context interactions#150
Star-sumi wants to merge 2 commits into
OlaProeis:masterfrom
Star-sumi:fix/tab-strip-context-polish

Conversation

@Star-sumi

@Star-sumi Star-sumi commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Description

Polishes tab-strip interactions so tabs respond immediately on pointer press, use stable egui IDs, show the full file path on hover, and expose a small right-click context menu.

Related: #118

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement

Changes Made

  • Use stable tab ids for tab and close-button egui IDs, reducing ID churn during tab rendering.
  • Activate tabs on primary pointer press so switching feels more immediate.
  • Add a tab right-click menu with New Tab, Close Tab, Copy File Path, and Reveal in Explorer.
  • Show configured shortcut hints in the tab context menu where available.
  • Show the full backing file path when hovering a tab.
  • Clear stale tab context menu state when a tab is closed via menu/button/shortcut.

Screenshots

If this PR includes UI changes, please add before/after screenshots:

Before After

Checklist

  • My code follows the project's code style
  • I have run cargo fmt and it produces no changes
  • I have run cargo clippy and it produces no warnings
  • I have run cargo test and all tests pass
  • I have run cargo build --release successfully
  • I have updated documentation if needed (not needed)
  • I have added tests for new functionality (if applicable)
  • My changes generate no new warnings

Breaking Changes

None.

Testing

  1. git diff --check
  2. cargo check

Additional Notes

cargo check passes with three pre-existing warnings in src/markdown/mod.rs and src/markdown/video_embed.rs about unused video embed exports/functions. I did not include a broad cargo fmt run because the current tree contains unrelated formatting diffs in files outside this change; this PR avoids that noise.

Summary by CodeRabbit

Release Notes

  • New Features
    • Enhanced tab context menus: right-click the “+” new-tab button or any tab to access context actions (new tab, close tab, copy path, reveal in explorer), with options shown only when a tab has an associated file path.
  • Improvements
    • Tab tooltips now show the full file system path when available.
    • Context menus are persistent at the pointer, dismiss on Escape/outside click, and Zen Mode clears any open tab menu state.

@coderabbitai

coderabbitai Bot commented Jun 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 15b1f477-eb30-4cf3-b97f-b885f2120cde

📥 Commits

Reviewing files that changed from the base of the PR and between e31e7ef and c820b05.

📒 Files selected for processing (2)
  • src/app/central_panel.rs
  • src/ui/action_registry.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/ui/action_registry.rs
  • src/app/central_panel.rs

📝 Walkthrough

Walkthrough

Adds a right-click context menu to the editor tab strip. A new action_registry module defines stable action IDs, context-aware action lists, and a shared menu renderer with shortcut hints. UiState gains a tab_context_menu field tracking the active menu's tab index and anchor position. Tab bar rendering is refactored to split click/drag interactions, carry per-tab filesystem paths, and dispatch four context actions: new tab, close tab, copy path to clipboard, and reveal in OS file explorer.

Changes

Tab Strip Right-Click Context Menu

Layer / File(s) Summary
Action registry types and menu renderer
src/ui/action_registry.rs, src/ui/mod.rs
Introduces ContextActionId, ActionContext, ActionDefinition, ActionRegistry::actions_for, render_action_menu_with_shortcuts, and localized_label. Wired into the UI module via declaration and re-exports.
Context menu state field and close-tab cleanup
src/state.rs, src/app/navigation.rs, src/app/central_panel.rs (line 643)
UiState gains tab_context_menu: Option<(usize, egui::Pos2)>. Both handle_close_current_tab and the close path in central_panel.rs clear this field before closing to prevent stale state.
Tab bar click/drag split and per-tab path metadata
src/app/central_panel.rs (imports, collection, destructuring, interaction refactor)
Imports extended for context-menu helpers and PathBuf. Tab collection carries Option<PathBuf> per tab. Egui interactions split into separate click and drag responses; hover, background highlight, drop-target detection, and close-button ID updated accordingly.
Tab activation logic and path tooltips
src/app/central_panel.rs (lines 491–525)
Tab selection updated to set active tab on primary press within the tab (excluding close button) or normal click outside close button. Middle-click close support added. Tab tooltips now display the filesystem path when present.
Context menu opening and action execution
src/app/central_panel.rs (lines 390–419, 571–632, 655–668, 686–687)
Secondary-click sets tab_context_menu and opens a popup menu. The "+" button routes through the same context-action flow. Menu renders actions with shortcuts and closes on selection, Escape, or outside click. Side effects execute copy-to-clipboard and reveal-in-explorer with error toast on failure. Zen Mode clears stale menu state.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 Hop, right-click, a menu blooms,
New tab, close tab — no more glooms!
Copy path with one swift press,
Reveal in Finder, nothing less.
The rabbit thumped and tabs obeyed,
A context menu smartly made! 🌿

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: polish tab strip context interactions' accurately reflects the main changes: improving tab-strip context menu interactions with refinements like right-click context menus, hover tooltips, and state cleanup.
Docstring Coverage ✅ Passed Docstring coverage is 83.33% which is sufficient. The required threshold is 80.00%.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/app/central_panel.rs`:
- Around line 659-673: The code in the tab_context_reveal_path block is
collapsing file paths to their parent directory before opening them in the
explorer, which prevents revealing the actual selected file. Remove the logic
that converts files to their parent directory (lines 660-664 containing the if
let Some(path) assignment and the folder variable construction). Instead, pass
the original path directly to open::that(), allowing RevealInExplorer to target
the selected file itself for file-backed tabs while still handling directory
paths correctly.
- Around line 577-628: The tab context menu dismissal logic is currently nested
inside the if let block that checks for an active menu, so it only runs while
the tab strip is visible. When the tab strip stops rendering (such as when
entering Zen Mode), the menu state in self.state.ui.tab_context_menu is never
cleared and persists as stale data. Add code outside the tab context menu
rendering block to clear self.state.ui.tab_context_menu to None when the tab
strip is not being rendered or is hidden, ensuring the popup cannot reappear at
stale screen positions when the tab strip becomes visible again.

In `@src/ui/action_registry.rs`:
- Line 58: The "Copy File Path" label in the ActionDefinition for
ContextActionId::CopyPath on line 58 is hardcoded in English instead of using a
localized label like the sibling actions in the same registry. Replace the
hardcoded string "Copy File Path" with a localized label using the same i18n
pattern that the adjacent action definitions use in this file, ensuring
consistency across all action labels in the action_registry.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 94ca2ca8-b40d-4bc9-8b70-dc74745b2ab6

📥 Commits

Reviewing files that changed from the base of the PR and between 3ba085c and e31e7ef.

📒 Files selected for processing (5)
  • src/app/central_panel.rs
  • src/app/navigation.rs
  • src/state.rs
  • src/ui/action_registry.rs
  • src/ui/mod.rs

Comment thread src/app/central_panel.rs
Comment thread src/app/central_panel.rs
Comment thread src/ui/action_registry.rs Outdated
@Star-sumi

Copy link
Copy Markdown
Contributor Author

Fresh refresh on PR 150: the latest CI run 27516751651 still fails in cargo test, but cargo check passed on both Linux and Windows. The first meaningful errors repeat in src/markdown/mermaid/mod.rs, and the later failure also hits src/ui/productivity_panel.rs, which are outside the files touched by this PR (src/app/central_panel.rs, src/ui/action_registry.rs, src/app/navigation.rs, src/state.rs, src/ui/mod.rs).

I also re-ran cargo check --bin ferrite locally in the tab-strip worktree and it passed. I’m treating the remaining red as upstream baseline, not expanding this PR.

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