diff --git a/src/pages/home/home.ts b/src/pages/home/home.ts index 715c57f..2ada4b5 100755 --- a/src/pages/home/home.ts +++ b/src/pages/home/home.ts @@ -153,6 +153,10 @@ export async function initHomePage(): Promise { console.log('🔐 Auto-triggering WebAuthn authentication...'); await handleMainPairing(); + // Display existing processes even if authentication fails + console.log('📊 Displaying existing processes...'); + await displayExistingProcesses(); + // Hide loading spinner after initialization console.log('🔧 Hiding loading spinner...'); hideHomeLoadingSpinner(); @@ -581,15 +585,79 @@ async function handleMainPairing(): Promise { // Now proceed with pairing process await prepareAndSendPairingTx(); + // Display any existing processes in the status field + await displayExistingProcesses(); + } catch (error) { console.error('Pairing failed:', error); - + if (mainStatus) { mainStatus.innerHTML = '❌ Authentication failed'; } } } +// Display existing processes in the status field +async function displayExistingProcesses(): Promise { + try { + const service = await Services.getInstance(); + const processes = await service.getProcesses(); + + const container = getCorrectDOM('login-4nk-component') as HTMLElement; + const mainStatus = container.querySelector('#main-status') as HTMLElement; + + if (!mainStatus) { + console.warn('Main status element not found'); + return; + } + + const processCount = Object.keys(processes).length; + console.log(`📊 Found ${processCount} existing processes`); + + if (processCount === 0) { + if (mainStatus) { + mainStatus.innerHTML = '📋 No existing processes found'; + } + return; + } + + // Create a list of processes to display + let processesHtml = `
+

📋 Existing Processes (${processCount})

`; + + for (const [processId, process] of Object.entries(processes)) { + const processInfo = { + id: processId.substring(0, 8) + '...', + states: process.states?.length || 0, + members: Object.keys(process.members || {}).length, + lastUpdate: process.last_update || 'Unknown' + }; + + processesHtml += ` +
+ Process: ${processInfo.id}
+ + States: ${processInfo.states} | Members: ${processInfo.members} | Updated: ${processInfo.lastUpdate} + +
`; + } + + processesHtml += '
'; + + if (mainStatus) { + mainStatus.innerHTML = processesHtml; + } + + } catch (error) { + console.error('❌ Error displaying processes:', error); + const container = getCorrectDOM('login-4nk-component') as HTMLElement; + const mainStatus = container.querySelector('#main-status') as HTMLElement; + if (mainStatus) { + mainStatus.innerHTML = '❌ Error loading processes'; + } + } +} + // Account Actions export function setupAccountActions(): void { const container = getCorrectDOM('login-4nk-component') as HTMLElement;