diff --git a/src/components/GitSettingsProvider.test.tsx b/src/components/GitSettingsProvider.test.tsx index 007f0667..b817c931 100644 --- a/src/components/GitSettingsProvider.test.tsx +++ b/src/components/GitSettingsProvider.test.tsx @@ -68,7 +68,6 @@ describe('GitSettingsProvider', () => { const { readGitSettings } = await import('@/lib/configUtils'); vi.mocked(readGitSettings).mockResolvedValue({ credentials: {}, - hostTokens: {}, }); }); @@ -185,7 +184,6 @@ describe('GitSettingsProvider', () => { password: 'gitlab-token', }, }, - hostTokens: {}, }; const { readGitSettings } = await import('@/lib/configUtils'); diff --git a/src/components/GitSettingsProvider.tsx b/src/components/GitSettingsProvider.tsx index f9fae98c..2eca0606 100644 --- a/src/components/GitSettingsProvider.tsx +++ b/src/components/GitSettingsProvider.tsx @@ -1,5 +1,5 @@ import { ReactNode, useState, useEffect } from 'react'; -import { GitSettingsContext, type GitSettings, type GitCredential, type GitHostToken, type GitSettingsContextType } from '@/contexts/GitSettingsContext'; +import { GitSettingsContext, type GitSettings, type GitCredential, type GitSettingsContextType } from '@/contexts/GitSettingsContext'; import { useFS } from '@/hooks/useFS'; import { useFSPaths } from '@/hooks/useFSPaths'; import { readGitSettings, writeGitSettings } from '@/lib/configUtils'; @@ -10,7 +10,6 @@ interface GitSettingsProviderProps { const DEFAULT_SETTINGS: GitSettings = { credentials: {}, - hostTokens: {}, }; export function GitSettingsProvider({ children }: GitSettingsProviderProps) { @@ -88,39 +87,6 @@ export function GitSettingsProvider({ children }: GitSettingsProviderProps) { })); }; - const addHostToken = (host: string, token: GitHostToken) => { - setSettings(prev => ({ - ...prev, - hostTokens: { - ...prev.hostTokens, - [host]: token, - }, - })); - }; - - const removeHostToken = (host: string) => { - setSettings(prev => { - const { [host]: removed, ...rest } = prev.hostTokens; - return { - ...prev, - hostTokens: rest, - }; - }); - }; - - const updateHostToken = (host: string, token: Partial) => { - setSettings(prev => ({ - ...prev, - hostTokens: { - ...prev.hostTokens, - [host]: { - ...prev.hostTokens[host], - ...token, - }, - }, - })); - }; - const isConfigured = Object.entries(settings.credentials).length > 0; const contextValue: GitSettingsContextType = { @@ -129,9 +95,6 @@ export function GitSettingsProvider({ children }: GitSettingsProviderProps) { addCredential, removeCredential, updateCredential, - addHostToken, - removeHostToken, - updateHostToken, isConfigured, isInitialized, }; diff --git a/src/contexts/GitSettingsContext.ts b/src/contexts/GitSettingsContext.ts index 4f36747f..10799ab3 100644 --- a/src/contexts/GitSettingsContext.ts +++ b/src/contexts/GitSettingsContext.ts @@ -5,16 +5,8 @@ export interface GitCredential { password: string; } -export interface GitHostToken { - token: string; - username?: string; - scopes?: string[]; - createdAt?: number; -} - export interface GitSettings { credentials: Record; // keyed by origin - hostTokens: Record; // keyed by host domain (e.g., 'github.com') name?: string; email?: string; coAuthorEnabled?: boolean; @@ -26,9 +18,6 @@ export interface GitSettingsContextType { addCredential: (origin: string, credential: GitCredential) => void; removeCredential: (origin: string) => void; updateCredential: (origin: string, credential: Partial) => void; - addHostToken: (host: string, token: GitHostToken) => void; - removeHostToken: (host: string) => void; - updateHostToken: (host: string, token: Partial) => void; isConfigured: boolean; isInitialized: boolean; } diff --git a/src/hooks/useGitHubOAuth.ts b/src/hooks/useGitHubOAuth.ts index 59287f9e..c9f70ca2 100644 --- a/src/hooks/useGitHubOAuth.ts +++ b/src/hooks/useGitHubOAuth.ts @@ -2,7 +2,6 @@ import { useCallback } from 'react'; import { useOAuth, type OAuthConfig, type OAuthResult } from './useOAuth'; import { useGitSettings } from './useGitSettings'; import { proxyUrl } from '@/lib/proxyUrl'; -import type { GitHostToken } from '@/contexts/GitSettingsContext'; interface GitHubUserInfo { login: string; @@ -18,7 +17,7 @@ interface GitHubUserInfo { * Uses the generic useOAuth hook with GitHub-specific configuration. */ export function useGitHubOAuth() { - const { addCredential, addHostToken, isInitialized } = useGitSettings(); + const { addCredential, isInitialized } = useGitSettings(); // GitHub OAuth configuration const config: OAuthConfig = { @@ -71,23 +70,14 @@ export function useGitHubOAuth() { return false; } - // Store the credentials (legacy format for existing push/pull operations) + // Store the credentials addCredential('https://github.com', { username: result.username || 'git', password: result.accessToken, }); - // Also store as host token for PR/contribution operations - const hostToken: GitHostToken = { - token: result.accessToken, - username: result.username || 'git', - scopes: result.scopes || [], - createdAt: Date.now(), - }; - addHostToken('github.com', hostToken); - return true; - }, [oauth, addCredential, addHostToken, isInitialized]); + }, [oauth, addCredential, isInitialized]); return { ...oauth, diff --git a/src/lib/configUtils.test.ts b/src/lib/configUtils.test.ts index bd4c1ab5..912e94a2 100644 --- a/src/lib/configUtils.test.ts +++ b/src/lib/configUtils.test.ts @@ -161,7 +161,6 @@ describe('configUtils', () => { password: 'token123', }, }, - hostTokens: {}, }; describe('readGitSettings', () => { @@ -182,7 +181,6 @@ describe('configUtils', () => { expect(result).toEqual({ credentials: {}, - hostTokens: {}, coAuthorEnabled: true, }); }); diff --git a/src/lib/configUtils.ts b/src/lib/configUtils.ts index 828437fe..bcb1fd29 100644 --- a/src/lib/configUtils.ts +++ b/src/lib/configUtils.ts @@ -62,16 +62,8 @@ const gitCredentialSchema = z.object({ password: z.string(), }); -const gitHostTokenSchema = z.object({ - token: z.string(), - username: z.string().optional(), - scopes: z.array(z.string()).optional(), - createdAt: z.number().optional(), -}); - const gitSettingsSchema = z.object({ credentials: z.record(z.string(), gitCredentialSchema), - hostTokens: z.record(z.string(), gitHostTokenSchema).optional(), name: z.string().optional(), email: z.string().optional(), coAuthorEnabled: z.boolean().optional(), @@ -220,7 +212,6 @@ export async function writeAISettings(fs: JSRuntimeFS, settings: AISettings, con export async function readGitSettings(fs: JSRuntimeFS, configPath = '/config'): Promise { const defaultSettings: GitSettings = { credentials: {}, - hostTokens: {}, coAuthorEnabled: true, }; @@ -229,12 +220,7 @@ export async function readGitSettings(fs: JSRuntimeFS, configPath = '/config'): const gitConfigPath = getGitConfigPath(configPath); const content = await fs.readFile(gitConfigPath, 'utf8'); const data = JSON.parse(content); - const parsed = gitSettingsSchema.parse(data); - // Ensure hostTokens exists even if not in parsed data - return { - ...parsed, - hostTokens: parsed.hostTokens || {}, - }; + return gitSettingsSchema.parse(data); } catch { return defaultSettings; } diff --git a/src/lib/git.test.ts b/src/lib/git.test.ts index c856ed75..50068350 100644 --- a/src/lib/git.test.ts +++ b/src/lib/git.test.ts @@ -306,7 +306,6 @@ describe('Git', () => { const { readGitSettings } = await import('./configUtils'); vi.mocked(readGitSettings).mockResolvedValue({ credentials: {}, - hostTokens: {}, coAuthorEnabled: true, }); @@ -334,7 +333,6 @@ describe('Git', () => { const { readGitSettings } = await import('./configUtils'); vi.mocked(readGitSettings).mockResolvedValue({ credentials: {}, - hostTokens: {}, name: 'John Doe', email: 'john@example.com', coAuthorEnabled: true, @@ -364,7 +362,6 @@ describe('Git', () => { const { readGitSettings } = await import('./configUtils'); vi.mocked(readGitSettings).mockResolvedValue({ credentials: {}, - hostTokens: {}, name: 'John Doe', email: 'john@example.com', coAuthorEnabled: false, @@ -394,7 +391,6 @@ describe('Git', () => { const { readGitSettings } = await import('./configUtils'); vi.mocked(readGitSettings).mockResolvedValue({ credentials: {}, - hostTokens: {}, name: 'John Doe', email: 'john@example.com', coAuthorEnabled: true, diff --git a/src/pages/GitSettings.tsx b/src/pages/GitSettings.tsx index ba9f8b91..b14fdb08 100644 --- a/src/pages/GitSettings.tsx +++ b/src/pages/GitSettings.tsx @@ -319,6 +319,7 @@ export function GitSettings() { onClick={() => handleAddPresetProvider(preset)} disabled={!presetTokens[preset.id]?.trim()} size="sm" + className="h-10" > {t('add')}