address comments

This commit is contained in:
Christine Betts
2026-03-10 16:11:41 -04:00
parent f34821c79b
commit 76cd4beb95
3 changed files with 12 additions and 9 deletions

View File

@@ -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();
});
});

View File

@@ -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 });

View File

@@ -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,
)}