Skip to content

Commit be0c0b7

Browse files
committed
fix(desktop): move design usage totals into the shared package
1 parent 094eb98 commit be0c0b7

8 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎.changeset/usage-budget.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
"@open-codesign/desktop": minor
33
"@open-codesign/i18n": patch
4+
"@open-codesign/shared": patch
45
---
56

67
Show recorded token and USD totals for the current design, including today and the local week, beside the existing per-run token count.

‎apps/desktop/src/main/ipc/generate.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ import {
2929
deriveResourceStateFromChatRows,
3030
GeneratePayloadV1,
3131
ListActiveMessagesInputV1,
32+
summarizeUsageBudget,
33+
type UsageTotals,
3234
} from '@open-codesign/shared';
3335
import { computeFingerprint } from '@open-codesign/shared/fingerprint';
3436
import type { BrowserWindow as ElectronBrowserWindow, WebContents } from 'electron';
@@ -88,7 +90,6 @@ import {
8890
} from '../snapshots-db';
8991
import { registerSourceEditBusyCheck } from '../source-edits-ipc';
9092
import { withTlsBypass } from '../tls-override';
91-
import { summarizeUsageBudget, type UsageTotals } from '../usage-budget';
9293
import { createResearchHost, createWebResearchAuthorization } from '../web-research';
9394
import { createWebResearchRun } from '../web-research-run';
9495
import { withStableWorkspacePath } from '../workspace-path-lock';

‎apps/desktop/src/renderer/src/components/Sidebar.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import { getCurrentLocale, useT, useTranslation } from '@open-codesign/i18n';
2-
import type { LocalInputFile, OnboardingState } from '@open-codesign/shared';
2+
import {
3+
formatUsageCost,
4+
formatUsageTokens,
5+
type LocalInputFile,
6+
type OnboardingState,
7+
} from '@open-codesign/shared';
38
import { FolderOpen, Link2, Paperclip, X } from 'lucide-react';
49
import { useCallback, useEffect, useRef } from 'react';
5-
import { formatUsageCost, formatUsageTokens } from '../../../main/usage-budget';
610
import { useCodesignStore } from '../store';
711
import { AskModal } from './AskModal';
812
import { AddMenu } from './chat/AddMenu';

‎apps/desktop/src/renderer/src/components/usage-budget-refresh.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { nextLocalMidnight } from '@open-codesign/shared';
12
import { useEffect, useRef, useState } from 'react';
2-
import { nextLocalMidnight } from '../../../main/usage-budget';
33
import type { UsageBudgetResult } from '../../../preload/index';
44
import { useCodesignStore } from '../store';
55

‎apps/desktop/tsconfig.web.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "../../tsconfig.base.json",
3-
"include": ["src/renderer/**/*", "src/main/usage-budget.ts"],
3+
"include": ["src/renderer/**/*"],
44
"compilerOptions": {
55
"outDir": "out/renderer",
66
"jsx": "react-jsx",

‎packages/shared/src/index.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,4 +626,14 @@ export {
626626
replaceTweakSchema,
627627
} from './editmode';
628628

629+
export {
630+
formatUsageCost,
631+
formatUsageTokens,
632+
nextLocalMidnight,
633+
summarizeUsageBudget,
634+
type UsageBudget,
635+
type UsageRecord,
636+
type UsageTotals,
637+
} from './usage-budget';
638+
629639
export * from './web-research';
File renamed without changes.

0 commit comments

Comments
 (0)