Skip to content

[codex] Share AI final edit semantics#115

Merged
batuhan merged 1 commit into
mainfrom
batuhan/final-stream-edit-helpers
Jun 2, 2026
Merged

[codex] Share AI final edit semantics#115
batuhan merged 1 commit into
mainfrom
batuhan/final-stream-edit-helpers

Conversation

@batuhan
Copy link
Copy Markdown
Member

@batuhan batuhan commented Jun 2, 2026

Summary

  • Add shared ai-stream bridgev2 helpers for final edit extra content
  • Clear com.beeper.stream in both m.new_content and top-level final edit content
  • Route connector final edits through the shared helpers and preserve model updates for future writer events

Validation

  • go test ./pkg/ai-stream/... ./pkg/connector

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9beac94f-2a23-4d3d-8507-fe19bc528b96

📥 Commits

Reviewing files that changed from the base of the PR and between 1f707fd and 78722ad.

📒 Files selected for processing (6)
  • pkg/ai-stream/bridgev2/events.go
  • pkg/ai-stream/bridgev2/events_test.go
  • pkg/ai-stream/run.go
  • pkg/ai-stream/stream_test.go
  • pkg/connector/client.go
  • pkg/connector/stream_test.go
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-docker
  • GitHub Check: Build 1.25
  • GitHub Check: build-docker
  • GitHub Check: Build 1.25
🔇 Additional comments (6)
pkg/ai-stream/bridgev2/events.go (1)

72-85: LGTM!

Also applies to: 105-109

pkg/ai-stream/bridgev2/events_test.go (1)

107-119: LGTM!

pkg/connector/client.go (1)

991-995: LGTM!

pkg/connector/stream_test.go (1)

1011-1017: LGTM!

pkg/ai-stream/run.go (1)

185-185: LGTM!

Also applies to: 241-241, 257-264

pkg/ai-stream/stream_test.go (1)

33-46: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added ability to dynamically set the AI model during stream operations.
  • Bug Fixes

    • Improved edited message metadata handling to properly clear stream fields and apply render settings.
  • Tests

    • Added and updated tests to verify model updates and metadata normalization in edited messages.

Walkthrough

The PR adds helper functions to normalize final message edit metadata across the AI stream pipeline, ensuring com.beeper.stream is cleared and com.beeper.dont_render_edited is set consistently. It also introduces a SetModel method on the Writer to allow runtime model updates while keeping the event builder in sync with the new model.

Changes

Message Event Handling Improvements

Layer / File(s) Summary
Final edit metadata normalization
pkg/ai-stream/bridgev2/events.go, pkg/ai-stream/bridgev2/events_test.go, pkg/connector/client.go, pkg/connector/stream_test.go
FinalEditExtra() and FinalEditTopLevelExtra() helpers standardize final edit metadata by copying extra maps, clearing com.beeper.stream, and setting com.beeper.dont_render_edited; these replace inline metadata construction in bridgev2 conversion and connector assistant finalization, with tests verifying the correct fields are set and cleared.
Runtime model update capability
pkg/ai-stream/run.go, pkg/ai-stream/stream_test.go
Writer struct stores the now callback; SetModel(model string) validates/trims input, updates w.Run.Model, and recreates agui.EventBuilder with the new model; test verifies both the Run field and subsequent event envelopes reflect the updated model.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: introducing shared AI final edit semantics across the codebase.
Description check ✅ Passed The description is directly related to the changeset, detailing the addition of shared helpers, the clearing of stream fields, and model update preservation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch batuhan/final-stream-edit-helpers

Comment @coderabbitai help to get the list of available commands and usage tips.

@batuhan batuhan marked this pull request as ready for review June 2, 2026 15:22
@indent
Copy link
Copy Markdown

indent Bot commented Jun 2, 2026

PR Summary

Centralizes the "AI final edit" payload semantics so the AI-stream final-metadata path and the connector's assistant-final path emit identical metadata, and adds a Writer.SetModel helper for mid-run model swaps. The shared helpers ensure final edits explicitly clear com.beeper.stream (both top-level and inside m.new_content) while keeping com.beeper.dont_render_edited: true, so clients reliably tear down the streaming marker on the original message.

  • Add FinalEditExtra and FinalEditTopLevelExtra helpers in pkg/ai-stream/bridgev2/events.go and use them from FinalMetadataEditWithContent and Client.assistantFinalEditWithProjection, deduplicating the previously hard-coded top-level extras.
  • Add Writer.SetModel(model) in pkg/ai-stream/run.go that updates Run.Model and rebuilds the agui.EventBuilder (new now field on Writer) so subsequent event envelopes carry the new model; earlier events keep the model they were emitted with.
  • Extend tests in pkg/ai-stream/bridgev2/events_test.go, pkg/connector/stream_test.go, and pkg/ai-stream/stream_test.go to assert both the cleared com.beeper.stream keys (presence + nil) on final edits and that SetModel updates Run.Model and future event envelopes.

Issues

No issues found.

CI Checks

Waiting for CI checks...

@batuhan batuhan merged commit 7505763 into main Jun 2, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant