mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-10 12:37:55 +01:00
Fix missions list date handling
This commit is contained in:
1 parent
49db2755e6
commit
8231868774
3 files changed
+43
-2
No files matched your search
@@ -331,6 +331,12 @@ function normalizeId(value: string) {
|
||||
return value.trim().toUpperCase();
|
||||
}
|
||||
|
||||
function toIsoDateString(value: Date | string | null | undefined): string {
|
||||
if (value instanceof Date) return value.toISOString();
|
||||
if (typeof value === "string") return value;
|
||||
return new Date(0).toISOString();
|
||||
}
|
||||
|
||||
function rootMissionOrigin(pluginId: string) {
|
||||
return `plugin:${pluginId}`;
|
||||
}
|
||||
@@ -1585,7 +1591,7 @@ export async function listMissionSummaries(ctx: PluginContext, companyId: string
|
||||
},
|
||||
costCents: summary.costSummary.costCents,
|
||||
latestRunStatus: summary.runSummary.latestRunStatus,
|
||||
updatedAt: root.updatedAt.toISOString(),
|
||||
updatedAt: toIsoDateString(root.updatedAt),
|
||||
}))
|
||||
.sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
||||
}
|
||||
@@ -204,6 +204,10 @@ function formatDate(value: string | null) {
|
||||
});
|
||||
}
|
||||
|
||||
function findingRenderKey(finding: MissionSummary["validationSummary"]["findings"][number]) {
|
||||
return `${finding.sourceReportKey}:${finding.id}`;
|
||||
}
|
||||
|
||||
function Section({
|
||||
title,
|
||||
action,
|
||||
@@ -408,7 +412,7 @@ function SummarySections({
|
||||
{summary.validationSummary.findings.length > 0 ? (
|
||||
<div style={listGridStyle}>
|
||||
{summary.validationSummary.findings.map((finding) => (
|
||||
<div key={finding.id} style={metricStyle}>
|
||||
<div key={findingRenderKey(finding)} style={metricStyle}>
|
||||
<div style={rowStyle}>
|
||||
<strong>{finding.title}</strong>
|
||||
<span style={mutedTextStyle}>
|
||||
|
||||
@@ -220,4 +220,35 @@ describe("missions plugin worker", () => {
|
||||
expect.objectContaining({ id: workerAgentId, name: "Worker One" }),
|
||||
]);
|
||||
});
|
||||
|
||||
it("lists persisted mission roots when host issue timestamps are serialized strings", async () => {
|
||||
const companyId = randomUUID();
|
||||
const rootIssueId = randomUUID();
|
||||
const updatedAt = "2026-04-20T12:00:00.000Z";
|
||||
const harness = createTestHarness({ manifest });
|
||||
|
||||
harness.seed({
|
||||
issues: [
|
||||
issue({
|
||||
id: rootIssueId,
|
||||
companyId,
|
||||
title: "Persisted mission root",
|
||||
identifier: "PAP-1691",
|
||||
originKind: "plugin:paperclip.missions",
|
||||
updatedAt: updatedAt as unknown as Date,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
await plugin.definition.setup(harness.ctx);
|
||||
|
||||
const list = await harness.getData<Array<Record<string, unknown>>>("mission-list", { companyId });
|
||||
expect(list).toEqual([
|
||||
expect.objectContaining({
|
||||
missionIssueId: rootIssueId,
|
||||
missionTitle: "Persisted mission root",
|
||||
updatedAt,
|
||||
}),
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user