Fix updatePart input narrowing for delta wrapper #6848

Closed
opened 2026-02-16 18:05:25 -05:00 by yindo · 1 comment
Owner

Originally created by @adolago on GitHub (Jan 19, 2026).

Originally assigned to: @rekram1-node on GitHub.

Problem

Session.updatePart uses "delta" in input to select the part, but TypeScript cannot narrow the union and rejects part.messageID and part.id.

Proposed fix

  • Use "part" in input as the guard and set const part = "part" in input ? input.part : input.
  • If needed, introduce a discriminant (e.g., { kind: "delta", part: TextPart | ReasoningPart, delta?: string }) to make the union explicit.

Acceptance criteria

  • TS2339/TS2322 errors around part.messageID and part.id are resolved.
  • MessageV2.Event.PartUpdated still emits part and optional delta.

Test plan

  • bun run typecheck
Originally created by @adolago on GitHub (Jan 19, 2026). Originally assigned to: @rekram1-node on GitHub. ## Problem `Session.updatePart` uses `"delta" in input` to select the part, but TypeScript cannot narrow the union and rejects `part.messageID` and `part.id`. ## Proposed fix - Use `"part" in input` as the guard and set `const part = "part" in input ? input.part : input`. - If needed, introduce a discriminant (e.g., `{ kind: "delta", part: TextPart | ReasoningPart, delta?: string }`) to make the union explicit. ## Acceptance criteria - TS2339/TS2322 errors around `part.messageID` and `part.id` are resolved. - `MessageV2.Event.PartUpdated` still emits `part` and optional `delta`. ## Test plan - `bun run typecheck`
yindo closed this issue 2026-02-16 18:05:25 -05:00
Author
Owner

@adolago commented on GitHub (Jan 19, 2026):

Opened in the wrong repo; will recreate on the fork.

@adolago commented on GitHub (Jan 19, 2026): Opened in the wrong repo; will recreate on the fork.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6848