Skip to content

Add search by name, project, and prompt for automations - #12561

Merged
AmethystLiang merged 3 commits into
mainfrom
add-search-for-automations-name
Aug 4, 2026
Merged

AmethystLiang merged 3 commits into
mainfrom
add-search-for-automations-name

Conversation

@AmethystLiang

Copy link
Copy Markdown
Contributor

Summary

Adds search functionality to the automations list, allowing users to filter automations by name, project, or prompt text. Also refactors AutomationsPage to extract UI components and utility functions into separate modules for better maintainability.

Changes

  • Search UI (AutomationListSearchField.tsx): Input field with query validation, character limit feedback, and escape/clear handlers
  • Search logic (automation-list-search.ts): Query resolution with bounds checking (2KB max), field normalization and truncation (prevents indexing multi-MB prompts), substring matching, and fingerprint-based change detection to skip rebuilds on unrelated updates
  • Search hook (use-automation-list-search.ts): Deferred value pattern keeps input responsive while filtering runs in background; auto-adjusts selection when search hides current row
  • Component extraction: Broke out AutomationsListPanel, AutomationsDetailPane, AutomationDeleteDialogs, AutomationListLocalRows, AutomationListExternalRows to reduce main page complexity
  • Utility modules: Extracted automation-draft-model.ts, automation-run-content.ts, automation-source-context.ts, external-automation-display.ts, external-automation-list-entries.ts for reusability

Testing

Included automation-list-search.test.ts with 10+ test cases:

  • Query normalization and bounds validation
  • Surrogate pair safety during field truncation
  • Unknown project fallback for missing repos
  • Oversized query rejection (leaves list unfiltered, skips work)
  • Whitespace-only queries treated as inactive
  • Fingerprint stability across equivalent sources

Notes

Search caps indexed field lengths so large prompts (multi-MB) don't block filtering. Deferred matching ensures input caret never waits on substring scans. Selection auto-heal on filter matches first visible row so list highlight and detail pane stay in sync.

Split the monolithic automations page into focused modules: extract dialog logic, list panel rendering, search functionality, and utility helpers into separate files. Introduce deferred search matching to keep the input responsive, with proper bounds checking to reject oversized pastes. The page stays unfiltered when search is inactive or too large, preserving the original list view in those cases.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 3a3f5260-7396-4df9-a172-feaf48f38449

📥 Commits

Reviewing files that changed from the base of the PR and between 45b5f8f and bc112af.

📒 Files selected for processing (13)
  • src/renderer/src/components/automations/AutomationDeleteDialogs.tsx
  • src/renderer/src/components/automations/AutomationListExternalRows.tsx
  • src/renderer/src/components/automations/AutomationListLocalRows.tsx
  • src/renderer/src/components/automations/AutomationListSearchField.tsx
  • src/renderer/src/components/automations/AutomationRunHistory.tsx
  • src/renderer/src/components/automations/AutomationsDetailPane.tsx
  • src/renderer/src/components/automations/AutomationsListPanel.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/automation-list-search.test.ts
  • src/renderer/src/components/automations/automation-list-search.ts
  • src/renderer/src/components/automations/automation-page-state.ts
  • src/renderer/src/components/automations/use-automation-list-search.ts
  • src/renderer/src/i18n/locales/en.json

📝 Walkthrough

Walkthrough

The change extracts automation page functionality into shared helpers and dedicated components. It adds bounded search with indexing, filtering, fingerprints, selection synchronization, and query feedback. It adds local and external automation list rows, detail rendering, deletion dialogs, and list-panel orchestration. It centralizes draft, host-target, source-context, external-display, run-content, and rerun-state logic. AutomationsPage now wires these modules through explicit props and shared state.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary, implementation, testing, and notes, but omits the required Screenshots, AI Review Report, and Security Audit sections. Add the required Screenshots, AI Review Report, and Security Audit sections, and record the applicable results or state that no visual change occurred.
Docstring Coverage ⚠️ Warning Docstring coverage is 14.81% which is insufficient. The required threshold is 80.00%. 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 and concisely describes the primary user-visible change: searching automations by name, project, and prompt.
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.
✨ Finishing Touches
📝 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.

@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: 6

🧹 Nitpick comments (11)
src/renderer/src/components/automations/AutomationDeleteDialogs.tsx (2)

54-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Compose each description from one translation unit with interpolation.

Both descriptions build a sentence from several translate() fragments ('Delete', 'and its run history...', 'from', 'on'). Word order and grammar change per language, so translators cannot reorder these fragments. Use a single key per sentence with named placeholders for the automation name, provider label, and target label.

Also applies to: 143-157


79-96: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Prefer the shadcn checkbox primitive for the "Don't ask again" control.

This control re-implements a checkbox with a <button role="checkbox"> and manual indicator styling. src/renderer/src/components/ui/ provides the shadcn primitive, and the coding guidelines require shadcn primitives for UI work. The primitive also supplies the label association and indicator states.

