@@ -133,7 +133,7 @@ import MasterPasswordModal from './components/MasterPasswordModal';
133133import CommitModal from './components/CommitModal' ;
134134import GitHistoryModal from './components/GitHistoryModal' ;
135135import GitStatusIndicator from './components/GitStatusIndicator' ;
136- import { gitManager } from './gitManager ' ;
136+ import { getGitManager } from './gitManagerWrapper ' ;
137137import { gitCredentialManager } from './gitCredentialManager' ;
138138import ToastContainer from './components/ToastContainer' ;
139139
@@ -143,6 +143,7 @@ const App = () => {
143143 const [ historyIndex , setHistoryIndex ] = useState < number > ( - 1 ) ;
144144 const [ isHorizontal , setIsHorizontal ] = useState < boolean > ( false ) ;
145145 const previewRef = useRef < HTMLDivElement > ( null ! ) ;
146+ const [ gitManager , setGitManager ] = useState < any > ( null ) ;
146147 const textareaRef = useRef < HTMLTextAreaElement > ( null ! ) ;
147148 const cursorPositionRef = useRef < number > ( 0 ) ;
148149 const [ tableModalOpen , setTableModalOpen ] = useState ( false ) ;
@@ -254,6 +255,13 @@ const App = () => {
254255 setToasts ( prev => prev . filter ( toast => toast . id !== id ) ) ;
255256 } ;
256257
258+ // Initialize git manager based on environment
259+ useEffect ( ( ) => {
260+ getGitManager ( ) . then ( manager => {
261+ setGitManager ( manager ) ;
262+ } ) ;
263+ } , [ ] ) ;
264+
257265 // Detect Electron environment and add class to body for CSS targeting
258266 useEffect ( ( ) => {
259267 if ( typeof window !== 'undefined' && ( window as any ) . electronAPI ) {
@@ -274,6 +282,7 @@ const App = () => {
274282
275283 // Check for saved repository directory
276284 const checkRepo = ( ) => {
285+ if ( ! gitManager ) return ;
277286 const savedRepoDir = gitManager . getRepoDir ( ) ;
278287 if ( savedRepoDir ) {
279288 console . log ( '[App] Restored repository from session:' , savedRepoDir ) ;
@@ -284,7 +293,7 @@ const App = () => {
284293
285294 checkCredentials ( ) ;
286295 checkRepo ( ) ;
287- } , [ ] ) ;
296+ } , [ gitManager ] ) ;
288297
289298 // Selection state fixing the issue with the Headers selection
290299 const [ selectionStart , setSelectionStart ] = useState < number | null > ( null ) ;
@@ -969,7 +978,9 @@ const App = () => {
969978 onConfirm : async ( ) => {
970979 try {
971980 await gitCredentialManager . clearCredentials ( ) ;
972- gitManager . clearCredentials ( ) ;
981+ if ( gitManager ) {
982+ gitManager . clearCredentials ( ) ;
983+ }
973984 setHasStoredCredentials ( false ) ;
974985 showToast ( 'Credentials cleared successfully.' , 'success' ) ;
975986 } catch ( error ) {
@@ -980,6 +991,11 @@ const App = () => {
980991 } ;
981992
982993 const ensureCredentials = async ( action : ( ) => Promise < void > ) => {
994+ if ( ! gitManager ) {
995+ showToast ( 'Git manager not initialized yet. Please wait.' , 'info' ) ;
996+ return false ;
997+ }
998+
983999 // Check if we have stored credentials
9841000 if ( ! gitCredentialManager . hasCredentials ( ) ) {
9851001 // No stored credentials, prompt user to set them up
@@ -1025,6 +1041,11 @@ const App = () => {
10251041
10261042 // Helper function to perform the actual clone
10271043 const performClone = async ( ) => {
1044+ if ( ! gitManager ) {
1045+ showToast ( 'Git manager not initialized yet. Please wait.' , 'error' ) ;
1046+ return ;
1047+ }
1048+
10281049 try {
10291050 // Show loading state
10301051 showToast ( 'Cloning repository... This may take a moment.' , 'info' ) ;
@@ -1295,6 +1316,11 @@ const App = () => {
12951316 } ;
12961317
12971318 const handleGitPull = async ( ) => {
1319+ if ( ! gitManager ) {
1320+ showToast ( 'Git manager not initialized yet. Please wait.' , 'info' ) ;
1321+ return ;
1322+ }
1323+
12981324 if ( ! isGitRepo ) {
12991325 showToast ( 'No active Git repository. Please clone a repository first.' , 'info' ) ;
13001326 return ;
@@ -1511,6 +1537,11 @@ const App = () => {
15111537
15121538 // Phase 4: View commit history
15131539 const handleViewHistory = async ( ) => {
1540+ if ( ! gitManager ) {
1541+ showToast ( 'Git manager not initialized yet. Please wait.' , 'info' ) ;
1542+ return ;
1543+ }
1544+
15141545 if ( ! isGitRepo ) {
15151546 showToast ( 'No active Git repository. Please clone a repository first.' , 'info' ) ;
15161547 return ;
0 commit comments