@khalilgharbaoui/opencode-claude-code-plugin 0.58.0 → 0.59.0

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
@@ -1325,6 +1325,65 @@ function accountUsageLines(usage, now, width = SIDEBAR_ROW_WIDTH, known = /* @__
1325
1325
  });
1326
1326
  }
1327
1327
 
1328
+ // src/plugin-notice.ts
1329
+ var NOTICE_RPC_ID = "opencode-claude-code-plugin";
1330
+ var NOTICE_EVENT = "notice";
1331
+ var NOTICE_EVENT_TYPE = `rpc.${NOTICE_RPC_ID}.${NOTICE_EVENT}`;
1332
+ var NOTICE_RPC_DEFINITION = {
1333
+ id: NOTICE_RPC_ID,
1334
+ methods: {},
1335
+ events: {
1336
+ [NOTICE_EVENT]: {
1337
+ schema: {
1338
+ type: "object",
1339
+ properties: {
1340
+ id: { type: "string" },
1341
+ level: { type: "string", enum: ["warn", "error"] },
1342
+ message: { type: "string" }
1343
+ },
1344
+ required: ["id", "level", "message"],
1345
+ additionalProperties: false
1346
+ }
1347
+ }
1348
+ }
1349
+ };
1350
+ var TOAST_TITLE = "claude-code";
1351
+ var TOAST_DURATION_MS = 1e4;
1352
+ var MAX_TOAST_CHARS = 240;
1353
+ function toastMessage(message) {
1354
+ const flat = message.replace(/\s+/g, " ").trim();
1355
+ if (flat.length <= MAX_TOAST_CHARS) return flat;
1356
+ return `${flat.slice(0, MAX_TOAST_CHARS - 1)}\u2026`;
1357
+ }
1358
+ function readPluginNotice(type, data) {
1359
+ if (type !== NOTICE_EVENT_TYPE) return void 0;
1360
+ if (!data || typeof data !== "object") return void 0;
1361
+ const { id, level, message } = data;
1362
+ if (typeof id !== "string" || id.length === 0) return void 0;
1363
+ if (level !== "warn" && level !== "error") return void 0;
1364
+ if (typeof message !== "string" || message.trim().length === 0) return void 0;
1365
+ return { id, level, message: toastMessage(message) };
1366
+ }
1367
+ var MAX_SEEN_NOTICES = 256;
1368
+ function createNoticeToaster(show) {
1369
+ const seen = /* @__PURE__ */ new Set();
1370
+ return (type, data) => {
1371
+ const notice = readPluginNotice(type, data);
1372
+ if (!notice || seen.has(notice.id)) return false;
1373
+ seen.add(notice.id);
1374
+ if (seen.size > MAX_SEEN_NOTICES) {
1375
+ const oldest = seen.values().next().value;
1376
+ if (oldest !== void 0) seen.delete(oldest);
1377
+ }
1378
+ try {
1379
+ show(notice);
1380
+ return true;
1381
+ } catch {
1382
+ return false;
1383
+ }
1384
+ };
1385
+ }
1386
+
1328
1387
  // src/tui.ts
1329
1388
  var SUBAGENTS_TUI_PLUGIN_ID = "opencode-claude-code-plugin.subagents";
1330
1389
  var SECTION_ORDER = 900;
@@ -1954,8 +2013,21 @@ function setupV2(context) {
1954
2013
  }),
1955
2014
  void 0
1956
2015
  );
2016
+ const toastNotice = createNoticeToaster(
2017
+ (notice) => context.ui.toast?.show({
2018
+ title: TOAST_TITLE,
2019
+ message: notice.message,
2020
+ variant: notice.level === "error" ? "error" : "warning",
2021
+ duration: TOAST_DURATION_MS
2022
+ })
2023
+ );
2024
+ const stopNotices = attempt(
2025
+ () => context.data.listen?.((event) => void toastNotice(event?.details?.type, event?.details?.data)),
2026
+ void 0
2027
+ );
1957
2028
  return () => {
1958
2029
  if (release) attempt(release, void 0);
2030
+ if (stopNotices) attempt(stopNotices, void 0);
1959
2031
  sidebar.dispose();
1960
2032
  };
1961
2033
  }