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:修复显示问题;去掉拖拽文件进对话框的能力;去掉前端根据前缀过滤会话的判断,过滤由后端处理
xiaoyao420c8fe16ef289
diff --git a/jiuwenswarm/channels/web/frontend/src/App.tsx b/jiuwenswarm/channels/web/frontend/src/App.tsxindex 8023862005..e144a8ec1c 100644--- a/jiuwenswarm/channels/web/frontend/src/App.tsx+++ b/jiuwenswarm/channels/web/frontend/src/App.tsx@@ -230,11 +230,6 @@ function downloadDataUrl(dataUrl: string, filename: string): void {document.body.removeChild(link);}-// 判断 session_id 是否为可恢复/可展示的会话(web 渠道 sess_ 与 cron 触发的 cron_ 前缀均需支持)-function isRestorableSessionId(sessionId: string): boolean {- return sessionId.startsWith('sess_') || sessionId.startsWith('cron_');-}-async function saveShareImage(dataUrl: string, filename: string): Promise<boolean> {const pywebviewApi = (window as WindowWithPyWebview).pywebview?.api;if (pywebviewApi?.save_data_url) {@@ -499,7 +494,7 @@ function AppContent() {const messages = useChatStore((s) => s.runtimes[sessionId]?.messages ?? []);const isLoadingHistory = useChatStore((s) => s.runtimes[sessionId]?.isLoadingHistory ?? false);const replaceHistoryMessages = useChatStore((s) => s.replaceHistoryMessages);- const isRestoringHistorySession = isRestorableSessionId(sessionId) && isLoadingHistory && !historyPagerMeta && messages.length === 0;+ const isRestoringHistorySession = isLoadingHistory && !historyPagerMeta && messages.length === 0;const isRestoringTeamHistory = mode === 'team' && isRestoringHistorySession;useEffect(() => {@@ -799,7 +794,6 @@ function AppContent() {}, []);const loadSessionMetadata = useCallback(async (targetSessionId: string): Promise<Session | null> => {- if (!isRestorableSessionId(targetSessionId)) return null;try {const session = await request<Session>('session.get_metadata', {session_id: targetSessionId,@@ -1271,9 +1265,6 @@ function AppContent() {useEffect(() => {if (!isConnected || !sessionId || sessionId === NEW_CONVERSATION_ID) return;- // 仅处理以 sess_ 开头的会话 ID- if (!isRestorableSessionId(sessionId)) return;-if (promotedFromNewSessionIdsRef.current.has(sessionId)) {setHistoryPagerMeta(sessionId, null);setHistoryLoadingMore(false);@@ -1493,7 +1484,6 @@ function AppContent() {// 都不算错误。useEffect(() => {if (!isConnected || !sessionId || sessionId === NEW_CONVERSATION_ID) return;- if (!isRestorableSessionId(sessionId)) return;void (async () => {await refreshGoal(sessionId);// 等 get 落地这段时间里用户可能已经切到别的会话,避免对着旧会话发 resume。@@ -1717,7 +1707,7 @@ function AppContent() {}, [sendUserAnswer]);const handleLoadMoreHistory = useCallback(async () => {- if (!isRestorableSessionId(sessionId) || !historyPagerMeta) return;+ if (!historyPagerMeta) return;if (historyLoadingSessionsRef.current.has(sessionId) || historyPagerMeta.loadedPages >= historyPagerMeta.totalPages) return;const sid = sessionId;@@ -1763,8 +1753,6 @@ function AppContent() {const handleRestoreSession = useCallback(async (targetSessionId: string, targetMode?: string, targetSession?: Session, options?: { skipHistoryLoad?: boolean }) => {- if (!isRestorableSessionId(targetSessionId)) return;-const resolvedMode = targetMode ?? targetSession?.mode ?? mode;disposeInFlightHistoryHandles(targetSessionId);setHistoryLoadingMore(false);diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.cssindex 2dd9b80209..2b663aaa79 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/ChatPanel.css@@ -174,13 +174,6 @@ overflow: hidden;border-color: var(--color-feedback-danger) !important;}-.chat-input-container--dragging {- border-color: var(--color-action-primary);- box-shadow:- var(--effect-chat-composer-shadow),- 0 0 0 2px rgba(var(--color-action-primary-rgb), 0.22);-}-.chat-input-frame {position: relative;width: 100%;diff --git a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsxindex e8c97b57ec..fd519c22f1 100644--- a/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx+++ b/jiuwenswarm/channels/web/frontend/src/components/ChatPanel/InputArea.tsx@@ -257,7 +257,6 @@ export function InputArea({const [attachments, setAttachments] = useState<AttachmentDraft[]>([]);const [attachmentAlerts, setAttachmentAlerts] = useState<AttachmentAlert[]>([]);const [attachmentMenuId, setAttachmentMenuId] = useState<string | null>(null);- const [isDraggingImage, setIsDraggingImage] = useState(false);const fileInputRef = useRef<HTMLInputElement>(null);const [workMenuOpen, setWorkMenuOpen] = useState<'project' | null>(null);const [workDialogOpen, setWorkDialogOpen] = useState(false);@@ -1120,39 +1119,21 @@ export function InputArea({}, [appendImageFiles]);const handlePaste = useCallback((event: ClipboardEvent<HTMLDivElement>) => {- const items = Array.from(event.clipboardData.items);- const files = items- .filter((item) => item.kind === 'file' && ACCEPTED_IMAGE_TYPES.has(item.type))- .map((item) => item.getAsFile())- .filter((file): file is File => Boolean(file));- if (files.length) {+ if (Array.from(event.clipboardData.items).some((item) => item.kind === 'file')) {event.preventDefault();- void appendImageFiles(files);}- }, [appendImageFiles]);-- const handleDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {- const hasImage = Array.from(event.dataTransfer.items).some(- (item) => item.kind === 'file' && ACCEPTED_IMAGE_TYPES.has(item.type)- );- if (!hasImage) return;- event.preventDefault();- setIsDraggingImage(true);}, []);- const handleDragLeave = useCallback((event: DragEvent<HTMLDivElement>) => {- if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {- setIsDraggingImage(false);- }+ const handleFileDragOver = useCallback((event: DragEvent<HTMLDivElement>) => {+ if (!Array.from(event.dataTransfer.types).includes('Files')) return;+ event.preventDefault();+ event.dataTransfer.dropEffect = 'none';}, []);- const handleDrop = useCallback((event: DragEvent<HTMLDivElement>) => {- setIsDraggingImage(false);- const files = Array.from(event.dataTransfer.files).filter((file) => ACCEPTED_IMAGE_TYPES.has(file.type));- if (!files.length) return;+ const handleFileDrop = useCallback((event: DragEvent<HTMLDivElement>) => {+ if (!Array.from(event.dataTransfer.types).includes('Files')) return;event.preventDefault();- void appendImageFiles(files);- }, [appendImageFiles]);+ }, []);/** 在光标处插入技能 chip(不可编辑原子节点) */const insertSkillChip = useCallback((skillName: string) => {@@ -1417,11 +1398,9 @@ export function InputArea({(isModeMenuOpen || workMenuOpen) && 'chat-input-container--menu-open',composerSuggestion && 'chat-input-container--suggestion-open',isListening && 'chat-input-container--recording',- isDraggingImage && 'chat-input-container--dragging',)}- onDragOver={handleDragOver}- onDragLeave={handleDragLeave}- onDrop={handleDrop}+ onDragOver={handleFileDragOver}+ onDrop={handleFileDrop}>{isListening && (<div className="chat-input-recording-bar">diff --git a/jiuwenswarm/channels/web/frontend/src/index.css b/jiuwenswarm/channels/web/frontend/src/index.cssindex df4e12abb1..9717ec7a0e 100644--- a/jiuwenswarm/channels/web/frontend/src/index.css+++ b/jiuwenswarm/channels/web/frontend/src/index.css@@ -1241,7 +1241,7 @@ select {}.tool-group-frame--team {- width: min(95%, 920px);+ width: min(100%, 920px);margin: 12px auto;display: grid;grid-template-columns: 36px minmax(0, 1fr);diff --git a/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts b/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.tsindex 7429f816a7..ab7f6d4574 100644--- a/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts+++ b/jiuwenswarm/channels/web/frontend/src/multi-session/routing/route.ts@@ -9,9 +9,7 @@ export function parseChatRoute(pathname: string): ChatRoute | null {const match = path.match(/^\/chat\/([^/]+)$/);if (!match) return null;const sessionId = decodeURIComponent(match[1]);- return /^(sess_|cron_)[A-Za-z0-9_.@-]+$/.test(sessionId)- ? { kind: 'chat-session', sessionId }- : { kind: 'not-found', pathname: path };+ return { kind: 'chat-session', sessionId };}export function chatRoutePath(route: ChatRoute): string {