···140140 useEffect(() => {
141141 // If session exists, create an Agent instance
142142 if (session) {
143143- // The session object from the main AuthContext might be structured differently.
144144- // Assuming it has an `accessJwt` and `did` (or `sub`)
145145- const agentInstance = new Agent({
146146- service: 'https://bsky.social', // Or get from session if available
147147- session: session // Pass the session object directly
148148- });
143143+ // The session object from AuthContext IS the session manager
144144+ // Pass it directly to the Agent constructor.
145145+ const agentInstance = new Agent(session);
149146 setAgent(agentInstance);
150147151148 // Fetch logged-in user's profile info using the authenticated API
152152- agentInstance.api.app.bsky.actor.getProfile({ actor: session.did /* Ensure correct DID property */ })
149149+ // Use the agent's built-in DID reference after initialization
150150+ agentInstance.getProfile({ actor: agentInstance.session.did })
153151 .then(res => {
154152 console.log('Logged-in user profile fetched successfully:', res.data);
155153 setUserInfo(res.data);