Skip to content

Commit 67792db

Browse files
authored
feat(vscode): refresh lineage on file changes (#4415)
1 parent bfbacf5 commit 67792db

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

vscode/bus/src/callbacks.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export type VSCodeCallback = {
3434
requestId: string
3535
response: any
3636
}
37+
savedFile: {
38+
fileUri: string
39+
}
3740
}
3841

3942
export type VSCodeEvent = {

vscode/extension/src/webviews/lineagePanel.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ export class LineagePanel implements WebviewViewProvider, Disposable {
2626
this.panel.webview.html = this.getHTML(this.panel.webview)
2727
}
2828

29+
workspace.onDidSaveTextDocument(document => {
30+
this.panel?.webview.postMessage({
31+
key: 'vscode_send',
32+
payload: {
33+
key: 'savedFile',
34+
payload: { fileUri: document.uri.fsPath },
35+
},
36+
})
37+
})
38+
2939
window.onDidChangeActiveTextEditor(editor => {
3040
if (editor) {
3141
this.panel?.webview.postMessage({

vscode/react/src/hooks/eventBus.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export type EventMap = {
1515
changeFocusedFile: {
1616
fileUri: string
1717
}
18+
savedFile: {
19+
fileUri: string
20+
}
1821
}
1922

2023
/**

vscode/react/src/pages/lineage.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
QueryCache,
44
QueryClient,
55
QueryClientProvider,
6+
useQueryClient,
67
} from '@tanstack/react-query'
78
import { useApiModels } from '@/api'
89
import LineageFlowProvider from '@/components/graph/context'
@@ -24,9 +25,11 @@ export function LineagePage() {
2425
const payload: VSCodeEvent = event.data.payload
2526
switch (payload.key) {
2627
case 'changeFocusOnFile':
27-
console.log('emitted focus to file:', payload.payload.path)
2828
emit('changeFocusedFile', { fileUri: payload.payload.path })
2929
break
30+
case 'savedFile':
31+
emit('savedFile', { fileUri: payload.payload.fileUri })
32+
break
3033
default:
3134
console.error(
3235
'Unhandled message type in lineage page:',
@@ -65,6 +68,7 @@ function Lineage() {
6568
undefined,
6669
)
6770
const { on } = useEventBus()
71+
const queryClient = useQueryClient()
6872

6973
const { data: models, isLoading: isLoadingModels } = useApiModels()
7074
React.useEffect(() => {
@@ -104,6 +108,10 @@ function Lineage() {
104108
setSelectedModelSet(model.name)
105109
}
106110
})
111+
on('savedFile', () => {
112+
queryClient.invalidateQueries()
113+
})
114+
107115
return (
108116
<LineageComponentFromWeb
109117
selectedModel={selectedModel}

0 commit comments

Comments
 (0)