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
32 changes: 22 additions & 10 deletions packages/cli/src/commands/agent-conversation/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ import {
LIST_MAX_LIMIT,
LIST_MIN_LIMIT,
LIST_PERIOD_FLAG,
LIST_TARGET_POSITIONAL,
ORG_ALL_TARGET_BRIEF,
PERIOD_ALIASES,
paginationHint,
targetPatternExplanation,
} from "../../lib/list-command.js";
import { withProgress } from "../../lib/polling.js";
import { toNumericId } from "../../lib/resolve-target.js";
import {
resolveOrgOptionalFromArg,
toNumericId,
} from "../../lib/resolve-target.js";
type OrgOptionalTarget,
orgOptionalTarget,
} from "../../lib/target-positional.js";
import {
appendPeriodHint,
serializeTimeRange,
Expand Down Expand Up @@ -86,7 +87,6 @@ type ConversationListResult = {
project?: string;
};

const COMMAND_NAME = "agent-conversation list";
const PAGINATION_KEY = "agent-conversation-list";
const DEFAULT_PERIOD = "7d";

Expand Down Expand Up @@ -194,7 +194,17 @@ export const listCommand = buildListCommand("agent-conversation", {
schema: ConversationListItemSchema,
},
parameters: {
positional: LIST_TARGET_POSITIONAL,
positional: {
kind: "tuple",
parameters: [
{
placeholder: "org/project",
brief: ORG_ALL_TARGET_BRIEF,
parse: orgOptionalTarget,
optional: true,
},
],
},
flags: {
limit: {
kind: "parsed",
Expand Down Expand Up @@ -225,10 +235,12 @@ export const listCommand = buildListCommand("agent-conversation", {
s: "sort",
},
},
async *func(this: SentryContext, flags: ListFlags, target?: string) {
const { cwd } = this;

const resolved = await resolveOrgOptionalFromArg(target, cwd, COMMAND_NAME);
async *func(
this: SentryContext,
flags: ListFlags,
target: OrgOptionalTarget,
) {
const resolved = await target.resolved;
const { org, project } = resolved;
let projectId: number | undefined;
if (project) {
Expand Down
7 changes: 4 additions & 3 deletions packages/cli/test/commands/agent-conversation/list.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function createMockContext() {
stdout: { write: stdoutWrite },
stderr: { write: stderrWrite },
cwd: "/tmp",
commandPrefix: ["sentry", "agent-conversation", "list"],
},
stdoutWrite,
stderrWrite,
Expand Down Expand Up @@ -208,7 +209,7 @@ describe("listCommand.func", () => {
getProjectSpy = vi.spyOn(apiClient, "getProject");
listConversationsSpy = vi.spyOn(apiClient, "listConversations");
resolveTargetSpy = vi
.spyOn(resolveTarget, "resolveOrgOptionalFromArg")
.spyOn(resolveTarget, "resolveOrgOptionalTarget")
.mockResolvedValue({ org: ORG });
withProgressSpy = vi
.spyOn(polling, "withProgress")
Expand Down Expand Up @@ -246,7 +247,7 @@ describe("listCommand.func", () => {
await func.call(context, JSON_FLAGS, `${ORG}/`);

expect(resolveTargetSpy).toHaveBeenCalledWith(
`${ORG}/`,
{ type: "org-all", org: ORG },
"/tmp",
"agent-conversation list",
);
Expand All @@ -268,7 +269,7 @@ describe("listCommand.func", () => {
await func.call(context, JSON_FLAGS, undefined);

expect(resolveTargetSpy).toHaveBeenCalledWith(
undefined,
{ type: "auto-detect" },
"/tmp",
"agent-conversation list",
);
Expand Down
Loading