Skip to content

Commit b287dc8

Browse files
committed
Fixing query block sync invalidation
1 parent c0e85e8 commit b287dc8

File tree

4 files changed

+22
-13
lines changed

4 files changed

+22
-13
lines changed

frontend/apps/desktop/src/app-sync.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,18 @@ async function runDiscovery(
499499
// Invalidate so UI shows the found resource
500500
appInvalidateQueries([queryKeys.ENTITY, id.id])
501501
appInvalidateQueries([queryKeys.RESOLVED_ENTITY, id.id])
502+
503+
// For recursive subscriptions, also invalidate directory queries
504+
// so query blocks refresh when discovery completes
505+
if (recursive) {
506+
appInvalidateQueries([queryKeys.DOC_LIST_DIRECTORY, id.id])
507+
getParentPaths(id.path).forEach((parentPath) => {
508+
const parentId = hmId(id.uid, {path: parentPath})
509+
appInvalidateQueries([queryKeys.DOC_LIST_DIRECTORY, parentId.id])
510+
})
511+
const rootId = hmId(id.uid)
512+
appInvalidateQueries([queryKeys.DOC_LIST_DIRECTORY, rootId.id])
513+
}
502514
}
503515

504516
// Also check for version changes (for resources already known but updated)

frontend/apps/desktop/src/editor/query-block.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ function Render(
123123
recursive: mode === 'AllDescendants',
124124
})
125125
const directoryItems = useDirectory(queryId, {
126-
// @ts-ignore
127-
mode: queryIncludes[0]?.mode,
126+
mode,
128127
})
129128

130129
const sortedItems = useMemo(() => {
@@ -248,7 +247,7 @@ function Render(
248247
banner={banner}
249248
accountsMetadata={accountsMetadata}
250249
getEntity={getEntity}
251-
isDiscovering={entity.isDiscovering}
250+
isDiscovering={entity.isDiscovering || directoryItems.isLoading}
252251
/>
253252
</div>
254253
)

frontend/packages/ui/src/blocks-content.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2968,14 +2968,10 @@ export function DocumentCardGrid({
29682968
})}
29692969
</div>
29702970
) : null}
2971-
{items.length == 0 ? (
2972-
<BlankQueryBlockMessage
2973-
message={
2974-
isDiscovering
2975-
? 'Searching for documents...'
2976-
: 'No Documents found in this Query Block.'
2977-
}
2978-
/>
2971+
{items.length == 0 && isDiscovering ? (
2972+
<BlankQueryBlockMessage message="Searching for documents..." />
2973+
) : items.length == 0 ? (
2974+
<BlankQueryBlockMessage message="No Documents found in this Query Block." />
29792975
) : null}
29802976
</div>
29812977
)

frontend/packages/ui/src/query-block-content.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,17 @@ function QueryBlockListView({
9090
accountsMetadata: HMAccountsMetadata
9191
isDiscovering?: boolean
9292
}) {
93-
if (isDiscovering && items.length === 0) {
93+
// Show loading state when discovering and no items yet
94+
if (items.length === 0 && isDiscovering) {
9495
return (
9596
<div className="bg-muted flex items-center rounded-lg p-4">
96-
<span className="text-muted-foreground">
97+
<span className="text-muted-foreground italic">
9798
Searching for documents...
9899
</span>
99100
</div>
100101
)
101102
}
103+
102104
return (
103105
<div className="my-4 flex w-full flex-col gap-1">
104106
{items.map((item) => {

0 commit comments

Comments
 (0)