mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
address comments
This commit is contained in:
@@ -108,12 +108,16 @@ describe('ExtensionDetails', () => {
|
||||
});
|
||||
|
||||
it('should NOT call onInstall when Enter is pressed and already installed', async () => {
|
||||
vi.useFakeTimers();
|
||||
const { stdin } = renderDetails(true);
|
||||
await React.act(async () => {
|
||||
stdin.write('\r'); // Enter
|
||||
});
|
||||
// Wait a bit to ensure it's not called
|
||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||
// Advance timers to trigger the keypress flush
|
||||
await React.act(async () => {
|
||||
vi.runAllTimers();
|
||||
});
|
||||
expect(mockOnInstall).not.toHaveBeenCalled();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
*/
|
||||
|
||||
import type React from 'react';
|
||||
import { useState } from 'react';
|
||||
import { Box, Text } from 'ink';
|
||||
import type { RegistryExtension } from '../../../config/extensionRegistryClient.js';
|
||||
import { useKeypress } from '../../hooks/useKeypress.js';
|
||||
@@ -17,12 +18,10 @@ export interface ExtensionDetailsProps {
|
||||
onBack: () => void;
|
||||
onInstall: (
|
||||
requestConsentOverride: (consent: string) => Promise<boolean>,
|
||||
) => void;
|
||||
) => void | Promise<void>;
|
||||
isInstalled: boolean;
|
||||
}
|
||||
|
||||
import { useState } from 'react';
|
||||
|
||||
export function ExtensionDetails({
|
||||
extension,
|
||||
onBack,
|
||||
@@ -59,7 +58,7 @@ export function ExtensionDetails({
|
||||
}
|
||||
if (keyMatchers[Command.RETURN](key) && !isInstalled && !isInstalling) {
|
||||
setIsInstalling(true);
|
||||
onInstall(
|
||||
void onInstall(
|
||||
(prompt: string) =>
|
||||
new Promise((resolve) => {
|
||||
setConsentRequest({ prompt, resolve });
|
||||
|
||||
@@ -255,9 +255,9 @@ export function ExtensionRegistryView({
|
||||
<ExtensionDetails
|
||||
extension={selectedExtension}
|
||||
onBack={handleBack}
|
||||
onInstall={(requestConsentOverride) =>
|
||||
handleInstall(selectedExtension, requestConsentOverride)
|
||||
}
|
||||
onInstall={async (requestConsentOverride) => {
|
||||
await handleInstall(selectedExtension, requestConsentOverride);
|
||||
}}
|
||||
isInstalled={installedExtensions.some(
|
||||
(e) => e.name === selectedExtension.extensionName,
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user