feat: update desktop workflows and app center
This commit is contained in:
@@ -166,6 +166,71 @@ describe('chat history actions', () => {
|
||||
expect(h.read().loading).toBe(false);
|
||||
});
|
||||
|
||||
it('preserves task name labels when loading cron session history', async () => {
|
||||
const { createHistoryActions } = await import('@/stores/chat/history-actions');
|
||||
const h = makeHarness({
|
||||
currentSessionKey: 'agent:main:cron:job-1',
|
||||
sessionLabels: { 'agent:main:cron:job-1': '每日经营日报' },
|
||||
});
|
||||
const actions = createHistoryActions(h.set as never, h.get as never);
|
||||
|
||||
invokeIpcMock.mockResolvedValueOnce({
|
||||
success: true,
|
||||
result: {
|
||||
messages: [
|
||||
{ role: 'user', content: '请生成今天的经营日报', timestamp: 1773281731 },
|
||||
{ role: 'assistant', content: '已生成', timestamp: 1773281732 },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
await actions.loadHistory();
|
||||
|
||||
expect(h.read().sessionLabels['agent:main:cron:job-1']).toBe('每日经营日报');
|
||||
expect(h.read().sessionLastActivity['agent:main:cron:job-1']).toBe(1773281732000);
|
||||
});
|
||||
|
||||
it('merges cron fallback history when gateway only returns the current prompt', async () => {
|
||||
const { createHistoryActions } = await import('@/stores/chat/history-actions');
|
||||
const h = makeHarness({
|
||||
currentSessionKey: 'agent:main:cron:job-1',
|
||||
});
|
||||
const actions = createHistoryActions(h.set as never, h.get as never);
|
||||
|
||||
invokeIpcMock.mockResolvedValueOnce({
|
||||
success: true,
|
||||
result: {
|
||||
messages: [
|
||||
{ role: 'user', content: '当前这次执行的问题', timestamp: 1773281800 },
|
||||
],
|
||||
},
|
||||
});
|
||||
hostApiFetchMock.mockResolvedValueOnce({
|
||||
messages: [
|
||||
{
|
||||
id: 'cron-meta-job-1',
|
||||
role: 'system',
|
||||
content: 'Scheduled task: 每日经营日报',
|
||||
timestamp: 1773281700000,
|
||||
},
|
||||
{
|
||||
id: 'cron-run-previous',
|
||||
role: 'assistant',
|
||||
content: '上一轮执行结果',
|
||||
timestamp: 1773281732000,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
await actions.loadHistory();
|
||||
|
||||
expect(h.read().messages.map((message) => message.content)).toEqual([
|
||||
'上一轮执行结果',
|
||||
'当前这次执行的问题',
|
||||
]);
|
||||
expect(h.read().sessionLastActivity['agent:main:cron:job-1']).toBe(1773281800000);
|
||||
});
|
||||
|
||||
it('does not use cron fallback for normal sessions', async () => {
|
||||
const { createHistoryActions } = await import('@/stores/chat/history-actions');
|
||||
const h = makeHarness({
|
||||
|
||||
Reference in New Issue
Block a user