Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/server/src/guide/topics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ While this computer is asleep or Threadlines is closed, assistants are told it's

Claude's models come from Claude Code itself, so a new one shows up without a Threadlines update. A model Threadlines has no settings of its own for starts on Default reasoning: no level is sent and Claude Code picks one. When Claude Code stops listing a model, the picker stops offering it, but a thread, room agent or setting already on it keeps it.

How much of each plan you've used is on {place:usage}. The ring beside the composer's send button shows the same limits when you hover or tap it; a short upright tick on each bar marks how much of that limit's window has passed, so a bar filled past its tick is on track to run out before the reset, and its line says "ahead of pace" once it is clearly past. Clicking a limit there opens {place:usage}.
How much of each plan you've used is on {place:usage}. The ring beside the composer's send button shows the same limits when you hover or tap it; a short upright tick on each bar marks how much of that limit's window has passed (hover the tick for the exact share, "55% of the week has passed"), so a bar filled past its tick is on track to run out before the reset, and its line says "ahead of pace" once it is clearly past. The same ticks show on a provider's Usage tab in Settings › Providers. Clicking a limit there opens {place:usage}.

An agent's row that says Can't start means its program is on this computer but fails to launch, usually because an update stopped partway. It is not a sign-in problem: the sign-in is still saved. The row has Reinstall when Threadlines can put that same copy back: with npm, bun or Homebrew for a copy they installed, or with the agent's own installer for a copy sitting where that installer puts it (Claude, OpenCode, Cursor, fx, Muse Code, and Codex on Windows). For Pi it reinstalls an npm copy, or installs Threadlines' own copy of Pi. There is no Reinstall for a copy from pnpm, Scoop, winget or Nix, for one at a custom path, or for Grok from xAI's installer (it would switch the release channel); reinstall those the way they were installed. An update that leaves an agent unable to start runs that reinstall once on its own before reporting. Community agents are installed by Threadlines itself and have Install again instead. Antigravity is downloaded and checked by Threadlines, so it isn't covered.

Expand Down
11 changes: 9 additions & 2 deletions apps/web/src/components/ProviderUsageDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { Button } from "./ui/button";
import { SegmentedControl, SegmentedControlItem } from "./ui/segmented-control";
import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
import { ProviderExternalResetsButton } from "./ProviderRateLimitResetCredit";
import { UsagePaceMark, usagePaceLabel } from "./usage/UsagePaceMark";

