Skip to content

feat(files): move workspace indexing and search to native for saf/files#2529

Open
bajrangCoder wants to merge 2 commits into
mainfrom
feat/native-workspace-index
Open

feat(files): move workspace indexing and search to native for saf/files#2529
bajrangCoder wants to merge 2 commits into
mainfrom
feat/native-workspace-index

Conversation

@bajrangCoder

@bajrangCoder bajrangCoder commented Jul 23, 2026

Copy link
Copy Markdown
Member

Summary

Moves file indexing and project-wide search for SAF and file:// workspaces to the Android native layer.

This prevents large workspaces, such as Termux home, from creating a complete file tree in the WebView.

Changes

  • Added a native SQLite workspace index.
  • Added paginated native filename queries.
  • Added the new asynchronous fileIndex plugin API.
  • Migrated Quick Open to native queries.
  • Migrated project-wide search to native root-based search.
  • Batched native search results to reduce Cordova bridge callbacks.
  • Removed progress callbacks from individual file reads.
  • Skips files and directories that return permission errors.
  • Fixed project search after closing one folder and opening another.
  • Fixed folder exclusion matching, including node_modules.
  • Prevented recursive indexing of Termux ~/storage.
  • Kept FTP, SFTP, and custom storage providers on the JavaScript fallback.

Breaking changes

acode.require("fileList") is deprecated.

It now contains files from non-native providers only. Plugins using it for SAF or file:// workspaces must migrate to:

const fileIndex = acode.require("fileIndex");
const result = await fileIndex.query({
  roots: [workspaceUrl],
  text: "filename",
  limit: 200,
});

Differences from fileList:

  • fileIndex is asynchronous.
  • Results are flat metadata records instead of Tree objects.
  • Large results use cursor pagination.
  • Native search can emit batched search-results events.

The native index database version is also updated. Existing generated indexes will be rebuilt automatically.

Compatibility

  • SAF and file://: native index and search.
  • FTP and SFTP: existing JavaScript fallback.
  • Low-level sdcard.workspaceSearch() keeps single-result events unless batchResults: true is provided.

@bajrangCoder
bajrangCoder marked this pull request as ready for review July 23, 2026 14:11
@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves local workspace indexing and search into the Android native layer. The main changes are:

  • Adds a SQLite index for SAF and file:// workspaces.
  • Adds asynchronous filename queries and paginated results.
  • Moves Quick Open and project search onto the native index.
  • Batches native search events across the Cordova bridge.
  • Keeps remote and custom providers on the JavaScript fallback.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.
  • JavaScript and native method signatures align.
  • Search consumers handle both individual and batched events.
  • Async Quick Open and search paths reject stale results.

Important Files Changed

Filename Overview
src/plugins/sdcard/src/android/WorkspaceIndex.java Adds native workspace traversal, SQLite indexing, pagination, content search, cancellation, exclusions, and result batching.
src/plugins/sdcard/src/android/SDcard.java Routes the new workspace index operations through the Android Cordova plugin.
src/lib/fileIndex.js Adds the asynchronous JavaScript API for native scans, queries, searches, cancellation, and index maintenance.
src/sidebarApps/searchInFiles/index.js Moves eligible project searches to the native index and queues batched results for rendering.
src/palettes/findFile/index.js Moves Quick Open for native workspaces to asynchronous paginated filename queries.
src/components/inputhints/index.js Adds debounced dynamic hint generation with stale-response guards.
src/lib/fileList.js Keeps tree indexing for fallback providers and routes local workspace updates to the native index.
src/lib/openFolder.js Reorders folder removal so native index cleanup runs while the root is still registered.
src/plugins/sdcard/www/plugin.js Exposes the new native workspace operations through Cordova.
src/plugins/sdcard/index.d.ts Adds declarations for native queries and batched search events.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Open workspace] --> B{Native indexing supported?}
    B -->|SAF or file URL| C[Native workspace scan]
    C --> D[(SQLite index)]
    B -->|Remote or custom provider| E[JavaScript file tree]
    F[Quick Open] --> G[Native filename query]
    G --> D
    H[Project search] --> I[Native root search]
    I --> D
    I --> J[Batched result events]
    E --> K[JavaScript search fallback]
Loading

Reviews (1): Last reviewed commit: "fix batch stuff" | Re-trigger Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant