Skip to content

Add Cmd+F terminal search with case-sensitive option - #241

Merged
AviPeltz merged 6 commits into
mainfrom
magenta-mountain-79
Dec 2, 2025
Merged

AviPeltz merged 6 commits into
mainfrom
magenta-mountain-79

Conversation

@AviPeltz

@AviPeltz AviPeltz commented Dec 2, 2025 •

Copy link
Copy Markdown
Collaborator
  • Add FIND_IN_TERMINAL hotkey (meta+f) to hotkeys.ts
  • Create TerminalSearch component using xterm search addon
  • Support case-sensitive toggle with tooltip
  • Only trigger search in focused terminal
  • Remove unused HotkeyModal component

🤖 Generated with Claude Code

Description

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Other (please describe):

Testing

Screenshots (if applicable)

Additional Notes

Summary by CodeRabbit

  • New Features

    • Terminal search UI with case-sensitivity toggle, next/previous navigation, and keyboard controls (Enter/Shift+Enter, Esc).
    • Cmd/Ctrl+F opens the find UI when the terminal is focused.
    • New "Find in Terminal" shortcut added to the shortcuts list.
  • Removed

    • Keyboard shortcuts modal dialog (Hotkeys viewer) has been removed.

✏️ Tip: You can customize this high-level summary in your review settings.

- Add FIND_IN_TERMINAL hotkey (meta+f) to hotkeys.ts
- Create TerminalSearch component using xterm search addon
- Support case-sensitive toggle with tooltip
- Only trigger search in focused terminal
- Remove unused HotkeyModal component

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel

vercel Bot commented Dec 2, 2025 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
website Ready Ready Preview Comment Dec 2, 2025 8:48am

@coderabbitai

coderabbitai Bot commented Dec 2, 2025 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@AviPeltz has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 14 minutes and 27 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 1353532 and 9baa15d.

📒 Files selected for processing (3)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (7 hunks)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx (1 hunks)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/WindowView/WindowPane.tsx (1 hunks)

Walkthrough

This PR removes the HotkeyModal component and its export, and adds an xterm.js-powered terminal search: Terminal now loads and manages a SearchAddon, supports Cmd/Ctrl+F to open a new TerminalSearch UI, and a FIND_IN_TERMINAL hotkey was added to shared hotkeys.

Changes

Cohort / File(s) Summary
HotkeyModal Removal
apps/desktop/src/renderer/components/HotkeyModal/HotkeyModal.tsx, apps/desktop/src/renderer/components/HotkeyModal/index.ts
Deleted the HotkeyModal component file and removed its re-export from the index.
Terminal Search Integration
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
Loads xterm.js SearchAddon on terminal init, stores addon ref, tracks pane focus, handles Cmd/Ctrl+F to toggle search UI, renders TerminalSearch overlay, and cleans up addon on teardown.
TerminalSearch Component
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx, .../TerminalSearch/index.ts
New TerminalSearch component (exported via index): manages query, match count, case sensitivity, keyboard navigation (Enter/Shift+Enter), Esc to close, decoration cleanup, and auto-focus when opened.
Hotkeys Definition
apps/desktop/src/shared/hotkeys.ts
Added FIND_IN_TERMINAL hotkey (meta+f) under the Terminal category with label and description.

Sequence Diagram

sequenceDiagram
    participant User
    participant Terminal
    participant TerminalSearch
    participant SearchAddon

    User->>Terminal: Focus terminal pane
    Terminal->>Terminal: set isFocused = true
    User->>Terminal: Press Cmd/Ctrl+F
    Terminal->>Terminal: detect shortcut -> set isSearchOpen = true
    Terminal->>TerminalSearch: render with searchAddon & isOpen=true
    TerminalSearch->>TerminalSearch: auto-focus input
    User->>TerminalSearch: Type query
    TerminalSearch->>SearchAddon: find(query, caseSensitive)
    SearchAddon-->>TerminalSearch: matchCount / highlights
    User->>TerminalSearch: Press Enter / Shift+Enter
    TerminalSearch->>SearchAddon: findNext() / findPrevious()
    SearchAddon-->>TerminalSearch: highlight match in terminal
    User->>TerminalSearch: Press Esc or close
    TerminalSearch->>SearchAddon: clearDecorations()
    TerminalSearch->>Terminal: onClose callback
    Terminal->>Terminal: set isSearchOpen = false
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify SearchAddon lifecycle and proper disposal in Terminal.tsx.
  • Check keyboard shortcut gating by focus and absence of conflicts with existing handlers.
  • Review TerminalSearch.tsx for event handling, decoration cleanup, and focus/accessibility behavior.

Possibly related PRs

Poem

🐰
I hopped into code with keys that gleam,
Cmd+F now opens a searching stream,
Modal's gone, the terminal sings,
Matches hop up on nimble springs,
A little rabbit finds all things ✨

