@threadbase-sh/streamer 1.15.0 → 1.15.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/index.cjs CHANGED
@@ -5104,28 +5104,37 @@ var StreamerServer = class {
5104
5104
  projectName: body.projectName,
5105
5105
  branch: body.branch
5106
5106
  });
5107
- if (conv) {
5108
- session.sessionName = conv.sessionName ?? void 0;
5109
- session.messageCount = conv.messageCount ?? 0;
5110
- session.account = conv.account ?? void 0;
5111
- session.filePath = conv.filePath ?? void 0;
5112
- const scanner = await this.getScanner();
5113
- const meta = conv.filePath ? scanner.getMetadataCache().get(conv.filePath) : void 0;
5114
- if (meta) {
5115
- session.model = meta.model ?? void 0;
5116
- session.preview = meta.preview ?? void 0;
5117
- session.firstMessageText = meta.firstMessage?.text ?? void 0;
5118
- session.firstMessageAt = meta.firstMessage?.timestamp ? new Date(meta.firstMessage.timestamp) : void 0;
5119
- session.lastMessageText = meta.lastMessage?.text ?? void 0;
5120
- session.lastMessageAt = meta.lastMessage?.timestamp ? new Date(meta.lastMessage.timestamp) : void 0;
5107
+ this.sessionStore.addManaged(session);
5108
+ void this.watchConversationFile(sessionId);
5109
+ const resp = this.sessionStore.get(session.id, this.ptyAttachedIds());
5110
+ this.broadcastOrUnicastSessionList(req);
5111
+ json(res, 201, resp ?? session);
5112
+ this.enrichResumedSessionAsync(sessionId, projectPath, conv);
5113
+ }
5114
+ enrichResumedSessionAsync(sessionId, projectPath, conv) {
5115
+ try {
5116
+ const session = this.sessionStore.get(sessionId, this.ptyAttachedIds());
5117
+ if (!session) return;
5118
+ if (conv) {
5119
+ session.sessionName = conv.sessionName ?? void 0;
5120
+ session.messageCount = conv.messageCount ?? 0;
5121
+ session.account = conv.account ?? void 0;
5122
+ session.filePath = conv.filePath ?? void 0;
5121
5123
  }
5122
- }
5123
- if (this.cache && this.projectsRepo && this.conversationsRepo) {
5124
- let resolvedProjectId = null;
5125
- const cachedConv = this.cache.getMetaById(sessionId);
5126
- if (cachedConv?.projectId) {
5127
- resolvedProjectId = cachedConv.projectId;
5128
- } else {
5124
+ if (!this.cache || !this.projectsRepo || !this.conversationsRepo) return;
5125
+ const cached2 = this.cache.getMetaById(sessionId);
5126
+ if (cached2) {
5127
+ session.model = cached2.model ?? void 0;
5128
+ session.preview = cached2.preview ?? void 0;
5129
+ const first = cached2.firstMessage ? JSON.parse(cached2.firstMessage) : null;
5130
+ const last = cached2.lastMessage ? JSON.parse(cached2.lastMessage) : null;
5131
+ session.firstMessageText = first?.text ?? void 0;
5132
+ session.firstMessageAt = first?.timestamp ? new Date(first.timestamp).toISOString() : void 0;
5133
+ session.lastMessageText = last?.text ?? void 0;
5134
+ session.lastMessageAt = last?.timestamp ? new Date(last.timestamp).toISOString() : void 0;
5135
+ }
5136
+ let resolvedProjectId = cached2?.projectId ?? null;
5137
+ if (!resolvedProjectId) {
5129
5138
  const project = this.projectsRepo.upsertProjectByPath(projectPath);
5130
5139
  resolvedProjectId = project.id;
5131
5140
  this.conversationsRepo.updateConversationProjectId({
@@ -5137,12 +5146,9 @@ var StreamerServer = class {
5137
5146
  session.projectId = resolvedProjectId;
5138
5147
  session.resumedFromConversationId = sessionId;
5139
5148
  }
5149
+ } catch (err) {
5150
+ console.error(`[enrichResumedSessionAsync] ${sessionId}:`, err);
5140
5151
  }
5141
- this.sessionStore.addManaged(session);
5142
- void this.watchConversationFile(sessionId);
5143
- const resp = this.sessionStore.get(session.id, this.ptyAttachedIds());
5144
- this.broadcastOrUnicastSessionList(req);
5145
- json(res, 201, resp ?? session);
5146
5152
  }
5147
5153
  async handleSendInput(sessionId, req, res) {
5148
5154
  if (this.agentConfig.enabled) {