chore: optimize process sinner #1362
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Greptile Overview
Greptile Summary
Enhanced spinner message handling to normalize multiline messages by trimming whitespace and joining with spaces, and added HTTP client mock support to the testing framework.
Changes
process/running.go: Improved spinner UX by normalizing multiline messages - splits on newlines, trims each line, and joins with single spacestesting/mock/mock.go: AddedHttp()factory method returning*mockshttpclient.Factoryto enable HTTP client mocking in testsBoth changes are straightforward improvements with no breaking changes or security concerns.
Confidence Score: 5/5
Important Files Changed
Http()mock factory method for HTTP client testing with proper importSequence Diagram
sequenceDiagram participant User participant Running participant spinner participant collect participant huhspinner User->>Running: Call method that triggers loading Running->>Running: spinner(ctx, loading, loadingMessage, fn) alt loading is false Running->>Running: Execute fn() directly Running-->>User: Return result else loading is true Running->>spinner: Process message spinner->>spinner: strings.Split(message, "\n") spinner->>collect: Map(messageSlice, TrimSpace) collect-->>spinner: Trimmed message slice spinner->>spinner: strings.Join(messageSlice, " ") spinner->>huhspinner: New().Title(message).Style().TitleStyle() spinner->>huhspinner: Context(ctx).Action(fn) huhspinner->>huhspinner: Run() huhspinner-->>spinner: Result spinner-->>Running: Return result Running-->>User: Return result end