mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-15 02:49:49 +08:00
🐛 fix(ai-chat): 统一历史模式会话排序
- 面板内历史模式按最近更新时间优先展示会话 - 保持与历史侧栏一致的最近会话浏览体验 - 增加静态测试防止排序逻辑回退
This commit is contained in:
@@ -27,4 +27,10 @@ describe('AIChatPanel message render isolation', () => {
|
||||
expect(source).toContain('以下是当前启用的 Skill');
|
||||
expect(source).toContain('buildAvailableAIChatTools');
|
||||
});
|
||||
|
||||
it('keeps the v2 history mode sorted by the latest updated session first', () => {
|
||||
expect(source).toContain('const orderedAISessions = useMemo(');
|
||||
expect(source).toContain('right.updatedAt - left.updatedAt');
|
||||
expect(source).toContain('const sessions = orderedAISessions.slice(0, 8);');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -310,6 +310,10 @@ export const AIChatPanel: React.FC<AIChatPanelProps> = ({
|
||||
'sendAIChatMessage',
|
||||
activeShortcutPlatform,
|
||||
));
|
||||
const orderedAISessions = useMemo(
|
||||
() => [...aiChatSessions].sort((left, right) => right.updatedAt - left.updatedAt),
|
||||
[aiChatSessions],
|
||||
);
|
||||
|
||||
const getCurrentJVMPlanContext = useCallback((): JVMAIPlanContext | undefined => {
|
||||
const state = useStore.getState();
|
||||
@@ -1850,7 +1854,7 @@ SELECT * FROM users WHERE status = 1;
|
||||
}, [contextTableNames, sqlLogs]);
|
||||
|
||||
const renderPanelHistoryList = () => {
|
||||
const sessions = aiChatSessions.slice(0, 8);
|
||||
const sessions = orderedAISessions.slice(0, 8);
|
||||
if (sessions.length === 0) {
|
||||
return <div className="gn-v2-ai-empty-note">暂无历史会话</div>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user