mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-12-03 11:47:42 +01:00
Revert "PAP-2731 Implement sky explicit-wait UI surfaces"
This reverts commit 08a9e0caf0.
This commit is contained in:
1 parent
0a345e9648
commit
caf37a355d
43 files changed
+181
-4777
No files matched your search
@@ -85,9 +85,6 @@ import { recoveryService } from "../services/recovery/service.js";
|
||||
|
||||
const RUN_LOG_DEFAULT_LIMIT_BYTES = 256_000;
|
||||
const RUN_LOG_MAX_LIMIT_BYTES = 1024 * 1024;
|
||||
const LIVE_RUNS_DEFAULT_LIMIT = 50;
|
||||
const WATCHDOG_DECISIONS = ["snooze", "continue", "dismissed_false_positive", "cancel_run"] as const;
|
||||
type WatchdogDecision = (typeof WATCHDOG_DECISIONS)[number];
|
||||
|
||||
function readRunLogLimitBytes(value: unknown) {
|
||||
const parsed = Number(value ?? RUN_LOG_DEFAULT_LIMIT_BYTES);
|
||||
@@ -2575,7 +2572,7 @@ export function agentRoutes(
|
||||
assertCompanyAccess(req, companyId);
|
||||
|
||||
const minCount = readLiveRunsQueryInt(req.query.minCount, 50);
|
||||
const limit = readLiveRunsQueryInt(req.query.limit, LIVE_RUNS_DEFAULT_LIMIT, LIVE_RUNS_DEFAULT_LIMIT);
|
||||
const limit = readLiveRunsQueryInt(req.query.limit, 50);
|
||||
|
||||
const columns = {
|
||||
id: heartbeatRuns.id,
|
||||
@@ -2698,20 +2695,12 @@ export function agentRoutes(
|
||||
}
|
||||
assertCompanyAccess(req, existing.companyId);
|
||||
const decision = typeof req.body?.decision === "string" ? req.body.decision : "";
|
||||
if (!WATCHDOG_DECISIONS.includes(decision as WatchdogDecision)) {
|
||||
if (!["snooze", "continue", "dismissed_false_positive"].includes(decision)) {
|
||||
res.status(400).json({ error: "Unsupported watchdog decision" });
|
||||
return;
|
||||
}
|
||||
const evaluationIssueId = typeof req.body?.evaluationIssueId === "string" ? req.body.evaluationIssueId : null;
|
||||
const reason = typeof req.body?.reason === "string" ? req.body.reason.slice(0, 4000) : null;
|
||||
if (decision === "cancel_run" && !reason?.trim()) {
|
||||
res.status(400).json({ error: "Cancellation reason is required" });
|
||||
return;
|
||||
}
|
||||
if (decision === "cancel_run" && !evaluationIssueId) {
|
||||
res.status(400).json({ error: "evaluationIssueId is required for cancellation" });
|
||||
return;
|
||||
}
|
||||
const snoozedUntil = decision === "snooze"
|
||||
? new Date(String(req.body?.snoozedUntil ?? ""))
|
||||
: null;
|
||||
@@ -2723,47 +2712,14 @@ export function agentRoutes(
|
||||
const row = await recovery.recordWatchdogDecision({
|
||||
runId: existing.id,
|
||||
actor: req.actor,
|
||||
decision: decision as WatchdogDecision,
|
||||
decision: decision as "snooze" | "continue" | "dismissed_false_positive",
|
||||
evaluationIssueId,
|
||||
reason,
|
||||
snoozedUntil,
|
||||
createdByRunId: req.actor.runId ?? null,
|
||||
});
|
||||
|
||||
if (decision !== "cancel_run") {
|
||||
res.json(row);
|
||||
return;
|
||||
}
|
||||
|
||||
const cancelledRun = await heartbeat.cancelRun(existing.id, reason?.trim());
|
||||
if (cancelledRun) {
|
||||
await logActivity(db, {
|
||||
companyId: cancelledRun.companyId,
|
||||
actorType: req.actor.type === "agent" ? "agent" : "user",
|
||||
actorId: req.actor.type === "agent"
|
||||
? req.actor.agentId ?? "agent"
|
||||
: req.actor.type === "board"
|
||||
? req.actor.userId ?? "board"
|
||||
: "unknown",
|
||||
agentId: req.actor.type === "agent" ? req.actor.agentId ?? null : null,
|
||||
runId: cancelledRun.id,
|
||||
action: "heartbeat.watchdog_cancelled",
|
||||
entityType: "heartbeat_run",
|
||||
entityId: cancelledRun.id,
|
||||
details: {
|
||||
source: "routes.heartbeat_runs.watchdog_decisions",
|
||||
decision,
|
||||
evaluationIssueId,
|
||||
reason: reason?.trim() ?? null,
|
||||
createdByRunId: req.actor.runId ?? null,
|
||||
targetRunId: cancelledRun.id,
|
||||
previousStatus: existing.status,
|
||||
resultStatus: cancelledRun.status,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
res.json({ decision: row, run: cancelledRun });
|
||||
res.json(row);
|
||||
});
|
||||
|
||||
router.get("/heartbeat-runs/:runId/events", async (req, res) => {
|
||||
|
||||
+16
-74
@@ -1113,21 +1113,6 @@ export function issueRoutes(
|
||||
documentsSvc.getIssueDocumentByKey(issue.id, ISSUE_CONTINUATION_SUMMARY_DOCUMENT_KEY),
|
||||
currentExecutionWorkspacePromise,
|
||||
]);
|
||||
const executionDisposition = await svc
|
||||
.listExecutionDispositions(issue.companyId, [
|
||||
{
|
||||
id: issue.id,
|
||||
companyId: issue.companyId,
|
||||
status: issue.status,
|
||||
assigneeAgentId: issue.assigneeAgentId,
|
||||
assigneeUserId: issue.assigneeUserId,
|
||||
originKind: issue.originKind ?? null,
|
||||
executionRunId: issue.executionRunId ?? null,
|
||||
executionState: issue.executionState ?? null,
|
||||
blockedBy: relations.blockedBy,
|
||||
},
|
||||
])
|
||||
.then((map) => map.get(issue.id) ?? null);
|
||||
|
||||
res.json({
|
||||
issue: {
|
||||
@@ -1137,7 +1122,6 @@ export function issueRoutes(
|
||||
description: issue.description,
|
||||
status: issue.status,
|
||||
...(blockerAttention ? { blockerAttention } : {}),
|
||||
...(executionDisposition ? { executionDisposition } : {}),
|
||||
productivityReview,
|
||||
priority: issue.priority,
|
||||
projectId: issue.projectId,
|
||||
@@ -1236,27 +1220,11 @@ export function issueRoutes(
|
||||
? await executionWorkspacesSvc.getById(issue.executionWorkspaceId)
|
||||
: null;
|
||||
const workProducts = await workProductsSvc.listForIssue(issue.id);
|
||||
const executionDisposition = await svc
|
||||
.listExecutionDispositions(issue.companyId, [
|
||||
{
|
||||
id: issue.id,
|
||||
companyId: issue.companyId,
|
||||
status: issue.status,
|
||||
assigneeAgentId: issue.assigneeAgentId,
|
||||
assigneeUserId: issue.assigneeUserId,
|
||||
originKind: issue.originKind ?? null,
|
||||
executionRunId: issue.executionRunId ?? null,
|
||||
executionState: issue.executionState ?? null,
|
||||
blockedBy: relations.blockedBy,
|
||||
},
|
||||
])
|
||||
.then((map) => map.get(issue.id) ?? null);
|
||||
res.json({
|
||||
...issue,
|
||||
goalId: goal?.id ?? issue.goalId,
|
||||
ancestors,
|
||||
...(blockerAttention ? { blockerAttention } : {}),
|
||||
...(executionDisposition ? { executionDisposition } : {}),
|
||||
productivityReview,
|
||||
blockedBy: relations.blockedBy,
|
||||
blocks: relations.blocks,
|
||||
@@ -2115,6 +2083,10 @@ export function issueRoutes(
|
||||
}
|
||||
}
|
||||
|
||||
const runToCancelForCancelledStatus = shouldCancelActiveRunForCancelledStatus
|
||||
? await resolveActiveIssueRun(existing)
|
||||
: null;
|
||||
|
||||
if (hiddenAtRaw !== undefined) {
|
||||
updateFields.hiddenAt = hiddenAtRaw ? new Date(hiddenAtRaw) : null;
|
||||
}
|
||||
@@ -2297,50 +2269,26 @@ export function issueRoutes(
|
||||
return;
|
||||
}
|
||||
|
||||
const cancelledStatusRunIds: string[] = [];
|
||||
const cancelledStatusWakeupIds: string[] = [];
|
||||
if (shouldCancelActiveRunForCancelledStatus) {
|
||||
let cancelledStatusRunId: string | null = null;
|
||||
if (runToCancelForCancelledStatus) {
|
||||
try {
|
||||
const cancelled = await heartbeat.cancelIssueRuns({
|
||||
companyId: issue.companyId,
|
||||
issueId: issue.id,
|
||||
reason: "Cancelled because the issue was marked cancelled",
|
||||
});
|
||||
for (const cancelledRun of cancelled.runs) {
|
||||
cancelledStatusRunIds.push(cancelledRun.id);
|
||||
const cancelled = await heartbeat.cancelRun(runToCancelForCancelledStatus.id);
|
||||
if (cancelled) {
|
||||
cancelledStatusRunId = cancelled.id;
|
||||
await logActivity(db, {
|
||||
companyId: cancelledRun.companyId,
|
||||
companyId: cancelled.companyId,
|
||||
actorType: actor.actorType,
|
||||
actorId: actor.actorId,
|
||||
agentId: actor.agentId,
|
||||
runId: actor.runId,
|
||||
action: "heartbeat.cancelled",
|
||||
entityType: "heartbeat_run",
|
||||
entityId: cancelledRun.id,
|
||||
details: { agentId: cancelledRun.agentId, source: "issue_status_cancelled", issueId: existing.id },
|
||||
});
|
||||
}
|
||||
for (const cancelledWakeup of cancelled.wakeups) {
|
||||
cancelledStatusWakeupIds.push(cancelledWakeup.id);
|
||||
await logActivity(db, {
|
||||
companyId: issue.companyId,
|
||||
actorType: actor.actorType,
|
||||
actorId: actor.actorId,
|
||||
agentId: actor.agentId,
|
||||
runId: actor.runId,
|
||||
action: "issue.wakeup_cancelled",
|
||||
entityType: "agent_wakeup_request",
|
||||
entityId: cancelledWakeup.id,
|
||||
details: {
|
||||
agentId: cancelledWakeup.agentId,
|
||||
previousReason: cancelledWakeup.reason,
|
||||
source: "issue_status_cancelled",
|
||||
issueId: existing.id,
|
||||
},
|
||||
entityId: cancelled.id,
|
||||
details: { agentId: cancelled.agentId, source: "issue_status_cancelled", issueId: existing.id },
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
logger.warn({ err, issueId: existing.id }, "failed to cancel runs for cancelled issue");
|
||||
logger.warn({ err, issueId: existing.id, runId: runToCancelForCancelledStatus.id }, "failed to cancel run for cancelled issue");
|
||||
await logActivity(db, {
|
||||
companyId: existing.companyId,
|
||||
actorType: actor.actorType,
|
||||
@@ -2348,8 +2296,8 @@ export function issueRoutes(
|
||||
agentId: actor.agentId,
|
||||
runId: actor.runId,
|
||||
action: "heartbeat.cancel_failed",
|
||||
entityType: "issue",
|
||||
entityId: existing.id,
|
||||
entityType: "heartbeat_run",
|
||||
entityId: runToCancelForCancelledStatus.id,
|
||||
details: { source: "issue_status_cancelled", issueId: existing.id },
|
||||
});
|
||||
}
|
||||
@@ -2421,13 +2369,7 @@ export function issueRoutes(
|
||||
...(resumeRequested === true ? { resumeIntent: true, followUpRequested: true } : {}),
|
||||
...(reopened ? { reopened: true, reopenedFrom: reopenFromStatus } : {}),
|
||||
...(interruptedRunId ? { interruptedRunId } : {}),
|
||||
...(cancelledStatusRunIds.length > 0
|
||||
? {
|
||||
cancelledStatusRunId: cancelledStatusRunIds[0],
|
||||
cancelledStatusRunIds,
|
||||
}
|
||||
: {}),
|
||||
...(cancelledStatusWakeupIds.length > 0 ? { cancelledStatusWakeupIds } : {}),
|
||||
...(cancelledStatusRunId ? { cancelledStatusRunId } : {}),
|
||||
_previous: hasFieldChanges ? previous : undefined,
|
||||
...summarizeIssueReferenceActivityDetails(
|
||||
updateReferenceDiff
|
||||
|
||||
Reference in new issue
Block a user