Skip to content

Commit 2f5cce8

Browse files
authored
Merge pull request #88 from httpsphl/feat/tokens-spent-only
feat(app): show only the tokens a bot spent, without the reread conversation
2 parents e681d78 + 143e14a commit 2f5cce8

13 files changed

Lines changed: 29 additions & 41 deletions

File tree

‎app/src/features/account/TokensByBot.tsx‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Tokens each bot used over a period (spec 8.7), in the usage dialog: the
2-
// new text read plus the replies written, with the conversation reread
3-
// each time shown apart. Each bot shows its crew, as two crews can have
2+
// new text read plus the replies written, with the conversation sent
3+
// again after a pause shown apart. Each bot shows its crew, as two crews can have
44
// bots with the same name.
55

66
import { useEffect, useState } from "react";
@@ -100,12 +100,7 @@ function Row({ bot, most }: { bot: BotTokens; most: number }) {
100100
/>
101101
</div>
102102
<span className="text-muted text-xs">
103-
{u.detail(
104-
bot.crew,
105-
bot.turns,
106-
tokens(bot.tokens.cacheRead),
107-
reloadedTokens(bot.tokens.reloaded),
108-
)}
103+
{u.detail(bot.crew, bot.turns, reloadedTokens(bot.tokens.reloaded))}
109104
</span>
110105
</div>
111106
</li>
@@ -116,17 +111,14 @@ function Total({ bots }: { bots: BotTokens[] }) {
116111
const u = useT().account.usage.tokens;
117112
const used = bots.reduce((sum, bot) => sum + usedTokens(bot.tokens), 0);
118113
const turns = bots.reduce((sum, bot) => sum + bot.turns, 0);
119-
const reread = bots.reduce((sum, bot) => sum + bot.tokens.cacheRead, 0);
120114
const reloaded = bots.reduce((sum, bot) => sum + bot.tokens.reloaded, 0);
121115
return (
122116
<li className="flex flex-col gap-1 border-line border-t pt-3">
123117
<div className="flex items-baseline justify-between gap-3 font-semibold">
124118
<span>{u.total}</span>
125119
<span className="tabular-nums">{tokens(used)}</span>
126120
</div>
127-
<span className="text-muted text-xs">
128-
{u.detail(null, turns, tokens(reread), reloadedTokens(reloaded))}
129-
</span>
121+
<span className="text-muted text-xs">{u.detail(null, turns, reloadedTokens(reloaded))}</span>
130122
</li>
131123
);
132124
}

‎app/src/features/account/tokens.test.tsx‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ describe("tokens by bot", () => {
3434
const rows = within(list).getAllByRole("listitem");
3535
// Each turn: 12 new, 1,800 into the cache and 640 written count; 24,000 reread do not.
3636
expect(rows.map((row) => row.textContent)).toEqual([
37-
"Scout4.9kOps · Worked 2 times · 48k reread",
38-
"Writer2.5kOps · Worked once · 24k reread",
39-
"All bots7.4kWorked 3 times · 72k reread",
37+
"Scout4.9kOps · Worked 2 times",
38+
"Writer2.5kOps · Worked once",
39+
"All bots7.4kWorked 3 times",
4040
]);
4141

4242
fireEvent.click(within(dialog).getByRole("radio", { name: "7 days" }));
@@ -64,7 +64,7 @@ describe("tokens by bot", () => {
6464
within(list)
6565
.getAllByRole("listitem")
6666
.map((row) => row.textContent),
67-
).toEqual(["Scout4.1kOps · Worked 2 times · 24k reread · 72k reloaded"]);
67+
).toEqual(["Scout4.1kOps · Worked 2 times · 72k reloaded"]);
6868
});
6969

7070
test("bots with the same name in two crews show their crew", async () => {
@@ -81,9 +81,9 @@ describe("tokens by bot", () => {
8181
.getAllByRole("listitem")
8282
.map((row) => row.textContent),
8383
).toEqual([
84-
"Scout2.5kNewsroom · Worked once · 24k reread",
85-
"Scout2.5kOps · Worked once · 24k reread",
86-
"All bots4.9kWorked 2 times · 48k reread",
84+
"Scout2.5kNewsroom · Worked once",
85+
"Scout2.5kOps · Worked once",
86+
"All bots4.9kWorked 2 times",
8787
]);
8888
});
8989

‎app/src/features/chat/BotRun.tsx‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ function TurnEnd({ turn }: { turn: TurnItem }) {
3737
const detail = used && {
3838
read: tokens(used.input + used.cacheWrite - used.reloaded),
3939
wrote: tokens(used.output),
40-
reread: tokens(used.cacheRead),
4140
reloaded,
4241
};
4342
return (

‎app/src/features/chat/chat.test.tsx‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,7 @@ describe("chat", () => {
9191
expect(within(chat()).getByText("Command")).toBeDefined();
9292
expect(within(chat()).getByText("npm test")).toBeDefined();
9393
const done = within(chat()).getByText("Done in 4.2 s · 2.5k tokens");
94-
expect(done.title).toBe(
95-
"Took 4.2 s. Read 1.8k new tokens and wrote 640; reread 24k of the conversation, which weighs much less.",
96-
);
94+
expect(done.title).toBe("Took 4.2 s. Read 1.8k new tokens and wrote 640.");
9795
});
9896

9997
test("an approval waits for the owner, and a denial carries a note", async () => {

‎app/src/features/chat/context.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ describe("conversation space", () => {
5353
});
5454
const done = screen.getByText("Done in 4.2 s · 1.6k tokens · reloaded the conversation (72k)");
5555
expect(done.title).toBe(
56-
"Took 4.2 s. Read 638 new tokens and wrote 983; reread 0 of the conversation, which weighs much less. It also sent 72k of the conversation again, as the model no longer had it after a pause.",
56+
"Took 4.2 s. Read 638 new tokens and wrote 983. It also sent 72k of the conversation again, as the model no longer had it after a pause.",
5757
);
5858
});
5959

‎app/src/i18n/en/account.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ export const account = {
3030
tokens: {
3131
title: "Tokens by bot",
3232
intro:
33-
"Tokens are the pieces of text a bot reads and writes. The count adds the new text read and the replies written. The conversation reread each time shows apart, as it weighs much less, and so does the conversation sent again after a pause.",
33+
"Tokens are the pieces of text a bot reads and writes. The count adds the new text read and the replies written. The conversation sent again after a pause shows apart.",
3434
period: "Period",
3535
periods: { today: "Today", week: "7 days", month: "30 days", all: "All time" },
3636
empty: "No bot worked in this period.",
3737
failed: "Could not load the tokens",
3838
archived: "archived",
3939
/** `crew` is null on the total of all bots. */
40-
detail: (crew: string | null, times: number, reread: string, reloaded: string | null) =>
41-
`${crew === null ? "" : `${crew} · `}Worked ${times === 1 ? "once" : `${times} times`} · ${reread} reread${
40+
detail: (crew: string | null, times: number, reloaded: string | null) =>
41+
`${crew === null ? "" : `${crew} · `}Worked ${times === 1 ? "once" : `${times} times`}${
4242
reloaded === null ? "" : ` · ${reloaded} reloaded`
4343
}`,
4444
total: "All bots",

‎app/src/i18n/en/chat.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
export interface TurnTokens {
77
read: string;
88
wrote: string;
9-
reread: string;
109
/** The conversation sent again after a pause, if it was worth telling. */
1110
reloaded: string | null;
1211
}
@@ -64,7 +63,7 @@ export const chat = {
6463
`Took ${time}${
6564
tokens === null
6665
? ""
67-
: `. Read ${tokens.read} new tokens and wrote ${tokens.wrote}; reread ${tokens.reread} of the conversation, which weighs much less.${
66+
: `. Read ${tokens.read} new tokens and wrote ${tokens.wrote}.${
6867
tokens.reloaded === null
6968
? ""
7069
: ` It also sent ${tokens.reloaded} of the conversation again, as the model no longer had it after a pause.`

‎app/src/i18n/es/account.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ export const account: Messages["account"] = {
3030
tokens: {
3131
title: "Tokens por bot",
3232
intro:
33-
"Los tokens son los trozos de texto que un bot lee y escribe. La cuenta suma el texto nuevo leído y las respuestas escritas. La conversación releída cada vez aparece aparte, porque pesa mucho menos, y también la conversación enviada de nuevo tras una pausa.",
33+
"Los tokens son los trozos de texto que un bot lee y escribe. La cuenta suma el texto nuevo leído y las respuestas escritas. La conversación enviada de nuevo tras una pausa aparece aparte.",
3434
period: "Período",
3535
periods: { today: "Hoy", week: "7 días", month: "30 días", all: "Todo" },
3636
empty: "Ningún bot trabajó en este período.",
3737
failed: "No se pudieron cargar los tokens",
3838
archived: "archivado",
3939
/** `crew` is null on the total of all bots. */
40-
detail: (crew: string | null, times: number, reread: string, reloaded: string | null) =>
41-
`${crew === null ? "" : `${crew} · `}Trabajó ${times === 1 ? "1 vez" : `${times} veces`} · ${reread} releídos${
40+
detail: (crew: string | null, times: number, reloaded: string | null) =>
41+
`${crew === null ? "" : `${crew} · `}Trabajó ${times === 1 ? "1 vez" : `${times} veces`}${
4242
reloaded === null ? "" : ` · ${reloaded} recargados`
4343
}`,
4444
total: "Todos los bots",

‎app/src/i18n/es/chat.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export const chat: Messages["chat"] = {
5757
`Tardó ${time}${
5858
tokens === null
5959
? ""
60-
: `. Leyó ${tokens.read} tokens nuevos y escribió ${tokens.wrote}; releyó ${tokens.reread} de la conversación, que pesa mucho menos.${
60+
: `. Leyó ${tokens.read} tokens nuevos y escribió ${tokens.wrote}.${
6161
tokens.reloaded === null
6262
? ""
6363
: ` También volvió a enviar ${tokens.reloaded} de la conversación, que el modelo ya no tenía tras una pausa.`

‎app/src/i18n/pt-BR/account.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ export const account: Messages["account"] = {
3030
tokens: {
3131
title: "Tokens por bot",
3232
intro:
33-
"Tokens são os pedaços de texto que um bot lê e escreve. A conta soma o texto novo lido e as respostas escritas. A conversa relida a cada vez aparece à parte, porque pesa bem menos, e a conversa mandada de novo depois de uma pausa também.",
33+
"Tokens são os pedaços de texto que um bot lê e escreve. A conta soma o texto novo lido e as respostas escritas. A conversa mandada de novo depois de uma pausa aparece à parte.",
3434
period: "Período",
3535
periods: { today: "Hoje", week: "7 dias", month: "30 dias", all: "Tudo" },
3636
empty: "Nenhum bot trabalhou nesse período.",
3737
failed: "Não deu para carregar os tokens",
3838
archived: "arquivado",
3939
/** `crew` is null on the total of all bots. */
40-
detail: (crew: string | null, times: number, reread: string, reloaded: string | null) =>
41-
`${crew === null ? "" : `${crew} · `}Trabalhou ${times === 1 ? "1 vez" : `${times} vezes`} · ${reread} relidos${
40+
detail: (crew: string | null, times: number, reloaded: string | null) =>
41+
`${crew === null ? "" : `${crew} · `}Trabalhou ${times === 1 ? "1 vez" : `${times} vezes`}${
4242
reloaded === null ? "" : ` · ${reloaded} recarregados`
4343
}`,
4444
total: "Todos os bots",

0 commit comments

Comments
 (0)