acp-kernel 0.0.46-pr.164.19 → 0.0.46-pr.165.20

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.js CHANGED
@@ -2914,7 +2914,7 @@ function collectVisible(messages, state, countTokens) {
2914
2914
  if (!ref) return;
2915
2915
  const tokens = countTokens(message.text ?? "");
2916
2916
  const tool = message.toolName ?? "text";
2917
- if (tokens > 0) visible.push({ ref, tokens, tool, index });
2917
+ if (tokens > 0) visible.push({ ref, tokens, tool, index, isUser: message.role === "user" });
2918
2918
  });
2919
2919
  return { visible, summaryTokens };
2920
2920
  }
@@ -2933,7 +2933,7 @@ function buildStatusReport(state, messages, countTokens, options = {}) {
2933
2933
  if (view === "messages") {
2934
2934
  return renderMessageDrilldown(visible, toolFilter, sort, limit);
2935
2935
  }
2936
- return renderUncompressedRanges(visible);
2936
+ return renderUncompressedRanges(visible, sort, limit);
2937
2937
  }
2938
2938
  return renderOverview(visible, summaryTokens, activeBlocks2, state, countTokens, limit);
2939
2939
  }
@@ -2988,7 +2988,7 @@ function renderOverview(visible, summaryTokens, blocks, state, countTokens, limi
2988
2988
  );
2989
2989
  return lines.join("\n");
2990
2990
  }
2991
- function renderUncompressedRanges(visible) {
2991
+ function renderUncompressedRanges(visible, sort, limit) {
2992
2992
  const lines = [];
2993
2993
  const totalTokens = visible.reduce((s, m) => s + m.tokens, 0);
2994
2994
  lines.push(`UNCOMPRESSED \u2014 ${formatTokens2(totalTokens)} | ${visible.length} visible messages`);
@@ -3005,7 +3005,9 @@ function renderUncompressedRanges(visible) {
3005
3005
  for (const m of visible) {
3006
3006
  const num = refNum2(m.ref);
3007
3007
  const last = merged[merged.length - 1];
3008
- if (last && num === last.startNum + last.count) {
3008
+ const contiguous = !!last && num === last.startNum + last.count;
3009
+ const turnBoundary = !!last && m.isUser && last.count >= 3;
3010
+ if (contiguous && !turnBoundary) {
3009
3011
  last.endRef = m.ref;
3010
3012
  last.count += 1;
3011
3013
  last.tokens += m.tokens;
@@ -3013,12 +3015,16 @@ function renderUncompressedRanges(visible) {
3013
3015
  merged.push({ startRef: m.ref, endRef: m.ref, startNum: num, count: 1, tokens: m.tokens, tool: m.tool });
3014
3016
  }
3015
3017
  }
3016
- for (const r of merged.slice(0, 30)) {
3018
+ if (sort !== "time") merged.sort((a, b) => b.tokens - a.tokens || a.startNum - b.startNum);
3019
+ lines.push(`Sorted by ${sort === "time" ? "time" : "size"}`);
3020
+ lines.push("");
3021
+ const shown = merged.slice(0, limit);
3022
+ for (const r of shown) {
3017
3023
  const range = r.count === 1 ? r.startRef : `${r.startRef}\u2013${r.endRef}`;
3018
3024
  lines.push(` ${range} (${r.count} msgs, ${formatTokens2(r.tokens)}${r.count > 1 ? ` (${Math.round(r.tokens / r.count)}/msg)` : ""}) ${r.tool}`);
3019
3025
  }
3020
- if (merged.length > 30) {
3021
- lines.push(` ... and ${merged.length - 30} more ranges`);
3026
+ if (merged.length > shown.length) {
3027
+ lines.push(` ... and ${merged.length - shown.length} more ranges`);
3022
3028
  }
3023
3029
  return lines.join("\n");
3024
3030
  }