Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
23 changes: 23 additions & 0 deletions apps/ade-cli/src/services/sync/syncRemoteCommandService.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,29 @@ describe("createSyncRemoteCommandService", () => {
await expect(service.execute(makePayload("usage.getAdeStats", { preset: "decade" }))).rejects.toThrow(
"usage.getAdeStats preset must be today, 7d, 30d, year, or all.",
);

getAdeUsageStats.mockClear();
await service.execute(makePayload("usage.getAdeStats", { preset: "7d", scope: "project" }));
expect(getAdeUsageStats).toHaveBeenCalledWith({ preset: "7d", scope: "project" });
await expect(service.execute(makePayload("usage.getAdeStats", { scope: "galaxy" }))).rejects.toThrow(
"usage.getAdeStats scope must be machine or project.",
);

getAdeUsageStats.mockClear();
await service.execute(makePayload("usage.getAdeStats", {
since: "2026-07-01T00:00:00.000Z",
until: "2026-07-08T00:00:00.000Z",
}));
expect(getAdeUsageStats).toHaveBeenCalledWith({
since: "2026-07-01T00:00:00.000Z",
until: "2026-07-08T00:00:00.000Z",
});
await expect(service.execute(makePayload("usage.getAdeStats", { since: "not-a-date" }))).rejects.toThrow(
"usage.getAdeStats since must be an ISO timestamp.",
);
await expect(service.execute(makePayload("usage.getAdeStats", { until: "not-a-date" }))).rejects.toThrow(
"usage.getAdeStats until must be an ISO timestamp.",
);
});

it("advertises and executes machine personal chats as runtime commands", async () => {
Expand Down
17 changes: 16 additions & 1 deletion apps/ade-cli/src/services/sync/syncRemoteCommandService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ import type {
UpdatePrTitleArgs,
WriteTextAtomicArgs,
} from "../../../../desktop/src/shared/types";
import { isAdeUsageRangePreset } from "../../../../desktop/src/shared/types";
import { isAdeUsageRangePreset, isAdeUsageScope } from "../../../../desktop/src/shared/types";
import type { OrchestrationRunCreateRequest } from "../../../../desktop/src/shared/types/orchestration";
import { PERSONAL_CHAT_ACTIONS, isPersonalChatActionQueueable } from "../../../../desktop/src/shared/types/personalChats";
import {
Expand Down Expand Up @@ -4527,8 +4527,23 @@ export function createSyncRemoteCommandService(args: SyncRemoteCommandServiceArg
if (preset && !isAdeUsageRangePreset(preset)) {
throw new Error("usage.getAdeStats preset must be today, 7d, 30d, year, or all.");
}
const scope = asTrimmedString(payload.scope);
if (scope && !isAdeUsageScope(scope)) {
throw new Error("usage.getAdeStats scope must be machine or project.");
}
const since = asTrimmedString(payload.since);
if (since && Number.isNaN(Date.parse(since))) {
throw new Error("usage.getAdeStats since must be an ISO timestamp.");
}
const until = asTrimmedString(payload.until);
if (until && Number.isNaN(Date.parse(until))) {
throw new Error("usage.getAdeStats until must be an ISO timestamp.");
}
return await args.usageTrackingService.getAdeUsageStats({
...(isAdeUsageRangePreset(preset) ? { preset } : {}),
...(isAdeUsageScope(scope) ? { scope } : {}),
...(since ? { since } : {}),
...(until ? { until } : {}),
});
Comment thread
greptile-apps[bot] marked this conversation as resolved.
});

Expand Down
Loading