From 57377447b64fc2fa360249b3d4130f3aba0e1699 Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Mon, 19 Jan 2026 18:33:52 +0800 Subject: [PATCH] Add comprehensive logging to diagnose git-log-refreshed issue - Log before RAF and inside RAF to pinpoint exact failure location - Add try-catch to capture any errors - Two log markers: before-raf and in-raf - This will definitively show where the logging fails in CI --- src/windows/GitLog/useGitLogData.ts | 40 ++++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/src/windows/GitLog/useGitLogData.ts b/src/windows/GitLog/useGitLogData.ts index db8314b4..9879f3f8 100644 --- a/src/windows/GitLog/useGitLogData.ts +++ b/src/windows/GitLog/useGitLogData.ts @@ -208,23 +208,33 @@ export function useGitLogData(workspaceID: string): IGitLogData { isUnpushed: unpushedHashes.has(entry.hash), })); + // Prepare log data + const logData = { + commitCount: entriesWithUnpushedFlag.length, + wikiFolderLocation: workspaceInfo.wikiFolderLocation, + entriesFingerprint: entriesWithUnpushedFlag.map(entry => entry.hash || 'uncommitted').join(','), + }; + + // Log BEFORE RAF + try { + void window.service.native.log('debug', '[test-id-git-log-refreshed]', { ...logData, source: 'before-raf' }); + } catch (error) { + console.error('[CRITICAL] Log before RAF failed:', error); + } + // Use requestAnimationFrame to batch the state updates and reduce flicker requestAnimationFrame(() => { - setEntries(entriesWithUnpushedFlag); - setCurrentBranch(result.currentBranch); - setTotalCount(result.totalCount); - setCurrentPage(0); - - // Log refresh marker right after setting entries in RAF - // This ensures the log call happens in the same context as successful state updates - const logData = { - commitCount: entriesWithUnpushedFlag.length, - wikiFolderLocation: workspaceInfo.wikiFolderLocation, - entriesFingerprint: entriesWithUnpushedFlag.map(entry => entry.hash || 'uncommitted').join(','), - source: 'raf-after-setEntries', - }; - window.service.native.log('debug', '[test-id-git-log-refreshed]', logData); - window.service.native.log('debug', '[test-id-git-log-refreshed]', logData); + try { + setEntries(entriesWithUnpushedFlag); + setCurrentBranch(result.currentBranch); + setTotalCount(result.totalCount); + setCurrentPage(0); + + // Log AFTER setEntries in RAF + void window.service.native.log('debug', '[test-id-git-log-refreshed]', { ...logData, source: 'in-raf' }); + } catch (error) { + console.error('[CRITICAL] RAF callback failed:', error); + } }); } catch (error_) { const error = error_ as Error;