π€― LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
π fix(scm): link a teammate's acceptance round to the PR it ingested (#21764)
Arvin Xu9e167115e65d
diff --git a/apps/server/src/services/scm/__tests__/links.test.ts b/apps/server/src/services/scm/__tests__/links.test.tsindex 30d349adaad..ea77e96cd00 100644--- a/apps/server/src/services/scm/__tests__/links.test.ts+++ b/apps/server/src/services/scm/__tests__/links.test.ts@@ -388,6 +388,46 @@ describe('resolveChangeRequestLinks', () => {expect(await resolve({ ...base, number: 19_720, scope })).toEqual({});});+ it("finds a teammate's round in a workspace the author can write to", async () => {+ // A teammate verified the delivery and ingested its rounds; the author+ // opened the PR and never touched the acceptance.+ const workspace = await workspaceWith('scm-links-run-ws', otherUserId);+ await serverDB.insert(acceptances).values({+ id: acceptanceId,+ subjectId: 's',+ subjectType: 'standalone',+ userId: otherUserId,+ workspaceId: workspace.id,+ });+ await serverDB.insert(verifyRuns).values({+ acceptanceId,+ context: { pullRequest: { number: 19_719, url: base.url } },+ roundIndex: 1,+ scenario: 'coding',+ userId: otherUserId,+ workspaceId: workspace.id,+ });+ const scope = { kind: 'author', userId } as const;++ // Not a member: the round stays out of reach.+ expect(await resolve({ ...base, scope })).toEqual({});++ // A viewer cannot accept it in the app, so a merge must not either.+ await serverDB+ .insert(workspaceMembers)+ .values({ role: 'viewer', userId, workspaceId: workspace.id });+ expect(await resolve({ ...base, scope })).toEqual({});++ await serverDB+ .update(workspaceMembers)+ .set({ role: 'member' })+ .where(eq(workspaceMembers.userId, userId));+ expect(await resolveChangeRequestLinks(serverDB, { ...base, scope })).toEqual({+ links: { acceptanceId },+ workspaceId: workspace.id,+ });+ });+it('keeps the acceptance the row already carries over a later hand link', async () => {// Two acceptances list the same PR: the first claimed the row, the second// was refused by `link-pr` and kept its link. The newest link must notdiff --git a/apps/server/src/services/scm/links.ts b/apps/server/src/services/scm/links.tsindex 47e08ec0fc1..abad22924e0 100644--- a/apps/server/src/services/scm/links.ts+++ b/apps/server/src/services/scm/links.ts@@ -23,6 +23,7 @@ import { SCM_WRITE_ROLES } from './scope';* (`works.resourceId = owner/repo#number`). Gives topic + agent.* 3. The acceptance round that recorded this PR url in its coding context* (`verify_runs.context.pullRequest.url`), written by `lh acceptance run ingest`.+ * Fenced by tenant, like 4: whoever ingested the round need not be the author.* 4. The acceptance this PR was linked to by hand (`lh acceptance link-pr`,* stored in `acceptances.metadata.pullRequests`). The acceptance already* bound to the row wins over the newest link, so a link that lost the@@ -275,7 +276,11 @@ export const resolveChangeRequestLinks = async (if (!links.topicId && work.originTopicId) links.topicId = work.originTopicId;}- // 3. The acceptance round in this scope that ingested this PR url.+ // 3. The acceptance round in this scope that ingested this PR url. Like a+ // hand link, the round is often ingested by someone other than the PR's+ // author β a teammate verifies, the author opens the PR β so the fence is+ // the tenant: a workspace round the author can write to, or their own+ // personal one.if (!links.acceptanceId) {const [run] = await db.select({ acceptanceId: verifyRuns.acceptanceId, workspaceId: verifyRuns.workspaceId })@@ -283,7 +288,7 @@ export const resolveChangeRequestLinks = async (.where(and(isNotNull(verifyRuns.acceptanceId),- inScope(db, verifyRuns, params.scope, pin),+ inTenantScope(db, verifyRuns, params.scope, pin),sql`${verifyRuns.context} -> 'pullRequest' ->> 'url' = ${params.url}`,),)