refactor: address issues

This commit is contained in:
Catriel Müller
2026-04-01 16:15:51 -03:00
parent a1abbc2b4d
commit f1075fc6a9
2 changed files with 5 additions and 3 deletions
@@ -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-/, "")}`
}
+4 -2
View File
@@ -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)