personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

convey/entities: upgrade loading scaffold + migrate loaders (wave 2)

Upgrade the #entities-loading scaffold to the shared surface-state--loading
contract so SurfaceState.replaceLoading() can swap it in place on failure.
Preserve the legacy .spinner class on the new spinner element so existing CSS
still applies.

Migrate loadEntities() and loadJournalEntities() from raw fetch+then to
window.apiJson(), and replace the scaffold-polluting .error-message hack with
SurfaceState.replaceLoading() + errorCard() so failures no longer live inside
the loading slot.

Wave 2 bundle 1 of 13.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

+20 -22
+20 -22
apps/entities/workspace.html
··· 1256 1256 1257 1257 <div class="workspace-content"> 1258 1258 <div id="entities-loading" class="entities-loading"> 1259 - <div class="spinner"></div> 1260 - <p>Loading entities...</p> 1259 + <div class="surface-state surface-state--loading" role="status" aria-busy="true"> 1260 + <div class="surface-state-spinner spinner" aria-hidden="true"></div> 1261 + <span class="surface-state-text" data-role="loading-status">Loading entities...</span> 1262 + </div> 1261 1263 </div> 1262 1264 1263 1265 <!-- Journal-wide entities view (all-facet mode) --> ··· 2644 2646 } 2645 2647 2646 2648 // Facet-specific mode 2647 - return fetch(`api/${encodeURIComponent(currentFacet)}`) 2648 - .then(response => response.json()) 2649 + return window.apiJson(`api/${encodeURIComponent(currentFacet)}`) 2649 2650 .then(data => { 2650 - if (data.error) { 2651 - throw new Error(data.error); 2652 - } 2653 - 2654 2651 entitiesData = { 2655 2652 attached: data.attached || [], 2656 2653 detected: data.detected || [] ··· 2668 2665 detectedPage = 1; 2669 2666 renderEntities(); 2670 2667 }) 2671 - .catch(error => { 2672 - console.error('Error loading entities:', error); 2673 - document.getElementById('entities-loading').innerHTML = 2674 - `<div class="error-message">${window.AppServices.escapeHtml(error.message || 'Network error')}</div>`; 2668 + .catch(err => { 2669 + window.logError(err, { context: 'entities: loadEntities failed' }); 2670 + window.SurfaceState.replaceLoading('entities-loading', window.SurfaceState.errorCard({ 2671 + heading: "Couldn't load entities", 2672 + desc: 'Reload to try again.', 2673 + serverMessage: err?.serverMessage 2674 + })); 2675 2675 }); 2676 2676 } 2677 2677 2678 2678 function loadJournalEntities() { 2679 - return fetch('api/journal') 2680 - .then(response => response.json()) 2679 + return window.apiJson('api/journal') 2681 2680 .then(data => { 2682 - if (data.error) { 2683 - throw new Error(data.error); 2684 - } 2685 - 2686 2681 journalEntitiesData = data.entities || []; 2687 2682 2688 2683 document.getElementById('entities-loading').style.display = 'none'; ··· 2696 2691 2697 2692 renderJournalEntities(); 2698 2693 }) 2699 - .catch(error => { 2700 - console.error('Error loading journal entities:', error); 2701 - document.getElementById('entities-loading').innerHTML = 2702 - `<div class="error-message">${window.AppServices.escapeHtml(error.message || 'Network error')}</div>`; 2694 + .catch(err => { 2695 + window.logError(err, { context: 'entities: loadJournalEntities failed' }); 2696 + window.SurfaceState.replaceLoading('entities-loading', window.SurfaceState.errorCard({ 2697 + heading: "Couldn't load entities", 2698 + desc: 'Reload to try again.', 2699 + serverMessage: err?.serverMessage 2700 + })); 2703 2701 }); 2704 2702 } 2705 2703