Skip to content

Commit 8c282cd

Browse files
authored
Merge pull request #109 from wecode-ai/fix_kilo_error
add MainThreadStatusBarShape
2 parents 3320aef + f011055 commit 8c282cd

File tree

5 files changed

+78
-4
lines changed

5 files changed

+78
-4
lines changed

jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/actors/MainThreadLanguageFeaturesShape.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface MainThreadLanguageFeaturesShape : Disposable {
3636
* @param selector Document selector
3737
* @param eventHandle Event handle
3838
*/
39-
fun registerCodeLensSupport(handle: Int, selector: List<Map<String, Any?>>, eventHandle: Int?)
39+
fun registerCodeLensSupport(handle: Number, selector: List<Map<String, Any?>>, eventHandle: Number?)
4040

4141
/**
4242
* Emits code lens event.
@@ -459,7 +459,7 @@ class MainThreadLanguageFeatures : MainThreadLanguageFeaturesShape {
459459
logger.info("Registering document symbol provider: handle=$handle, selector=$selector, label=$label")
460460
}
461461

462-
override fun registerCodeLensSupport(handle: Int, selector: List<Map<String, Any?>>, eventHandle: Int?) {
462+
override fun registerCodeLensSupport(handle: Number, selector: List<Map<String, Any?>>, eventHandle: Number?) {
463463
logger.info("Registering code lens support: handle=$handle, selector=$selector, eventHandle=$eventHandle")
464464
}
465465

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-FileCopyrightText: 2025 Weibo, Inc.
2+
//
3+
// SPDX-License-Identifier: Apache-2.0
4+
5+
package com.sina.weibo.agent.actors
6+
7+
import com.intellij.openapi.Disposable
8+
import com.intellij.openapi.diagnostic.Logger
9+
import java.net.URI
10+
11+
/**
12+
* Main thread search service interface.
13+
* Corresponds to the MainThreadSearchShape interface in VSCode.
14+
*/
15+
interface MainThreadStatusBarShape : Disposable {
16+
fun setEntry(
17+
entryId: String,
18+
id: String,
19+
extensionId: String?,
20+
name: String,
21+
text: String,
22+
tooltip: Any?,
23+
hasTooltipProvider: Boolean,
24+
command: Map<Any, Any>?,
25+
color: Any?,
26+
backgroundColor: Any?,
27+
alignLeft: Boolean,
28+
priority: Number?,
29+
accessibilityInformation: Any?
30+
)
31+
32+
}
33+
34+
/**
35+
* Implementation of the main thread search service.
36+
* Provides search-related functionality for the IDEA platform.
37+
*/
38+
class MainThreadStatusBar : MainThreadStatusBarShape {
39+
private val logger = Logger.getInstance(MainThreadStatusBar::class.java)
40+
override fun setEntry(
41+
entryId: String,
42+
id: String,
43+
extensionId: String?,
44+
name: String,
45+
text: String,
46+
tooltip: Any?,
47+
hasTooltipProvider: Boolean,
48+
command: Map<Any, Any>?,
49+
color: Any?,
50+
backgroundColor: Any?,
51+
alignLeft: Boolean,
52+
priority: Number?,
53+
accessibilityInformation: Any?
54+
) {
55+
logger.info("Set entry $entryId")
56+
}
57+
58+
override fun dispose() {
59+
logger.info("Disposing main thread")
60+
}
61+
62+
}

jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/core/RPCManager.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ class RPCManager(
3434
setupExtensionRequiredProtocols()
3535
setupWeCodeRequiredProtocols()
3636
setupRooCodeFuncitonProtocols()
37+
setupKiloCodeFunctionProtocols()
3738
setupWebviewProtocols()
3839
}
3940

41+
4042
/**
4143
* Start initializing plugin environment
4244
* Send configuration and workspace information to extension process
@@ -141,6 +143,7 @@ class RPCManager(
141143

142144
// MainThreadConfiguration
143145
rpcProtocol.set(ServiceProxyRegistry.MainContext.MainThreadConfiguration, MainThreadConfiguration())
146+
144147
}
145148

146149
/**
@@ -191,6 +194,7 @@ class RPCManager(
191194

192195
//MainThreadDocuments
193196
rpcProtocol.set(ServiceProxyRegistry.MainContext.MainThreadDocuments, MainThreadDocuments(project))
197+
194198
}
195199

196200
/**
@@ -242,6 +246,10 @@ class RPCManager(
242246
// MainThreadSecretState
243247
rpcProtocol.set(ServiceProxyRegistry.MainContext.MainThreadSecretState, MainThreadSecretState())
244248
}
249+
private fun setupKiloCodeFunctionProtocols() {
250+
// MainThreadStatusBar
251+
rpcProtocol.set(ServiceProxyRegistry.MainContext.MainThreadStatusBar, MainThreadStatusBar())
252+
}
245253

246254
private fun setupWebviewProtocols() {
247255
logger.info("Setting up protocol handlers required for Webview")

jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/core/ServiceProxyRegistry.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class ServiceProxyRegistry private constructor() {
228228
val MainThreadProgress = createProxyIdentifier<Any>("MainThreadProgress")
229229
val MainThreadQuickDiff = createProxyIdentifier<Any>("MainThreadQuickDiff")
230230
val MainThreadQuickOpen = createProxyIdentifier<Any>("MainThreadQuickOpen")
231-
val MainThreadStatusBar = createProxyIdentifier<Any>("MainThreadStatusBar")
231+
val MainThreadStatusBar = createProxyIdentifier<MainThreadStatusBarShape>("MainThreadStatusBar")
232232
val MainThreadSecretState = createProxyIdentifier<MainThreadSecretStateShape>("MainThreadSecretState")
233233
val MainThreadStorage = createProxyIdentifier<MainThreadStorageShape>("MainThreadStorage")
234234
val MainThreadSpeech = createProxyIdentifier<Any>("MainThreadSpeechProvider")

jetbrains_plugin/src/main/kotlin/com/sina/weibo/agent/ipc/proxy/RPCProtocol.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,11 @@ class RPCProtocol(
680680
* Execute handler invocation
681681
*/
682682
private suspend fun doInvokeHandler(rpcId: Int, methodName: String, args: List<Any?>): Any? {
683-
val actor = locals[rpcId] ?: throw IllegalStateException("Unknown actor ${getStringIdentifierForProxy(rpcId)}")
683+
val actor = locals[rpcId]
684+
if(actor == null) {
685+
LOG.error("Unknown actor ${getStringIdentifierForProxy(rpcId)}")
686+
return null
687+
}
684688
// Use reflection to get method with parameter type matching
685689
val method = try {
686690
findBestMatchingMethod(actor, methodName, args)

0 commit comments

Comments
 (0)