Skip to content

refactor(prompt): extract resolvePart from createUserMessage as sibling Effect.fn#635

Open
ozgurulukir wants to merge 1 commit into
XiaomiMiMo:mainfrom
ozgurulukir:refactor/extract-resolve-part
Open

refactor(prompt): extract resolvePart from createUserMessage as sibling Effect.fn#635
ozgurulukir wants to merge 1 commit into
XiaomiMiMo:mainfrom
ozgurulukir:refactor/extract-resolve-part

Conversation

@ozgurulukir

Copy link
Copy Markdown

Summary

  • 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)
  • Hoist DraftPart<T> and ResolveUserPartCtx types to module scope so both createUserMessage (via assign) and resolveUserPart can reference them

Why

createUserMessage was a 367-line function with a 265-line nested Effect.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) passes
  • bun test test/session/prompt.test.ts: 10/10 pass
  • Full session suite (577 tests): no new failures vs baseline (19 pre-existing failures identical to baseline, modulo timing)
  • Behavior is unchanged — body is byte-identical except for Draft<DraftPart< rename and ag.permissionctx.agentPermission

Test plan

  • bun typecheck
  • bun test test/session/prompt.test.ts
  • bun test test/session/ (diff against baseline)

…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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant