In the reflection output the standalone service should only show the Protobus services (#4339)

* The standalone service should only show the Protobus services in the reflection output.

The proto descriptor set is including all the proto services, allowlist the services in the cline and health packages.

* Remove debug code

* Fix variable name
This commit is contained in:
Sarah Fortune authored and GitHub committed 2025-06-23 11:35:09 -07:00
1 parent f8a284c6fe
commit 3e1565da59
2 files changed
+20 -5

No files matched your search

+18 -3
View File
@@ -20,6 +20,10 @@ async function main() {
hostProviders.initializeHostProviders(createWebview, new ExternalHostBridgeClientManager())
activate(extensionContext)
const controller = new Controller(extensionContext, outputChannel, postMessage, uuidv4())
startProtobusService(controller)
}
function startProtobusService(controller: Controller) {
const server = new grpc.Server()
// Set up health check.
@@ -29,12 +33,15 @@ async function main() {
// Add all the handlers for the ProtoBus services to the server.
addProtobusServices(server, controller, wrapHandler, wrapStreamingResponseHandler)
// Set up reflection.
const reflection = new ReflectionService(getPackageDefinition())
// Create reflection service with protobus service names
const packageDefinition = getPackageDefinition()
const reflection = new ReflectionService(packageDefinition, {
services: getProtobusServiceNames(packageDefinition),
})
reflection.addToServer(server)
// Start the server.
const host = "127.0.0.1:50051"
const host = process.env.PROTOBUS_ADDRESS || "127.0.0.1:50051"
server.bindAsync(host, grpc.ServerCredentials.createInsecure(), (err) => {
if (err) {
log(`Error: Failed to bind to ${host}, port may be unavailable. ${err.message}`)
@@ -45,6 +52,14 @@ async function main() {
})
}
function getProtobusServiceNames(packageDefinition: { [x: string]: any }): string[] {
// Filter service names to only include cline services
const protobusServiceNames = Object.keys(packageDefinition).filter(
(name) => name.startsWith("cline.") || name.startsWith("grpc.health"),
)
return protobusServiceNames
}
const createWebview = () => {
return new ExternalWebviewProvider(extensionContext, outputChannel, WebviewProviderType.SIDEBAR)
}
+2 -2
View File
@@ -11,9 +11,9 @@ const log = (...args: unknown[]) => {
function getPackageDefinition() {
// Load service definitions.
const descriptorSet = fs.readFileSync("proto/descriptor_set.pb")
const clineDef = protoLoader.loadFileDescriptorSetFromBuffer(descriptorSet)
const descriptorDefs = protoLoader.loadFileDescriptorSetFromBuffer(descriptorSet)
const healthDef = protoLoader.loadSync(health.protoPath)
const packageDefinition = { ...clineDef, ...healthDef }
const packageDefinition = { ...descriptorDefs, ...healthDef }
return packageDefinition
}