feat(media): Optimize Media Manager loading performance

Significant performance improvements to the 'Loading media...' phase:
- Reduced client-server round trips by consolidating the initial handshake (diagnostics + media fetch) into a single backend call: getMediaManagerInitialState.
- Implemented batched Google Drive metadata retrieval in GASDriveService using the Advanced Drive API, eliminating per-file property fetching calls.
- Switched to HtmlService templates in showMediaManager to pass initial SKU/Title data directly, enabling the UI shell to appear instantly upon opening.
- Updated documentation (ARCHITECTURE.md, MEMORY.md) to clarify Webpack global assignment requirements for GAS functions.
- Verified with comprehensive updates to unit and integration tests.
This commit is contained in:
Ben Miller
2025-12-31 09:46:56 -07:00
parent fc25e877f1
commit e39bc862cc
11 changed files with 314 additions and 150 deletions

View File

@ -12,7 +12,8 @@ const mockDrive = {
trashFile: jest.fn(),
updateFileProperties: jest.fn(),
getFileProperties: jest.fn(),
getFileById: jest.fn()
getFileById: jest.fn(),
getFilesWithProperties: jest.fn()
}
const mockShopify = {
getProductMedia: jest.fn(),
@ -80,6 +81,13 @@ describe("MediaService V2 Integration Logic", () => {
getId: () => "new_created_file_id"
})
mockDrive.getFileProperties.mockReturnValue({})
mockDrive.getFilesWithProperties.mockImplementation((folderId: string) => {
const files = mockDrive.getFiles(folderId) || []
return files.map(f => ({
file: f,
properties: mockDrive.getFileProperties(f.getId())
}))
})
})
describe("getUnifiedMediaState (Phase A)", () => {