Skip to content

feat(storage): search the backend when no loaded entries match#9835

Merged
Light2Dark merged 3 commits into
mainfrom
Light2Dark/feat-storage-remote-search
Jun 18, 2026
Merged

feat(storage): search the backend when no loaded entries match#9835
Light2Dark merged 3 commits into
mainfrom
Light2Dark/feat-storage-remote-search

Conversation

@Light2Dark

@Light2Dark Light2Dark commented Jun 9, 2026

Copy link
Copy Markdown
Member

📝 Summary

Split out from #9708. Part of the work for #9662.

When a prefix query produces no matches among the already-loaded entries, this pages through the backend to surface remote results:

  • Entries are now matched by full path (not just basename), so partial path queries like folder/x resolve folder/xsomething. Because object stores evaluate prefixes on a path-segment basis, the parent directory is listed and filtered client-side.
  • When there are no loaded matches, the panel offers a "Search more entries" action (the button or pressing Enter) that pages through the backend up to 5 pages per trigger, stopping early on a match or when the listing is exhausted. If it reaches the cap without a match, it shows "Continue searching" to fetch the next batch. Status rows reflect the search state (searching / found / no matches / capped / error).

📋 Pre-Review Checklist

  • For large changes, or changes that affect the public API: this change was discussed or approved through an issue, on Discord, or the community discussions (Please provide a link if applicable).
  • Any AI generated code has been reviewed line-by-line by the human PR author, who stands by it.
  • Video or media evidence is provided for any visual changes (optional).

✅ Merge Checklist

  • I have read the contributor guidelines.
  • Documentation has been updated where applicable, including docstrings for API changes.
  • Tests have been added for the changes made.
@vercel

vercel Bot commented Jun 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Jun 18, 2026 4:50am

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Architecture diagram
sequenceDiagram
    participant UI as Storage Panel
    participant Hooks as useStorage / useStoragePageFetcher
    participant State as Storage State (Zustand)
    participant Backend as Backend API (obstore)

    Note over UI,Backend: Search Flow with Remote Fallback

    UI->>UI: User types search query in filter input
    UI->>UI: filterEntries() checks loaded entries by full path + basename
    alt Has loaded matches
        UI->>UI: Display matching local entries
    else No loaded matches AND has directory prefix
        UI->>UI: remoteSearchPrefix() extracts parent directory
        UI->>Hooks: Trigger remote search via useStoragePageFetcher
        Hooks->>State: Request page for directory prefix
        State->>Backend: listObjects(prefix=directory)
        Backend-->>State: Page of entries + nextPageToken
        State-->>UI: Update entriesByPath with new entries
        UI->>UI: filterEntries() client-side on fetched entries
        alt Entries match query
            UI->>UI: Display matching remote entries
            UI->>UI: Set remoteSearch status to "found"
        else No entries yet AND nextPageToken exists
            UI->>UI: Show "Search more entries" button
            alt User clicks "Search more" (up to MAX_REMOTE_SEARCH_PAGES=5)
                UI->>Hooks: fetchNextPage()
                Hooks->>State: Request next page with token
                State->>Backend: listObjects(prefix, pageToken)
                Backend-->>State: Next page of entries
                State-->>UI: Update entriesByPath
                UI->>UI: Re-filter and loop
            else User presses Enter
                UI->>Hooks: fetchNextPage() (repeat until matched or exhausted)
            end
        end
    end

    Note over UI,Backend: Status/Error Handling

    alt Remote search exhausted
        UI->>UI: Set remoteSearch status to "exhausted"
        UI->>UI: Show "No results found" message
    else Remote search capped at 5 pages
        UI->>UI: Set remoteSearch status to "capped"
        UI->>UI: Show "Searched more entries" with retry option
    else Remote search error
        UI->>UI: Set remoteSearch status to "error"
        UI->>UI: Show error message with retry button
    end
