Skip to content

Add native 2+ arg RPC support and wire a concrete TestMultiArgCommand through server, generated clients, and CLI#2963

Merged
sawka merged 5 commits intomainfrom
copilot/support-multiple-arguments
Mar 2, 2026
Merged

Add native 2+ arg RPC support and wire a concrete TestMultiArgCommand through server, generated clients, and CLI#2963
sawka merged 5 commits intomainfrom
copilot/support-multiple-arguments

Conversation

Copy link
Contributor

Copilot AI commented Mar 2, 2026

This PR extends WSH RPC command signatures to support ctx + 2+ typed args while preserving existing ctx and ctx + 1 arg behavior. It also adds a concrete TestMultiArgCommand end-to-end so the generated Go/TS client surfaces can be inspected and exercised from CLI.

  • RPC wire + dispatch model

    • Added wshrpc.MultiArg (args []any) as the over-the-wire envelope for 2+ arg commands.
    • Extended RPC metadata to track all command arg types (CommandDataTypes) and exposed a helper for normalized access.
    • Updated server adapter unmarshalling to:
      • decode MultiArg for 2+ arg commands,
      • validate arg count,
      • re-unmarshal each arg into its declared type before invoking typed handlers.
    • Kept single-arg commands on the existing non-MultiArg path.
  • Code generation (Go + TS)

    • Go codegen now emits multi-parameter wrappers for 2+ arg methods and packs payload as wshrpc.MultiArg.
    • TS codegen now emits multi-parameter API methods and packs payload as { args: [...] }.
    • 0/1-arg generation remains unchanged to avoid wire/API churn.
  • Concrete command added for validation

    • Added to WshRpcInterface:
      • TestMultiArgCommand(ctx context.Context, arg1 string, arg2 int, arg3 bool) (string, error)
    • Implemented in wshserver with deterministic formatted return output including source + all args.
    • Updated wsh test command to call TestMultiArgCommand and print the returned string.
  • Focused coverage

    • Added/updated targeted tests around RPC metadata and Go/TS multi-arg codegen behavior, including command declaration for testmultiarg.

Example generated call shape:

func TestMultiArgCommand(w *wshutil.WshRpc, arg1 string, arg2 int, arg3 bool, opts *wshrpc.RpcOpts) (string, error) {
    return sendRpcRequestCallHelper[string](
        w,
        "testmultiarg",
        wshrpc.MultiArg{Args: []any{arg1, arg2, arg3}},
        opts,
    )
}

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits March 2, 2026 19:05
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for multiple arguments in wshrpctypes Support 2+ typed RPC arguments via MultiArg without changing 0/1-arg wire format Mar 2, 2026
Copilot finished work on behalf of sawka March 2, 2026 19:09
Co-authored-by: sawka <2722291+sawka@users.noreply.github.com>
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Mar 2, 2026

Deploying waveterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: bd973b6
Status: ✅  Deploy successful!
Preview URL: https://f35d3962.waveterm.pages.dev
Branch Preview URL: https://copilot-support-multiple-arg.waveterm.pages.dev

View logs

Copilot AI changed the title Support 2+ typed RPC arguments via MultiArg without changing 0/1-arg wire format Add native 2+ arg RPC support and wire a concrete TestMultiArgCommand through server, generated clients, and CLI Mar 2, 2026
Copilot finished work on behalf of sawka March 2, 2026 19:31
@sawka sawka marked this pull request as ready for review March 2, 2026 19:49
@kilo-code-bot
Copy link
Contributor

kilo-code-bot bot commented Mar 2, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Other Observations (not in diff)

Issues found in unchanged code that cannot receive inline comments:

File Line Issue
pkg/wshutil/wshadapter.go 80 CRITICAL: Logic error in condition - should use `
Files Reviewed (10 files)
  • cmd/wsh/cmd/wshcmd-test.go - Test command implementation looks correct
  • frontend/app/store/wshclientapi.ts - Generated TypeScript client API is correct
  • pkg/gogen/gogen.go - Go code generation logic is well-structured
  • pkg/gogen/gogen_test.go - Good test coverage for multi-arg generation
  • pkg/tsgen/tsgen.go - TypeScript code generation logic is correct
  • pkg/tsgen/tsgen_wshclientapi_test.go - Good test coverage for TS generation
  • pkg/wshrpc/wshclient/wshclient.go - Generated Go client is correct
  • pkg/wshrpc/wshrpcmeta.go - Metadata handling is properly implemented
  • pkg/wshrpc/wshrpcmeta_test.go - Good test coverage for metadata
  • pkg/wshrpc/wshrpctypes.go - Type definitions are correct, formatting change is fine
  • pkg/wshrpc/wshserver/wshserver.go - Test implementation is correct
  • pkg/wshutil/wshadapter.go - Multi-arg dispatch logic is well-implemented with proper validation

Review Notes

This PR adds support for RPC commands with multiple typed arguments (2+) while maintaining backward compatibility with existing 0-arg and 1-arg commands. The implementation is solid:

Well-structured approach: Uses MultiArg envelope for 2+ args, keeps existing paths unchanged
Proper validation: Validates arg count and types before dispatch
Good test coverage: Tests for metadata, Go codegen, and TS codegen
Clean code generation: Both Go and TypeScript generators handle multi-arg correctly
End-to-end validation: TestMultiArgCommand provides concrete validation path

The only issue found is in pre-existing code (not part of this PR) and should be addressed separately.

@sawka sawka merged commit df24959 into main Mar 2, 2026
9 checks passed
@sawka sawka deleted the copilot/support-multiple-arguments branch March 2, 2026 20:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants