fix(google-docs): search all drives in doc picker, log result count

This commit is contained in:
Gagancreates 2026-06-01 13:53:23 +05:30
parent b35bd8fe2e
commit 112bf461c9

View file

@ -190,14 +190,21 @@ export async function listGoogleDocs(query?: string): Promise<{ files: GoogleDoc
if (trimmed) { if (trimmed) {
clauses.push(`name contains '${escapeDriveQueryValue(trimmed)}'`); clauses.push(`name contains '${escapeDriveQueryValue(trimmed)}'`);
} }
const q = clauses.join(' and ');
const result = await driveClient.files.list({ const result = await driveClient.files.list({
q: clauses.join(' and '), q,
pageSize: 25, pageSize: 25,
orderBy: 'modifiedTime desc', orderBy: 'modifiedTime desc',
fields: 'files(id,name,webViewLink,modifiedTime,owners(displayName,emailAddress))', fields: 'files(id,name,webViewLink,modifiedTime,owners(displayName,emailAddress))',
// Also surface docs in shared drives and "Shared with me", not just My Drive.
corpora: 'allDrives',
includeItemsFromAllDrives: true,
supportsAllDrives: true,
}); });
return { files: (result.data.files ?? []).map(toGoogleDocListItem).filter((file) => file.id) }; const files = (result.data.files ?? []).map(toGoogleDocListItem).filter((file) => file.id);
console.log(`[GoogleDocs] list q="${q}" → ${files.length} doc(s)`);
return { files };
} }
/** Import a Google Doc as a local .docx and register the link. */ /** Import a Google Doc as a local .docx and register the link. */