Skip to content

Commit f7e5398

Browse files
authored
Fix warnings for protobuf object literals (RooCodeInc#3948)
Create protobuf objects with .create()
1 parent 89f35b0 commit f7e5398

30 files changed

+99
-96
lines changed

src/core/controller/account/accountLoginClicked.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { EmptyRequest, String } from "../../../shared/proto/common"
1212
* @param controller The controller instance.
1313
* @returns The login URL as a string.
1414
*/
15-
export async function accountLoginClicked(controller: Controller, unused: EmptyRequest): Promise<String> {
15+
export async function accountLoginClicked(controller: Controller, _: EmptyRequest): Promise<String> {
1616
// Generate nonce for state validation
1717
const nonce = crypto.randomBytes(32).toString("hex")
1818
await storeSecret(controller.context, "authNonce", nonce)
@@ -27,7 +27,7 @@ export async function accountLoginClicked(controller: Controller, unused: EmptyR
2727
`https://app.cline.bot/auth?state=${encodeURIComponent(nonce)}&callback_url=${encodeURIComponent(`${uriScheme || "vscode"}://saoudrizwan.claude-dev/auth`)}`,
2828
)
2929
await vscode.env.openExternal(authUrl)
30-
return {
30+
return String.create({
3131
value: authUrl.toString(),
32-
}
32+
})
3333
}

src/core/controller/account/accountLogoutClicked.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Empty } from "../../../shared/proto/common"
1+
import { Empty } from "../../../shared/proto/common"
22
import type { EmptyRequest } from "../../../shared/proto/common"
33
import type { Controller } from "../index"
44

@@ -10,5 +10,5 @@ import type { Controller } from "../index"
1010
*/
1111
export async function accountLogoutClicked(controller: Controller, _request: EmptyRequest): Promise<Empty> {
1212
await controller.handleSignOut()
13-
return {}
13+
return Empty.create({})
1414
}

src/core/controller/browser/discoverBrowser.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,24 @@ export async function discoverBrowser(controller: Controller, request: EmptyRequ
2424
const browserSession = new BrowserSession(controller.context, browserSettings)
2525
const result = await browserSession.testConnection(discoveredHost)
2626

27-
return {
27+
return BrowserConnection.create({
2828
success: true,
2929
message: `Successfully discovered and connected to Chrome at ${discoveredHost}`,
3030
endpoint: result.endpoint || "",
31-
}
31+
})
3232
} else {
33-
return {
33+
return BrowserConnection.create({
3434
success: false,
3535
message:
3636
"No Chrome instances found. Make sure Chrome is running with remote debugging enabled (--remote-debugging-port=9222).",
3737
endpoint: "",
38-
}
38+
})
3939
}
4040
} catch (error) {
41-
return {
41+
return BrowserConnection.create({
4242
success: false,
4343
message: `Error discovering browser: ${error instanceof Error ? error.message : String(error)}`,
4444
endpoint: "",
45-
}
45+
})
4646
}
4747
}

