Code-generate inbound (server→client) RPC dispatch for the Rust SDK
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 55/100
- Type d'issue
- Refactorisation
- Clarté
- Clairement spécifiée
- Activité
- Calme
- Stack technique
- rust, typescript
- Domaine
- api, backend-api-design, tooling
Piste de recherche
Commencez par scripts/codegen/rust.ts et comparez l’émission entrante dans scripts/codegen/{csharp,go,python,typescript}.ts. Examinez ensuite rust/src/canvas_dispatch.rs, rust/src/session_fs_dispatch.rs et rust/src/copilot_request_handler.rs, en préservant les traits ergonomiques et le pont de streaming. Le travail est considéré comme terminé lorsque les traits entrants générés et le dispatch remplacent les matches écrits à la main, tandis que cargo build, clippy et la suite e2e Rust complète restent au vert.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Background
The SDK protocol has two directions of RPC:
- Outbound (client→server): the SDK calls into the runtime.
- Inbound (server→client): the runtime calls back into the SDK — e.g.
clientSession.*(canvas,sessionFs) and the newclientGlobal.*(llmInference) callbacks added in #1689.
For inbound dispatch, the four SDKs split into two camps:
-
C#, Go, Python, TypeScript code-generate the inbound handler scaffolding (handler interfaces + the dispatch/registration glue) from
api.schema.json. Adding theclientGlobalbucket in #1689 required teaching all fourscripts/codegen/*.tsgenerators about it. -
Rust generates only the inbound wire types (
generated/api_types.rs) and method-name constants (rpc_methods::*ingenerated/rpc.rs). The per-group dispatch + handler trait is hand-written, consistently, across all three inbound groups:canvas.*→rust/src/canvas_dispatch.rssessionFs.*→rust/src/session_fs_dispatch.rsllmInference.*→rust/src/copilot_request_handler.rs(dispatch)
Each follows the identical shape: prefix-check → match
rpc_methods::*constant → deserialize generated params → call the hand-written handler trait → serialize the result. -
Java has no codegen pipeline at all (entire RPC surface hand-authored), so it's out of scope here.
Proposal
Bring Rust to parity with the other generated SDKs by code-generating the inbound handler trait + dispatch helper per group into rust/src/generated/, so future inbound callbacks (new clientSession / clientGlobal groups) come for free, as they already do in C#/Go/Python/TS.
Why this is its own PR, not part of #1689
This was investigated during #1689 and deliberately deferred:
-
Do all three groups, not a one-off. Rust's hand-written-dispatch convention is currently uniform across
canvas,sessionFs, andllmInference. Generating onlyllmInference(the group #1689 touches) would trade Rust's internal consistency for cross-SDK symmetry and leave a confusing one-off. The clean change converts all three groups together — a cross-cutting refactor of shipped, well-tested dispatchers and their public trait surfaces (CanvasHandler,SessionFsProvider,CopilotRequestHandler), out of scope for a callbacks PR. -
Generate only the low-level wire trait; keep ergonomic traits + streaming bridges hand-written. The public
CopilotRequestHandler(send_request+open_websocket) does not mirror the wire methods (httpRequestStart+httpRequestChunk); ~1200 lines bridge frame-oriented streaming ↔ that 2-method seam with stateful exchange correlation. Codegen should emit only the thin wire-level trait + dispatch (mirroring what TS generates), with the ergonomic traits and the llmInference bridge staying hand-written. Net hand-written savings are small (≈ the dispatchmatch+ method constants); the value is future-proofing and symmetry, not LOC. -
Validation. The streaming handler is heavily covered by Rust e2e (cancel / error / session-id) record-replay tests that should gate the refactor in CI.
Suggested scope of work
- Add inbound handler-trait + dispatch emission to
scripts/codegen/rust.ts(readclientSession+clientGlobal), emitting intorust/src/generated/. - Migrate
canvas_dispatch.rs,session_fs_dispatch.rs, andcopilot_request_handler.rsto implement/use the generated trait + dispatch instead of their hand-rolledmatch+ local method-name constants. - Keep ergonomic public traits (
CanvasHandler,SessionFsProvider,CopilotRequestHandler) and the llmInference streaming bridge hand-written. - Verify
cargo build+ clippy + the full Rust e2e suite stay green.
References
- PR #1689 (LLM inference callbacks) — where the
clientGlobalbucket and the C#/Go/Python/TS generator changes landed. - Generators with inbound support:
scripts/codegen/{csharp,go,python,typescript}.ts(emitClientGlobalApiRegistration/emitClientSessionApiRegistration). - Rust generator (outbound only today):
scripts/codegen/rust.ts.
- Langage dominant
- TypeScript
- Étoiles
- 10.6k
- Forks
- 1.5k
- Merge moyen
- 1 j 4 h
- PR mergées (30 j)
- 10
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Aucun modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de github/copilot-sdk
-
Clarify SDK architecture and in-process runtime transportPeut-être pris @KalebCole l’a pris il y a 16 jours. Ouvertedocumentation
Difficulté 1/5 Moins d'une heure Accessibilité débutants 92/100
github/copilot-sdk#2804 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Python ModelLimits drops max_output_tokens from model metadataPeut-être pris @HDMowri l’a pris il y a 18 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
github/copilot-sdk#2798 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
github/copilot-sdk#2793 ·
Les mainteneurs répondent en général sous 1 jour
-
agentic-workflows
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
github/copilot-sdk#2782 ·
Les mainteneurs répondent en général sous 1 jour
-
agentic-workflows
Difficulté 2/5 1-3 heures Accessibilité débutants 65/100
github/copilot-sdk#2779 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de github/copilot-sdk
Issues similaires
-
documentation
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
components-web-app/docs#260 ·
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 65/100
521xueweihan/HelloGitHub#4025 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
ctrf-io/playwright-ctrf-json-reporter#117 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
voidzero-dev/void#478 ·
Les mainteneurs répondent en général sous 1 jour