🐛 fix tooltip hover
This commit is contained in:
@@ -213,6 +213,7 @@ const annotationHoverTooltip = hoverTooltip(
|
|||||||
create() {
|
create() {
|
||||||
const dom = document.createElement('div')
|
const dom = document.createElement('div')
|
||||||
dom.className = 'annotation-tooltip'
|
dom.className = 'annotation-tooltip'
|
||||||
|
dom.addEventListener('mousemove', (e) => e.stopPropagation())
|
||||||
const label = document.createElement('span')
|
const label = document.createElement('span')
|
||||||
label.className = 'annotation-tooltip-label'
|
label.className = 'annotation-tooltip-label'
|
||||||
label.textContent = 'Your comment'
|
label.textContent = 'Your comment'
|
||||||
@@ -243,6 +244,7 @@ const annotationHoverTooltip = hoverTooltip(
|
|||||||
create() {
|
create() {
|
||||||
const dom = document.createElement('div')
|
const dom = document.createElement('div')
|
||||||
dom.className = 'annotation-tooltip'
|
dom.className = 'annotation-tooltip'
|
||||||
|
dom.addEventListener('mousemove', (e) => e.stopPropagation())
|
||||||
|
|
||||||
const label = document.createElement('span')
|
const label = document.createElement('span')
|
||||||
label.className = 'annotation-tooltip-label'
|
label.className = 'annotation-tooltip-label'
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ export function FileTreeNode({ node, depth, dirPath, siblings }: Props): JSX.Ele
|
|||||||
|
|
||||||
const openFile = async (): Promise<void> => {
|
const openFile = async (): Promise<void> => {
|
||||||
if (node.type === 'file') {
|
if (node.type === 'file') {
|
||||||
|
if (node.path === activeFilePath) return
|
||||||
const content = await window.api.readFile(node.path)
|
const content = await window.api.readFile(node.path)
|
||||||
setActiveFile(node.path, content)
|
setActiveFile(node.path, content)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,6 +109,19 @@ function scheduleSave(getData: () => Record<string, unknown>): void {
|
|||||||
}, 1500)
|
}, 1500)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Debounced auto-save — writes the active file to disk 10s after the user stops typing,
|
||||||
|
// protecting against content loss if the renderer crashes while the editor is idle.
|
||||||
|
let _autoSaveTimer: ReturnType<typeof setTimeout> | null = null
|
||||||
|
function scheduleAutoSave(getData: () => { path: string; content: string } | null): void {
|
||||||
|
if (_autoSaveTimer) clearTimeout(_autoSaveTimer)
|
||||||
|
_autoSaveTimer = setTimeout(() => {
|
||||||
|
const d = getData()
|
||||||
|
if (!d) return
|
||||||
|
const api = (window as unknown as { api?: { writeFile: (p: string, c: string) => Promise<void> } }).api
|
||||||
|
api?.writeFile(d.path, d.content).catch(console.error)
|
||||||
|
}, 10_000)
|
||||||
|
}
|
||||||
|
|
||||||
export const useEditorStore = create<EditorState>((set, get) => ({
|
export const useEditorStore = create<EditorState>((set, get) => ({
|
||||||
fileTree: [],
|
fileTree: [],
|
||||||
setFileTree: (fileTree) => set({ fileTree }),
|
setFileTree: (fileTree) => set({ fileTree }),
|
||||||
@@ -175,7 +188,13 @@ export const useEditorStore = create<EditorState>((set, get) => ({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
setContent: (content) => set({ activeFileContent: content, isDirty: true }),
|
setContent: (content) => {
|
||||||
|
set({ activeFileContent: content, isDirty: true })
|
||||||
|
scheduleAutoSave(() => {
|
||||||
|
const { activeFilePath, activeFileContent } = get()
|
||||||
|
return activeFilePath ? { path: activeFilePath, content: activeFileContent } : null
|
||||||
|
})
|
||||||
|
},
|
||||||
markSaved: () => set({ isDirty: false }),
|
markSaved: () => set({ isDirty: false }),
|
||||||
|
|
||||||
chatSessionsByFile: {},
|
chatSessionsByFile: {},
|
||||||
|
|||||||
Reference in New Issue
Block a user