From ed9058c93d42bcd9819d5fbfe27e824b5b67cbaf Mon Sep 17 00:00:00 2001 From: Misaka_Company Date: Fri, 17 Apr 2026 11:11:26 +0800 Subject: [PATCH] feat(cleaner-history): add renderer search types and highlight utility Co-Authored-By: Claude Opus 4.6 --- .../components/cleaner-history-highlight.tsx | 27 +++++++++++++++++++ src/renderer/src/hooks/cleaner/types.ts | 18 +++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/renderer/src/components/cleaner-history-highlight.tsx diff --git a/src/renderer/src/components/cleaner-history-highlight.tsx b/src/renderer/src/components/cleaner-history-highlight.tsx new file mode 100644 index 0000000..426cee9 --- /dev/null +++ b/src/renderer/src/components/cleaner-history-highlight.tsx @@ -0,0 +1,27 @@ +import React from 'react' + +/** + * Highlight matching text with a tag + * Case-insensitive matching of the query within text + */ +export function highlightText(text: string, query: string): React.ReactNode { + if (!query || !text) return text + + const lowerText = text.toLowerCase() + const lowerQuery = query.toLowerCase() + + const index = lowerText.indexOf(lowerQuery) + if (index === -1) return text + + const before = text.substring(0, index) + const match = text.substring(index, index + query.length) + const after = text.substring(index + query.length) + + return ( + <> + {before} + {match} + {highlightText(after, query)} + + ) +} diff --git a/src/renderer/src/hooks/cleaner/types.ts b/src/renderer/src/hooks/cleaner/types.ts index 0f4698d..4aed1d8 100644 --- a/src/renderer/src/hooks/cleaner/types.ts +++ b/src/renderer/src/hooks/cleaner/types.ts @@ -129,3 +129,21 @@ export interface CleanerHistoryMaterialRecord { attemptCount: number finalErrorCategory: string | null } + +// Search result types (mirrors main process types) + +export interface CleanerHistorySearchOrderResult { + order: CleanerHistoryOrderRecord + materials: CleanerHistoryMaterialRecord[] +} + +export interface CleanerHistorySearchBatchResult { + batch: CleanerHistoryBatchStats + executions: CleanerHistoryExecutionRecord[] + orders: CleanerHistorySearchOrderResult[] +} + +export interface CleanerHistorySearchResult { + batches: CleanerHistorySearchBatchResult[] + totalMatches: number +}