As per coding guidelines: "use shadcn primitives from src/renderer/src/components/ui/".

Source: Coding guidelines

src/renderer/src/components/automations/AutomationListLocalRows.tsx (1)

91-93: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Group runs by automation once instead of filtering inside the map.

Line 92 scans the full runs array for every rendered automation. The cost is O(automations × runs) on each render, and relativeNow changes re-render this list on a timer. Build one Map<string, AutomationRun[]> before the map callback and read each automation's runs from it.

♻️ Proposed refactor
 }): React.JSX.Element {
+  const runsByAutomationId = React.useMemo(() => {
+    const grouped = new Map<string, AutomationRun[]>()
+    for (const run of runs) {
+      const existing = grouped.get(run.automationId)
+      if (existing) {
+        existing.push(run)
+      } else {
+        grouped.set(run.automationId, [run])
+      }
+    }
+    return grouped
+  }, [runs])
   return (
     <>
       {automations.map((automation) => {
-        const usageSummary = summarizeAutomationRunUsage(
-          runs.filter((run) => run.automationId === automation.id)
-        )
+        const usageSummary = summarizeAutomationRunUsage(
+          runsByAutomationId.get(automation.id) ?? []
+        )
src/renderer/src/components/automations/AutomationsDetailPane.tsx (2)

42-48: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Declare the shared automation page types once. The extraction re-declared types that AutomationsPage also owns, so a change to either shape must be applied in several files and can silently diverge.

  • src/renderer/src/components/automations/AutomationsDetailPane.tsx#L42-L48: move AutomationPaneTab and SelectedExternalRunPage into a shared automation page-state module and import them here.
  • src/renderer/src/components/automations/AutomationsListPanel.tsx#L50: import AutomationPaneTab from that module instead of inlining the 'overview' | 'runs' union in the setActivePaneTab signature.

73-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Accept ReadonlyMap for worktreeMap.

AutomationRunHistory only reads from this prop, so use ReadonlyMap<string, Worktree> here or update the same prop type on AutomationsDetailPane if this child should match the panel’s readonly map interface.

src/renderer/src/components/automations/AutomationListSearchField.tsx (2)

46-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the inline pixel padding with utility classes.

Line 49 sets paddingRight to raw 72 or 28. UI work must use the token/utility system rather than invented spacing values. The 72 value is also tuned to the English string "Too long", so a longer translation of tooLongShort can overlap the clear button.

Use padding utilities, and let the badge width drive the reservation where possible.

As per coding guidelines: "All UI work must follow docs/STYLEGUIDE.md, use tokens from src/renderer/src/assets/main.css, and use shadcn primitives from src/renderer/src/components/ui/; do not invent documented colors, font sizes, or shadow tiers."

♻️ Use utility classes for the trailing padding
-        className="h-8 border-border/60 bg-background pl-8 text-xs"
-        style={hasText ? { paddingRight: isTooLarge ? 72 : 28 } : undefined}
+        className={cn(
+          'h-8 border-border/60 bg-background pl-8 text-xs',
+          hasText && (isTooLarge ? 'pr-20' : 'pr-7')
+        )}

Source: Coding guidelines


64-75: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use a documented font-size tier instead of text-[10px].

Line 68 introduces an arbitrary font size. Use an existing tier such as text-xs, or add the tier to the style tokens first.

As per coding guidelines: "do not invent documented colors, font sizes, or shadow tiers."

Source: Coding guidelines

src/renderer/src/components/automations/automation-list-search.test.ts (2)

33-67: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a multi-byte over-limit query case.

Every oversized fixture here uses ASCII 'a', so text.length > maxBytes short-circuits inside isClipboardTextByteLengthOverLimit. The UTF-8 measurement branch in src/shared/clipboard-text.ts is never reached. Add a query whose code-unit length is under the cap but whose UTF-8 byte length is over it.

💚 Cover the byte-measurement branch
+  it('rejects queries that exceed the byte limit but not the code-unit limit', () => {
+    // 3 bytes per character in UTF-8, so 1024 chars = 3072 bytes > 2048.
+    const multiByte = '한'.repeat(1_024)
+    expect(multiByte.length).toBeLessThanOrEqual(AUTOMATION_LIST_SEARCH_QUERY_MAX_BYTES)
+    expect(isAutomationListSearchQueryTooLarge(multiByte)).toBe(true)
+    expect(resolveAutomationListSearchQuery(multiByte)).toEqual({ status: 'too_large' })
+  })

128-155: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the index/item length-mismatch fallback.

filterByActiveAutomationListSearchQuery returns a copy of all items when indexes.length !== items.length. That branch is the guard that stops a desynchronized index from blanking the list, and no test exercises it.

💚 Assert the mismatch fallback
     expect(filterByAutomationListSearchIndex(items, indexes, '   ')).toBe(items)
+    // Why: a desynchronized index must leave the list unfiltered, not blank it.
+    expect(
+      filterByActiveAutomationListSearchQuery(items, indexes.slice(0, 1), 'apk').map(
+        (item) => item.id
+      )
+    ).toEqual(['1', '2', '3'])
src/renderer/src/components/automations/AutomationsPage.tsx (1)

2008-2037: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Give each delete dialog its own confirm-button ref.

deleteConfirmButtonRef is passed to both AutomationDeleteDialog and ExternalAutomationDeleteDialog. Both components stay mounted, and each assigns the same ref from its own confirm Button and reads it in onOpenAutoFocus. If both targets are ever set, one dialog's unmount clears the ref the other dialog needs for initial focus. Use two refs so each dialog owns its focus target.

♻️ Separate the refs
-  const deleteConfirmButtonRef = useRef<HTMLButtonElement>(null)
+  const deleteConfirmButtonRef = useRef<HTMLButtonElement>(null)
+  const externalDeleteConfirmButtonRef = useRef<HTMLButtonElement>(null)
       <ExternalAutomationDeleteDialog
         externalDeleteTarget={externalDeleteTarget}
-        confirmButtonRef={deleteConfirmButtonRef}
+        confirmButtonRef={externalDeleteConfirmButtonRef}
src/renderer/src/components/automations/automation-list-search.ts (1)

80-93: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Remove the deprecated getAutomationListSearchQuery wrapper.

resolveAutomationListSearchQuery is the canonical query-resolution API, and all callers of the deprecated legacy wrapper are test-only here. Drop the wrapper and the related assertions so the module exposes one query-resolution contract.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c983a123-0976-49b7-a98d-948ae1b405b1

📥 Commits

Reviewing files that changed from the base of the PR and between 4734428 and 805a516.

📒 Files selected for processing (19)
  • src/renderer/src/components/automations/AutomationDeleteDialogs.tsx
  • src/renderer/src/components/automations/AutomationListExternalRows.tsx
  • src/renderer/src/components/automations/AutomationListLocalRows.tsx
  • src/renderer/src/components/automations/AutomationListSearchField.tsx
  • src/renderer/src/components/automations/AutomationsDetailPane.tsx
  • src/renderer/src/components/automations/AutomationsListPanel.tsx
  • src/renderer/src/components/automations/AutomationsPage.tsx
  • src/renderer/src/components/automations/ExternalAutomationManagers.tsx
  • src/renderer/src/components/automations/ExternalAutomationRunTable.tsx
  • src/renderer/src/components/automations/automation-draft-model.ts
  • src/renderer/src/components/automations/automation-host-client.ts
  • src/renderer/src/components/automations/automation-list-search.test.ts
  • src/renderer/src/components/automations/automation-list-search.ts
  • src/renderer/src/components/automations/automation-run-content.ts
  • src/renderer/src/components/automations/automation-run-view-state.ts
  • src/renderer/src/components/automations/automation-source-context.ts
  • src/renderer/src/components/automations/external-automation-display.ts
  • src/renderer/src/components/automations/external-automation-list-entries.ts
  • src/renderer/src/components/automations/use-automation-list-search.ts

Sync en.json keys used by AutomationListSearchField and the no-matches empty state so static analysis localization catalog check passes.
@AmethystLiang

Copy link
Copy Markdown
Contributor Author

@coderabbitai Fixing. Will be in the next commit

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@AmethystLiang Acknowledged. I will verify the fix after the next commit.

You are interacting with an AI system.

- Add 12 i18n keys for automation labels, counts, and usage display
- Extract AutomationPaneTab and SelectedExternalRunPage types to shared automation-page-state module
- Optimize search fingerprint by truncating prompts to indexed prefix for bounded performance per tick
- Improve escape-key handling in search field to clear input before blurring
- Remove deprecated getAutomationListSearchQuery function
@AmethystLiang
AmethystLiang merged commit bc1feb5 into main Aug 4, 2026
0 of 40 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Add search by name, project, and prompt for automations

Split the monolithic automations page into focused modules: extract dialog logic, list panel rendering, search functionality, and utility helpers into separate files. Introduce deferred search matching to keep the input responsive, with proper bounds checking to reject oversized pastes. The page stays unfiltered when search is inactive or too large, preserving the original list view in those cases.

* fix(i18n): add missing automation search localization keys

Sync en.json keys used by AutomationListSearchField and the no-matches empty state so static analysis localization catalog check passes.

* Localize remaining automation strings and optimize search

- Add 12 i18n keys for automation labels, counts, and usage display
- Extract AutomationPaneTab and SelectedExternalRunPage types to shared automation-page-state module
- Optimize search fingerprint by truncating prompts to indexed prefix for bounded performance per tick
- Improve escape-key handling in search field to clear input before blurring
- Remove deprecated getAutomationListSearchQuery function
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