feat: do file-listing and index on java for file:/// and saf locations#2283
Conversation
- add cap on file size - fix issue with include file and its cap - improve getSurrounding to show meaning full snippet - tweaked ui a bit for nicer ux - show progress and status when searching - improve binary detection
Greptile SummaryThis PR offloads file-tree listing and search/replace to native Java (
Confidence Score: 5/5Safe to merge; the functional logic is sound and no data-loss or correctness bugs were found. The core scan/search flow is well-structured: the src/plugins/sdcard/src/android/WorkspaceIndex.java — specifically the Important Files Changed
Sequence Diagram%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant JS as JavaScript (index.js / fileList.js)
participant Bridge as Cordova Bridge (plugin.js)
participant Java as WorkspaceIndex.java
participant DB as SQLite DB
Note over JS,DB: File-tree listing (native path)
JS->>Bridge: workspaceScan(options, onEvent)
Bridge->>Java: scan(options, callback)
Java->>DB: beginTransaction / delete files
loop per directory entry
Java->>DB: replace into files
Java-->>Bridge: batch event (200 entries)
Bridge-->>JS: onEvent type batch entries
JS->>JS: addNativeEntries(root, entries)
end
Java->>DB: setTransactionSuccessful / endTransaction
Java-->>Bridge: done event
Bridge-->>JS: onEvent type done
Note over JS,DB: Search (native path)
JS->>Bridge: workspaceSearch(options, onEvent)
Bridge->>Java: search(options, callback)
loop per file
Java->>DB: query content if useIndex
alt cache hit
DB-->>Java: cached text
else cache miss
Java->>Java: readFileText
Java->>DB: replace into content
end
Java->>Java: pattern.matcher(content)
Java-->>Bridge: search-result event
Bridge-->>JS: appendSearchResult(data)
end
Java-->>Bridge: done-searching event
Bridge-->>JS: finishSearchTask(version)
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
participant JS as JavaScript (index.js / fileList.js)
participant Bridge as Cordova Bridge (plugin.js)
participant Java as WorkspaceIndex.java
participant DB as SQLite DB
Note over JS,DB: File-tree listing (native path)
JS->>Bridge: workspaceScan(options, onEvent)
Bridge->>Java: scan(options, callback)
Java->>DB: beginTransaction / delete files
loop per directory entry
Java->>DB: replace into files
Java-->>Bridge: batch event (200 entries)
Bridge-->>JS: onEvent type batch entries
JS->>JS: addNativeEntries(root, entries)
end
Java->>DB: setTransactionSuccessful / endTransaction
Java-->>Bridge: done event
Bridge-->>JS: onEvent type done
Note over JS,DB: Search (native path)
JS->>Bridge: workspaceSearch(options, onEvent)
Bridge->>Java: search(options, callback)
loop per file
Java->>DB: query content if useIndex
alt cache hit
DB-->>Java: cached text
else cache miss
Java->>Java: readFileText
Java->>DB: replace into content
end
Java->>Java: pattern.matcher(content)
Java-->>Bridge: search-result event
Bridge-->>JS: appendSearchResult(data)
end
Java-->>Bridge: done-searching event
Bridge-->>JS: finishSearchTask(version)
Reviews (5): Last reviewed commit: "fix(search): quote native replace-all re..." | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.