Skip to content

Commit bd2f2a1

Browse files
committed
Merge branch 'pr-1021' into pr-1021-merge
2 parents 81e6c7f + 7dd8d0d commit bd2f2a1

14 files changed

Lines changed: 462 additions & 223 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ release
1919
backend/context_files/
2020

2121
# Editor directories and files
22-
.vscode/.debug.env
22+
.vscode/
2323
.idea
2424
.DS_Store
2525
*.suo

.vscode/.debug.script.mjs

Lines changed: 0 additions & 23 deletions
This file was deleted.

.vscode/extensions.json

Lines changed: 0 additions & 13 deletions
This file was deleted.

.vscode/launch.json

Lines changed: 0 additions & 70 deletions
This file was deleted.

.vscode/settings.json

Lines changed: 0 additions & 54 deletions
This file was deleted.

.vscode/tasks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
{
77
"label": "Before Debug",
88
"type": "shell",
9-
"command": "node .vscode/.debug.script.mjs",
9+
"command": "node .vscode/.debug.script.js",
1010
"isBackground": true,
1111
"problemMatcher": {
1212
"owner": "typescript",

src/components/SearchHistoryDialog.tsx

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@
1414

1515
'use client';
1616

17-
import { ScanFace, Search } from 'lucide-react';
17+
import { ScanFace, Search, Trash2 } from 'lucide-react';
1818
import { useEffect, useState } from 'react';
1919

20+
import { proxyFetchDelete } from '@/api/http';
2021
import GroupedHistoryView from '@/components/GroupedHistoryView';
2122
import {
2223
CommandDialog,
@@ -30,6 +31,7 @@ import {
3031
import useChatStoreAdapter from '@/hooks/useChatStoreAdapter';
3132
import { replayProject } from '@/lib';
3233
import { fetchHistoryTasks } from '@/service/historyApi';
34+
import { getAuthStore } from '@/store/authStore';
3335
import { useGlobalStore } from '@/store/globalStore';
3436
import { VisuallyHidden } from '@radix-ui/react-visually-hidden';
3537
import { useTranslation } from 'react-i18next';
@@ -74,9 +76,35 @@ export function SearchHistoryDialog() {
7476
await replayProject(projectStore, navigate, projectId, question, historyId);
7577
};
7678

77-
const handleDelete = (taskId: string) => {
78-
// TODO: Implement delete functionality similar to HistorySidebar
79-
console.log('Delete task:', taskId);
79+
const handleDelete = async (historyId: string, callback?: () => void) => {
80+
try {
81+
await proxyFetchDelete(`/api/chat/history/${historyId}`);
82+
83+
// Also delete local files for this task if available (via Electron IPC)
84+
const history = historyTasks.find(
85+
(item) => String(item.id) === String(historyId)
86+
);
87+
const { email } = getAuthStore();
88+
if (history?.task_id && (window as any).ipcRenderer) {
89+
try {
90+
await (window as any).ipcRenderer.invoke(
91+
'delete-task-files',
92+
email,
93+
history.task_id,
94+
history.project_id ?? undefined
95+
);
96+
} catch (error) {
97+
console.warn('Local file cleanup failed:', error);
98+
}
99+
}
100+
101+
setHistoryTasks((list) =>
102+
list.filter((item) => String(item.id) !== String(historyId))
103+
);
104+
callback?.();
105+
} catch (error) {
106+
console.error('Failed to delete history task:', error);
107+
}
80108
};
81109

82110
const handleShare = (taskId: string) => {
@@ -137,6 +165,20 @@ export function SearchHistoryDialog() {
137165
<div className="overflow-hidden text-ellipsis whitespace-nowrap">
138166
{task.question}
139167
</div>
168+
<Button
169+
type="button"
170+
variant="ghost"
171+
size="icon"
172+
className="text-muted-foreground hover:text-foreground ml-auto"
173+
aria-label="Delete history"
174+
onClick={(e) => {
175+
e.preventDefault();
176+
e.stopPropagation();
177+
void handleDelete(String(task.id));
178+
}}
179+
>
180+
<Trash2 size={16} />
181+
</Button>
140182
</CommandItem>
141183
))}
142184
</CommandGroup>

0 commit comments

Comments
 (0)