perf(recents): look up manual routine runs through the linked-issue index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
devinfoleyandClaude Opus 5.5 committed 2026-12-03 23:53:30 +00:00
1 parent 6c8323e511
commit 13726f5d98
2 files changed
+8 -1

No files matched your search

@@ -101,6 +101,10 @@ describeEmbeddedPostgres("bounded issue summaries", () => {
createdByUserId: title === "someone-else" ? "other-user" : title === "scheduled" ? null : user,
responsibleUserId: user,
}))).returning();
// A run links the task it created, as the routine service records it.
for (const row of rows.filter(row => row.originRunId)) {
await ctx.db.update(routineRuns).set({ linkedIssueId: row.id }).where(eq(routineRuns.id, row.originRunId!));
}
const res = await request(app(f.actor)).get(url(f.companyId)).query({ ids: rows.map(row => row.id).join(","), navigation: "true" }).expect(200);
const byTitle = new Map(res.body.map((row: { title: string }) => [row.title, row]));
// Mine keeps routine work out, including runs the person starts manually.
+4 -1
View File
@@ -127,8 +127,11 @@ export async function listIssueNavigationState(
exists (
-- The viewer started the routine run that created this task. This is
-- recent personal activity, but not Mine participation.
-- The linked-issue index bounds this lookup; the origin-run check keeps
-- only the run that created the task, not later runs coalesced into it.
select 1 from ${issues} join ${routineRuns}
on ${routineRuns.id}::text = ${issues.originRunId} and ${routineRuns.companyId} = ${companyId}
on ${routineRuns.linkedIssueId} = ${issues.id} and ${routineRuns.companyId} = ${companyId}
and ${routineRuns.id}::text = ${issues.originRunId}
where ${issues.id} = c.id and ${issues.companyId} = ${companyId}
and ${issues.createdByUserId} = ${userId} and ${issues.createdByAgentId} is null
and ${routineRuns.source} = 'manual'