Loading

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread frontend/src/components/storage/storage-inspector.tsx Outdated
@Light2Dark Light2Dark force-pushed the Light2Dark/feat-storage-pagination branch 2 times, most recently from 167f472 to 0ca831a Compare June 15, 2026 03:33
Base automatically changed from Light2Dark/feat-storage-pagination to main June 15, 2026 15:12
@github-actions github-actions Bot added the bash-focus Area to focus on during release bug bash label Jun 15, 2026
When a prefix query has no matches among the loaded entries, page
through the backend (up to a cap, or on Enter) to surface remote
results, and match entries by full path so partial path queries work
across object-store prefix boundaries.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Light2Dark Light2Dark force-pushed the Light2Dark/feat-storage-remote-search branch from 3688ca0 to 5a36755 Compare June 15, 2026 15:25
@Light2Dark Light2Dark added the enhancement New feature or request label Jun 15, 2026
Gate the "Search more entries" affordance on the same directory-prefix
condition the action uses, so slashless queries (which remote search
can't act on) no longer render a no-op button and Enter hint.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Light2Dark Light2Dark marked this pull request as ready for review June 15, 2026 16:06
Copilot AI review requested due to automatic review settings June 15, 2026 16:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread frontend/src/components/storage/storage-inspector.tsx
Comment thread frontend/src/components/storage/storage-inspector.tsx
Gate the search-input Enter handler on namespaces.some(canContinueRemoteSearch)
instead of hasSearch, so slashless queries (which can't trigger a backend
search) no longer swallow CmdK's default Enter selection.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

@kirangadhave kirangadhave left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀 Looks good, just some nits

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 =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just call filterEntries? filtering on empty array should return empty anyways.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! will address these in follow-up

return false;
}

const canFetchPrefix =

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a function canSearchMoreRemoteEntries which does the same check right?

if (remoteSearch.status === "exhausted" && !hasLoadedMatches) {
return "No matches";
}
if (!hasSearch && !isPending && entries.length === 0 && !error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can combine with above as one predicate?

@Light2Dark Light2Dark merged commit 80d52cb into main Jun 18, 2026
31 checks passed
@Light2Dark Light2Dark deleted the Light2Dark/feat-storage-remote-search branch June 18, 2026 05:15
Light2Dark added a commit that referenced this pull request Jun 18, 2026
**This pull request was authored by a coding agent.**

## 📝 Summary

Follow-up to #9835 — small cleanups from review feedback, no behavior
change to the storage inspector beyond clearer tooltip copy.

- Extract `hasUnfetchedPrefixPage`, shared by
`canSearchMoreRemoteEntries` and `canContinueRemoteSearch`, removing the
duplicated next-page check.
- Drop the redundant length guard on `filteredRemoteEntries`
(`filterEntries` already returns empty for an empty input).
- Drop the redundant `!error` guard in the "No entries" status row
(`statusRow` only renders when there is no error).
- Clarify the search-input help tooltip: "Search by file name within
loaded entries, or by prefix (e.g. `folder/x`) for backend search. Press
Enter to fetch more results."

## 📋 Pre-Review Checklist
<!-- These checks need to be completed before a PR is reviewed -->

- [x] For large changes, or changes that affect the public API: this
change was discussed or approved through an issue, on
[Discord](https://marimo.io/discord?ref=pr), or the community
[discussions](https://github.com/marimo-team/marimo/discussions) (Please
provide a link if applicable).
- [ ] Any AI generated code has been reviewed line-by-line by the human
PR author, who stands by it.
- [x] Video or media evidence is provided for any visual changes
(optional). <!-- PR is more likely to be merged if evidence is provided
for changes made -->

## ✅ Merge Checklist

- [x] I have read the [contributor
guidelines](https://github.com/marimo-team/marimo/blob/main/CONTRIBUTING.md).
- [ ] Documentation has been updated where applicable, including
docstrings for API changes.
- [ ] Tests have been added for the changes made.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/marimo-team/marimo/pull/9920?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bash-focus Area to focus on during release bug bash enhancement New feature or request

3 participants