Skip to content

Commit ede6ff5

Browse files
feat(web): open Usage on the Limits tab by default
Limits is the view most people come to the Usage page for, but it was the last option after Cost and Tokens and easy to miss. The first-visit default is now Limits on web, desktop, and mobile; the last-picked tab still sticks. Made with Claude Fable 5 in Claude Code. Co-Authored-By: Claude Code <[email protected]>
1 parent 2ebc9fa commit ede6ff5

3 files changed

Lines changed: 13 additions & 11 deletions

File tree

‎apps/mobile/src/features/usage/UsageRouteScreen.tsx‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ const CHART_HEIGHT = 180;
6767
export function UsageRouteScreen() {
6868
const navigation = useNavigation();
6969
const insets = useSafeAreaInsets();
70-
const [tab, setTab] = useState<UsageTab>("usage");
70+
// Limits first: remaining quota and reset time are what most people open
71+
// the screen for.
72+
const [tab, setTab] = useState<UsageTab>("limits");
7173
const [windowSelection, setWindowSelection] = useState(() => ({
7274
days: 30,
7375
window: makeWindow(30),

‎apps/web/src/components/usage/usagePagePreferences.test.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ afterEach(() => {
2525

2626
describe("Usage page preferences", () => {
2727
it("uses defaults when no preference has been saved", () => {
28-
expect(readUsagePagePreferences()).toEqual({ metric: "cost", windowDays: 30 });
28+
expect(readUsagePagePreferences()).toEqual({ metric: "limits", windowDays: 30 });
2929
});
3030

3131
it.each([1, 7, 30, 90] as const)("round-trips every metric with a %i-day range", (windowDays) => {
@@ -41,7 +41,7 @@ describe("Usage page preferences", () => {
4141
'{"metric":"cost","windowDays":365}',
4242
])("replaces invalid preferences on the next save: %s", (value) => {
4343
values.set(key, value);
44-
expect(readUsagePagePreferences()).toEqual({ metric: "cost", windowDays: 30 });
44+
expect(readUsagePagePreferences()).toEqual({ metric: "limits", windowDays: 30 });
4545
saveUsagePagePreferences({ metric: "tokens", windowDays: 7 });
4646
expect(readUsagePagePreferences()).toEqual({ metric: "tokens", windowDays: 7 });
4747
});
@@ -64,7 +64,7 @@ describe("Usage page preferences", () => {
6464
throw new Error("SecurityError");
6565
},
6666
});
67-
expect(readUsagePagePreferences()).toEqual({ metric: "cost", windowDays: 30 });
67+
expect(readUsagePagePreferences()).toEqual({ metric: "limits", windowDays: 30 });
6868
expect(() => saveUsagePagePreferences({ metric: "tokens", windowDays: 7 })).not.toThrow();
6969
});
7070
});

‎apps/web/src/components/usage/usagePagePreferences.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ const UsagePagePreferencesSchema = Schema.Struct({
99
});
1010
export type UsagePagePreferences = typeof UsagePagePreferencesSchema.Type;
1111

12+
// Limits is what most people open the page for (how much subscription quota is
13+
// left, and when it resets), so it is the first-visit default; the last picked
14+
// tab sticks after that.
15+
const DEFAULT_PREFERENCES: UsagePagePreferences = { metric: "limits", windowDays: 30 };
16+
1217
export function readUsagePagePreferences(): UsagePagePreferences {
1318
try {
14-
return (
15-
getLocalStorageItem(STORAGE_KEY, UsagePagePreferencesSchema) ?? {
16-
metric: "cost",
17-
windowDays: 30,
18-
}
19-
);
19+
return getLocalStorageItem(STORAGE_KEY, UsagePagePreferencesSchema) ?? DEFAULT_PREFERENCES;
2020
} catch (error) {
2121
console.error("Could not read Usage page preferences.", error);
22-
return { metric: "cost", windowDays: 30 };
22+
return DEFAULT_PREFERENCES;
2323
}
2424
}
2525

0 commit comments

Comments
 (0)