From a8bf568b947dfab3552a4b86791a159c4bcb4a3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Troed=20S=C3=A5ngberg?= Date: Sat, 13 Jun 2026 23:17:55 +0200 Subject: [PATCH] fix: v0.0.45 - use Node.js fs for debug logging --- package.json | 2 +- tui.tsx | 29 +++++------------------------ 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/package.json b/package.json index 1020cf5..a7bf4b3 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/package.json", "name": "@troed/oc-ls-stats", - "version": "0.0.44", + "version": "0.0.45", "type": "module", "exports": { "./tui": { diff --git a/tui.tsx b/tui.tsx index 35b5be2..bd41d7e 100644 --- a/tui.tsx +++ b/tui.tsx @@ -1,31 +1,14 @@ /** @jsxImportSource @opentui/solid */ import type { TuiPlugin, TuiPluginModule } from "@opencode-ai/plugin/tui" import { createMemo, createSignal } from "solid-js" +import { writeFileSync, appendFileSync } from "fs" const DEBUG_LOG = "/tmp/oc-ls-stats-debug.log" -let debugBuf: string[] = [] -let debugFlushTimer: ReturnType | null = null -async function debugFlush() { - if (debugBuf.length === 0) return - const data = debugBuf.join("") - debugBuf = [] - try { - await fetch(`file://${DEBUG_LOG}`, { - method: "PUT", - body: data, - mode: "no-cors", - }) - } catch {} -} function debug(...args: unknown[]) { - const line = `${args.map(a => typeof a === "object" ? JSON.stringify(a) : String(a)).join(" ")}\n` - debugBuf.push(line) - if (debugBuf.length >= 20) { - debugFlush() - } - if (!debugFlushTimer) { - debugFlushTimer = setInterval(() => { debugFlush(); debugFlushTimer = null }, 5000) - } + try { + const line = `${args.map(a => typeof a === "object" ? JSON.stringify(a) : String(a)).join(" ")}\n` + appendFileSync(DEBUG_LOG, line) + } catch {} } type StreamSample = { @@ -549,8 +532,6 @@ const tui: TuiPlugin = async (api) => { onPart() clearInterval(timer) clearInterval(slotTimer) - if (debugFlushTimer) clearInterval(debugFlushTimer) - debugFlush() }) try {