mirror of
https://github.com/EthanMarti/infio-copilot.git
synced 2026-01-18 00:47:51 +00:00
update release logs
This commit is contained in:
parent
09aed46739
commit
7b48192bd9
@ -3,7 +3,7 @@ import * as path from 'path'
|
|||||||
import { BaseSerializedNode } from '@lexical/clipboard/clipboard'
|
import { BaseSerializedNode } from '@lexical/clipboard/clipboard'
|
||||||
import { useMutation } from '@tanstack/react-query'
|
import { useMutation } from '@tanstack/react-query'
|
||||||
import { CircleStop, History, NotebookPen, Plus, Search, Server, SquareSlash, Undo } from 'lucide-react'
|
import { CircleStop, History, NotebookPen, Plus, Search, Server, SquareSlash, Undo } from 'lucide-react'
|
||||||
import { App, Notice } from 'obsidian'
|
import { App, Notice, TFile, WorkspaceLeaf } from 'obsidian'
|
||||||
import {
|
import {
|
||||||
forwardRef,
|
forwardRef,
|
||||||
useCallback,
|
useCallback,
|
||||||
@ -15,8 +15,9 @@ import {
|
|||||||
} from 'react'
|
} from 'react'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
|
|
||||||
import { ApplyViewState } from '../../ApplyView'
|
import { ApplyView, ApplyViewState } from '../../ApplyView'
|
||||||
import { APPLY_VIEW_TYPE, PREVIEW_VIEW_TYPE } from '../../constants'
|
import { APPLY_VIEW_TYPE, PREVIEW_VIEW_TYPE } from '../../constants'
|
||||||
|
import { PreviewView } from '../../PreviewView'
|
||||||
import { useApp } from '../../contexts/AppContext'
|
import { useApp } from '../../contexts/AppContext'
|
||||||
import { useDiffStrategy } from '../../contexts/DiffStrategyContext'
|
import { useDiffStrategy } from '../../contexts/DiffStrategyContext'
|
||||||
import { useLLM } from '../../contexts/LLMContext'
|
import { useLLM } from '../../contexts/LLMContext'
|
||||||
@ -181,7 +182,7 @@ const Chat = forwardRef<ChatRef, ChatProps>((props, ref) => {
|
|||||||
const [tab, setTab] = useState<'chat' | 'commands' | 'custom-mode' | 'mcp' | 'search' | 'history'>('chat')
|
const [tab, setTab] = useState<'chat' | 'commands' | 'custom-mode' | 'mcp' | 'search' | 'history'>('chat')
|
||||||
|
|
||||||
const [selectedSerializedNodes, setSelectedSerializedNodes] = useState<BaseSerializedNode[]>([])
|
const [selectedSerializedNodes, setSelectedSerializedNodes] = useState<BaseSerializedNode[]>([])
|
||||||
|
|
||||||
// 跟踪正在编辑的消息ID
|
// 跟踪正在编辑的消息ID
|
||||||
const [editingMessageId, setEditingMessageId] = useState<string | null>(null)
|
const [editingMessageId, setEditingMessageId] = useState<string | null>(null)
|
||||||
|
|
||||||
@ -854,6 +855,8 @@ const Chat = forwardRef<ChatRef, ChatProps>((props, ref) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setFocusedMessageId(inputMessage.id)
|
setFocusedMessageId(inputMessage.id)
|
||||||
|
// 初始化当前活动文件引用
|
||||||
|
currentActiveFileRef.current = app.workspace.getActiveFile()
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
@ -871,20 +874,27 @@ const Chat = forwardRef<ChatRef, ChatProps>((props, ref) => {
|
|||||||
updateConversationAsync()
|
updateConversationAsync()
|
||||||
}, [currentConversationId, chatMessages, createOrUpdateConversation])
|
}, [currentConversationId, chatMessages, createOrUpdateConversation])
|
||||||
|
|
||||||
|
// 保存当前活动文件的引用,用于比较是否真的发生了变化
|
||||||
|
const currentActiveFileRef = useRef<TFile | null>(null)
|
||||||
|
|
||||||
// Updates the currentFile of the focused message (input or chat history)
|
// Updates the currentFile of the focused message (input or chat history)
|
||||||
// This happens when active file changes or focused message changes
|
// This happens when active file changes or focused message changes
|
||||||
const handleActiveLeafChange = useCallback(() => {
|
const handleActiveLeafChange = useCallback((leaf: WorkspaceLeaf | null) => {
|
||||||
// 如果当前活动的是PreviewView或ApplyView,不更新状态以避免不必要的重新渲染
|
// 过滤掉 ApplyView 和 PreviewView 的切换
|
||||||
// @ts-expect-error Obsidian API type mismatch
|
if ((leaf?.view instanceof ApplyView) || (leaf?.view instanceof PreviewView)) {
|
||||||
const activeLeaf = app.workspace.getActiveLeaf()
|
|
||||||
if (activeLeaf?.view && (
|
|
||||||
activeLeaf.view.getViewType() === PREVIEW_VIEW_TYPE ||
|
|
||||||
activeLeaf.view.getViewType() === APPLY_VIEW_TYPE
|
|
||||||
)) {
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeFile = app.workspace.getActiveFile()
|
const activeFile = app.workspace.getActiveFile()
|
||||||
|
|
||||||
|
// 🎯 关键优化:只有当活动文件真正发生变化时才更新
|
||||||
|
if (activeFile === currentActiveFileRef.current) {
|
||||||
|
return // 文件没有变化,不需要更新
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新文件引用
|
||||||
|
currentActiveFileRef.current = activeFile
|
||||||
|
|
||||||
if (!activeFile) return
|
if (!activeFile) return
|
||||||
|
|
||||||
const mentionable: Omit<MentionableCurrentFile, 'id'> = {
|
const mentionable: Omit<MentionableCurrentFile, 'id'> = {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
import mermaid from "mermaid"
|
import mermaid from "mermaid"
|
||||||
import { useEffect, useRef, useState } from "react"
|
import { memo, useEffect, useRef, useState } from "react"
|
||||||
import styled from "styled-components"
|
import styled from "styled-components"
|
||||||
|
|
||||||
import { PREVIEW_VIEW_TYPE } from "../../../constants"
|
import { PREVIEW_VIEW_TYPE } from "../../../constants"
|
||||||
@ -76,7 +76,7 @@ interface MermaidBlockProps {
|
|||||||
code: string
|
code: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function MermaidBlock({ code }: MermaidBlockProps) {
|
function MermaidBlock({ code }: MermaidBlockProps) {
|
||||||
const containerRef = useRef<HTMLDivElement>(null)
|
const containerRef = useRef<HTMLDivElement>(null)
|
||||||
const [isLoading, setIsLoading] = useState(false)
|
const [isLoading, setIsLoading] = useState(false)
|
||||||
const [error, setError] = useState<string | null>(null)
|
const [error, setError] = useState<string | null>(null)
|
||||||
@ -206,7 +206,8 @@ export default function MermaidBlock({ code }: MermaidBlockProps) {
|
|||||||
|
|
||||||
if (existingLeaf) {
|
if (existingLeaf) {
|
||||||
// 如果已存在,关闭现有的然后重新创建以更新内容
|
// 如果已存在,关闭现有的然后重新创建以更新内容
|
||||||
existingLeaf.detach()
|
// existingLeaf.detach()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建新的预览 tab
|
// 创建新的预览 tab
|
||||||
@ -391,3 +392,5 @@ const SvgContainer = styled.div<SvgContainerProps>`
|
|||||||
z-index: 10;
|
z-index: 10;
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
||||||
|
export const MemoizedMermaidBlock = memo(MermaidBlock)
|
||||||
@ -5,7 +5,7 @@ import remarkGfm from 'remark-gfm'
|
|||||||
|
|
||||||
import { useDarkModeContext } from '../../../contexts/DarkModeContext'
|
import { useDarkModeContext } from '../../../contexts/DarkModeContext'
|
||||||
|
|
||||||
import MermaidBlock from './MermaidBlock'
|
import { MemoizedMermaidBlock } from './MermaidBlock'
|
||||||
import { MemoizedSyntaxHighlighterWrapper } from './SyntaxHighlighterWrapper'
|
import { MemoizedSyntaxHighlighterWrapper } from './SyntaxHighlighterWrapper'
|
||||||
|
|
||||||
interface RawMarkdownBlockProps {
|
interface RawMarkdownBlockProps {
|
||||||
@ -34,7 +34,7 @@ export default function RawMarkdownBlock({
|
|||||||
if (!isInline && language === 'mermaid') {
|
if (!isInline && language === 'mermaid') {
|
||||||
const codeText = String(children || "")
|
const codeText = String(children || "")
|
||||||
return (
|
return (
|
||||||
<MermaidBlock
|
<MemoizedMermaidBlock
|
||||||
code={codeText}
|
code={codeText}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user