src/core/controller/browser/getBrowserConnectionInfo.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getAllExtensionState } from "@core/storage/state"
99
* @param request The request message
1010
* @returns The browser connection info
1111
*/
12-
export async function getBrowserConnectionInfo(controller: Controller, request: EmptyRequest): Promise<BrowserConnectionInfo> {
12+
export async function getBrowserConnectionInfo(controller: Controller, _: EmptyRequest): Promise<BrowserConnectionInfo> {
1313
try {
1414
// Get browser settings from extension state
1515
const { browserSettings } = await getAllExtensionState(controller.context)
@@ -23,25 +23,25 @@ export async function getBrowserConnectionInfo(controller: Controller, request:
2323
const connectionInfo = browserSession.getConnectionInfo()
2424

2525
// Convert from BrowserSession.BrowserConnectionInfo to proto.BrowserConnectionInfo
26-
return {
26+
return BrowserConnectionInfo.create({
2727
isConnected: connectionInfo.isConnected,
2828
isRemote: connectionInfo.isRemote,
2929
host: connectionInfo.host || "", // Ensure host is never undefined
30-
}
30+
})
3131
}
3232

3333
// Fallback to browser settings if no active browser session
34-
return {
34+
return BrowserConnectionInfo.create({
3535
isConnected: false,
3636
isRemote: !!browserSettings.remoteBrowserEnabled,
3737
host: browserSettings.remoteBrowserHost || "",
38-
}
38+
})
3939
} catch (error: unknown) {
4040
console.error("Error getting browser connection info:", error)
41-
return {
41+
return BrowserConnectionInfo.create({
4242
isConnected: false,
4343
isRemote: false,
4444
host: "",
45-
}
45+
})
4646
}
4747
}

src/core/controller/browser/getDetectedChromePath.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,21 @@ import { BrowserSession } from "../../../services/browser/BrowserSession"
1010
* @param request The empty request message
1111
* @returns The detected Chrome path and whether it's bundled
1212
*/
13-
export async function getDetectedChromePath(controller: Controller, request: EmptyRequest): Promise<ChromePath> {
13+
export async function getDetectedChromePath(controller: Controller, _: EmptyRequest): Promise<ChromePath> {
1414
try {
1515
const { browserSettings } = await getAllExtensionState(controller.context)
1616
const browserSession = new BrowserSession(controller.context, browserSettings)
1717
const result = await browserSession.getDetectedChromePath()
1818

19-
return {
19+
return ChromePath.create({
2020
path: result.path,
2121
isBundled: result.isBundled,
22-
}
22+
})
2323
} catch (error) {
2424
console.error("Error getting detected Chrome path:", error)
25-
return {
25+
return ChromePath.create({
2626
path: "",
2727
isBundled: false,
28-
}
28+
})
2929
}
3030
}

src/core/controller/browser/relaunchChromeDebugMode.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { BrowserSession } from "../../../services/browser/BrowserSession"
88
* @param request The empty request message
99
* @returns The browser relaunch result as a string message
1010
*/
11-
export async function relaunchChromeDebugMode(controller: Controller, request: EmptyRequest): Promise<StringMessage> {
11+
export async function relaunchChromeDebugMode(controller: Controller, _: EmptyRequest): Promise<StringMessage> {
1212
try {
1313
const { browserSettings } = await controller.getStateToPostToWebview()
1414
const browserSession = new BrowserSession(controller.context, browserSettings)
@@ -18,9 +18,9 @@ export async function relaunchChromeDebugMode(controller: Controller, request: E
1818

1919
// The actual result will be sent via postMessageToWebview in the BrowserSession.relaunchChromeDebugMode method
2020
// Here we just return a message as a placeholder
21-
return {
21+
return StringMessage.create({
2222
value: "Chrome relaunch initiated",
23-
}
23+
})
2424
} catch (error) {
2525
throw new Error(`Error relaunching Chrome: ${error instanceof Error ? error.message : globalThis.String(error)}`)
2626
}

src/core/controller/browser/testBrowserConnection.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,40 +24,40 @@ export async function testBrowserConnection(controller: Controller, request: Str
2424
if (discoveredHost) {
2525
// Test the connection to the discovered host
2626
const result = await browserSession.testConnection(discoveredHost)
27-
return {
27+
return BrowserConnection.create({
2828
success: result.success,
2929
message: `Auto-discovered and tested connection to Chrome at ${discoveredHost}: ${result.message}`,
3030
endpoint: result.endpoint || "",
31-
}
31+
})
3232
} else {
33-
return {
33+
return BrowserConnection.create({
3434
success: false,
3535
message:
3636
"No Chrome instances found on the network. Make sure Chrome is running with remote debugging enabled (--remote-debugging-port=9222).",
3737
endpoint: "",
38-
}
38+
})
3939
}
4040
} catch (error) {
41-
return {
41+
return BrowserConnection.create({
4242
success: false,
4343
message: `Error during auto-discovery: ${error instanceof Error ? error.message : String(error)}`,
4444
endpoint: "",
45-
}
45+
})
4646
}
4747
} else {
4848
// Test the provided URL
4949
const result = await browserSession.testConnection(text)
50-
return {
50+
return BrowserConnection.create({
5151
success: result.success,
5252
message: result.message,
5353
endpoint: result.endpoint || "",
54-
}
54+
})
5555
}
5656
} catch (error) {
57-
return {
57+
return BrowserConnection.create({
5858
success: false,
5959
message: `Error testing connection: ${error instanceof Error ? error.message : String(error)}`,
6060
endpoint: "",
61-
}
61+
})
6262
}
6363
}

src/core/controller/browser/updateBrowserSettings.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ export async function updateBrowserSettings(controller: Controller, request: Upd
5050
// Post updated state to webview
5151
await controller.postStateToWebview()
5252

53-
return {
53+
return Boolean.create({
5454
value: true,
55-
}
55+
})
5656
} catch (error) {
5757
console.error("Error updating browser settings:", error)
58-
return {
58+
return Boolean.create({
5959
value: false,
60-
}
60+
})
6161
}
6262
}

src/core/controller/checkpoints/checkpointRestore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ export async function checkpointRestore(controller: Controller, request: Checkpo
1818
// NOTE: cancelTask awaits abortTask, which awaits diffViewProvider.revertChanges, which reverts any edited files, allowing us to reset to a checkpoint rather than running into a state where the revertChanges function is called alongside or after the checkpoint reset
1919
await controller.task?.restoreCheckpoint(request.number, request.restoreType as ClineCheckpointRestore, request.offset)
2020
}
21-
return {}
21+
return Empty.create({})
2222
}

src/core/controller/file/refreshRules.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ export async function refreshRules(controller: Controller, _request: EmptyReques
1818
const { cursorLocalToggles, windsurfLocalToggles } = await refreshExternalRulesToggles(controller.context, cwd)
1919
const { localWorkflowToggles, globalWorkflowToggles } = await refreshWorkflowToggles(controller.context, cwd)
2020

21-
return {
21+
return RefreshedRules.create({
2222
globalClineRulesToggles: { toggles: globalToggles },
2323
localClineRulesToggles: { toggles: localToggles },
2424
localCursorRulesToggles: { toggles: cursorLocalToggles },
2525
localWindsurfRulesToggles: { toggles: windsurfLocalToggles },
2626
localWorkflowToggles: { toggles: localWorkflowToggles },
2727
globalWorkflowToggles: { toggles: globalWorkflowToggles },
28-
}
28+
})
2929
} catch (error) {
3030
console.error("Failed to refresh rules:", error)
3131
throw error

0 commit comments

Comments
 (0)