Pre-merge checks and finishing touches

❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The description provides a bullet-point summary of changes but largely omits required template sections (Related Issues, Type of Change, Testing, Screenshots, Additional Notes are empty or unchecked). Fill in the required template sections: select a Type of Change, link related issues if applicable, document testing steps, and add any other relevant context.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main feature addition: terminal search with Cmd+F and case-sensitive option, matching the primary changes in the changeset.

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
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx (2)

29-29: Consider renaming matchCount to clarify its purpose.

The variable name matchCount suggests a numeric count of matches, but it's actually used as a tri-state indicator (1 = found, 0 = not found, null = empty). The xterm SearchAddon doesn't provide actual match counts, only boolean found/not-found results.

Consider renaming to searchResult or hasMatch with a boolean type:

-const [matchCount, setMatchCount] = useState<number | null>(null);
+const [hasMatch, setHasMatch] = useState<boolean | null>(null);

Then update the corresponding usage throughout the file (lines 67, 78, 80, 93, 113, 130-132).


90-95: Remove redundant query dependency to prevent duplicate searches.

The effect re-runs the search when query changes, but handleInputChange (lines 72-83) already performs the search on every keystroke. This causes the search to execute twice per character typed—once in the input handler and once in the effect.

Remove query from the dependency array since the effect's purpose is to re-run the search only when case sensitivity changes:

 	useEffect(() => {
 		if (searchAddon && query) {
 			const found = searchAddon.findNext(query, searchOptions);
 			setMatchCount(found ? 1 : 0);
 		}
-	}, [caseSensitive, searchAddon, query, searchOptions]);
+	}, [caseSensitive, searchAddon, searchOptions]);

Note: searchOptions already depends on caseSensitive, so you could simplify further to [searchOptions, searchAddon], but the current form is more explicit.

apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (1)

128-132: Consider guarding against race condition in async addon loading.

If the component unmounts before the dynamic import completes, searchAddonRef.current will be set after cleanup. While this is a minor issue (the ref will eventually be garbage collected), a more robust approach would check if the component is still mounted.

Add a mounted flag to guard the async operation:

+		let mounted = true;
+
 		// Load search addon for Cmd+F functionality
 		import("@xterm/addon-search").then(({ SearchAddon }) => {
+			if (!mounted) return;
 			const searchAddon = new SearchAddon();
 			xterm.loadAddon(searchAddon);
 			searchAddonRef.current = searchAddon;
 		});

 		// ... rest of effect

 		return () => {
+			mounted = false;
 			inputDisposable.dispose();
 			cleanupFocus?.();
 			// ... rest of cleanup

This is optional and may be overkill for this use case.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 257caad and 6773963.

📒 Files selected for processing (6)
  • apps/desktop/src/renderer/components/HotkeyModal/HotkeyModal.tsx (0 hunks)
  • apps/desktop/src/renderer/components/HotkeyModal/index.ts (0 hunks)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (6 hunks)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx (1 hunks)
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts (1 hunks)
  • apps/desktop/src/shared/hotkeys.ts (1 hunks)
💤 Files with no reviewable changes (2)
  • apps/desktop/src/renderer/components/HotkeyModal/index.ts
  • apps/desktop/src/renderer/components/HotkeyModal/HotkeyModal.tsx
🧰 Additional context used
📓 Path-based instructions (6)
apps/desktop/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

For Electron interprocess communication, ALWAYS use tRPC as defined in src/lib/trpc

Files:

  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts
apps/desktop/**/*.{ts,tsx}

📄 CodeRabbit inference engine (apps/desktop/AGENTS.md)

apps/desktop/**/*.{ts,tsx}: Please use alias as defined in tsconfig.json when possible
Prefer zustand for state management if it makes sense. Do not use effect unless absolutely necessary

Files:

  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx}: Avoid using any type - use explicit types instead for type safety
Use camelCase for variable and function names following existing codebase patterns
Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications
Follow existing patterns and match the codebase style when writing new code

Files:

  • apps/desktop/src/shared/hotkeys.ts
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts
**/components/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

**/components/**/*.tsx: Create one folder per component with structure: ComponentName/ComponentName.tsx + index.ts for barrel export
Co-locate tests next to the component file they test (e.g., ComponentName.test.tsx)
Co-locate dependencies (utils, hooks, constants, config, stories) next to the file using them
Use nested components/ subdirectory within a parent component only if a sub-component is used 2+ times within that parent; otherwise keep it in the parent's components/ folder
One component per file - avoid multi-component files

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx
apps/desktop/src/renderer/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Never import Node.js modules (fs, path, os, net, etc.) in renderer process code - browser environment only

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts
apps/desktop/src/renderer/**/*.tsx

📄 CodeRabbit inference engine (AGENTS.md)

Call IPC methods using window.ipcRenderer.invoke() with object parameters - TypeScript will infer the exact response type automatically

