feat(agents): Current branch and time spent in the agent session header

A local-checkout task shows the repository's current branch in its header, and
Changes compares against it; both follow branch switches. The header also shows
the time the agent has spent on the task's turns.

A usage update without a cost (Claude sends one for its rate limits) no longer
clears the session cost.
Цей коміт міститься в:
l0ng-ai committed 2026-10-28 11:57:18 +08:00
1 джерело 6e4d927ff0
коміт 93f87f49c1
7 files changed
+149 -38

No files matched your search

+20
Переглянути файл
@@ -14,6 +14,7 @@ import {
recall,
toPrompt,
usageLabel,
workTime,
} from "./composerModel";
import { age, attentionChange, branchLabel, groupTasks, upsertEntry } from "./model";
import { markdownHtml } from "./Markdown";
@@ -132,6 +133,25 @@ describe("agent composer", () => {
});
});
describe("usage meters", () => {
it("formats token counts", () => {
expect(usageLabel({ used: 83_100, size: 1_000_000, cost: null, currency: null }).detail).toBe("83.1k / 1M tokens");
});
it("adds up the time spent on turns", () => {
const user = (sentMs: number, doneMs: number | null): AgentEntry => ({
type: "user",
text: "",
attachments: [],
sentMs,
doneMs,
});
const entries = [user(0, 5_000), { type: "agent", text: "" } as AgentEntry, user(10_000, null)];
expect(workTime(entries, 12_000)).toBe(7_000);
expect(workTime(entries, null)).toBe(5_000);
});
});
describe("agents model", () => {
it("groups tasks by what they need, newest first", () => {
const groups = groupTasks([