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 @@ -294,7 +294,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}.
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}.

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
4 changes: 4 additions & 0 deletions apps/web/src/components/chat/ChatComposer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
useState,
} from "react";
import { useQuery } from "@tanstack/react-query";
import { useNavigate } from "@tanstack/react-router";
import { useDebouncedValue } from "@tanstack/react-pacer";
import { serializeComposerMentionPath } from "~/composerMentionPath";
import type { FileSelectionContextDraft } from "~/lib/fileSelectionContext";
Expand Down Expand Up @@ -376,6 +377,8 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions(
contextCompactInFlight?: boolean | undefined;
contextCompactDisabledReason?: string | null | undefined;
}) {
const navigate = useNavigate();
const openUsage = useCallback(() => void navigate({ to: "/usage" }), [navigate]);
return (
<>
<ContextWindowMeter
Expand All @@ -392,6 +395,7 @@ const ComposerFooterPrimaryActions = memo(function ComposerFooterPrimaryActions(
contextWindowLabel={props.contextWindowLabel}
onResetAccountUsage={props.onResetAccountUsage}
accountUsageResetInFlight={props.accountUsageResetInFlight}
onOpenUsage={openUsage}
onCompactContext={props.onCompactContext}
contextCompactDisabled={props.contextCompactDisabled}
contextCompactInFlight={props.contextCompactInFlight}
Expand Down
30 changes: 30 additions & 0 deletions apps/web/src/components/chat/ContextWindowMeter.browser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,36 @@ describe("ContextWindowMeter", () => {
}
});

it("marks the pace on a usage bar and opens the Usage page from its row", async () => {
const openUsage = vi.fn();
const screen = await render(
<ContextWindowMeter
usage={TEST_CONTEXT_WINDOW}
accountUsage={{
...TEST_ACCOUNT_USAGE,
windows: TEST_ACCOUNT_USAGE.windows.map((window) =>
window.key === "secondary" ? { ...window, elapsedPercent: 14.3 } : window,
),
}}
onOpenUsage={openUsage}
/>,
);

try {
await page.getByRole("button", { name: /Context window/ }).click();
const paceMarks = document.querySelectorAll<HTMLElement>("[data-usage-pace-mark]");
// Only the window that knows its length gets a mark.
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();
expect(openUsage).toHaveBeenCalledTimes(1);
await expect.element(page.getByText("Codex usage")).not.toBeInTheDocument();
} finally {
await screen.unmount();
}
});

it("offers Sign in from the usage popout only when the provider is signed out", async () => {
const signIn = vi.fn();
const meter = (notice: NonNullable<ProviderAccountUsagePresentation["notice"]>) => (
Expand Down
66 changes: 54 additions & 12 deletions apps/web/src/components/chat/ContextWindowMeter.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ChevronDownIcon } from "lucide-react";
import { type ReactNode, useCallback, useLayoutEffect, useRef, useState } from "react";
import { type ReactNode, useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";

import { openExternalUrl } from "~/lib/externalLinks";
import { cn } from "~/lib/utils";
Expand All @@ -15,6 +15,7 @@ import {
usageMeterColor,
} from "~/lib/providerUsage";
import { Popover, PopoverPopup, PopoverTrigger } from "../ui/popover";
import { UsagePaceMark, usagePaceLabel } from "../usage/UsagePaceMark";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";

function isDomNode(value: unknown): value is Node {
Expand All @@ -24,34 +25,59 @@ function isDomNode(value: unknown): value is Node {
const contextWindowActionButtonClassName =
"h-5 shrink-0 cursor-pointer rounded-sm border border-border/70 px-1.5 font-medium text-[10px] text-foreground leading-none transition-colors hover:border-border hover:bg-muted hover:text-foreground focus-visible:border-focus-ring focus-visible:bg-muted focus-visible:outline-none disabled:pointer-events-none disabled:cursor-default disabled:opacity-55";

/**
* One account usage line: its label and detail over a bar, with the pace mark
* when the window's length is known. With `onOpen` the whole line is a button
* (the Usage page), plain until hover like the rest of a popover's rows.
*/
function AccountUsageBar(props: {
usageLabel: string;
rowLabel: string;
detail: string;
usedPercent: number;
warning: boolean;
elapsedPercent?: number | undefined;
onOpen?: (() => void) | undefined;
}) {
const meterColor = usageMeterColor(props.usedPercent, props.warning);
return (
<div className="space-y-1">
<div className="flex min-w-0 items-baseline justify-between gap-3 text-xs">
const meterLabel = `${props.usageLabel} ${props.rowLabel} ${props.usedPercent}% used${usagePaceLabel(props.elapsedPercent)}`;
const content = (
<>
<span className="flex min-w-0 items-baseline justify-between gap-3 text-xs">
<span className="shrink-0 font-medium text-foreground">{props.rowLabel}</span>
<span className="min-w-0 text-right text-muted-foreground">{props.detail}</span>
</div>
<div
</span>
<span
role="meter"
aria-label={`${props.usageLabel} ${props.rowLabel} ${props.usedPercent}% used`}
aria-label={meterLabel}
aria-valuemin={0}
aria-valuemax={100}
aria-valuenow={props.usedPercent}
className="h-1 overflow-hidden rounded-full bg-muted"
className="relative block h-1 rounded-full bg-muted"
>
<div
className={cn("h-full rounded-full transition-[width]", !meterColor && "bg-primary")}
<span
className={cn(
"block h-full rounded-full transition-[width]",
!meterColor && "bg-primary",
)}
style={{ width: `${props.usedPercent}%`, backgroundColor: meterColor }}
/>
</div>
</div>
{props.elapsedPercent !== undefined ? (
<UsagePaceMark elapsedPercent={props.elapsedPercent} />
) : null}
</span>
</>
);
if (!props.onOpen) return <div className="flex flex-col gap-1">{content}</div>;
return (
<button
type="button"
aria-label={`${meterLabel}. Open usage`}
onClick={props.onOpen}
className="-mx-1.5 -my-1 flex w-[calc(100%+--spacing(3))] cursor-pointer flex-col gap-1 rounded-md px-1.5 py-1 text-left transition-colors hover:bg-muted/60 focus-visible:bg-muted/60 focus-visible:outline-none"
>
{content}
</button>
);
}

Expand Down Expand Up @@ -156,6 +182,8 @@ export function ContextWindowMeter(props: {
contextWindowLabel?: string | null;
onResetAccountUsage?: (() => void) | undefined;
accountUsageResetInFlight?: boolean | undefined;
/** Opens the Usage page; makes each usage line in the popover a button. */
onOpenUsage?: (() => void) | undefined;
onCompactContext?: (() => void) | undefined;
contextCompactDisabled?: boolean | undefined;
contextCompactInFlight?: boolean | undefined;
Expand Down Expand Up @@ -256,6 +284,17 @@ export function ContextWindowMeter(props: {
};
}, [isOpen, onOpenChange]);
const isMeterActive = isOpen || isPinnedOpen;
const { onOpenUsage } = props;
const openUsage = useMemo(
() =>
onOpenUsage
? () => {
onOpenChange(false);
onOpenUsage();
}
: undefined,
[onOpenChange, onOpenUsage],
);

return (
<Popover onOpenChange={onOpenChange} open={isOpen}>
Expand Down Expand Up @@ -531,6 +570,7 @@ export function ContextWindowMeter(props: {
detail={accountUsage.spendControl.detail}
usedPercent={accountUsage.spendControl.usedPercent}
warning={accountUsage.spendControl.warning}
onOpen={openUsage}
/>
) : null}
{accountUsage.windows.map((window) => (
Expand All @@ -541,6 +581,8 @@ export function ContextWindowMeter(props: {
detail={window.detail}
usedPercent={window.usedPercent}
warning={window.warning}
elapsedPercent={window.elapsedPercent}
onOpen={openUsage}
/>
))}
{accountUsage.notice ? (
Expand Down
28 changes: 28 additions & 0 deletions apps/web/src/components/usage/UsagePaceMark.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { cn } from "~/lib/utils";

/**
* 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.
*/
export function UsagePaceMark(props: { elapsedPercent: number; 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}%` }}
/>
);
}

/** "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`;
}
6 changes: 5 additions & 1 deletion apps/web/src/components/usage/UsageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Fragment, useMemo, useState, type ReactNode } from "react";
import { useMediaQuery } from "../../hooks/useMediaQuery";
import { useRelativeTimeTick } from "../../hooks/useRelativeTimeTick";
import { usageMeterColor } from "../../lib/providerUsage";
import { UsagePaceMark } from "./UsagePaceMark";
import { cn } from "../../lib/utils";
import {
deriveUsageWindow,
Expand Down Expand Up @@ -461,7 +462,7 @@ function UsagePlanLimits({
{meter.detail}
</span>
</span>
<div className="h-[3px] w-full bg-border/40">
<div className="relative h-[3px] w-full bg-border/40">
<div
className="h-full"
style={{
Expand All @@ -470,6 +471,9 @@ function UsagePlanLimits({
usageMeterColor(meter.usedPercent, meter.warning) ?? fill,
}}
/>
{meter.elapsedPercent !== undefined ? (
<UsagePaceMark elapsedPercent={meter.elapsedPercent} className="h-2" />
) : null}
</div>
</div>
))}
Expand Down
3 changes: 3 additions & 0 deletions apps/web/src/components/usage/usageView.logic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,8 @@ export interface UsagePlanLimitMeter {
readonly usedPercent: number;
readonly warning: boolean;
readonly reachedLimit: boolean;
/** How much of the window has passed, for the pace mark; see the shared presentation. */
readonly elapsedPercent?: number;
}

export interface UsagePlanLimitRow {
Expand Down Expand Up @@ -1031,6 +1033,7 @@ export function buildUsagePlanLimitRows(
usedPercent: window.usedPercent,
warning: window.warning,
reachedLimit: window.reachedLimit,
...(window.elapsedPercent !== undefined ? { elapsedPercent: window.elapsedPercent } : {}),
}));
if (presentation.spendControl) {
meters.push({
Expand Down
Loading