Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(cli): auto-stop spinner on error and add TerminalUI tests

jkomynoaecf75852cf0
diff --git a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
index 66457c6b2..e1c7f5cef 100644
--- a/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
+++ b/ts/packages/cli/src/commands/py/commands/py.generate.cmd.ts
@@ -67,7 +67,7 @@ export function generatePythonTypeStubs({
})
);
- yield* Effect.log(`Writing type stubs to ${outputDir}...`);
+ yield* ui.log.step(`Writing type stubs to ${outputDir}`);
yield* fs.makeDirectory(outputDir, { recursive: true });
// Read toolkit version overrides from environment variables
@@ -84,83 +84,92 @@ export function generatePythonTypeStubs({
client,
});
- const spinner = yield* ui.makeSpinner('Fetching data from Composio API...');
-
- // Validate toolkit slugs if specified (separate from version validation)
- const validatedToolkitSlugs = hasToolkitsFilter
- ? yield* client
- .validateToolkits(toolkitsOpt)
- .pipe(
- Effect.catchTag('services/InvalidToolkitsError', error =>
- Effect.fail(
- new Error(
- `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. ` +
- `Available toolkits: ${error.availableToolkits.slice(0, 10).join(', ')}${error.availableToolkits.length > 10 ? '...' : ''}`
+ // Fetch, generate, and write with a spinner that auto-cleans up on error
+ yield* ui.useMakeSpinner('Fetching data from Composio API...', spinner =>
+ Effect.gen(function* () {
+ // Validate toolkit slugs if specified (separate from version validation)
+ const validatedToolkitSlugs = hasToolkitsFilter
+ ? yield* client
+ .validateToolkits(toolkitsOpt)
+ .pipe(
+ Effect.catchTag('services/InvalidToolkitsError', error =>
+ Effect.fail(
+ new Error(
+ `Invalid toolkit(s): ${error.invalidToolkits.join(', ')}. ` +
+ `Available toolkits: ${error.availableToolkits.slice(0, 10).join(', ')}${error.availableToolkits.length > 10 ? '...' : ''}`
+ )
+ )
)
)
- )
- )
- : [];
-
- const [allToolkits, tools, triggerTypes] = yield* Effect.all(
- [
- Effect.logDebug('Fetching toolkits...').pipe(Effect.flatMap(() => client.getToolkits())),
- Effect.logDebug('Fetching tools...').pipe(Effect.flatMap(() => client.getToolsAsEnums())),
- Effect.logDebug('Fetching trigger types...').pipe(
- Effect.flatMap(() => client.getTriggerTypes())
- ),
- ],
- { concurrency: 'unbounded' }
- );
+ : [];
+
+ const [allToolkits, tools, triggerTypes] = yield* Effect.all(
+ [
+ Effect.logDebug('Fetching toolkits...').pipe(
+ Effect.flatMap(() => client.getToolkits())
+ ),
+ Effect.logDebug('Fetching tools...').pipe(
+ Effect.flatMap(() => client.getToolsAsEnums())
+ ),
+ Effect.logDebug('Fetching trigger types...').pipe(
+ Effect.flatMap(() => client.getTriggerTypes())
+ ),
+ ],
+ { concurrency: 'unbounded' }
+ );
+
+ // Filter toolkits if --toolkits was specified
+ const toolkits = hasToolkitsFilter
+ ? client.filterToolkitsBySlugs(allToolkits, validatedToolkitSlugs)
+ : allToolkits;
+
+ if (hasToolkitsFilter) {
+ yield* spinner.message(
+ `Found ${toolkits.length} toolkit(s): ${toolkits.map(t => t.slug).join(', ')}`
+ );
+ }
+
+ // Build version map for toolkits being generated (using validated overrides)
+ const versionMap: ToolkitVersionOverrides = new Map();
+ for (const toolkit of toolkits) {
+ const version = validatedOverrides.get(toolkit.slug.toLowerCase() as Lowercase<string>);
+ if (version && version !== 'latest') {
+ versionMap.set(toolkit.slug.toLowerCase() as Lowercase<string>, version);
+ }
+ }
+
+ const typeableTools = { withTypes: false as const, tools };
+
+ yield* spinner.message('Generating Python type stubs...');
+ const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes, versionMap });
+
+ // Generate Python sources
+ const sources = generatePythonSources({
+ banner: BANNER,
+ outputDir,
+ })(index);
+
+ yield* spinner.message('Writing files to disk...');
+
+ // Write all generated files
+ yield* pipe(
+ Effect.all(
+ sources.map(([filePath, content]) =>
+ fs
+ .writeFileString(filePath, content)
+ .pipe(
+ Effect.mapError(error => new Error(`Failed to write file ${filePath}: ${error}`))
+ )
+ ),
+ { concurrency: 1 }
+ ),
+ Effect.mapError(error => new Error(`Failed to write generated files: ${error}`))
+ );
- // Filter toolkits if --toolkits was specified
- const toolkits = hasToolkitsFilter
- ? client.filterToolkitsBySlugs(allToolkits, validatedToolkitSlugs)
- : allToolkits;
-
- if (hasToolkitsFilter) {
- yield* spinner.message(
- `Found ${toolkits.length} toolkit(s): ${toolkits.map(t => t.slug).join(', ')}`
- );
- }
-
- // Build version map for toolkits being generated (using validated overrides)
- const versionMap: ToolkitVersionOverrides = new Map();
- for (const toolkit of toolkits) {
- const version = validatedOverrides.get(toolkit.slug.toLowerCase() as Lowercase<string>);
- if (version && version !== 'latest') {
- versionMap.set(toolkit.slug.toLowerCase() as Lowercase<string>, version);
- }
- }
-
- const typeableTools = { withTypes: false as const, tools };
-
- yield* spinner.message('Generating Python type stubs...');
- const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes, versionMap });
-
- // Generate Python sources
- const sources = generatePythonSources({
- banner: BANNER,
- outputDir,
- })(index);
-
- yield* spinner.message('Writing files to disk...');
-
- // Write all generated files
- yield* pipe(
- Effect.all(
- sources.map(([filePath, content]) =>
- fs
- .writeFileString(filePath, content)
- .pipe(Effect.mapError(error => new Error(`Failed to write file ${filePath}: ${error}`)))
- ),
- { concurrency: 1 }
- ),
- Effect.mapError(error => new Error(`Failed to write generated files: ${error}`))
+ yield* spinner.stop('Type stubs generated successfully');
+ })
);
- yield* spinner.stop('Type stubs generated successfully');
-
yield* Option.isNone(outputOpt)
? ui.note(
'from composio.generated.<toolkit_name> import <TOOLKIT_NAME>',
diff --git a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
index 8015978cd..8559800a0 100644
--- a/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
+++ b/ts/packages/cli/src/commands/ts/commands/ts.generate.cmd.ts
@@ -374,7 +374,7 @@ export function generateTypescriptTypeStubs({
})
);
- yield* Effect.log(`Writing type stubs to ${outputDir}...`);
+ yield* ui.log.step(`Writing type stubs to ${outputDir}`);
yield* fs.makeDirectory(outputDir, { recursive: true });
// Read toolkit version overrides from environment variables
@@ -393,51 +393,56 @@ export function generateTypescriptTypeStubs({
client,
});
- // Fetch data using a spinner for progress
- const spinner = yield* ui.makeSpinner('Fetching data from Composio API...');
-
- const { toolkits, triggerTypes, typeableTools, versionMap } = yield* toolkitSlugsFilter !== null
- ? fetchFilteredData(client, toolkitSlugsFilter, typeTools, validatedOverrides, spinner)
- : fetchAllData(client, typeTools, validatedOverrides, spinner);
-
- yield* spinner.message('Generating TypeScript type stubs...');
- const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes, versionMap });
-
- // Generate TypeScript sources
- const sources = yield* generateTypeScriptSources({
- outputDir,
- emitSingleFile: Boolean(compact), // Ensure boolean type
- banner: BANNER,
- importExtension: 'js',
- })(index);
-
- yield* spinner.message('Writing files to disk...');
-
- // Write all generated files
- yield* pipe(
- Effect.all(
- sources.map(([filePath, content]) =>
- fs
- .writeFileString(filePath, content)
- .pipe(Effect.mapError(error => new Error(`Failed to write file ${filePath}: ${error}`)))
- ),
- { concurrency: 'unbounded' }
- ),
- Effect.mapError(error => new Error(`Failed to write generated files: ${error}`))
- );
-
- // Compile TypeScript to JavaScript if needed
- if (transpiled) {
- yield* spinner.message('Transpiling to JavaScript...');
- yield* pipe(
- transpileTypeScriptSources({ sources, outputDir }),
- Effect.catchAll(error =>
- Effect.logWarning(`Failed to compile TypeScript files: ${error.message}`)
- )
- );
- }
+ // Fetch, generate, and write with a spinner that auto-cleans up on error
+ yield* ui.useMakeSpinner('Fetching data from Composio API...', spinner =>
+ Effect.gen(function* () {
+ const { toolkits, triggerTypes, typeableTools, versionMap } = yield* toolkitSlugsFilter !==
+ null
+ ? fetchFilteredData(client, toolkitSlugsFilter, typeTools, validatedOverrides, spinner)
+ : fetchAllData(client, typeTools, validatedOverrides, spinner);
+
+ yield* spinner.message('Generating TypeScript type stubs...');
+ const index = createToolkitIndex({ toolkits, typeableTools, triggerTypes, versionMap });
+
+ // Generate TypeScript sources
+ const sources = yield* generateTypeScriptSources({
+ outputDir,
+ emitSingleFile: Boolean(compact), // Ensure boolean type
+ banner: BANNER,
+ importExtension: 'js',
+ })(index);
+
+ yield* spinner.message('Writing files to disk...');
+
+ // Write all generated files
+ yield* pipe(
+ Effect.all(
+ sources.map(([filePath, content]) =>
+ fs
+ .writeFileString(filePath, content)
+ .pipe(
+ Effect.mapError(error => new Error(`Failed to write file ${filePath}: ${error}`))
+ )
+ ),
+ { concurrency: 'unbounded' }
+ ),
+ Effect.mapError(error => new Error(`Failed to write generated files: ${error}`))
+ );
+
+ // Compile TypeScript to JavaScript if needed
+ if (transpiled) {
+ yield* spinner.message('Transpiling to JavaScript...');
+ yield* pipe(
+ transpileTypeScriptSources({ sources, outputDir }),
+ Effect.catchAll(error =>
+ Effect.logWarning(`Failed to compile TypeScript files: ${error.message}`)
+ )
+ );
+ }
- yield* spinner.stop('Type stubs generated successfully');
+ yield* spinner.stop('Type stubs generated successfully');
+ })
+ );
yield* Option.isNone(outputOpt)
? ui.note(
diff --git a/ts/packages/cli/src/services/terminal-ui.ts b/ts/packages/cli/src/services/terminal-ui.ts
index 76bb206d2..c0ec89c8a 100644
--- a/ts/packages/cli/src/services/terminal-ui.ts
+++ b/ts/packages/cli/src/services/terminal-ui.ts
@@ -59,8 +59,23 @@ export interface TerminalUI {
/**
* Create a controllable spinner for multi-step flows (e.g., login polling).
* The caller is responsible for calling `stop()` or `error()`.
+ *
+ * WARNING: If the surrounding Effect fails, this spinner will NOT be cleaned up.
+ * Use `useMakeSpinner` instead for automatic cleanup on error.
*/
readonly makeSpinner: (message: string) => Effect.Effect<SpinnerHandle>;
+
+ /**
+ * Create a controllable spinner that is automatically stopped on error or interruption.
+ * The `use` function receives a SpinnerHandle and must return an Effect.
+ * On success: the caller should call `spinner.stop(...)` inside `use`.
+ * On failure: the spinner is automatically stopped with an error message.
+ * On interruption: the spinner is automatically cancelled.
+ */
+ readonly useMakeSpinner: <A, E, R>(
+ message: string,
+ use: (spinner: SpinnerHandle) => Effect.Effect<A, E, R>
+ ) => Effect.Effect<A, E, R>;
}
export const TerminalUI = Context.GenericTag<TerminalUI>('services/TerminalUI');
@@ -69,6 +84,14 @@ export const TerminalUI = Context.GenericTag<TerminalUI>('services/TerminalUI');
// TerminalUILive — production layer using @clack/prompts
// ---------------------------------------------------------------------------
+function createClackSpinnerHandle(s: p.SpinnerResult, defaultMessage: string): SpinnerHandle {
+ return {
+ message: (msg: string) => Effect.sync(() => s.message(msg)),
+ stop: (msg?: string) => Effect.sync(() => s.stop(msg ?? defaultMessage)),
+ error: (msg?: string) => Effect.sync(() => s.error(msg ?? defaultMessage)),
+ };
+}
+
const makeLive: TerminalUI = {
intro: title => Effect.sync(() => p.intro(title)),
outro: message => Effect.sync(() => p.outro(message)),
@@ -110,12 +133,26 @@ const makeLive: TerminalUI = {
Effect.sync(() => {
const s = p.spinner();
s.start(message);
- return {
- message: (msg: string) => Effect.sync(() => s.message(msg)),
- stop: (msg?: string) => Effect.sync(() => s.stop(msg ?? message)),
- error: (msg?: string) => Effect.sync(() => s.error(msg ?? message)),
- };
+ return createClackSpinnerHandle(s, message);
}),
+
+ useMakeSpinner: (message, use) =>
+ Effect.acquireUseRelease(
+ Effect.sync(() => {
+ const s = p.spinner();
+ s.start(message);
+ return { raw: s, handle: createClackSpinnerHandle(s, message) };
+ }),
+ ({ handle }) => use(handle),
+ ({ raw }, exit) =>
+ Effect.sync(() => {
+ // Only clean up if the spinner is still active (user didn't call stop/error)
+ // Clack spinners have an internal `isCancelled` state after stop/error/cancel
+ if (Exit.isFailure(exit) && !raw.isCancelled) {
+ raw.error(message);
+ }
+ })
+ ),
};
export const TerminalUILive = Layer.succeed(TerminalUI, makeLive);
diff --git a/ts/packages/cli/src/services/upgrade-binary.ts b/ts/packages/cli/src/services/upgrade-binary.ts
index 249f05421..9de5691d0 100644
--- a/ts/packages/cli/src/services/upgrade-binary.ts
+++ b/ts/packages/cli/src/services/upgrade-binary.ts
@@ -328,43 +328,44 @@ export class UpgradeBinary extends Effect.Service<UpgradeBinary>()('services/Upg
return;
}
- const spinner = yield* ui.makeSpinner('Checking for updates...');
-
- const release = yield* fetchLatestRelease();
- const updateAvailable = yield* isUpdateAvailable(release);
- if (!updateAvailable) {
- yield* spinner.stop('You are already running the latest version!');
- yield* ui.outro('');
- return;
- }
+ yield* ui.useMakeSpinner('Checking for updates...', spinner =>
+ Effect.gen(function* () {
+ const release = yield* fetchLatestRelease();
+ const updateAvailable = yield* isUpdateAvailable(release);
+ if (!updateAvailable) {
+ yield* spinner.stop('You are already running the latest version!');
+ return;
+ }
+
+ yield* spinner.message(
+ `New version available: ${release.tag_name} (current: ${APP_VERSION}). Downloading...`
+ );
- yield* spinner.message(
- `New version available: ${release.tag_name} (current: ${APP_VERSION}). Downloading...`
+ const platformArch = yield* detectPlatform;
+ const { name, data } = yield* downloadBinary(release, platformArch);
+
+ yield* spinner.message('Extracting...');
+
+ // The temporary directory is automatically cleaned up
+ const tmpDir = yield* fs
+ .makeTempDirectoryScoped({ prefix: `${CLI_BINARY_NAME}-upgrade}` })
+ .pipe(
+ Effect.catchAll(error =>
+ Effect.fail(
+ new UpgradeBinaryError({
+ cause: error as Error,
+ message: 'Failed to create temporary directory',
+ })
+ )
+ )
+ );
+
+ const extractedBinaryPath = yield* extractBinary({ name, data }, tmpDir);
+ yield* replaceBinary(extractedBinaryPath, currentPath);
+
+ yield* spinner.stop('Upgrade completed!');
+ })
);
-
- const platformArch = yield* detectPlatform;
- const { name, data } = yield* downloadBinary(release, platformArch);
-
- yield* spinner.message('Extracting...');
-
- // The temporary directory is automatically cleaned up
- const tmpDir = yield* fs
- .makeTempDirectoryScoped({ prefix: `${CLI_BINARY_NAME}-upgrade}` })
- .pipe(
- Effect.catchAll(error =>
- Effect.fail(
- new UpgradeBinaryError({
- cause: error as Error,
- message: 'Failed to create temporary directory',
- })
- )
- )
- );
-
- const extractedBinaryPath = yield* extractBinary({ name, data }, tmpDir);
- yield* replaceBinary(extractedBinaryPath, currentPath);
-
- yield* spinner.stop('Upgrade completed!');
yield* ui.outro('Restart your terminal to use the new version.');
});
diff --git a/ts/packages/cli/test/__utils__/services/terminal-ui-test.ts b/ts/packages/cli/test/__utils__/services/terminal-ui-test.ts
index 9e68b552f..2046ed1a1 100644
--- a/ts/packages/cli/test/__utils__/services/terminal-ui-test.ts
+++ b/ts/packages/cli/test/__utils__/services/terminal-ui-test.ts
@@ -1,4 +1,4 @@
-import { Console, Effect, Layer } from 'effect';
+import { Console, Effect, Exit, Layer } from 'effect';
import { TerminalUI } from 'src/services/terminal-ui';
/**
@@ -44,5 +44,28 @@ export const TerminalUITest = Layer.succeed(
error: (msg?: string) => (msg ? Console.error(msg) : Effect.void),
};
}),
+
+ useMakeSpinner: (message, use) =>
+ Effect.gen(function* () {
+ let stopped = false;
+ const handle = {
+ message: (_msg: string) => Effect.void,
+ stop: (msg?: string) =>
+ Effect.gen(function* () {
+ stopped = true;
+ if (msg) yield* Console.log(msg);
+ }),
+ error: (msg?: string) =>
+ Effect.gen(function* () {
+ stopped = true;
+ if (msg) yield* Console.error(msg);
+ }),
+ };
+ const exit = yield* Effect.exit(use(handle));
+ if (Exit.isFailure(exit) && !stopped) {
+ yield* Console.error(message);
+ }
+ return yield* exit;
+ }),
})
);
diff --git a/ts/packages/cli/test/src/services/terminal-ui.test.ts b/ts/packages/cli/test/src/services/terminal-ui.test.ts
new file mode 100644
index 000000000..2d0c0764a
--- /dev/null
+++ b/ts/packages/cli/test/src/services/terminal-ui.test.ts
@@ -0,0 +1,185 @@
+import { describe, expect, layer } from '@effect/vitest';
+import { Effect } from 'effect';
+import { TerminalUI } from 'src/services/terminal-ui';
+import { TestLive, MockConsole } from 'test/__utils__';
+
+describe('TerminalUI', () => {
+ layer(TestLive())(it => {
+ // -----------------------------------------------------------------------
+ // Log text capture
+ // -----------------------------------------------------------------------
+
+ it.scoped('log.info writes text capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.log.info('hello from info');
+
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('hello from info');
+ })
+ );
+
+ it.scoped('log.success writes text capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.log.success('operation succeeded');
+
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('operation succeeded');
+ })
+ );
+
+ it.scoped('log.warn writes text capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.log.warn('something is off');
+
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('something is off');
+ })
+ );
+
+ it.scoped('log.error writes text capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.log.error('something broke');
+
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('something broke');
+ })
+ );
+
+ it.scoped('log.step writes text capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.log.step('step completed');
+
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('step completed');
+ })
+ );
+
+ it.scoped('note writes title and message capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.note('api_key_123', 'API Key');
+
+ const lines = yield* MockConsole.getLines();
+ const output = lines.join('\n');
+ expect(output).toContain('api_key_123');
+ expect(output).toContain('API Key');
+ })
+ );
+
+ it.scoped('intro and outro write text capturable by MockConsole', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ yield* ui.intro('my command');
+ yield* ui.outro('all done');
+
+ const lines = yield* MockConsole.getLines();
+ const output = lines.join('\n');
+ expect(output).toContain('my command');
+ expect(output).toContain('all done');
+ })
+ );
+
+ // -----------------------------------------------------------------------
+ // withSpinner lifecycle
+ // -----------------------------------------------------------------------
+
+ it.scoped('withSpinner captures success message', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ const result = yield* ui.withSpinner('loading', Effect.succeed(42), {
+ successMessage: 'loaded 42 items',
+ });
+
+ expect(result).toBe(42);
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('loaded 42 items');
+ })
+ );
+
+ it.scoped('withSpinner propagates errors', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+ const exit = yield* Effect.exit(
+ ui.withSpinner('loading', Effect.fail(new Error('network error')))
+ );
+
+ expect(exit._tag).toBe('Failure');
+ })
+ );
+
+ // -----------------------------------------------------------------------
+ // useMakeSpinner — auto-cleanup on error
+ // -----------------------------------------------------------------------
+
+ it.scoped('useMakeSpinner auto-stops spinner on error', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+
+ const exit = yield* Effect.exit(
+ ui.useMakeSpinner('fetching data', _spinner => Effect.fail(new Error('API returned 400')))
+ );
+
+ expect(exit._tag).toBe('Failure');
+
+ // The spinner error message should be captured
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('fetching data');
+ })
+ );
+
+ it.scoped('useMakeSpinner does NOT double-stop if user already stopped', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+
+ yield* ui.useMakeSpinner('processing', spinner =>
+ Effect.gen(function* () {
+ yield* spinner.stop('done processing');
+ })
+ );
+
+ const lines = yield* MockConsole.getLines();
+ // Should see the user's stop message, not the auto-cleanup
+ expect(lines).toContain('done processing');
+ // Should NOT see the default message as an error (which would happen with double-stop)
+ expect(lines.filter(l => l === 'processing')).toHaveLength(0);
+ })
+ );
+
+ it.scoped('useMakeSpinner allows message updates before stop', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+
+ yield* ui.useMakeSpinner('starting', spinner =>
+ Effect.gen(function* () {
+ yield* spinner.message('step 1');
+ yield* spinner.message('step 2');
+ yield* spinner.stop('finished');
+ })
+ );
+
+ const lines = yield* MockConsole.getLines();
+ expect(lines).toContain('finished');
+ })
+ );
+
+ it.scoped('useMakeSpinner returns the value from the use callback', () =>
+ Effect.gen(function* () {
+ const ui = yield* TerminalUI;
+
+ const result = yield* ui.useMakeSpinner('computing', spinner =>
+ Effect.gen(function* () {
+ yield* spinner.stop('computed');
+ return 99;
+ })
+ );
+
+ expect(result).toBe(99);
+ })
+ );
+ });
+});