feat: remove API worker and batch size configurations; update CodexLens settings for v2

This commit is contained in:
catlog22
2026-03-17 20:44:26 +08:00
parent f37189dc64
commit ef2c5a58e1
11 changed files with 313 additions and 142 deletions

View File

@@ -20,8 +20,6 @@ const mockStatus: CodexLensVenvStatus = {
const mockConfig: CodexLensConfig = {
index_dir: '~/.codexlens/indexes',
index_count: 100,
api_max_workers: 4,
api_batch_size: 8,
};
// Mock window.alert
@@ -243,8 +241,6 @@ describe('OverviewTab', () => {
const emptyConfig: CodexLensConfig = {
index_dir: '',
index_count: 0,
api_max_workers: 4,
api_batch_size: 8,
};
render(

View File

@@ -54,8 +54,6 @@ import {
const mockConfig: CodexLensConfig = {
index_dir: '~/.codexlens/indexes',
index_count: 100,
api_max_workers: 4,
api_batch_size: 8,
};
const mockEnv: Record<string, string> = {
@@ -75,8 +73,6 @@ function setupDefaultMocks() {
config: mockConfig,
indexDir: mockConfig.index_dir,
indexCount: 100,
apiMaxWorkers: 4,
apiBatchSize: 8,
isLoading: false,
error: null,
refetch: vi.fn(),
@@ -298,8 +294,6 @@ describe('SettingsTab', () => {
config: mockConfig,
indexDir: mockConfig.index_dir,
indexCount: 100,
apiMaxWorkers: 4,
apiBatchSize: 8,
isLoading: true,
error: null,
refetch: vi.fn(),

View File

@@ -1,8 +1,8 @@
// ========================================
// CodexLens Settings Tab
// ========================================
// Structured form for CodexLens env configuration
// Renders 5 groups: embedding, reranker, concurrency, cascade, chunking
// Structured form for CodexLens v2 env configuration
// Renders 4 groups: embedding, reranker, search, indexing
// Plus a general config section (index_dir)
import { useState, useEffect, useCallback, useMemo } from 'react';
@@ -33,12 +33,10 @@ export function SettingsTab({ enabled = true }: SettingsTabProps) {
const { formatMessage } = useIntl();
const { success, error: showError } = useNotifications();
// Fetch current config (index_dir, workers, batch_size)
// Fetch current config (index_dir, index_count)
const {
config,
indexCount,
apiMaxWorkers,
apiBatchSize,
isLoading: isLoadingConfig,
refetch: refetchConfig,
} = useCodexLensConfig({ enabled });
@@ -199,25 +197,13 @@ export function SettingsTab({ enabled = true }: SettingsTabProps) {
<div className="space-y-6">
{/* Current Info Card */}
<Card className="p-4 bg-muted/30">
<div className="grid grid-cols-1 md:grid-cols-3 gap-4 text-sm">
<div className="text-sm">
<div>
<span className="text-muted-foreground">
{formatMessage({ id: 'codexlens.settings.currentCount' })}
</span>
<p className="text-foreground font-medium">{indexCount}</p>
</div>
<div>
<span className="text-muted-foreground">
{formatMessage({ id: 'codexlens.settings.currentWorkers' })}
</span>
<p className="text-foreground font-medium">{apiMaxWorkers}</p>
</div>
<div>
<span className="text-muted-foreground">
{formatMessage({ id: 'codexlens.settings.currentBatchSize' })}
</span>
<p className="text-foreground font-medium">{apiBatchSize}</p>
</div>
</div>
</Card>

View File

@@ -65,8 +65,6 @@ const mockDashboardData = {
config: {
index_dir: '~/.codexlens/indexes',
index_count: 100,
api_max_workers: 4,
api_batch_size: 8,
},
semantic: { available: true },
};
@@ -165,8 +163,6 @@ describe('useCodexLens Hook', () => {
const mockConfig = {
index_dir: '~/.codexlens/indexes',
index_count: 100,
api_max_workers: 4,
api_batch_size: 8,
};
vi.mocked(api.fetchCodexLensConfig).mockResolvedValue(mockConfig);
@@ -177,8 +173,6 @@ describe('useCodexLens Hook', () => {
expect(api.fetchCodexLensConfig).toHaveBeenCalledOnce();
expect(result.current.indexDir).toBe('~/.codexlens/indexes');
expect(result.current.indexCount).toBe(100);
expect(result.current.apiMaxWorkers).toBe(4);
expect(result.current.apiBatchSize).toBe(8);
});
});
@@ -253,14 +247,10 @@ describe('useCodexLens Hook', () => {
const updateResult = await result.current.updateConfig({
index_dir: '~/.codexlens/indexes',
api_max_workers: 8,
api_batch_size: 16,
});
expect(api.updateCodexLensConfig).toHaveBeenCalledWith({
index_dir: '~/.codexlens/indexes',
api_max_workers: 8,
api_batch_size: 16,
});
expect(updateResult.success).toBe(true);
expect(updateResult.message).toBe('Config updated');

View File

@@ -259,8 +259,6 @@ export interface UseCodexLensConfigReturn {
config: CodexLensConfig | undefined;
indexDir: string;
indexCount: number;
apiMaxWorkers: number;
apiBatchSize: number;
isLoading: boolean;
error: Error | null;
refetch: () => Promise<void>;
@@ -288,8 +286,6 @@ export function useCodexLensConfig(options: UseCodexLensConfigOptions = {}): Use
config: query.data,
indexDir: query.data?.index_dir ?? '~/.codexlens/indexes',
indexCount: query.data?.index_count ?? 0,
apiMaxWorkers: query.data?.api_max_workers ?? 4,
apiBatchSize: query.data?.api_batch_size ?? 8,
isLoading: query.isLoading,
error: query.error,
refetch,
@@ -530,7 +526,7 @@ export function useCodexLensIgnorePatterns(options: UseCodexLensIgnorePatternsOp
// ========== Mutation Hooks ==========
export interface UseUpdateCodexLensConfigReturn {
updateConfig: (config: { index_dir: string; api_max_workers?: number; api_batch_size?: number }) => Promise<{ success: boolean; message?: string }>;
updateConfig: (config: { index_dir: string }) => Promise<{ success: boolean; message?: string }>;
isUpdating: boolean;
error: Error | null;
}

View File

@@ -5273,8 +5273,6 @@ export interface CodexLensStatusData {
export interface CodexLensConfig {
index_dir: string;
index_count: number;
api_max_workers: number;
api_batch_size: number;
}
/**
@@ -5530,8 +5528,6 @@ export async function fetchCodexLensConfig(): Promise<CodexLensConfig> {
*/
export async function updateCodexLensConfig(config: {
index_dir: string;
api_max_workers?: number;
api_batch_size?: number;
}): Promise<{ success: boolean; message?: string; error?: string }> {
return fetchApi('/api/codexlens/config', {
method: 'POST',

View File

@@ -63,8 +63,6 @@ const mockDashboardData = {
config: {
index_dir: '~/.codexlens/indexes',
index_count: 100,
api_max_workers: 4,
api_batch_size: 8,
},
semantic: { available: true },
};