Files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx
🧠 Learnings (2)
📚 Learning: 2025-11-28T01:03:47.963Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-28T01:03:47.963Z
Learning: Applies to **/*.{ts,tsx} : Keep diffs minimal with targeted edits only - avoid unnecessary changes when making modifications

Applied to files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx
📚 Learning: 2025-11-24T21:33:13.267Z
Learnt from: CR
Repo: superset-sh/superset PR: 0
File: apps/desktop/AGENTS.md:0-0
Timestamp: 2025-11-24T21:33:13.267Z
Learning: Applies to apps/desktop/**/*.{ts,tsx} : Please use alias as defined in `tsconfig.json` when possible

Applied to files:

  • apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts
🧬 Code graph analysis (1)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx (1)
packages/ui/src/components/tooltip.tsx (3)
  • Tooltip (74-74)
  • TooltipTrigger (74-74)
  • TooltipContent (74-74)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (13)
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/index.ts (1)

1-1: LGTM! Follows component structure guidelines.

The barrel export follows the prescribed pattern of index.ts exporting from ComponentName.tsx.

apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/TerminalSearch/TerminalSearch.tsx (4)

1-11: LGTM! Clean imports and type definitions.

The props interface correctly handles the nullable searchAddon to account for async addon loading, and all imports are well-organized.


13-20: LGTM! Well-defined search decoration theme.

The decoration colors appropriately distinguish between regular matches and the active match for good UX.


56-115: LGTM! Event handlers are well-implemented.

The handlers correctly manage search navigation, input changes, case sensitivity toggling, and keyboard shortcuts. The null checks for searchAddon and query prevent errors during async loading.


117-177: LGTM! Well-structured search UI with good accessibility.

The UI provides clear visual feedback and includes helpful tooltips and title attributes for all interactive elements. The absolute positioning and backdrop blur create good visual separation from the terminal content.

apps/desktop/src/shared/hotkeys.ts (1)

106-111: LGTM! Well-integrated hotkey definition.

The new FIND_IN_TERMINAL hotkey follows the existing pattern and is appropriately categorized. The meta+f binding intentionally overrides the browser's default find behavior to provide terminal-specific search functionality, which aligns with the PR objectives.

apps/desktop/src/renderer/screens/main/components/WorkspaceView/ContentView/TabsContent/Terminal/Terminal.tsx (7)

3-3: LGTM! Clean imports for search integration.

All imports are appropriately typed and follow the codebase patterns. The type-only import for SearchAddon on line 3 is correct for the initial type annotation.

Also applies to: 6-6, 10-10, 18-18


31-31: LGTM! Appropriate refs and state for search integration.

The searchAddonRef stores the addon instance, and isSearchOpen tracks visibility—both are correctly implemented for the search feature.

Also applies to: 35-35


105-112: LGTM! Properly scoped hotkey handler.

The hotkey is correctly restricted to the focused terminal via enabled: isFocused, preventing multiple terminals from responding to the same shortcut. The dependency array is appropriate.


255-255: LGTM! Proper cleanup of search addon reference.

Resetting the ref to null prevents stale references after terminal disposal. The addon itself is automatically disposed by xterm.dispose() on line 253.


300-300: LGTM! Required positioning for search overlay.

The relative class is necessary for the absolutely positioned TerminalSearch component to anchor correctly within the terminal container.


305-309: LGTM! Proper integration of search component.

The TerminalSearch component is correctly wired with the addon reference, visibility state, and close callback. The rendering order ensures the search UI overlays the terminal content.


37-43: No issues found—focusedPaneIds is the correct, intentional API.

The plural form focusedPaneIds is a Record<string, string> (map of windowId → paneId) as defined in the store types and documented with the comment "last focused pane in each window". All usages across the codebase consistently follow this pattern. This is the proper design for multi-window architectures, not an undocumented API change.

Add isUnmounted flag to prevent loading addon on disposed xterm instance
if the terminal unmounts before the dynamic import resolves.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Match app styling by using Button with ghost variant and icon-sm size.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- More compact layout with smaller icons and padding
- Subtler border and background opacity
- Grouped action buttons with separator
- Adjusted positioning (top-3 right-4)
- Smoother hover transitions

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Prevent Electron's native find overlay with preventDefault
- Auto-close search when terminal loses focus
- Refine search bar styling with better hover states
- Fix pane close button: tighter padding with circular highlight
- Remove unused Button import from WindowPane
- Remove redundant dependency in useEffect

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@AviPeltz
AviPeltz merged commit 712284e into main Dec 2, 2025
7 checks passed
This was referenced Dec 3, 2025
@Kitenite
Kitenite deleted the magenta-mountain-79 branch December 3, 2025 16:48

This branch was successfully deployed

1 active deployment
Preview — 9baa15df Deployed Dec 2, 2025 by vercel[bot]
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