Rust: add race-safe canvas availability waiter - #2290
Open
ellismg wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a Rust helper for race-safe waiting on canvas declarations without starting a model turn.
Changes:
- Adds
Session::wait_for_canvaswith provider matching and timeout handling. - Adds dedicated timeout and session-closed errors.
- Adds coverage for registration races, lag, shutdown, and timeout behavior.
Show a summary per file
| File | Description |
|---|---|
rust/src/session.rs |
Implements the canvas availability waiter. |
rust/src/types.rs |
Defines waiter configuration options. |
rust/src/errors.rs |
Adds canvas-wait error variants and messages. |
rust/tests/session_test.rs |
Tests matching, races, lag, timeout, and shutdown. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Balanced
Comment on lines
+368
to
+370
| Err(error) => match error.kind() { | ||
| RecvErrorKind::Lagged(_) => break, | ||
| RecvErrorKind::Closed => { |
Comment on lines
+3496
to
+3502
| let initial_list = server.read_request().await; | ||
| for sequence in 0..600 { | ||
| server | ||
| .send_event("test.event", serde_json::json!({ "sequence": sequence })) | ||
| .await; | ||
| } | ||
| tokio::time::sleep(Duration::from_millis(50)).await; |
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
Session::wait_for_canvas(WaitForCanvasOptions)for waiting on a known canvas declaration without sending a model turnsession.canvas.listsnapshot, then re-list on registry changes or subscription lagMotivation
github/github-app#11029 currently has to coordinate
session.canvas.listandsession.canvas.registry_changeditself while asynchronously loaded extensions register their canvases. This helper provides the smallest SDK-level primitive that removes the list/subscription race when the caller already knows the target canvas.The API deliberately guarantees only target availability. It does not claim that extension initialization or the complete canvas registry has settled. A handshake-backed bounded initialization snapshot remains a separate copilot-agent-runtime protocol follow-up for github/github-app#7544 and github/github-app#10224.
Compatibility
This is an additive Rust API implemented entirely over existing protocol-v3 methods and events. It does not change
session.create, add wire fields, block session creation on extension startup, or require a model turn. Older runtimes therefore need no protocol changes.CHANGELOG.mdis release-generated and has no unreleased section, so this PR relies on public rustdoc rather than editing it manually.Validation
cargo +nightly-2026-04-14 fmt --all -- --config-path .rustfmt.nightly.toml --checkcargo clippy --all-targets --features test-support -- --no-deps -D warnings -D clippy::unwrap_used -D clippy::disallowed_macros -D clippy::await_holding_invalid_typecargo test --features test-support