···641641 // Initial load (may be incomplete if extensions still loading)
642642 await refreshExtensionsList();
643643644644- // Reactively update when extensions finish loading
645645- api.subscribe('ext:all-loaded', () => {
646646- refreshExtensionsList();
647647- }, api.scopes.GLOBAL);
644644+ // Store refresh function for external access (ext:all-loaded is subscribed once in main init)
645645+ window._refreshExtensionsList = refreshExtensionsList;
648646649647 return container;
650648};
···10721070 await loadExtensionSettings();
1073107110741072 // Listen for all extensions loaded event to catch any we missed
10731073+ // NOTE: Only ONE ext:all-loaded subscription per source - pubsub overwrites duplicates
10751074 api.subscribe('ext:all-loaded', () => {
10761075 loadExtensionSettings();
10761076+ // Also refresh the Extensions list if it's been rendered
10771077+ if (window._refreshExtensionsList) {
10781078+ window._refreshExtensionsList();
10791079+ }
10771080 }, api.scopes.GLOBAL);
1078108110791082 // Add Datastore link
+49
extensions/example/background.html
···11+<!DOCTYPE html>
22+<html>
33+<head>
44+ <meta charset="UTF-8">
55+ <title>Example Extension</title>
66+</head>
77+<body>
88+<script type="module">
99+ import extension from './background.js';
1010+1111+ const api = window.app;
1212+ const extId = extension.id;
1313+1414+ console.log(`[ext:${extId}] background.html loaded`);
1515+1616+ // Signal ready to main process
1717+ api.publish('ext:ready', {
1818+ id: extId,
1919+ manifest: {
2020+ id: extension.id,
2121+ labels: extension.labels,
2222+ version: '1.0.0'
2323+ }
2424+ }, api.scopes.SYSTEM);
2525+2626+ // Initialize extension
2727+ if (extension.init) {
2828+ console.log(`[ext:${extId}] calling init()`);
2929+ extension.init();
3030+ }
3131+3232+ // Handle shutdown request from main process
3333+ api.subscribe('app:shutdown', () => {
3434+ console.log(`[ext:${extId}] received shutdown`);
3535+ if (extension.uninit) {
3636+ extension.uninit();
3737+ }
3838+ }, api.scopes.SYSTEM);
3939+4040+ // Handle extension-specific shutdown
4141+ api.subscribe(`ext:${extId}:shutdown`, () => {
4242+ console.log(`[ext:${extId}] received extension shutdown`);
4343+ if (extension.uninit) {
4444+ extension.uninit();
4545+ }
4646+ }, api.scopes.SYSTEM);
4747+</script>
4848+</body>
4949+</html>