Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

refactor(storage): tidy remote-search helpers and tooltip copy (#9920)

Shahmir Varqha3df7696596b9
diff --git a/frontend/src/components/storage/storage-inspector.tsx b/frontend/src/components/storage/storage-inspector.tsx
index e8ad976ca4..662f4e2b5e 100644
--- a/frontend/src/components/storage/storage-inspector.tsx
+++ b/frontend/src/components/storage/storage-inspector.tsx
@@ -187,6 +187,21 @@ function canRetryRemoteSearch(remoteSearch: RemoteSearchState): boolean {
);
}
+/**
+ * Whether the backend may still have an unfetched page for a prefix: either we
+ * have never listed it, or its last listing returned a next-page token.
+ */
+function hasUnfetchedPrefixPage(
+ searchKey: StoragePathKey,
+ entriesByPath: ReadonlyMap<StoragePathKey, StorageEntry[]>,
+ pageMetadataByPath: ReadonlyMap<StoragePathKey, StoragePageMetadata>,
+): boolean {
+ return (
+ entriesByPath.get(searchKey) === undefined ||
+ pageMetadataByPath.get(searchKey)?.nextPageToken != null
+ );
+}
+
function canSearchMoreRemoteEntries({
hasSearch,
hasLoadedMatches,
@@ -211,10 +226,7 @@ function canSearchMoreRemoteEntries({
return false;
}
- return (
- entriesByPath.get(searchKey) === undefined ||
- pageMetadataByPath.get(searchKey)?.nextPageToken != null
- );
+ return hasUnfetchedPrefixPage(searchKey, entriesByPath, pageMetadataByPath);
}
/**
@@ -635,14 +647,11 @@ const StorageNamespaceSection: React.FC<{
searchPrefix === "" ? [] : (entriesByPath.get(searchKey) ?? []);
// The fetched page is the whole parent directory; we still need to filter
// it by the full search query before showing entries to the user.
- const filteredRemoteEntries =
- remoteEntries.length > 0
- ? filterEntries(remoteEntries, {
- namespace: namespaceName,
- searchValue,
- entriesByPath,
- })
- : remoteEntries;
+ const filteredRemoteEntries = filterEntries(remoteEntries, {
+ namespace: namespaceName,
+ searchValue,
+ entriesByPath,
+ });
const hasSearch = !!searchValue.trim();
const hasLoadedMatches =
filtered.length > 0 || filteredRemoteEntries.length > 0;
@@ -702,7 +711,7 @@ const StorageNamespaceSection: React.FC<{
if (remoteSearch.status === "exhausted" && !hasLoadedMatches) {
return "No matches";
}
- if (!hasSearch && !isPending && entries.length === 0 && !error) {
+ if (!hasSearch && !isPending && entries.length === 0) {
return "No entries";
}
if (canSearchMore) {
@@ -899,10 +908,11 @@ export const StorageInspector: React.FC = () => {
return false;
}
- const canFetchPrefix =
- entriesByPath.get(searchKey) === undefined ||
- pageMetadataByPath.get(searchKey)?.nextPageToken != null;
- return canFetchPrefix;
+ return hasUnfetchedPrefixPage(
+ searchKey,
+ entriesByPath,
+ pageMetadataByPath,
+ );
},
[currentQuery, entriesByPath, pageMetadataByPath, remoteSearchForNamespace],
);
@@ -1061,7 +1071,7 @@ export const StorageInspector: React.FC = () => {
</Button>
)}
<Tooltip
- content="Filters loaded entries only. Expand directories or press Enter to search more entries from the backend."
+ content="Search by file name within loaded entries, or by prefix (e.g. 'folder/x') for backend search. Press Enter to fetch more results."
delayDuration={200}
>
<HelpCircleIcon className="h-3.5 w-3.5 shrink-0 cursor-help text-muted-foreground hover:text-foreground mr-2" />