Skip to content

JSON encode/decode ProtoBus messages in the webview when not in Vscode #5362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 5, 2025

Conversation

sjf
Copy link
Contributor

@sjf sjf commented Aug 5, 2025

1. Modified gRPC Client Generation (scripts/generate-protobus-setup.mjs)

  • In VSCode: Messages are passed as JS protobuf objects directly. Because the webview and the host are both using Javascript, it can skip the encoding.
  • In Standalone mode: Messages are JSON encoded/decoded for transport between the webview and the host.

This is part of the effort to make Cline work as a standalone application outside of VSCode, ensuring proper message serialization across different runtime environments.

2. Modified gRPC Client Generation (scripts/generate-protobus-setup.mjs)

  • Updated the generated client methods to pass JSON encoder/decoder functions

3. Updated Standalone Utils (src/standalone/utils.ts)

  • Added options { longs: Number } when loading the protobuf descriptor
  • This ensures int64 fields are received as JavaScript numbers instead of Long objects

Important

Add JSON encoding/decoding for gRPC messages in standalone mode, while using protobuf objects in VSCode, with updates to ProtoBusClient and generate-protobus-setup.mjs.

  • Behavior:
    • In ProtoBusClient, makeUnaryRequest and makeStreamingRequest now use encode and decode methods for JSON handling in standalone mode.
    • encode and decode methods added to ProtoBusClient to conditionally JSON encode/decode messages based on window.__is_standalone__.
  • Scripts:
    • Updated generate-protobus-setup.mjs to use makeUnaryRequest and makeStreamingRequest with JSON encoding/decoding.
  • Utils:
    • Added options to protoLoader.loadFileDescriptorSetFromBuffer in utils.ts to encode int64 fields as numbers.

This description was created by Ellipsis for 4954f15. You can customize this summary. It will automatically update as commits are pushed.

Copy link

changeset-bot bot commented Aug 5, 2025

⚠️ No Changeset found

Latest commit: 4954f15

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

github-actions bot commented Aug 5, 2025

Coverage Report

Extension Coverage

Base branch: 47%

PR branch: 48%

✅ Coverage increased or remained the same

Webview Coverage

Base branch: 17%

PR branch: 17%

✅ Coverage increased or remained the same

Overall Assessment

Test coverage has been maintained or improved

Last updated: 2025-08-05T04:08:29.029858

@sjf sjf changed the title In the webview grpc client, JSON encode/decode the messages when not running in Vscode JSON encode/decode ProtoBus messages in the webview when not in Vscode Aug 5, 2025
Copy link
Contributor

@Garoth Garoth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful, thank you!

@Garoth Garoth merged commit df3826a into main Aug 5, 2025
13 checks passed
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