Skip to content

Commit 96e5b2e

Browse files
add system prompt to bargraph session representation and use full braille ⣿ for current compress range
1 parent ed7e66f commit 96e5b2e

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

lib/tools/compress.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,18 @@ export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {
408408

409409
// Build token weight map for all messages (for proportional bar graph)
410410
const weights = new Map<string, number>()
411+
let contentWeight = 0
411412
for (const msg of messages) {
412-
weights.set(msg.info.id, countAllMessageTokens(msg))
413+
const w = countAllMessageTokens(msg)
414+
weights.set(msg.info.id, w)
415+
contentWeight += w
413416
}
414417

418+
// System prompt = API total minus message content
419+
const systemWeight = Math.max(0, totalSessionTokens - contentWeight)
420+
const sessionIds = ["__system__", ...messages.map((m) => m.info.id)]
421+
weights.set("__system__", systemWeight)
422+
415423
await sendCompressNotification(
416424
client,
417425
logger,
@@ -425,7 +433,7 @@ export function createCompressTool(ctx: ToolContext): ReturnType<typeof tool> {
425433
summaryTokens,
426434
totalSessionTokens,
427435
estimatedCompressedTokens,
428-
messages.map((m) => m.info.id),
436+
sessionIds,
429437
weights,
430438
messages.length,
431439
currentParams,

lib/ui/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ export function formatSessionMap(
216216
if (prunedMessages.has(messageIds[m])) {
217217
const start = Math.floor((cum[m] / totalWeight) * width)
218218
const end = Math.floor((cum[m + 1] / totalWeight) * width)
219-
const char = newPrunedIds.has(messageIds[m]) ? "" : "░"
219+
const char = newPrunedIds.has(messageIds[m]) ? "" : "░"
220220
for (let i = start; i < end; i++) {
221221
bar[i] = char
222222
}

0 commit comments

Comments
 (0)