From f1075fc6a9d88572afdb7fda6503979fcf5efd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Catriel=20M=C3=BCller?= Date: Wed, 1 Apr 2026 16:15:51 -0300 Subject: [PATCH] refactor: address issues --- packages/opencode/src/kilocode/claw/client.ts | 2 +- packages/opencode/src/kilocode/claw/hooks.ts | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/opencode/src/kilocode/claw/client.ts b/packages/opencode/src/kilocode/claw/client.ts index 9efcddfea9d..a609d672e9e 100644 --- a/packages/opencode/src/kilocode/claw/client.ts +++ b/packages/opencode/src/kilocode/claw/client.ts @@ -25,7 +25,7 @@ export type ClawChatClient = { onPresence: (cb: (online: boolean) => void) => () => void } -function botId(creds: ChatCredentials): string { +export function botId(creds: ChatCredentials): string { return `bot-${creds.channelId.replace(/^default-/, "")}` } diff --git a/packages/opencode/src/kilocode/claw/hooks.ts b/packages/opencode/src/kilocode/claw/hooks.ts index f25d3739e85..3fcc14438fa 100644 --- a/packages/opencode/src/kilocode/claw/hooks.ts +++ b/packages/opencode/src/kilocode/claw/hooks.ts @@ -9,7 +9,7 @@ import { createSignal, onMount, onCleanup } from "solid-js" import type { ClawStatus, ChatCredentials, ChatMessage } from "./types" -import { connect, history, presence, type ClawChatClient } from "./client" +import { botId, connect, history, presence, type ClawChatClient } from "./client" import { Log } from "@/util/log" const log = Log.create({ service: "claw-chat" }) @@ -31,6 +31,8 @@ export function createClawStatus(sdk: any, interval = 10_000) { setError(null) } else if (res?.error) { setError(typeof res.error === "string" ? res.error : (res.error?.error ?? "Unknown error")) + } else { + setError("Network error") } setLoading(false) } @@ -116,7 +118,7 @@ export function createClawChat(sdk: any) { log.info("connect() succeeded") // Load existing messages - const bot = `bot-${creds.channelId.replace(/^default-/, "")}` + const bot = botId(creds) const existing = await history(chat.channel, bot) log.info("loaded history", { count: existing.length }) setMessages(existing)