agentgui 1.0.734 → 1.0.735

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/database.js +18 -22
  2. package/package.json +1 -1
package/database.js CHANGED
@@ -1523,29 +1523,25 @@ export const queries = {
1523
1523
  },
1524
1524
 
1525
1525
  getRecentConversationChunks(conversationId, limit = 500) {
1526
- // Always include the complete latest session so tool_use/tool_result pairs are intact.
1527
- // Then fill remaining capacity with older chunks.
1528
- const latestSession = prep(
1529
- `SELECT sessionId FROM chunks WHERE conversationId = ? ORDER BY created_at DESC LIMIT 1`
1530
- ).get(conversationId);
1531
- if (!latestSession) return [];
1532
- const latestSid = latestSession.sessionId;
1533
- const latestRows = prep(
1534
- `SELECT id, sessionId, conversationId, sequence, type, data, created_at
1535
- FROM chunks WHERE conversationId = ? AND sessionId = ? ORDER BY created_at ASC`
1536
- ).all(conversationId, latestSid);
1537
- const remaining = limit - latestRows.length;
1538
- let olderRows = [];
1539
- if (remaining > 0) {
1540
- const oldestLatest = latestRows.length ? latestRows[0].created_at : Date.now();
1541
- olderRows = prep(
1542
- `SELECT id, sessionId, conversationId, sequence, type, data, created_at
1543
- FROM chunks WHERE conversationId = ? AND sessionId != ? AND created_at < ?
1544
- ORDER BY created_at DESC LIMIT ?`
1545
- ).all(conversationId, latestSid, oldestLatest, remaining);
1546
- olderRows.reverse();
1526
+ const sessions = prep(
1527
+ `SELECT sessionId, COUNT(*) as n FROM chunks WHERE conversationId = ?
1528
+ GROUP BY sessionId ORDER BY MAX(created_at) DESC`
1529
+ ).all(conversationId);
1530
+ if (!sessions.length) return [];
1531
+ const included = [];
1532
+ let total = 0;
1533
+ for (const s of sessions) {
1534
+ if (total + s.n > limit && included.length > 0) break;
1535
+ included.unshift(s.sessionId);
1536
+ total += s.n;
1547
1537
  }
1548
- return [...olderRows, ...latestRows].map(row => {
1538
+ const placeholders = included.map(() => '?').join(',');
1539
+ const rows = prep(
1540
+ `SELECT id, sessionId, conversationId, sequence, type, data, created_at
1541
+ FROM chunks WHERE conversationId = ? AND sessionId IN (${placeholders})
1542
+ ORDER BY created_at ASC`
1543
+ ).all(conversationId, ...included);
1544
+ return rows.map(row => {
1549
1545
  try { return { ...row, data: typeof row.data === 'string' ? JSON.parse(row.data) : row.data }; }
1550
1546
  catch (e) { return row; }
1551
1547
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.734",
3
+ "version": "1.0.735",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "electron/main.js",