opencode-go-usage-tui 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/tui.js CHANGED
@@ -55,6 +55,7 @@ function saveConfig(patch) {
55
55
  } catch {
56
56
  }
57
57
  }
58
+ var [configTick, setConfigTick] = createSignal(0);
58
59
  async function fetchUsage(workspaceId, authCookie) {
59
60
  if (!workspaceId || !authCookie) return {
60
61
  error: "not_configured"
@@ -194,7 +195,14 @@ function GoUsagePanel(props) {
194
195
  onMount(() => {
195
196
  refresh();
196
197
  const timer = setInterval(refresh, CHECK_INTERVAL);
197
- onCleanup(() => clearInterval(timer));
198
+ const stopWatch = createEffect(() => {
199
+ void configTick();
200
+ refresh();
201
+ });
202
+ onCleanup(() => {
203
+ clearInterval(timer);
204
+ stopWatch();
205
+ });
198
206
  });
199
207
  const [pal, setPal] = createSignal({
200
208
  ...FALLBACK
@@ -464,6 +472,7 @@ var tui = async (api) => {
464
472
  saveConfig({
465
473
  cookie
466
474
  });
475
+ setConfigTick((v) => v + 1);
467
476
  api.ui.toast({
468
477
  variant: "success",
469
478
  message: "Go \u7528\u91CF\u914D\u7F6E\u5DF2\u4FDD\u5B58"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-go-usage-tui",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "OpenCode TUI plugin displaying OpenCode Go usage in the sidebar",
5
5
  "type": "module",
6
6
  "exports": {
@@ -38,4 +38,4 @@
38
38
  "esbuild": "^0.25.0",
39
39
  "esbuild-plugin-solid": "^0.5.0"
40
40
  }
41
- }
41
+ }
package/src/index.tsx CHANGED
@@ -55,6 +55,9 @@ function saveConfig(patch: { workspace_id?: string; cookie?: string }): void {
55
55
  } catch { /* 写入失败忽略 */ }
56
56
  }
57
57
 
58
+ // 模块级共享信号:/go-config 保存配置后递增,面板监听它立即刷新
59
+ const [configTick, setConfigTick] = createSignal(0)
60
+
58
61
  interface Usage {
59
62
  rollingUsage: { usagePercent: number; resetInSec: number }
60
63
  weeklyUsage: { usagePercent: number; resetInSec: number }
@@ -183,7 +186,12 @@ function GoUsagePanel(props: { theme: TuiThemeCurrent; api: TuiPluginApi }): JSX
183
186
  onMount(() => {
184
187
  refresh()
185
188
  const timer = setInterval(refresh, CHECK_INTERVAL)
186
- onCleanup(() => clearInterval(timer))
189
+ // 监听配置变更(/go-config 保存后)立即刷新
190
+ const stopWatch = createEffect(() => {
191
+ void configTick()
192
+ refresh()
193
+ })
194
+ onCleanup(() => { clearInterval(timer); stopWatch() })
187
195
  })
188
196
 
189
197
  const [pal, setPal] = createSignal<Record<string, string>>({ ...FALLBACK })
@@ -322,6 +330,7 @@ const tui: TuiPlugin = async (api: TuiPluginApi) => {
322
330
  const cookie = val.trim()
323
331
  if (!cookie) { dialog?.clear(); return }
324
332
  saveConfig({ cookie })
333
+ setConfigTick((v) => v + 1)
325
334
  api.ui.toast({ variant: "success", message: "Go 用量配置已保存" })
326
335
  dialog?.clear()
327
336
  }}