Files
PaperClipAI/ui/src/api/issues.ts
T
DottaandPaperclip 018993140f feat: let agents name prompt-only tasks (#14761)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - Users create tasks with a title and a description.
> - A required title adds work when the prompt already explains the
request.
> - An agent can name the task once it reads that request.
> - This pull request accepts prompt-only tasks and starts them with a
short prompt slice.
> - A scoped title tool lets the assigned agent replace that slice early
without changing execution state.
> - A live browser eval checks the real agent call, saved title, audit
entry, and preservation of user titles.

## Linked Issues or Issue Description

**Subsystem affected**

Cross-cutting: task creation, shared contracts, database, server, runner
tools, and board UI.

**Problem or motivation**

Users must currently write a title before they can submit a detailed
task prompt. The agent has enough context to write a useful title
itself.

**Proposed solution**

Make the title optional when a description is present. Save the first
120 characters of the normalized prompt as a provisional title. Ask the
assigned agent to call `set_task_title` early. Use an atomic
provisional-title guard to preserve titles supplied or edited by users.
Keep explicit titles supported.

Related: #14543 and #14556 concern empty-title submission. This change
intentionally enables that submission when a prompt is present, instead
of requiring a title.

## What Changed

- Add the `titleNeedsGeneration` field with an idempotent migration.
Keep existing titles unchanged.
- Add `PUT /api/issues/:id/title` and the native and legacy
`set_task_title` tool. Enforce company access, active-run ownership,
shared, bounded retry receipts across native/HTTP calls, and
transactional audit logging. Refresh external-object links after commit,
with the same feature gate and plugin detectors as ordinary title edits.
- Add early naming guidance in Standard, Ask, and Plan task context.
Preserve the description, status, and assignment.
- Allow prompt-only root and child task creation, plus draft restoration
in the New Task dialog. Keep user titles supported.
- Add an opt-in Product E2E suite for prompt-only Standard and Ask
tasks, plus an explicit-title control. It checks actual provider calls
within the first five tools, persisted state, audit attribution, and the
reloaded UI.
- Preserve a closed vocabulary of API key maintenance phrases in
declared prose while rejecting opaque credential suffixes. Add one
bounded naming retry after wording is rejected, without treating the
rejected call as a saved title.
- Repair the native cleanup receipt check exposed during full
verification: accept matching input digests, retain legacy input checks,
and reject conflicting receipts.

## Verification

- Live Product E2E on `f43478473800e3a46b85c5ee79677efdb15108e7`: **3/3
passed** with native Codex `gpt-5.4-mini`, first attempts only,
automatic retries disabled. Standard and Ask each saved “Rotate expired
API key” on their first tool call, with matching persisted state and a
single same-run audit entry. The explicit-title control retained its
user title with zero title writes. All three verified the reloaded
browser UI.
- Campaign: `local-2026-09-30T21-30-11-021Z`. Earlier failed campaigns
are retained separately; they exposed credential-prose handling and
prompted the naming recovery fix. No failed result was regraded or
deleted.
- Reproduce with `pnpm test:e2e:runner -- --id
task-titles.runner-codex-mini.local.prompt-title-standard --id
task-titles.runner-codex-mini.local.prompt-title-ask --id
task-titles.runner-codex-mini.local.preserve-explicit-title
--max-automatic-retries 0` and an authorized provider key.
- Full `pnpm -r typecheck` and `pnpm build` passed on the latest commit.
The runner build used the configured external eval source tree.
- Product E2E unit suite: **61 files, 818 tests passed**; E2E typecheck
and UI token gates passed.
- Title API/native regressions cover prompt-only and explicit child
creation, user edits, ownership/company isolation, external reference
refresh, cross-surface retry replay, and the 64-key limit without
receipt eviction. All passed. Prompt-context coverage: **44 tests
passed**.
- Rust credential regressions: **35 tests passed**, including benign
maintenance qualifiers and opaque credential rejection in every declared
prose field. Catalog/report reconciliation: **28 tests passed**. Native
recovery: **560 tests passed**.
- Broad local `pnpm test:run`: **14,555 tests passed** in the general
server group; two suites failed to initialize embedded PostgreSQL and
the existing 40,000-file Git streaming stress test exceeded its
300-second macOS timeout. All three suites then passed in isolation (**5
tests passed**) without code or timeout changes. The original full local
command exited nonzero and is not being represented as a clean full run.
- Latest-head GitHub checks are green: **53 passed, 4 skipped, zero
failed or pending**, including all test shards and the canary packaging
dry run. Greptile reviewed the same commit at **5/5**, with zero
unresolved review threads.

## Risks

- The additive database field must reach the server and UI together. The
migration uses `IF NOT EXISTS` and defaults existing tasks to a final
title.
- Title generation depends on the assigned agent running. Tasks without
a run keep their provisional title.
- Live qualification covers the native Codex path in Standard and Ask
modes. API/legacy and Plan behavior have deterministic coverage.
- The credential-prose exception validates the entire suffix against a
closed maintenance vocabulary. Unknown suffixes, assignments, quoted
values, credential prefixes, and diagnostics retain strict checks.

## Model Used

OpenAI Codex, based on GPT-6, with reasoning, tool use, and code
execution. The exact deployment ID and context window are not exposed in
this session. The live eval uses the native Codex `gpt-5.4-mini`
profile.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-09-30 16:48:24 -05:00

615 lines
22 KiB
TypeScript

import type { SetIssueTitle } from "@paperclipai/shared";
import type { ExecutionReconciliation } from "@paperclipai/shared";
import type {
AcceptedPlanDecompositionSummary,
AskUserQuestionsAnswer,
Approval,
CompactIssue,
CreateIssueTreeHold,
DocumentRevision,
FeedbackTargetType,
FeedbackTrace,
FeedbackVote,
Issue,
IssueChanges,
IssueAttachment,
IssueCostSummary,
IssueComment,
IssueQueuedCommentQueue,
IssueDocument,
IssueLabel,
IssueRecoveryAction,
IssueRetryNowResponse,
StalledReviewDecision,
StalledReviewDecisionResponse,
IssueThreadInteraction,
IssueTreeControlPreview,
IssueTreeHold,
IssueWatchdog,
IssueWorkProduct,
RunnerGoalActionAccepted,
RunnerGoalActionRequest,
RunnerGoalProjection,
PreviewIssueTreeControl,
ReleaseIssueTreeHold,
ReleaseIssueTreeHoldResponse,
UpsertIssueWatchdog,
UpsertIssueDocument,
} from "@paperclipai/shared";
import { api, ApiError, type RequestOptions } from "./client";
import { CommentSubmissionUnknownError } from "../lib/comment-submit-result";
function hasCommentReceipt(value: unknown): boolean {
if (!value || typeof value !== "object" || Array.isArray(value)) return false;
const row = value as Record<string, unknown>;
const uuid = /^[0-9a-f]{8}-(?:[0-9a-f]{4}-){3}[0-9a-f]{12}$/i;
return (
typeof row.id === "string" &&
uuid.test(row.id) &&
typeof row.issueId === "string" &&
uuid.test(row.issueId) &&
typeof row.body === "string"
);
}
async function confirmedCommentResponse<T>(
request: Promise<T>,
valid: (response: T) => boolean,
): Promise<T> {
try {
const response = await request;
if (!valid(response)) throw new CommentSubmissionUnknownError();
return response;
} catch (error) {
// A rejected request is distinct from a lost/invalid receipt. A server 5xx
// may also happen after commit; it cannot establish that nothing was saved.
if (error instanceof ApiError && error.status < 500) throw error;
throw new CommentSubmissionUnknownError();
}
}
export type IssueUpdateResponse = Issue & {
comment?: IssueComment | null;
changes: IssueChanges;
blockedByIssueIds?: string[];
};
export type ResolveRecoveryActionResponse = {
issue: Issue;
recoveryAction: IssueRecoveryAction;
};
export type IssueListFilters = {
attention?: "blocked";
status?: string;
projectId?: string;
parentId?: string;
assigneeAgentId?: string;
participantAgentId?: string;
assigneeUserId?: string;
touchedByUserId?: string;
inboxArchivedByUserId?: string;
unreadForUserId?: string;
labelId?: string;
workspaceId?: string;
executionWorkspaceId?: string;
originKind?: string;
originKindPrefix?: string;
originId?: string;
descendantOf?: string;
createdFromIssueId?: string;
includeRoutineExecutions?: boolean;
includeBlockedBy?: boolean;
includeBlockedInboxAttention?: boolean;
includeLiveDescendantSummary?: boolean;
hasPlanDocument?: boolean;
q?: string;
limit?: number;
offset?: number;
sortField?: "updated" | "id";
afterId?: string;
sortDir?: "asc" | "desc";
};
function issueListSearchParams(filters?: IssueListFilters) {
const params = new URLSearchParams();
if (filters?.attention) params.set("attention", filters.attention);
if (filters?.status) params.set("status", filters.status);
if (filters?.projectId) params.set("projectId", filters.projectId);
if (filters?.parentId) params.set("parentId", filters.parentId);
if (filters?.assigneeAgentId)
params.set("assigneeAgentId", filters.assigneeAgentId);
if (filters?.participantAgentId)
params.set("participantAgentId", filters.participantAgentId);
if (filters?.assigneeUserId)
params.set("assigneeUserId", filters.assigneeUserId);
if (filters?.touchedByUserId)
params.set("touchedByUserId", filters.touchedByUserId);
if (filters?.inboxArchivedByUserId)
params.set("inboxArchivedByUserId", filters.inboxArchivedByUserId);
if (filters?.unreadForUserId)
params.set("unreadForUserId", filters.unreadForUserId);
if (filters?.labelId) params.set("labelId", filters.labelId);
if (filters?.workspaceId) params.set("workspaceId", filters.workspaceId);
if (filters?.executionWorkspaceId)
params.set("executionWorkspaceId", filters.executionWorkspaceId);
if (filters?.originKind) params.set("originKind", filters.originKind);
if (filters?.originKindPrefix)
params.set("originKindPrefix", filters.originKindPrefix);
if (filters?.originId) params.set("originId", filters.originId);
if (filters?.descendantOf) params.set("descendantOf", filters.descendantOf);
if (filters?.createdFromIssueId) params.set("createdFromIssueId", filters.createdFromIssueId);
if (filters?.includeRoutineExecutions)
params.set("includeRoutineExecutions", "true");
if (filters?.includeBlockedBy) params.set("includeBlockedBy", "true");
if (filters?.includeBlockedInboxAttention)
params.set("includeBlockedInboxAttention", "true");
if (filters?.includeLiveDescendantSummary)
params.set("includeLiveDescendantSummary", "true");
if (filters?.hasPlanDocument !== undefined) {
params.set("hasPlanDocument", filters.hasPlanDocument ? "true" : "false");
}
if (filters?.q) params.set("q", filters.q);
if (filters?.limit) params.set("limit", String(filters.limit));
if (filters?.offset !== undefined)
params.set("offset", String(filters.offset));
if (filters?.sortField) params.set("sortField", filters.sortField);
if (filters?.sortDir) params.set("sortDir", filters.sortDir);
if (filters?.afterId) params.set("afterId", filters.afterId);
return params;
}
export const issuesApi = {
/** Fetch every page for bounded task-detail relations, not just the default first page. */
listAll: async (companyId: string, filters: Omit<IssueListFilters, "limit" | "offset" | "sortField" | "sortDir" | "afterId" | "attention">, options?: RequestOptions): Promise<Issue[]> => {
const pageSize = 500;
const tasks = new Map<string, Issue>();
let afterId: string | undefined;
for (;;) {
const page = await issuesApi.list(companyId, { ...filters, limit: pageSize, sortField: "id", sortDir: "asc", afterId }, options);
for (const task of page) tasks.set(task.id, task);
if (page.length < pageSize) return [...tasks.values()];
afterId = page[page.length - 1]!.id;
}
},
list: (
companyId: string,
filters?: IssueListFilters,
options?: RequestOptions,
) => {
const params = issueListSearchParams(filters);
const qs = params.toString();
const path = `/companies/${companyId}/issues${qs ? `?${qs}` : ""}`;
return options ? api.get<Issue[]>(path, options) : api.get<Issue[]>(path);
},
listCompact: (
companyId: string,
filters?: IssueListFilters,
options?: RequestOptions,
) => {
const params = issueListSearchParams(filters);
params.set("view", "compact");
const path = `/companies/${companyId}/issues?${params.toString()}`;
return options
? api.get<CompactIssue[]>(path, options)
: api.get<CompactIssue[]>(path);
},
count: (
companyId: string,
filters: {
attention: "blocked";
status?: string;
assigneeAgentId?: string;
assigneeUserId?: string;
projectId?: string;
labelId?: string;
q?: string;
},
) => {
const params = new URLSearchParams();
params.set("attention", filters.attention);
if (filters.status) params.set("status", filters.status);
if (filters.assigneeAgentId)
params.set("assigneeAgentId", filters.assigneeAgentId);
if (filters.assigneeUserId)
params.set("assigneeUserId", filters.assigneeUserId);
if (filters.projectId) params.set("projectId", filters.projectId);
if (filters.labelId) params.set("labelId", filters.labelId);
if (filters.q) params.set("q", filters.q);
return api.get<{ count: number }>(
`/companies/${companyId}/issues/count?${params.toString()}`,
);
},
listLabels: (companyId: string) =>
api.get<IssueLabel[]>(`/companies/${companyId}/labels`),
createLabel: (companyId: string, data: { name: string; color: string }) =>
api.post<IssueLabel>(`/companies/${companyId}/labels`, data),
deleteLabel: (id: string) => api.delete<IssueLabel>(`/labels/${id}`),
get: (id: string, options?: RequestOptions) =>
options
? api.get<Issue>(`/issues/${id}`, options)
: api.get<Issue>(`/issues/${id}`),
getRunnerGoal: (id: string, agentId?: string | null) => {
const query = agentId ? `?agentId=${encodeURIComponent(agentId)}` : "";
return api.get<RunnerGoalProjection>(`/issues/${id}/runner-goal${query}`);
},
actOnRunnerGoal: (id: string, request: RunnerGoalActionRequest) =>
api.post<RunnerGoalActionAccepted>(
`/issues/${id}/runner-goal/actions`,
request,
),
getWatchdog: (id: string) =>
api.get<IssueWatchdog | null>(`/issues/${id}/watchdog`),
upsertWatchdog: (id: string, data: UpsertIssueWatchdog) =>
api.put<IssueWatchdog>(`/issues/${id}/watchdog`, data),
deleteWatchdog: (id: string) =>
api.delete<{ ok: true }>(`/issues/${id}/watchdog`),
markRead: (id: string) =>
api.post<{ id: string; lastReadAt: Date }>(`/issues/${id}/read`, {}),
markUnread: (id: string) =>
api.delete<{ id: string; removed: boolean }>(`/issues/${id}/read`),
archiveFromInbox: (id: string) =>
api.post<{ id: string; archivedAt: Date }>(
`/issues/${id}/inbox-archive`,
{},
),
unarchiveFromInbox: (id: string) =>
api.delete<{ id: string; archivedAt: Date } | { ok: true }>(
`/issues/${id}/inbox-archive`,
),
setTitle: (id: string, data: SetIssueTitle) =>
api.put<{ id: string; title: string; titleNeedsGeneration: boolean; changed: boolean }>(`/issues/${id}/title`, data),
create: (companyId: string, data: Record<string, unknown>) =>
api.post<Issue>(`/companies/${companyId}/issues`, data),
update: (id: string, data: Record<string, unknown>) => {
const response = api.patch<IssueUpdateResponse>(`/issues/${id}`, data);
return typeof data.comment === "string"
? confirmedCommentResponse(response, (value) =>
hasCommentReceipt(value?.comment),
)
: response;
},
decideStalledReview: (id: string, data: StalledReviewDecision) =>
api.post<StalledReviewDecisionResponse>(
`/issues/${id}/stalled-review-decision`,
data,
),
retryWorkspaceExport: (id: string, data: { actionId: string; runId: string; repairNote: string }) =>
api.post<{ runId: string; resultId: string; leaseId: string; status: "queued" }>(`/issues/${id}/recovery-actions/retry-workspace-export`, data),
resolveRecoveryAction: (
id: string,
data: {
executionReconciliation?: ExecutionReconciliation;
actionId?: string;
outcome: "restored" | "false_positive" | "blocked" | "cancelled";
sourceIssueStatus: "todo" | "done" | "in_review" | "blocked";
resolutionNote?: string | null;
},
) =>
api.post<ResolveRecoveryActionResponse>(
`/issues/${id}/recovery-actions/resolve`,
data,
),
previewTreeControl: (id: string, data: PreviewIssueTreeControl) =>
api.post<IssueTreeControlPreview>(
`/issues/${id}/tree-control/preview`,
data,
),
createTreeHold: (id: string, data: CreateIssueTreeHold) =>
api.post<{ hold: IssueTreeHold; preview: IssueTreeControlPreview }>(
`/issues/${id}/tree-holds`,
data,
),
getTreeHold: (id: string, holdId: string) =>
api.get<IssueTreeHold>(`/issues/${id}/tree-holds/${holdId}`),
listTreeHolds: (
id: string,
filters?: {
status?: "active" | "released";
mode?: "pause" | "resume" | "cancel" | "restore";
includeMembers?: boolean;
},
) => {
const params = new URLSearchParams();
if (filters?.status) params.set("status", filters.status);
if (filters?.mode) params.set("mode", filters.mode);
if (filters?.includeMembers) params.set("includeMembers", "true");
const qs = params.toString();
return api.get<IssueTreeHold[]>(
`/issues/${id}/tree-holds${qs ? `?${qs}` : ""}`,
);
},
getTreeControlState: (id: string) =>
api.get<{
activePauseHold: {
holdId: string;
rootIssueId: string;
issueId: string;
isRoot: boolean;
mode: "pause";
reason: string | null;
releasePolicy: {
strategy: "manual" | "after_active_runs_finish";
note?: string | null;
} | null;
} | null;
}>(`/issues/${id}/tree-control/state`),
releaseTreeHold: (id: string, holdId: string, data: ReleaseIssueTreeHold) =>
api.post<ReleaseIssueTreeHoldResponse>(
`/issues/${id}/tree-holds/${holdId}/release`,
data,
),
checkMonitorNow: (id: string) =>
api.post<{ ok: true }>(`/issues/${id}/monitor/check-now`, {}),
retryScheduledRetryNow: (id: string) =>
api.post<IssueRetryNowResponse>(
`/issues/${id}/scheduled-retry/retry-now`,
{},
),
remove: (id: string) => api.delete<Issue>(`/issues/${id}`),
checkout: (id: string, agentId: string) =>
api.post<Issue>(`/issues/${id}/checkout`, {
agentId,
expectedStatuses: ["todo", "backlog", "blocked", "in_review"],
}),
release: (id: string) => api.post<Issue>(`/issues/${id}/release`, {}),
listComments: (
id: string,
filters?: {
after?: string;
order?: "asc" | "desc";
limit?: number;
},
) => {
const params = new URLSearchParams();
if (filters?.after) params.set("after", filters.after);
if (filters?.order) params.set("order", filters.order);
if (filters?.limit) params.set("limit", String(filters.limit));
const qs = params.toString();
return api.get<IssueComment[]>(
`/issues/${id}/comments${qs ? `?${qs}` : ""}`,
);
},
getQueuedComments: (id: string) =>
api.get<IssueQueuedCommentQueue>(`/issues/${id}/queued-comments`),
editQueuedComment: (
id: string,
commentId: string,
data: { body: string; queueId: string; revision: string },
) =>
api.patch<IssueQueuedCommentQueue>(
`/issues/${id}/queued-comments/${commentId}`,
data,
),
reorderQueuedComments: (
id: string,
data: { orderedCommentIds: string[]; queueId: string; revision: string },
) =>
api.put<IssueQueuedCommentQueue>(
`/issues/${id}/queued-comments/order`,
data,
),
interruptQueuedComments: (
id: string,
data: { queueId: string; targetRunId: string | null; revision: string },
) => api.post<IssueQueuedCommentQueue>(`/issues/${id}/queued-comments/interrupt`, data),
interruptLatestQueuedComments: async (id: string, expectedTargetRunId: string | null): Promise<IssueQueuedCommentQueue> => {
const queue = await issuesApi.getQueuedComments(id);
if (!queue.queueId || (queue.targetRunId && queue.targetRunId !== expectedTargetRunId)) {
throw new Error("The queued messages changed. Refresh and try again.");
}
return issuesApi.interruptQueuedComments(id, {
queueId: queue.queueId, revision: queue.revision, targetRunId: queue.targetRunId,
});
},
steerQueuedComment: (
id: string,
commentId: string,
data: { queueId: string; targetRunId: string; revision: string },
) =>
api.post<IssueQueuedCommentQueue>(
`/issues/${id}/queued-comments/${commentId}/steer`,
data,
),
discardQueuedComment: (
id: string,
commentId: string,
data: { queueId: string; revision: string },
) =>
api.delete<IssueQueuedCommentQueue>(
`/issues/${id}/queued-comments/${commentId}`,
data,
),
listInteractions: (id: string) =>
api.get<IssueThreadInteraction[]>(`/issues/${id}/interactions`),
listAcceptedPlanDecompositions: (id: string) =>
api.get<AcceptedPlanDecompositionSummary[]>(
`/issues/${id}/accepted-plan-decompositions`,
),
createInteraction: (id: string, data: Record<string, unknown>) =>
api.post<IssueThreadInteraction>(`/issues/${id}/interactions`, data),
acceptInteraction: (
id: string,
interactionId: string,
data?: {
selectedClientKeys?: string[];
selectedOptionIds?: string[];
rememberAction?: boolean;
},
) =>
api.post<IssueThreadInteraction>(
`/issues/${id}/interactions/${interactionId}/accept`,
data ?? {},
),
rejectInteraction: (id: string, interactionId: string, reason?: string) =>
api.post<IssueThreadInteraction>(
`/issues/${id}/interactions/${interactionId}/reject`,
reason ? { reason } : {},
),
cancelInteraction: (id: string, interactionId: string, reason?: string) =>
api.post<IssueThreadInteraction>(
`/issues/${id}/interactions/${interactionId}/cancel`,
reason ? { reason } : {},
),
skipInteraction: (id: string, interactionId: string, reason?: string) =>
api.post<IssueThreadInteraction>(
`/issues/${id}/interactions/${interactionId}/skip`,
reason ? { reason } : {},
),
respondToInteraction: (
id: string,
interactionId: string,
data: {
answers: AskUserQuestionsAnswer[];
summaryMarkdown?: string | null;
},
) =>
api.post<IssueThreadInteraction>(
`/issues/${id}/interactions/${interactionId}/respond`,
data,
),
submitInteractionVerdicts: (
id: string,
interactionId: string,
verdicts: {
id: string;
verdict: "approve" | "reject" | "defer";
reason?: string | null;
}[],
) =>
api.post<IssueThreadInteraction>(
`/issues/${id}/interactions/${interactionId}/verdicts`,
{ verdicts },
),
getComment: (id: string, commentId: string) =>
api.get<IssueComment>(`/issues/${id}/comments/${commentId}`),
listFeedbackVotes: (id: string) =>
api.get<FeedbackVote[]>(`/issues/${id}/feedback-votes`),
getCostSummary: (id: string, options: { excludeRoot?: boolean } = {}) => {
const qs = options.excludeRoot ? "?excludeRoot=true" : "";
return api.get<IssueCostSummary>(`/issues/${id}/cost-summary${qs}`);
},
listFeedbackTraces: (
id: string,
filters?: Record<string, string | boolean | undefined>,
) => {
const params = new URLSearchParams();
for (const [key, value] of Object.entries(filters ?? {})) {
if (value === undefined) continue;
params.set(key, String(value));
}
const qs = params.toString();
return api.get<FeedbackTrace[]>(
`/issues/${id}/feedback-traces${qs ? `?${qs}` : ""}`,
);
},
upsertFeedbackVote: (
id: string,
data: {
targetType: FeedbackTargetType;
targetId: string;
vote: "up" | "down";
reason?: string;
allowSharing?: boolean;
},
) => api.post<FeedbackVote>(`/issues/${id}/feedback-votes`, data),
addComment: (
id: string,
body: string,
reopen?: boolean,
interrupt?: boolean,
attachmentIds?: string[],
clientRequestId?: string,
) =>
confirmedCommentResponse(
api.post<IssueComment>(`/issues/${id}/comments`, {
body,
...(clientRequestId ? { clientRequestId } : {}),
...(reopen === undefined ? {} : { reopen }),
...(interrupt === undefined ? {} : { interrupt }),
...(attachmentIds?.length ? { attachmentIds } : {}),
}),
hasCommentReceipt,
),
cancelComment: (id: string, commentId: string) =>
api.delete<IssueComment>(`/issues/${id}/comments/${commentId}?mode=cancel`),
deleteComment: (id: string, commentId: string) =>
api.delete<IssueComment>(`/issues/${id}/comments/${commentId}`),
listDocuments: (id: string, options?: { includeSystem?: boolean }) =>
api.get<IssueDocument[]>(
`/issues/${id}/documents${options?.includeSystem ? "?includeSystem=true" : ""}`,
),
getDocument: (id: string, key: string) =>
api.get<IssueDocument>(
`/issues/${id}/documents/${encodeURIComponent(key)}`,
),
upsertDocument: (id: string, key: string, data: UpsertIssueDocument) =>
api.put<IssueDocument>(
`/issues/${id}/documents/${encodeURIComponent(key)}`,
data,
),
lockDocument: (id: string, key: string) =>
api.post<IssueDocument>(
`/issues/${id}/documents/${encodeURIComponent(key)}/lock`,
{},
),
unlockDocument: (id: string, key: string) =>
api.post<IssueDocument>(
`/issues/${id}/documents/${encodeURIComponent(key)}/unlock`,
{},
),
listDocumentRevisions: (id: string, key: string) =>
api.get<DocumentRevision[]>(
`/issues/${id}/documents/${encodeURIComponent(key)}/revisions`,
),
restoreDocumentRevision: (id: string, key: string, revisionId: string) =>
api.post<IssueDocument>(
`/issues/${id}/documents/${encodeURIComponent(key)}/revisions/${revisionId}/restore`,
{},
),
deleteDocument: (id: string, key: string) =>
api.delete<{ ok: true }>(
`/issues/${id}/documents/${encodeURIComponent(key)}`,
),
listAttachments: (id: string) =>
api.get<IssueAttachment[]>(`/issues/${id}/attachments`),
uploadAttachment: (
companyId: string,
issueId: string,
file: File,
issueCommentId?: string | null,
) => {
const form = new FormData();
form.append("file", file);
if (issueCommentId) {
form.append("issueCommentId", issueCommentId);
}
return api.postForm<IssueAttachment>(
`/companies/${companyId}/issues/${issueId}/attachments`,
form,
);
},
deleteAttachment: (id: string) =>
api.delete<{ ok: true }>(`/attachments/${id}`),
listApprovals: (id: string) => api.get<Approval[]>(`/issues/${id}/approvals`),
linkApproval: (id: string, approvalId: string) =>
api.post<Approval[]>(`/issues/${id}/approvals`, { approvalId }),
unlinkApproval: (id: string, approvalId: string) =>
api.delete<{ ok: true }>(`/issues/${id}/approvals/${approvalId}`),
listWorkProducts: (id: string, options?: { refreshPullRequests?: boolean }) =>
api.get<IssueWorkProduct[]>(
`/issues/${id}/work-products${options?.refreshPullRequests ? "?refreshPullRequests=true" : ""}`,
),
ensureWorkProductReviewDocument: (id: string, workProductId: string) =>
api.post<IssueDocument>(
`/issues/${id}/work-products/${workProductId}/review-document`,
{},
),
createWorkProduct: (id: string, data: Record<string, unknown>) =>
api.post<IssueWorkProduct>(`/issues/${id}/work-products`, data),
updateWorkProduct: (id: string, data: Record<string, unknown>) =>
api.patch<IssueWorkProduct>(`/work-products/${id}`, data),
deleteWorkProduct: (id: string) =>
api.delete<IssueWorkProduct>(`/work-products/${id}`),
};