diff --git a/packages/ui/src/components/HistoryDrawer.vue b/packages/ui/src/components/HistoryDrawer.vue
index 5bbb5cb3..09c093d4 100644
--- a/packages/ui/src/components/HistoryDrawer.vue
+++ b/packages/ui/src/components/HistoryDrawer.vue
@@ -10,20 +10,33 @@
@update:show="(value: boolean) => !value && close()"
>
-
- {{ t('common.clear') }}
-
+
+
+
+ 🔍
+
+
+
+ {{ t('common.clear') }}
+
+
@@ -185,7 +198,7 @@ import { ref, watch, computed, type PropType } from 'vue'
import { useI18n } from 'vue-i18n'
import {
NModal, NScrollbar, NSpace, NCard, NText, NTag, NButton,
- NDivider, NCollapse, NCollapseItem, NEmpty
+ NDivider, NCollapse, NCollapseItem, NEmpty, NInput
} from 'naive-ui'
import type { PromptRecord, PromptRecordChain } from '@prompt-optimizer/core'
import { useToast } from '../composables/ui/useToast'
@@ -215,6 +228,7 @@ const emit = defineEmits<{
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
const _toast = useToast()
const expandedVersions = ref>({})
+const searchQuery = ref('')
// --- Close Logic ---
const close = () => {
@@ -227,6 +241,23 @@ const sortedHistory = computed(() => {
return props.history.sort((a, b) => b.currentRecord.timestamp - a.currentRecord.timestamp)
})
+const filteredHistory = computed(() => {
+ if (!searchQuery.value) return sortedHistory.value
+
+ const query = searchQuery.value.toLowerCase()
+ return sortedHistory.value.filter(chain => {
+ // 匹配原始提示词
+ if (chain.rootRecord.originalPrompt.toLowerCase().includes(query)) return true
+
+ // 匹配版本中的内容
+ return chain.versions.some(record => {
+ if (record.optimizedPrompt.toLowerCase().includes(query)) return true
+ if (record.iterationNote && record.iterationNote.toLowerCase().includes(query)) return true
+ return false
+ })
+ })
+})
+
// 切换版本展开/收起状态
// eslint-disable-next-line @typescript-eslint/no-unused-vars, no-unused-vars
const _toggleVersion = (recordId: string) => {
@@ -247,8 +278,9 @@ const handleClear = async () => {
// 监听显示状态变化
watch(() => props.show, (newShow) => {
if (!newShow) {
- // 关闭时重置所有展开状态
+ // 关闭时重置所有展开状态和搜索词
expandedVersions.value = {}
+ searchQuery.value = ''
}
})
diff --git a/packages/ui/src/i18n/locales/en-US.ts b/packages/ui/src/i18n/locales/en-US.ts
index 75d14641..f58b268d 100644
--- a/packages/ui/src/i18n/locales/en-US.ts
+++ b/packages/ui/src/i18n/locales/en-US.ts
@@ -981,6 +981,7 @@ export default {
title: "History",
iterationNote: "Iteration Note",
optimizedPrompt: "Optimized Prompt",
+ searchPlaceholder: "Search history...",
confirmClear:
"Are you sure you want to clear all history records? This action cannot be undone.",
confirmDeleteChain:
diff --git a/packages/ui/src/i18n/locales/zh-CN.ts b/packages/ui/src/i18n/locales/zh-CN.ts
index 8a31870b..e0a8f4db 100644
--- a/packages/ui/src/i18n/locales/zh-CN.ts
+++ b/packages/ui/src/i18n/locales/zh-CN.ts
@@ -951,6 +951,7 @@ export default {
title: "历史记录",
iterationNote: "迭代说明",
optimizedPrompt: "优化后",
+ searchPlaceholder: "搜索历史记录...",
confirmClear: "确定要清空所有历史记录吗?此操作不可恢复。",
confirmDeleteChain: "确定要删除此条历史记录吗?此操作不可恢复。",
cleared: "历史记录已清空",