mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
run preflight (#55)
This commit is contained in:
@@ -165,7 +165,7 @@ describe('AuthDialog', () => {
|
||||
);
|
||||
|
||||
// Since only OpenAI is available, it should be selected by default
|
||||
expect(lastFrame()).toContain('○ OpenAI');
|
||||
expect(lastFrame()).toContain('● OpenAI');
|
||||
});
|
||||
|
||||
it('should fall back to default if GEMINI_DEFAULT_AUTH_TYPE is not set', () => {
|
||||
@@ -188,7 +188,7 @@ describe('AuthDialog', () => {
|
||||
);
|
||||
|
||||
// Default is OpenAI (the only option)
|
||||
expect(lastFrame()).toContain('○ OpenAI');
|
||||
expect(lastFrame()).toContain('● OpenAI');
|
||||
});
|
||||
|
||||
it('should show an error and fall back to default if GEMINI_DEFAULT_AUTH_TYPE is invalid', () => {
|
||||
@@ -214,7 +214,7 @@ describe('AuthDialog', () => {
|
||||
|
||||
// Since the auth dialog doesn't show GEMINI_DEFAULT_AUTH_TYPE errors anymore,
|
||||
// it will just show the default OpenAI option
|
||||
expect(lastFrame()).toContain('○ OpenAI');
|
||||
expect(lastFrame()).toContain('● OpenAI');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -47,24 +47,27 @@ export function AuthDialog({
|
||||
const [showOpenAIKeyPrompt, setShowOpenAIKeyPrompt] = useState(false);
|
||||
const items = [{ label: 'OpenAI', value: AuthType.USE_OPENAI }];
|
||||
|
||||
const initialAuthIndex = Math.max(0, items.findIndex((item) => {
|
||||
if (settings.merged.selectedAuthType) {
|
||||
return item.value === settings.merged.selectedAuthType;
|
||||
}
|
||||
const initialAuthIndex = Math.max(
|
||||
0,
|
||||
items.findIndex((item) => {
|
||||
if (settings.merged.selectedAuthType) {
|
||||
return item.value === settings.merged.selectedAuthType;
|
||||
}
|
||||
|
||||
const defaultAuthType = parseDefaultAuthType(
|
||||
process.env.GEMINI_DEFAULT_AUTH_TYPE,
|
||||
);
|
||||
if (defaultAuthType) {
|
||||
return item.value === defaultAuthType;
|
||||
}
|
||||
const defaultAuthType = parseDefaultAuthType(
|
||||
process.env.GEMINI_DEFAULT_AUTH_TYPE,
|
||||
);
|
||||
if (defaultAuthType) {
|
||||
return item.value === defaultAuthType;
|
||||
}
|
||||
|
||||
if (process.env.GEMINI_API_KEY) {
|
||||
return item.value === AuthType.USE_GEMINI;
|
||||
}
|
||||
if (process.env.GEMINI_API_KEY) {
|
||||
return item.value === AuthType.USE_GEMINI;
|
||||
}
|
||||
|
||||
return item.value === AuthType.LOGIN_WITH_GOOGLE;
|
||||
}));
|
||||
return item.value === AuthType.LOGIN_WITH_GOOGLE;
|
||||
}),
|
||||
);
|
||||
|
||||
const handleAuthSelect = (authMethod: AuthType) => {
|
||||
const error = validateAuthMethod(authMethod);
|
||||
|
||||
@@ -56,7 +56,12 @@ export function RadioButtonSelect<T>({
|
||||
showScrollArrows = false,
|
||||
maxItemsToShow = 10,
|
||||
}: RadioButtonSelectProps<T>): React.JSX.Element {
|
||||
const [activeIndex, setActiveIndex] = useState(initialIndex);
|
||||
// Ensure initialIndex is within bounds
|
||||
const safeInitialIndex =
|
||||
items.length > 0
|
||||
? Math.max(0, Math.min(initialIndex, items.length - 1))
|
||||
: 0;
|
||||
const [activeIndex, setActiveIndex] = useState(safeInitialIndex);
|
||||
const [scrollOffset, setScrollOffset] = useState(0);
|
||||
|
||||
// Ensure activeIndex is always within bounds when items change
|
||||
@@ -102,7 +107,11 @@ export function RadioButtonSelect<T>({
|
||||
}
|
||||
if (key.return) {
|
||||
// Add bounds check before accessing items[activeIndex]
|
||||
if (activeIndex >= 0 && activeIndex < items.length && items[activeIndex]) {
|
||||
if (
|
||||
activeIndex >= 0 &&
|
||||
activeIndex < items.length &&
|
||||
items[activeIndex]
|
||||
) {
|
||||
onSelect(items[activeIndex].value);
|
||||
}
|
||||
}
|
||||
@@ -118,7 +127,13 @@ export function RadioButtonSelect<T>({
|
||||
}
|
||||
}
|
||||
},
|
||||
{ isActive: isFocused && items.length > 0 && activeIndex >= 0 && activeIndex < items.length },
|
||||
{
|
||||
isActive:
|
||||
isFocused &&
|
||||
items.length > 0 &&
|
||||
activeIndex >= 0 &&
|
||||
activeIndex < items.length,
|
||||
},
|
||||
);
|
||||
|
||||
const visibleItems = items.slice(scrollOffset, scrollOffset + maxItemsToShow);
|
||||
|
||||
Reference in New Issue
Block a user