refactor(prompt): extract resolvePart from createUserMessage as sibling Effect.fn#635
Open
ozgurulukir wants to merge 1 commit into
Open
refactor(prompt): extract resolvePart from createUserMessage as sibling Effect.fn#635ozgurulukir wants to merge 1 commit into
ozgurulukir wants to merge 1 commit into
Conversation
…ng Effect.fn Move the 265-line nested resolvePart closure out of createUserMessage to a sibling Effect.fn (resolveUserPart) inside the SessionPrompt layer. The function takes a ResolveUserPartCtx parameter carrying the per-message context (input, info, agentPermission), keeping closure access to shared services (mcp, fsys, registry, lsp, provider, bus). Also hoists DraftPart<T> and ResolveUserPartCtx types to module scope so both createUserMessage (via assign) and resolveUserPart can reference them. Behavior is unchanged. Type-check passes; all 10 prompt.test.ts tests pass; no new failures across the 577-test session suite (19 pre-existing failures identical to baseline).
3 tasks
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.
Summary
resolvePartclosure out ofcreateUserMessageto a siblingEffect.fn(resolveUserPart) inside theSessionPromptlayerResolveUserPartCtxparameter carrying the per-message context (input,info,agentPermission), keeping closure access to shared services (mcp,fsys,registry,lsp,provider,bus)DraftPart<T>andResolveUserPartCtxtypes to module scope so bothcreateUserMessage(viaassign) andresolveUserPartcan reference themWhy
createUserMessagewas a 367-line function with a 265-line nestedEffect.fn(resolvePart) that handled file/agent/text part resolution. The nesting prevented testing in isolation and made the closure dependencies implicit. Extracting to a sibling keeps the same closure access to layer-scoped services while making the per-message context explicit.Verification
bun typecheck(tsgo --noEmit) passesbun test test/session/prompt.test.ts: 10/10 passDraft<→DraftPart<rename andag.permission→ctx.agentPermissionTest plan
bun typecheckbun test test/session/prompt.test.tsbun test test/session/(diff against baseline)