Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix:1.修改查看历史会话消息的模式2.新建会话时保持任务规划/智能执行按钮选中状态

openJiuwen-bot773d080f36e5
diff --git a/jiuwenclaw/web/src/App.tsx b/jiuwenclaw/web/src/App.tsx
index eda54d31a5..50d0178758 100644
--- a/jiuwenclaw/web/src/App.tsx
+++ b/jiuwenclaw/web/src/App.tsx
@@ -276,7 +276,7 @@ function AppContent() {
useEffect(() => () => disposeInFlightHistoryHandles(), [disposeInFlightHistoryHandles]);
- const { setCurrentSession, setSessions, heartbeatMessage, heartbeatUpdatedAt } = useSessionStore();
+ const { setCurrentSession, setSessions, mode, heartbeatMessage, heartbeatUpdatedAt } = useSessionStore();
const {
clearMessages,
clearSubtasks,
@@ -587,7 +587,9 @@ function AppContent() {
historyRestoreHandleRef.current = null;
setHistoryPagerMeta(null);
console.error('Failed to load history:', error);
- if (sessionIdRef.current === sessionId) {
+ // 忽略 "invalid page_idx or session history not found" 错误,因为这是新会话的正常情况
+ const errorMessage = error instanceof Error ? error.message : String(error);
+ if (sessionIdRef.current === sessionId && !errorMessage.includes('invalid page_idx or session history not found')) {
clearMessages();
addMessage({
id: `history-load-failed-${Date.now()}`,
@@ -622,6 +624,14 @@ function AppContent() {
setSessionId(createdSid);
setCurrentSession(null);
storeSessionId(createdSid);
+ // 保持当前模式
+ if (switchMode) {
+ try {
+ await switchMode(createdSid, mode);
+ } catch (error) {
+ console.error('Failed to set mode for new session:', error);
+ }
+ }
await fetchSessions();
} catch (error) {
console.error('Failed to create session:', error);
@@ -639,11 +649,13 @@ function AppContent() {
clearTodos,
disposeInFlightHistoryHandles,
fetchSessions,
+ mode,
request,
setCurrentSession,
setPaused,
setProcessing,
setThinking,
+ switchMode,
]);
// 切换模式
diff --git a/jiuwenclaw/web/src/components/ChatPanel/HistoryPagerBar.tsx b/jiuwenclaw/web/src/components/ChatPanel/HistoryPagerBar.tsx
index 88fd5f9b73..d96168ec90 100644
--- a/jiuwenclaw/web/src/components/ChatPanel/HistoryPagerBar.tsx
+++ b/jiuwenclaw/web/src/components/ChatPanel/HistoryPagerBar.tsx
@@ -16,22 +16,30 @@ export function HistoryPagerBar({
const { t } = useTranslation();
const hasMore = loadedPages < totalPages;
+ const handleWheel = (e: React.WheelEvent<HTMLDivElement>) => {
+ // 只在有更多内容且未加载中时处理
+ if (hasMore && !loadingMore) {
+ // 向上滚动触发加载更多
+ if (e.deltaY < 0) {
+ e.preventDefault();
+ void onLoadMore();
+ }
+ }
+ };
+
return (
- <div className="history-pager-bar mb-3 rounded-lg border border-white/10 bg-secondary/50 px-3 py-2.5 flex flex-wrap items-center justify-between gap-2 text-sm">
+ <div
+ className="history-pager-bar mb-3 rounded-lg border border-white/10 bg-secondary/50 px-3 py-2.5 flex flex-wrap items-center justify-between gap-2 text-sm cursor-pointer"
+ onWheel={handleWheel}
+ title={t('chat.historyPager.wheelToLoadMore')}
+ >
<span className="text-text-muted tabular-nums">
{t('chat.historyPager.loadedOfTotal', { loaded: loadedPages, total: totalPages })}
</span>
{hasMore ? (
- <button
- type="button"
- className="btn !py-1.5 !px-3 text-xs shrink-0"
- disabled={loadingMore}
- onClick={() => {
- void onLoadMore();
- }}
- >
- {loadingMore ? t('chat.historyPager.loadingMore') : t('chat.historyPager.loadMore')}
- </button>
+ <span className="text-xs text-text-muted shrink-0">
+ {loadingMore ? t('chat.historyPager.loadingMore') : t('chat.historyPager.wheelToLoadMore')}
+ </span>
) : (
<span className="text-xs text-text-muted shrink-0">{t('chat.historyPager.allLoaded')}</span>
)}
diff --git a/jiuwenclaw/web/src/hooks/useWebSocket.ts b/jiuwenclaw/web/src/hooks/useWebSocket.ts
index 5b8e760da0..8dfb844c70 100644
--- a/jiuwenclaw/web/src/hooks/useWebSocket.ts
+++ b/jiuwenclaw/web/src/hooks/useWebSocket.ts
@@ -702,6 +702,10 @@ export function useWebSocket(options: UseWebSocketOptions): UseWebSocketReturn {
setThinking(false);
const errorMsg =
typeof payload.error === 'string' ? payload.error : i18n.t('network.unknownError');
+ // 忽略 "invalid page_idx or session history not found" 错误,因为这是新会话的正常情况
+ if (errorMsg.includes('invalid page_idx or session history not found')) {
+ return;
+ }
onErrorRef.current?.(errorMsg);
addMessage({
id: `error-${Date.now()}`,
diff --git a/jiuwenclaw/web/src/i18n/locales/en.json b/jiuwenclaw/web/src/i18n/locales/en.json
index 3f9251d12b..0a358efe7a 100644
--- a/jiuwenclaw/web/src/i18n/locales/en.json
+++ b/jiuwenclaw/web/src/i18n/locales/en.json
@@ -59,9 +59,9 @@
"newSessionDisabled": "Cannot create session while processing or recording",
"historyPager": {
"loadedOfTotal": "History loaded {{loaded}} / {{total}} pages",
- "loadMore": "Load older messages",
"loadingMore": "Loading…",
- "allLoaded": "All history loaded"
+ "allLoaded": "All history loaded",
+ "wheelToLoadMore": "Scroll up to load more"
}
},
"connection": {
diff --git a/jiuwenclaw/web/src/i18n/locales/zh.json b/jiuwenclaw/web/src/i18n/locales/zh.json
index cbc5118156..111ae5e0e2 100644
--- a/jiuwenclaw/web/src/i18n/locales/zh.json
+++ b/jiuwenclaw/web/src/i18n/locales/zh.json
@@ -59,9 +59,9 @@
"newSessionDisabled": "处理中或录音中不可新建",
"historyPager": {
"loadedOfTotal": "历史已加载 {{loaded}} / {{total}} 页",
- "loadMore": "加载更早的消息",
"loadingMore": "加载中…",
- "allLoaded": "已显示全部历史"
+ "allLoaded": "已显示全部历史",
+ "wheelToLoadMore": "向上滚动加载更多"
}
},
"connection": {