Repository navigation
refactor(packages/app/src/components/prompt-input/build-request-parts.ts): split builders - #207
Open
Yumeseeker wants to merge 2 commits into
Open
Yumeseeker wants to merge 2 commits into
Yumeseeker wants to merge 2 commits into
Conversation
Yumeseeker
marked this pull request as ready for review
September 14, 2026 22:38
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
P1B: Starter Task: Refactoring PR
1. Issue
Link to the associated GitHub issue:
#206
Full path to the refactored file:
packages/app/src/components/prompt-input/build-request- parts.tsWhat do you think this file does?
This file converts prompt attachments, context files, agent references, and images into request parts for the model. It also creates optimistic parts used to update the UI before the request completes.
What is the scope of your refactoring within that file?
I refactored
buildRequestPartsand extracted internal builders for file parts, agent parts, context and mention parts, and image parts.Which Qlty‑reported issue did you address?
Function with many returns (count = 9): buildRequestParts, at line 91.2. Refactoring
How did the specific issue you chose impact the codebase’s maintainability?
The function combined several unrelated responsibilities and contained many conditional return paths, making it harder to follow and safely modify. This increased the risk of accidentally changing ordering, deduplication, or path-handling behavior.
What changes did you make to resolve the issue?
I moved file, agent, context/comment, mention, and imageconstruction into focused internal helper functions.
buildRequestPartsnow coordinates these builders and produces the final request and optimistic parts.How do your changes improve maintainability? Did you consider alternatives?
Each helper now has one clear responsibility, while the main function reads as a straightforward assembly pipeline. I considered moving the logic into a separate module, but kept the helpers in the same file to avoid unnecessary abstraction.
3. Validation
How did you validate that the change is correct?
The focused test suite passes all 15 tests, including a new test covering file attachment source-text handling, and the refactored module has 100% function and line coverage. Targeted Qlty reports no remaining smells, changed-file lint reports 0 warnings and 0 errors, and the app typecheck passes.
screenshot of the test coverage showing the lines were executed by the tests.

screenshot showing the tests that cover the change passing during CI

screenshot of

qlty smells --no-snippets packages/app/src/components/prompt-input/build-request-parts.tsshowing fewer reported issues after the changes.