Skip to content

Conversation

kitlangton
Copy link
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Added a spinner to Prompt that animates a spinner while an effect is running.

const user = yield* Prompt.spinner("Fetching user…", fetchUser)
 Fetching user…

The message is updated when the effect completes successfully or fails.

 Loaded Ada (ID: 42)
 Processing failed: Network timeout

@kitlangton kitlangton requested a review from IMax153 as a code owner August 19, 2025 03:14
@github-project-automation github-project-automation bot moved this to Discussion Ongoing in PR Backlog Aug 19, 2025
Copy link

changeset-bot bot commented Aug 19, 2025

⚠️ No Changeset found

Latest commit: 731b16f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@emilwidlund
Copy link

Love it! 🎉

@johtso
Copy link
Contributor

johtso commented Aug 19, 2025

Awesome!!

Would be really cool to also support concurrency / multiple spinners.. 👀

import { Console, Effect } from "effect"

// Demonstration of success, failure, and custom final messages
const program = Effect.gen(function*() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like there are a bunch of compilation errors in the example here.

Comment on lines 56 to 60
export const spinner = <A, E, R>(
message: string,
effect: Effect.Effect<A, E, R>,
options?: SpinnerOptions<E, A>
): Effect.Effect<A, E, R | Terminal.Terminal> =>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make this signature dual - I can help with that if you're unsure, sometimes getting the signature right with an optional third param can be tricky.

Comment on lines 69 to 70
const indexRef = yield* Ref.make(0)
const exitRef = yield* Ref.make<Option.Option<Exit.Exit<A, E>>>(Option.none())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since these are only ever accessed / modified within the generator, they can be plain mutable variables.

Suggested change
const indexRef = yield* Ref.make(0)
const exitRef = yield* Ref.make<Option.Option<Exit.Exit<A, E>>>(Option.none())
const index = 0
const exit: Exit.Exit<A, E> | undefined = undefined

@github-project-automation github-project-automation bot moved this from Discussion Ongoing to Waiting on Author in PR Backlog Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

4 participants