File tree Expand file tree Collapse file tree 4 files changed +10
-16
lines changed
Expand file tree Collapse file tree 4 files changed +10
-16
lines changed Original file line number Diff line number Diff line change 11import { useActivityQuery } from './use-activity-query'
22import { getAuthToken } from '../utils/auth'
3- import { getApiClient , setApiClientAuthToken } from '../utils/codebuff-api'
3+ import { getApiClient } from '../utils/codebuff-api'
44import { logger as defaultLogger } from '../utils/logger'
55
66import type { Logger } from '@codebuff/common/types/contracts/logger'
@@ -48,8 +48,6 @@ export interface SubscriptionData {
4848export async function fetchSubscriptionData (
4949 logger : Logger = defaultLogger ,
5050) : Promise < SubscriptionData > {
51- const authToken = getAuthToken ( )
52- setApiClientAuthToken ( authToken )
5351 const client = getApiClient ( )
5452 const response = await client . get < SubscriptionData > (
5553 '/api/user/subscription' ,
Original file line number Diff line number Diff line change 11import { useQuery } from '@tanstack/react-query'
22
33import { getAuthToken } from '../utils/auth'
4- import { getApiClient , setApiClientAuthToken } from '../utils/codebuff-api'
4+ import { getApiClient } from '../utils/codebuff-api'
55import { logger as defaultLogger } from '../utils/logger'
66
77import type {
@@ -38,11 +38,7 @@ export async function fetchUserDetails<T extends UserField>({
3838 apiClient : providedApiClient ,
3939} : FetchUserDetailsParams < T > ) : Promise < UserDetails < T > | null > {
4040 const apiClient =
41- providedApiClient ??
42- ( ( ) => {
43- setApiClientAuthToken ( authToken )
44- return getApiClient ( )
45- } ) ( )
41+ providedApiClient ?? getApiClient ( )
4642
4743 const response = await apiClient . me ( fields )
4844
Original file line number Diff line number Diff line change @@ -24,8 +24,9 @@ import { runPlainLogin } from './login/plain-login'
2424import { initializeApp } from './init/init-app'
2525import { getProjectRoot , setProjectRoot } from './project-files'
2626import { initAnalytics , trackEvent } from './utils/analytics'
27- import { getAuthTokenDetails } from './utils/auth'
27+ import { getAuthToken , getAuthTokenDetails } from './utils/auth'
2828import { resetCodebuffClient } from './utils/codebuff-client'
29+ import { setApiClientAuthToken } from './utils/codebuff-api'
2930import { getCliEnv } from './utils/env'
3031import { initializeAgentRegistry } from './utils/local-agent-registry'
3132import { clearLogFile , logger } from './utils/logger'
@@ -181,6 +182,9 @@ async function main(): Promise<void> {
181182
182183 await initializeApp ( { cwd } )
183184
185+ // Set the auth token for the API client
186+ setApiClientAuthToken ( getAuthToken ( ) )
187+
184188 // Handle login command before rendering the app
185189 if ( isLoginCommand ) {
186190 await runPlainLogin ( )
Original file line number Diff line number Diff line change 11import { getAuthToken } from './auth'
2- import { getApiClient , setApiClientAuthToken } from './codebuff-api'
2+ import { getApiClient } from './codebuff-api'
33import { logger } from './logger'
44import { useChatStore } from '../state/chat-store'
55
@@ -42,11 +42,7 @@ export async function fetchAndUpdateUsage(
4242 }
4343
4444 const apiClient =
45- providedApiClient ??
46- ( ( ) => {
47- setApiClientAuthToken ( authToken )
48- return getApiClient ( )
49- } ) ( )
45+ providedApiClient ?? getApiClient ( )
5046
5147 try {
5248 const response = await apiClient . usage ( )
You can’t perform that action at this time.
0 commit comments