@yeaft/webchat-agent 0.0.21 → 0.0.23

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/history.js +15 -4
  2. package/package.json +1 -1
package/history.js CHANGED
@@ -86,15 +86,18 @@ export async function getHistorySessions(workDir) {
86
86
  let title = '';
87
87
  let firstMessage = '';
88
88
  let hasUserMessage = false;
89
+ let customTitle = '';
90
+ let jsonlSummary = '';
89
91
 
90
92
  try {
91
93
  const content = readFileSync(filePath, 'utf-8');
92
94
  const lines = content.split('\n').filter(l => l.trim());
93
95
 
94
- for (const line of lines.slice(0, 30)) {
96
+ for (const line of lines) {
95
97
  try {
96
98
  const data = JSON.parse(line);
97
- if (data.type === 'user' && data.message?.content) {
99
+ // First user message → preview + fallback title
100
+ if (!hasUserMessage && data.type === 'user' && data.message?.content) {
98
101
  const text = typeof data.message.content === 'string'
99
102
  ? data.message.content
100
103
  : data.message.content[0]?.text || '';
@@ -102,9 +105,16 @@ export async function getHistorySessions(workDir) {
102
105
  firstMessage = text.substring(0, 100);
103
106
  title = text.substring(0, 100);
104
107
  hasUserMessage = true;
105
- break;
106
108
  }
107
109
  }
110
+ // /rename → custom-title (keep last occurrence)
111
+ if (data.type === 'custom-title' && data.customTitle) {
112
+ customTitle = data.customTitle;
113
+ }
114
+ // Auto-generated summary
115
+ if (data.type === 'summary' && data.summary) {
116
+ jsonlSummary = data.summary;
117
+ }
108
118
  } catch {}
109
119
  }
110
120
  } catch (e) {
@@ -113,10 +123,11 @@ export async function getHistorySessions(workDir) {
113
123
 
114
124
  // 只添加有实际用户消息的会话,过滤掉空会话
115
125
  if (hasUserMessage) {
126
+ // Priority: custom-title (/rename) > auto-generated summary > first user message
116
127
  sessions.push({
117
128
  sessionId,
118
129
  workDir,
119
- title: title || sessionId.slice(0, 8),
130
+ title: customTitle || jsonlSummary || title || sessionId.slice(0, 8),
120
131
  preview: firstMessage,
121
132
  lastModified: stats.mtime.getTime(),
122
133
  size: stats.size
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",