Add support for appending media (vision support) - #23
Conversation
📝 WalkthroughWalkthroughThe PR adds optional media support to append requests, introduces ChangesAppend media support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
src/client/seq.rs (1)
380-406: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
append_mediaduplicates theappendsend/await boilerplate verbatim.The cid allocation, channel registration,
SeqCommand::Appendsend, andrx.recv()handling are identical toappend(Lines 352-378). Extract a shared helper that takes a fully-builtSeqAppendReqso the two entrypoints differ only in how they construct the request.♻️ Proposed helper extraction
async fn send_append(&self, req: SeqAppendReq) -> Result<(), ModelSocketError> { let cid = Uuid::new_v4().to_string(); let (tx, mut rx) = mpsc::channel(1); self.cmds.lock().await.insert(cid.clone(), tx); self.socket .send_request(MSRequest::SeqCommand { cid: cid.clone(), seq_id: self.seq_id.clone(), data: SeqCommand::Append(req), }) .await?; rx.recv() .await .ok_or_else(|| ModelSocketError::Command("failed to receive response".into()))??; Ok(()) } pub async fn append( &self, text: impl AsRef<str>, opts: AppendOpts, ) -> Result<(), ModelSocketError> { self.send_append(SeqAppendReq { text: text.as_ref().to_string(), role: opts.role, ..Default::default() }) .await } pub async fn append_media( &self, media: SeqAppendMedia, opts: AppendOpts, ) -> Result<(), ModelSocketError> { self.send_append(SeqAppendReq { media: Some(media), role: opts.role, ..Default::default() }) .await }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/client/seq.rs` around lines 380 - 406, The append_media implementation repeats the same cid setup, channel registration, MSRequest::SeqCommand send, and rx.recv() error handling already present in append. Extract that shared flow into a helper like send_append that accepts a fully built SeqAppendReq, then have append and append_media only build their respective request payloads and delegate to it so the duplication is removed.src/protocol.rs (1)
233-245: 🗄️ Data Integrity & Integration | 🔵 Trivial | 💤 Low value
uriandblobare mutually exclusive but the type permits both/neither.
SeqAppendMedialets callers set bothuriandblob(or omit both, serializing to"media":{}). The model can't express the intended one-of contract. If the server doesn't strictly reject the ambiguous cases, this can silently produce surprising behavior. Consider either an enum (e.g.uri/blobas variants) or documenting the invariant and validating it at the client entrypoint.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/protocol.rs` around lines 233 - 245, SeqAppendMedia currently allows both uri and blob to be present or absent, but the intended contract is one-of only. Update SeqAppendMedia in protocol.rs so the uri/blob relationship is enforced or clearly represented, ideally by replacing the struct shape with an enum variant design around SeqAppendMedia or by adding validation at the client entrypoint where SeqAppendMedia is constructed/used. If keeping the struct, ensure the relevant builder/constructor/path that creates SeqAppendMedia rejects ambiguous cases and documents the invariant using the SeqAppendMedia symbol.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/client/seq.rs`:
- Around line 380-406: The append_media implementation repeats the same cid
setup, channel registration, MSRequest::SeqCommand send, and rx.recv() error
handling already present in append. Extract that shared flow into a helper like
send_append that accepts a fully built SeqAppendReq, then have append and
append_media only build their respective request payloads and delegate to it so
the duplication is removed.
In `@src/protocol.rs`:
- Around line 233-245: SeqAppendMedia currently allows both uri and blob to be
present or absent, but the intended contract is one-of only. Update
SeqAppendMedia in protocol.rs so the uri/blob relationship is enforced or
clearly represented, ideally by replacing the struct shape with an enum variant
design around SeqAppendMedia or by adding validation at the client entrypoint
where SeqAppendMedia is constructed/used. If keeping the struct, ensure the
relevant builder/constructor/path that creates SeqAppendMedia rejects ambiguous
cases and documents the invariant using the SeqAppendMedia symbol.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: a22f5fd1-e143-4e9d-9b25-839bc29ecff9
📒 Files selected for processing (2)
src/client/seq.rssrc/protocol.rs
Media is carried with a
append:Summary by CodeRabbit
New Features
Bug Fixes