Repository navigation
Add search by name, project, and prompt for automations - #12561
Conversation
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.
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (13)
📝 WalkthroughWalkthroughThe 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. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches📝 Generate docstrings
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🧹 Nitpick comments (11)
src/renderer/src/components/automations/AutomationDeleteDialogs.tsx (2)
54-61: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCompose 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 valuePrefer 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 winGroup runs by automation once instead of filtering inside the map.
Line 92 scans the full
runsarray for every rendered automation. The cost is O(automations × runs) on each render, andrelativeNowchanges re-render this list on a timer. Build oneMap<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 winDeclare the shared automation page types once. The extraction re-declared types that
AutomationsPagealso 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: moveAutomationPaneTabandSelectedExternalRunPageinto a shared automation page-state module and import them here.src/renderer/src/components/automations/AutomationsListPanel.tsx#L50: importAutomationPaneTabfrom that module instead of inlining the'overview' | 'runs'union in thesetActivePaneTabsignature.
73-73: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAccept
ReadonlyMapforworktreeMap.
AutomationRunHistoryonly reads from this prop, so useReadonlyMap<string, Worktree>here or update the same prop type onAutomationsDetailPaneif 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 winReplace the inline pixel padding with utility classes.
Line 49 sets
paddingRightto raw72or28. UI work must use the token/utility system rather than invented spacing values. The72value is also tuned to the English string "Too long", so a longer translation oftooLongShortcan 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 fromsrc/renderer/src/assets/main.css, and use shadcn primitives fromsrc/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 valueUse 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 winAdd a multi-byte over-limit query case.
Every oversized fixture here uses ASCII
'a', sotext.length > maxBytesshort-circuits insideisClipboardTextByteLengthOverLimit. The UTF-8 measurement branch insrc/shared/clipboard-text.tsis 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 winCover the index/item length-mismatch fallback.
filterByActiveAutomationListSearchQueryreturns a copy of all items whenindexes.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 valueGive each delete dialog its own confirm-button ref.
deleteConfirmButtonRefis passed to bothAutomationDeleteDialogandExternalAutomationDeleteDialog. Both components stay mounted, and each assigns the same ref from its own confirmButtonand reads it inonOpenAutoFocus. 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 valueRemove the deprecated
getAutomationListSearchQuerywrapper.
resolveAutomationListSearchQueryis 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
📒 Files selected for processing (19)
src/renderer/src/components/automations/AutomationDeleteDialogs.tsxsrc/renderer/src/components/automations/AutomationListExternalRows.tsxsrc/renderer/src/components/automations/AutomationListLocalRows.tsxsrc/renderer/src/components/automations/AutomationListSearchField.tsxsrc/renderer/src/components/automations/AutomationsDetailPane.tsxsrc/renderer/src/components/automations/AutomationsListPanel.tsxsrc/renderer/src/components/automations/AutomationsPage.tsxsrc/renderer/src/components/automations/ExternalAutomationManagers.tsxsrc/renderer/src/components/automations/ExternalAutomationRunTable.tsxsrc/renderer/src/components/automations/automation-draft-model.tssrc/renderer/src/components/automations/automation-host-client.tssrc/renderer/src/components/automations/automation-list-search.test.tssrc/renderer/src/components/automations/automation-list-search.tssrc/renderer/src/components/automations/automation-run-content.tssrc/renderer/src/components/automations/automation-run-view-state.tssrc/renderer/src/components/automations/automation-source-context.tssrc/renderer/src/components/automations/external-automation-display.tssrc/renderer/src/components/automations/external-automation-list-entries.tssrc/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.
|
@coderabbitai Fixing. Will be in the next commit |
|
Tip For best results, initiate chat on the files or code changes.
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
* 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
Summary
Adds search functionality to the automations list, allowing users to filter automations by name, project, or prompt text. Also refactors
AutomationsPageto extract UI components and utility functions into separate modules for better maintainability.Changes
AutomationListSearchField.tsx): Input field with query validation, character limit feedback, and escape/clear handlersautomation-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 updatesuse-automation-list-search.ts): Deferred value pattern keeps input responsive while filtering runs in background; auto-adjusts selection when search hides current rowAutomationsListPanel,AutomationsDetailPane,AutomationDeleteDialogs,AutomationListLocalRows,AutomationListExternalRowsto reduce main page complexityautomation-draft-model.ts,automation-run-content.ts,automation-source-context.ts,external-automation-display.ts,external-automation-list-entries.tsfor reusabilityTesting
Included
automation-list-search.test.tswith 10+ test cases: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.