MCPcopy Create free account
hub / github.com/error311/FileRise / runSearchEverywhereAcrossSources

Function runSearchEverywhereAcrossSources

public/js/fileListView.js:5441–5546  ·  view source on GitHub ↗
(term, limit, sources, runId)

Source from the content-addressed store, hash-verified

5439}
5440
5441async function runSearchEverywhereAcrossSources(term, limit, sources, runId) {
5442 const uniqSources = [];
5443 const seen = new Set();
5444 sources.forEach((src) => {
5445 const id = String(src?.id || '').trim();
5446 if (!id || seen.has(id)) return;
5447 seen.add(id);
5448 uniqSources.push({
5449 id,
5450 name: String(src?.name || id),
5451 type: String(src?.type || ''),
5452 });
5453 });
5454
5455 if (!uniqSources.length) {
5456 renderSearchEverywhereResults([]);
5457 if (searchEverywhereStatusEl) searchEverywhereStatusEl.textContent = '';
5458 return;
5459 }
5460
5461 const perSourceLimit = Math.min(limit, 50);
5462 const statusById = {};
5463 const labelById = {};
5464 uniqSources.forEach((src) => {
5465 statusById[src.id] = 'pending';
5466 labelById[src.id] = formatSourceBadgeText(src) || src.name || src.id;
5467 });
5468
5469 const resultsMap = new Map();
5470 const reindexedSources = new Set();
5471
5472 const updateStatus = () => {
5473 if (!searchEverywhereStatusEl) return;
5474 const ids = Object.keys(statusById);
5475 if (!ids.length) {
5476 searchEverywhereStatusEl.textContent = '';
5477 return;
5478 }
5479 const doneCount = ids.filter(id => statusById[id] !== 'pending').length;
5480 const pendingLabels = ids.filter(id => statusById[id] === 'pending').map(id => labelById[id]).filter(Boolean);
5481 const failedLabels = ids.filter(id => statusById[id] === 'error').map(id => labelById[id]).filter(Boolean);
5482
5483 if (doneCount >= ids.length && pendingLabels.length === 0) {
5484 if (failedLabels.length) {
5485 searchEverywhereStatusEl.textContent = `Failed: ${failedLabels.join(', ')}`;
5486 } else {
5487 searchEverywhereStatusEl.textContent = '';
5488 }
5489 return;
5490 }
5491
5492 let text = `${t("loading") || "Loading..."} (${doneCount}/${ids.length})`;
5493 if (pendingLabels.length) {
5494 text += ` - Waiting on: ${pendingLabels.join(', ')}`;
5495 }
5496 if (failedLabels.length) {
5497 text += ` - Failed: ${failedLabels.join(', ')}`;
5498 }

Callers 1

runSearchEverywhereFunction · 0.85

Calls 6

formatSourceBadgeTextFunction · 0.85
updateStatusFunction · 0.85
fetchOneFunction · 0.85
tFunction · 0.85
showToastFunction · 0.70

Tested by

no test coverage detected