(ideSettingsPromise: Promise<IdeSettings>)
| 273 | |
| 274 | /* eslint-disable max-lines-per-function */ |
| 275 | private registerMessageHandlers(ideSettingsPromise: Promise<IdeSettings>) { |
| 276 | const on = this.messenger.on.bind(this.messenger); |
| 277 | |
| 278 | // Note, VsCode's in-process messenger doesn't do anything with this |
| 279 | // It will only show for jetbrains |
| 280 | this.messenger.onError((message, err) => { |
| 281 | // just to prevent duplicate error messages in jetbrains (same logic in webview protocol) |
| 282 | if ( |
| 283 | ["llm/streamChat", "chatDescriber/describe"].includes( |
| 284 | message.messageType, |
| 285 | ) |
| 286 | ) { |
| 287 | return; |
| 288 | } else { |
| 289 | void this.ide.showToast("error", err.message); |
| 290 | } |
| 291 | }); |
| 292 | |
| 293 | on("abort", (msg) => { |
| 294 | this.abortById(msg.data ?? msg.messageId); |
| 295 | }); |
| 296 | |
| 297 | on("ping", (msg) => { |
| 298 | if (msg.data !== "ping") { |
| 299 | throw new Error("ping message incorrect"); |
| 300 | } |
| 301 | return "pong"; |
| 302 | }); |
| 303 | |
| 304 | // History |
| 305 | on("history/list", async (msg) => { |
| 306 | const sessions = historyManager.list(msg.data); |
| 307 | const limit = msg.data?.limit ?? 100; |
| 308 | return sessions.slice(0, limit); |
| 309 | }); |
| 310 | |
| 311 | on("history/delete", (msg) => { |
| 312 | historyManager.delete(msg.data.id); |
| 313 | }); |
| 314 | |
| 315 | on("history/load", (msg) => { |
| 316 | return historyManager.load(msg.data.id); |
| 317 | }); |
| 318 | |
| 319 | on("history/save", (msg) => { |
| 320 | historyManager.save(msg.data); |
| 321 | }); |
| 322 | |
| 323 | on("history/share", async (msg) => { |
| 324 | const session = historyManager.load(msg.data.id); |
| 325 | const outputDir = msg.data.outputDir; |
| 326 | const history = session.history.map((msg) => msg.message); |
| 327 | await shareSession(this.ide, history, outputDir); |
| 328 | }); |
| 329 | |
| 330 | on("history/clear", (msg) => { |
| 331 | historyManager.clearAll(); |
| 332 | }); |
no test coverage detected