type TokenActivityMode = "daily" | "weekly" | "cumulative";
type TokenActivityRange = "13-weeks" | "1-year";
Expand Down Expand Up @@ -448,16 +449,22 @@ function UsageLimitBar(props: {
</div>
<div
role="meter"
aria-label={`${props.usageLabel} ${props.window.label} ${props.window.usedPercent}% used`}
aria-label={`${props.usageLabel} ${props.window.label} ${props.window.usedPercent}% used${usagePaceLabel(props.window.paceDetail)}`}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={props.window.usedPercent}
className="h-1.5 overflow-hidden rounded-full bg-muted"
className="relative h-1.5 rounded-full bg-muted"
>
<div
className={cn("h-full rounded-full transition-[width]", !meterColor && "bg-primary")}
style={{ width: `${props.window.usedPercent}%`, backgroundColor: meterColor }}
/>
{props.window.elapsedPercent !== undefined && props.window.paceDetail !== undefined ? (
<UsagePaceMark
elapsedPercent={props.window.elapsedPercent}
detail={props.window.paceDetail}
/>
) : null}
</div>
</div>
);
Expand Down
14 changes: 11 additions & 3 deletions apps/web/src/components/chat/ContextWindowMeter.browser.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import "../../index.css";

import { page } from "vite-plus/test/browser";
import { page, userEvent } from "vite-plus/test/browser";
import { describe, expect, it, vi } from "vite-plus/test";
import { render } from "vitest-browser-react";

Expand Down Expand Up @@ -121,7 +121,9 @@ describe("ContextWindowMeter", () => {
accountUsage={{
...TEST_ACCOUNT_USAGE,
windows: TEST_ACCOUNT_USAGE.windows.map((window) =>
window.key === "secondary" ? { ...window, elapsedPercent: 14.3 } : window,
window.key === "secondary"
? { ...window, elapsedPercent: 14.3, paceDetail: "14% of the week has passed" }
: window,
),
}}
onOpenUsage={openUsage}
Expand All @@ -135,7 +137,13 @@ describe("ContextWindowMeter", () => {
expect(paceMarks).toHaveLength(1);
expect(paceMarks[0]?.style.left).toBe("14.3%");

await page.getByRole("button", { name: /Weekly 36% used, 14% of the window passed/ }).click();
// Hovering the mark says what it measures.
await userEvent.hover(paceMarks[0]!);
await expect.element(page.getByText("14% of the week has passed")).toBeVisible();

await page
.getByRole("button", { name: /Weekly 36% used, 14% of the week has passed/ })
.click();
expect(openUsage).toHaveBeenCalledTimes(1);
// The row closes the popover. Checked on the meter's own state: the popup
// leaves the page only after its fade-out, which needs frames a busy CI
Expand Down
8 changes: 5 additions & 3 deletions apps/web/src/components/chat/ContextWindowMeter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,11 @@ function AccountUsageBar(props: {
usedPercent: number;
warning: boolean;
elapsedPercent?: number | undefined;
paceDetail?: string | undefined;
onOpen?: (() => void) | undefined;
}) {
const meterColor = usageMeterColor(props.usedPercent, props.warning);
const meterLabel = `${props.usageLabel} ${props.rowLabel} ${props.usedPercent}% used${usagePaceLabel(props.elapsedPercent)}`;
const meterLabel = `${props.usageLabel} ${props.rowLabel} ${props.usedPercent}% used${usagePaceLabel(props.paceDetail)}`;
const content = (
<>
<span className="flex min-w-0 items-baseline justify-between gap-3 text-xs">
Expand All @@ -62,8 +63,8 @@ function AccountUsageBar(props: {
)}
style={{ width: `${props.usedPercent}%`, backgroundColor: meterColor }}
/>
{props.elapsedPercent !== undefined ? (
<UsagePaceMark elapsedPercent={props.elapsedPercent} />
{props.elapsedPercent !== undefined && props.paceDetail !== undefined ? (
<UsagePaceMark elapsedPercent={props.elapsedPercent} detail={props.paceDetail} />
) : null}
</span>
</>
Expand Down Expand Up @@ -582,6 +583,7 @@ export function ContextWindowMeter(props: {
usedPercent={window.usedPercent}
warning={window.warning}
elapsedPercent={window.elapsedPercent}
paceDetail={window.paceDetail}
onOpen={openUsage}
/>
))}
Expand Down
49 changes: 34 additions & 15 deletions apps/web/src/components/usage/UsagePaceMark.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,47 @@
import { cn } from "~/lib/utils";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";

/**
* The pace mark on a usage bar: a short upright tick at how much of the
* window has passed. Usage that stops left of it lasts until the reset. Put it
* inside the bar's track, which needs `relative` and must not clip it.
*
* Hovering the tick says how much of the window has passed (`detail`, from the
* shared usage presentation). The hover area is wider than the tick so it can
* be found; keyboard and screen reader users get the same words from the
* bar's accessible name (`usagePaceLabel`).
*/
export function UsagePaceMark(props: { elapsedPercent: number; className?: string }) {
export function UsagePaceMark(props: {
elapsedPercent: number;
detail: string;
className?: string;
}) {
const left = Math.max(0, Math.min(100, props.elapsedPercent));
return (
<span
aria-hidden="true"
data-usage-pace-mark=""
className={cn(
"-translate-x-1/2 -translate-y-1/2 pointer-events-none absolute top-1/2 h-2.5 w-0.5 rounded-full bg-foreground",
props.className,
)}
style={{ left: `${left}%` }}
/>
<Tooltip>
<TooltipTrigger
render={
<span
data-usage-pace-mark=""
className="-translate-x-1/2 -translate-y-1/2 absolute top-1/2 flex h-4 w-3 items-center justify-center"
style={{ left: `${left}%` }}
/>
}
>
<span
aria-hidden="true"
className={cn("block h-2.5 w-0.5 rounded-full bg-foreground", props.className)}
/>
</TooltipTrigger>
<TooltipPopup side="top">
<p className="font-medium">{props.detail}</p>
<p className="text-muted-foreground">Usage left of this line lasts until the reset</p>
</TooltipPopup>
</Tooltip>
);
}

/** "12% used, 5% of the window passed", for a usage bar's accessible name. */
export function usagePaceLabel(elapsedPercent: number | undefined): string {
return elapsedPercent === undefined
? ""
: `, ${Math.round(elapsedPercent)}% of the window passed`;
/** ", 44% of the week has passed", for a usage bar's accessible name. */
export function usagePaceLabel(detail: string | undefined): string {
return detail === undefined ? "" : `, ${detail}`;
}
8 changes: 6 additions & 2 deletions apps/web/src/components/usage/UsageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,12 @@ function UsagePlanLimits({
usageMeterColor(meter.usedPercent, meter.warning) ?? fill,
}}
/>
{meter.elapsedPercent !== undefined ? (
<UsagePaceMark elapsedPercent={meter.elapsedPercent} className="h-2" />
{meter.elapsedPercent !== undefined && meter.paceDetail !== undefined ? (
<UsagePaceMark
elapsedPercent={meter.elapsedPercent}
detail={meter.paceDetail}
className="h-2"
/>
) : null}
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion apps/web/src/components/usage/usageView.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,8 @@ export interface UsagePlanLimitMeter {
readonly reachedLimit: boolean;
/** How much of the window has passed, for the pace mark; see the shared presentation. */
readonly elapsedPercent?: number;
/** The pace mark's hover text, set with `elapsedPercent`. */
readonly paceDetail?: string;
}

export interface UsagePlanLimitRow {
Expand Down Expand Up @@ -1033,7 +1035,9 @@ export function buildUsagePlanLimitRows(
usedPercent: window.usedPercent,
warning: window.warning,
reachedLimit: window.reachedLimit,
...(window.elapsedPercent !== undefined ? { elapsedPercent: window.elapsedPercent } : {}),
...(window.elapsedPercent !== undefined && window.paceDetail !== undefined
? { elapsedPercent: window.elapsedPercent, paceDetail: window.paceDetail }
: {}),
}));
if (presentation.spendControl) {
meters.push({
Expand Down
16 changes: 16 additions & 0 deletions apps/web/src/lib/providerUsage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 80,
paceDetail: "80% of the 5-hour window has passed",
},
],
});
Expand Down Expand Up @@ -113,6 +114,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 80,
paceDetail: "80% of the 5-hour window has passed",
},
{
key: "secondary",
Expand All @@ -123,6 +125,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 0,
paceDetail: "0% of the week has passed",
},
],
});
Expand Down Expand Up @@ -336,6 +339,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 80,
paceDetail: "80% of the 5-hour window has passed",
},
],
});
Expand Down Expand Up @@ -418,6 +422,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 49.3,
paceDetail: "49% of the 5-hour window has passed",
},
{
key: "secondary",
Expand All @@ -428,6 +433,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 0,
paceDetail: "0% of the week has passed",
},
],
});
Expand Down Expand Up @@ -478,6 +484,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 49.3,
paceDetail: "49% of the 5-hour window has passed",
},
{
key: "secondary",
Expand All @@ -488,6 +495,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 0,
paceDetail: "0% of the week has passed",
},
{
key: "scoped-0",
Expand All @@ -499,6 +507,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: true,
elapsedPercent: 0,
paceDetail: "0% of the week has passed",
scope: { name: "Fable", period: "Weekly", resetDetail: "resets in 7d" },
},
]);
Expand Down Expand Up @@ -554,6 +563,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: true,
warning: true,
elapsedPercent: 0,
paceDetail: "0% of the week has passed",
scope: { name: "Fable", period: "Weekly", resetDetail: "resets in 7d" },
},
]);
Expand Down Expand Up @@ -598,6 +608,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: true,
warning: true,
elapsedPercent: 33.3,
paceDetail: "33% of the 5-hour window has passed",
},
{
key: "secondary",
Expand All @@ -608,6 +619,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 78.7,
paceDetail: "79% of the week has passed",
},
],
});
Expand Down Expand Up @@ -657,6 +669,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: true,
warning: true,
elapsedPercent: 33.3,
paceDetail: "33% of the 5-hour window has passed",
},
{
key: "secondary",
Expand All @@ -667,6 +680,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 78.7,
paceDetail: "79% of the week has passed",
},
],
});
Expand Down Expand Up @@ -716,6 +730,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: false,
warning: false,
elapsedPercent: 33.3,
paceDetail: "33% of the 5-hour window has passed",
},
{
key: "secondary",
Expand All @@ -726,6 +741,7 @@ describe("deriveProviderAccountUsagePresentation", () => {
reachedLimit: true,
warning: true,
elapsedPercent: 78.7,
paceDetail: "79% of the week has passed",
},
],
});
Expand Down
37 changes: 35 additions & 2 deletions apps/web/src/lib/providerUsage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ export interface ProviderAccountUsageWindowPresentation {
* resets.
*/
readonly elapsedPercent?: number;
/**
* The pace mark's hover text, "44% of the week has passed". Set exactly
* when `elapsedPercent` is.
*/
readonly paceDetail?: string;
/**
* Set on a window that caps one model, not the whole account (Claude's
* per-model weekly limits): the name the provider gives it ("Fable"), its
Expand Down Expand Up @@ -250,6 +255,34 @@ export function usageWindowElapsedPercent(
return Math.round((1 - remainingMs / durationMs) * 1000) / 10;
}

/** "the week", "the day", "the 5-hour window": the span a pace mark measures. */
function formatUsageWindowSpan(minutes: number): string {
if (minutes === 10_080) return "the week";
if (minutes === 1_440) return "the day";
if (minutes % 1_440 === 0) return `the ${minutes / 1_440}-day window`;
if (minutes % 60 === 0) return `the ${minutes / 60}-hour window`;
return `the ${minutes}-minute window`;
}

/** "44% of the week has passed", for the pace mark's hover text. */
function formatUsagePaceDetail(
window: Pick<ServerProviderUsageWindow, "windowDurationMins">,
elapsedPercent: number | undefined,
): string | null {
const minutes = window.windowDurationMins;
if (elapsedPercent === undefined || minutes === undefined) return null;
return `${Math.round(elapsedPercent)}% of ${formatUsageWindowSpan(minutes)} has passed`;
}

/** The pace fields of a window presentation: both or neither. */
function usagePaceFields(
window: Pick<ServerProviderUsageWindow, "windowDurationMins">,
elapsedPercent: number | undefined,
): Pick<ProviderAccountUsageWindowPresentation, "elapsedPercent" | "paceDetail"> {
const paceDetail = formatUsagePaceDetail(window, elapsedPercent);
return elapsedPercent !== undefined && paceDetail !== null ? { elapsedPercent, paceDetail } : {};
}

/**
* How far usage may run past the pace mark before the detail says so, in
* percentage points. Keeps a bar sitting on its mark, or one early in its
Expand Down Expand Up @@ -453,7 +486,7 @@ function formatUsageWindowPresentation(
remainingPercent,
reachedLimit: windowReachedLimit,
warning: windowReachedLimit || usedPercent >= USAGE_WARNING_THRESHOLD_PERCENT,
...(elapsedPercent !== undefined ? { elapsedPercent } : {}),
...usagePaceFields(window, elapsedPercent),
};
}

Expand Down Expand Up @@ -493,7 +526,7 @@ function formatScopedUsageWindowPresentation(
remainingPercent,
reachedLimit,
warning: reachedLimit || severityWarning || usedPercent >= USAGE_WARNING_THRESHOLD_PERCENT,
...(elapsedPercent !== undefined ? { elapsedPercent } : {}),
...usagePaceFields(window, elapsedPercent),
scope: { name: window.scopeLabel, period: durationLabel || null, resetDetail },
};
}
Expand Down
Loading