@hienlh/ppm 0.9.37 → 0.9.39

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.9.39] - 2026-04-06
4
+
5
+ ### Fixed
6
+ - **Stream hangs 3 minutes after AI finishes**: `done` event was received but the `for-await` loop didn't break — `break` inside `switch` only exits the switch, not the loop. Used labeled `break eventLoop` to properly terminate on `done`.
7
+ - **Identity never saved to memory**: Memory extraction only ran on session end. Now saves identity directly when user responds to onboarding prompt, and runs AI extraction every 5 messages.
8
+
3
9
  ## [0.9.36] - 2026-04-06
4
10
 
5
11
  ### Fixed
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hienlh/ppm",
3
- "version": "0.9.37",
3
+ "version": "0.9.39",
4
4
  "description": "Personal Project Manager — mobile-first web IDE with AI assistance",
5
5
  "author": "hienlh",
6
6
  "license": "MIT",
@@ -36,6 +36,15 @@ class PPMBotService {
36
36
  /** Sessions that already had their title set */
37
37
  private titledSessions = new Set<string>();
38
38
 
39
+ /** Chat IDs that just received identity onboarding prompt */
40
+ private identityPending = new Set<string>();
41
+
42
+ /** Message count per session for periodic memory save */
43
+ private messageCount = new Map<string, number>();
44
+
45
+ /** Interval (messages) between automatic memory saves */
46
+ private readonly MEMORY_SAVE_INTERVAL = 5;
47
+
39
48
  // ── Lifecycle ─────────────────────────────────────────────────
40
49
 
41
50
  async start(): Promise<void> {
@@ -77,6 +86,8 @@ class PPMBotService {
77
86
  this.debouncedTexts.clear();
78
87
  this.processing.clear();
79
88
  this.messageQueue.clear();
89
+ this.identityPending.clear();
90
+ this.messageCount.clear();
80
91
 
81
92
  console.log("[ppmbot] Stopped");
82
93
  }
@@ -192,6 +203,7 @@ class PPMBotService {
192
203
  // Identity onboarding: if no identity memories exist, ask user
193
204
  const identityMemories = this.memory.recall("_global", "user identity name role");
194
205
  if (identityMemories.length === 0) {
206
+ this.identityPending.add(chatId);
195
207
  await this.telegram!.sendMessage(
196
208
  Number(chatId),
197
209
  "📝 <b>Quick intro?</b>\n\n" +
@@ -430,6 +442,22 @@ class PPMBotService {
430
442
  },
431
443
  );
432
444
 
445
+ // Capture identity if onboarding was just shown
446
+ if (this.identityPending.has(chatId)) {
447
+ this.identityPending.delete(chatId);
448
+ this.memory.saveOne("_global", `User identity: ${text}`, "preference", session.sessionId);
449
+ console.log("[ppmbot] Saved identity memory from onboarding");
450
+ }
451
+
452
+ // Periodic memory extraction — fire-and-forget every N messages
453
+ const count = (this.messageCount.get(session.sessionId) ?? 0) + 1;
454
+ this.messageCount.set(session.sessionId, count);
455
+ if (count % this.MEMORY_SAVE_INTERVAL === 0) {
456
+ this.saveSessionMemory(chatId).catch((err) =>
457
+ console.warn("[ppmbot] Periodic memory save failed:", (err as Error).message),
458
+ );
459
+ }
460
+
433
461
  // Check context window — auto-rotate if near limit
434
462
  if (
435
463
  result.contextWindowPct != null &&
@@ -151,7 +151,7 @@ export async function streamToTelegram(
151
151
  // Process event stream with per-event timeout
152
152
  let eventCount = 0;
153
153
  try {
154
- for await (const event of withEventTimeout(events, EVENT_TIMEOUT_MS)) {
154
+ eventLoop: for await (const event of withEventTimeout(events, EVENT_TIMEOUT_MS)) {
155
155
  eventCount++;
156
156
  // Debug: log each event type to help diagnose streaming issues
157
157
  if (event.type !== "text") {
@@ -207,7 +207,7 @@ export async function streamToTelegram(
207
207
  case "done": {
208
208
  result.contextWindowPct = event.contextWindowPct;
209
209
  result.resultSubtype = event.resultSubtype;
210
- break;
210
+ break eventLoop; // break the for-await, not just the switch
211
211
  }
212
212
 
213
213
  case "session_migrated": {