@cortexkit/pi-magic-context 0.30.1 → 0.30.2

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.
Files changed (2) hide show
  1. package/dist/index.js +32 -15
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -14945,12 +14945,30 @@ var require_src2 = __commonJS((exports, module) => {
14945
14945
  // ../plugin/src/shared/rpc-notifications.ts
14946
14946
  var exports_rpc_notifications = {};
14947
14947
  __export(exports_rpc_notifications, {
14948
+ registerNotificationSink: () => registerNotificationSink,
14948
14949
  pushNotification: () => pushNotification,
14949
14950
  isTuiConnected: () => isTuiConnected,
14950
14951
  drainNotifications: () => drainNotifications
14951
14952
  });
14953
+ function registerNotificationSink(sink) {
14954
+ sinks.add(sink);
14955
+ return () => {
14956
+ sinks.delete(sink);
14957
+ };
14958
+ }
14959
+ function notificationMatchesSink(notification, sink) {
14960
+ return notification.sessionId === undefined || sink.sessionId === undefined || notification.sessionId === sink.sessionId;
14961
+ }
14952
14962
  function pushNotification(type, payload, sessionId) {
14953
- queue.push({ id: nextNotificationId++, type, payload, sessionId });
14963
+ const notification = { id: nextNotificationId++, type, payload, sessionId };
14964
+ queue.push(notification);
14965
+ for (const sink of sinks) {
14966
+ if (!notificationMatchesSink(notification, sink))
14967
+ continue;
14968
+ try {
14969
+ sink.send(notification);
14970
+ } catch {}
14971
+ }
14954
14972
  if (queue.length > 100) {
14955
14973
  const newestPerSession = new Map;
14956
14974
  for (const n of queue) {
@@ -14970,10 +14988,6 @@ function pushNotification(type, payload, sessionId) {
14970
14988
  }
14971
14989
  }
14972
14990
  function drainNotifications(lastReceivedId = 0, sessionId) {
14973
- const now = Date.now();
14974
- lastDrainAtAny = now;
14975
- if (sessionId !== undefined)
14976
- lastDrainAtBySession.set(sessionId, now);
14977
14991
  const matchesClient = (notification) => sessionId === undefined || notification.sessionId === undefined || notification.sessionId === sessionId;
14978
14992
  if (lastReceivedId > 0) {
14979
14993
  queue = queue.filter((notification) => !(notification.id <= lastReceivedId && matchesClient(notification)));
@@ -14981,17 +14995,20 @@ function drainNotifications(lastReceivedId = 0, sessionId) {
14981
14995
  return queue.filter((notification) => notification.id > lastReceivedId && matchesClient(notification));
14982
14996
  }
14983
14997
  function isTuiConnected(sessionId) {
14984
- const now = Date.now();
14985
- if (sessionId !== undefined) {
14986
- const at = lastDrainAtBySession.get(sessionId) ?? 0;
14987
- return at > 0 && now - at < TUI_CONNECTED_WINDOW_MS;
14998
+ if (sinks.size === 0)
14999
+ return false;
15000
+ if (sessionId === undefined)
15001
+ return true;
15002
+ for (const sink of sinks) {
15003
+ if (sink.sessionId === undefined || sink.sessionId === sessionId)
15004
+ return true;
14988
15005
  }
14989
- return lastDrainAtAny > 0 && now - lastDrainAtAny < TUI_CONNECTED_WINDOW_MS;
15006
+ return false;
14990
15007
  }
14991
- var queue, nextNotificationId = 1, lastDrainAtBySession, lastDrainAtAny = 0, TUI_CONNECTED_WINDOW_MS = 3000;
15008
+ var queue, nextNotificationId = 1, sinks;
14992
15009
  var init_rpc_notifications = __esm(() => {
14993
15010
  queue = [];
14994
- lastDrainAtBySession = new Map;
15011
+ sinks = new Set;
14995
15012
  });
14996
15013
 
14997
15014
  // ../plugin/src/shared/safe-notification-target.ts
@@ -156467,9 +156484,9 @@ function compareSemverCore(a, b) {
156467
156484
 
156468
156485
  // ../plugin/src/shared/announcement.ts
156469
156486
  init_data_path();
156470
- var ANNOUNCEMENT_VERSION = "0.30.1";
156487
+ var ANNOUNCEMENT_VERSION = "0.30.2";
156471
156488
  var ANNOUNCEMENT_FEATURES = [
156472
- "Local embeddings work on OpenCode Desktop again (#195): /ctx-embed no longer fails with 'Unsupported device: cpu' on the Desktop app."
156489
+ "Fixed high idle CPU from the TUI sidebar (#200): it now uses a single persistent connection to the plugin instead of polling, so an idle session no longer burns CPU."
156473
156490
  ];
156474
156491
  var ANNOUNCEMENT_FOOTER = "Join us on Discord: https://discord.gg/F2uWxjGnU";
156475
156492
  var STATE_FILENAME = "last_announced_version";
@@ -199799,7 +199816,7 @@ function formatThresholdPercent(value) {
199799
199816
  // package.json
199800
199817
  var package_default = {
199801
199818
  name: "@cortexkit/pi-magic-context",
199802
- version: "0.30.1",
199819
+ version: "0.30.2",
199803
199820
  type: "module",
199804
199821
  description: "Pi coding agent extension for Magic Context — cross-session memory and context management",
199805
199822
  main: "dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/pi-magic-context",
3
- "version": "0.30.1",
3
+ "version": "0.30.2",
4
4
  "type": "module",
5
5
  "description": "Pi coding agent extension for Magic Context — cross-session memory and context management",
6
6
  "main": "dist/index.js",