This commit is contained in:
Wendong-Fan 2026-02-02 05:32:24 +08:00
parent de198ea025
commit 3cb3f565ac
3 changed files with 23 additions and 4 deletions

View file

@ -101,6 +101,19 @@ export function SearchHistoryDialog() {
setHistoryTasks((list) =>
list.filter((item) => String(item.id) !== String(historyId))
);
// If no remaining tasks share the same project, clean up project store
if (history?.project_id) {
const hasRemaining = historyTasks.some(
(item) =>
String(item.id) !== String(historyId) &&
item.project_id === history.project_id
);
if (!hasRemaining) {
projectStore.removeProject(history.project_id);
}
}
callback?.();
} catch (error) {
console.error('Failed to delete history task:', error);

View file

@ -52,10 +52,6 @@ export async function loginByStackToken(params: {
});
}
/**
* Attempts a passwordless SSO login first, and auto-creates the user if not found.
* This matches the UX request: check existing profile; if missing, create like signup.
*/
export function getLoginErrorMessage(
data: any,
fallbackCheckEmail: string,
@ -89,6 +85,10 @@ export function getLoginErrorMessage(
return data.text || fallbackGeneric;
}
/**
* Attempts a passwordless SSO login first, and auto-creates the user if not found.
* This matches the UX request: "check existing profile; if missing, create like signup".
*/
export async function loginByStackWithAutoCreate(
token: string
): Promise<StackLoginResponse> {

View file

@ -24,6 +24,7 @@ vi.mock('react-router-dom', () => ({
useNavigate: () => vi.fn(),
}));
const removeProjectMock = vi.fn();
vi.mock('@/hooks/useChatStoreAdapter', () => ({
default: () => ({
chatStore: { activeTaskId: undefined },
@ -31,6 +32,7 @@ vi.mock('@/hooks/useChatStoreAdapter', () => ({
getProjectById: vi.fn(() => null),
setHistoryId: vi.fn(),
setActiveProject: vi.fn(),
removeProject: removeProjectMock,
},
}),
}));
@ -112,6 +114,7 @@ describe('SearchHistoryDialog', () => {
(window as any).ipcRenderer = {
invoke: vi.fn().mockResolvedValue(undefined),
};
vi.spyOn(window, 'confirm').mockReturnValue(true);
});
it('deletes a history item from list view', async () => {
@ -141,6 +144,9 @@ describe('SearchHistoryDialog', () => {
'project-1'
);
// Project store should be cleaned up since this was the last task in the project
expect(removeProjectMock).toHaveBeenCalledWith('project-1');
await waitFor(() => {
expect(screen.queryByText('My history item')).not.toBeInTheDocument();
});