Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/provider-comment-untrusted-framing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@roomote/web": patch
---

Apply the untrusted-content prompt framing to GitLab, Bitbucket, Azure DevOps, and Gitea comment follow-up messages, wrapping the triggering comment in a mention-request block and appending the shared injection-resistance policy
16 changes: 15 additions & 1 deletion apps/api/src/handlers/ado/__tests__/handleComment.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions apps/api/src/handlers/ado/handleComment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { enqueueTask, getTaskUrl } from '@roomote/cloud-agents/server';
import {
buildMentionRequestBlock,
buildUntrustedContentPolicy,
enqueueTask,
escapeTaskContextText,
getTaskUrl,
} from '@roomote/cloud-agents/server';
import {
findActiveGitHubPrReviewTask,
findReusableGitHubPrFollowUpOwner,
Expand Down Expand Up @@ -207,14 +213,6 @@ function buildTaskStartFailedComment(): string {
return 'I saw the mention, but I could not start a task for this pull request right now. Please try again in a moment.';
}

function formatQuotedText(text: string): string {
return text
.trim()
.split('\n')
.map((line) => `> ${line}`)
.join('\n');
}

function buildExistingTaskFollowUpMessage({
repoFullName,
pullRequest,
Expand All @@ -227,8 +225,7 @@ function buildExistingTaskFollowUpMessage({
commentBody: string;
}): string {
const lines = [
`${commenter} mentioned Roomote in a comment on Azure DevOps pull request #${pullRequest.pullRequestId} (${pullRequest.title}) in ${repoFullName}:`,
formatQuotedText(commentBody),
`${commenter} mentioned Roomote in a comment on Azure DevOps pull request #${pullRequest.pullRequestId} (${escapeTaskContextText(pullRequest.title)}) in ${repoFullName}.`,
'',
'Please act on this comment as a follow-up to your existing work on this pull request.',
];
Expand All @@ -238,6 +235,14 @@ function buildExistingTaskFollowUpMessage({
lines.push(`The pull request source branch is \`${branchName}\`.`);
}

lines.push(
'',
'Mention comment (the request to act on):',
buildMentionRequestBlock(commentBody),
'',
buildUntrustedContentPolicy(),
);

return lines.join('\n');
}

Expand Down
81 changes: 79 additions & 2 deletions apps/api/src/handlers/bitbucket/__tests__/handleComment.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions apps/api/src/handlers/bitbucket/handleComment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { enqueueTask, getTaskUrl } from '@roomote/cloud-agents/server';
import {
buildMentionRequestBlock,
buildUntrustedContentPolicy,
enqueueTask,
escapeTaskContextText,
getTaskUrl,
} from '@roomote/cloud-agents/server';
import {
findActiveGitHubPrReviewTask,
findReusableGitHubPrFollowUpOwner,
Expand Down Expand Up @@ -141,14 +147,6 @@ function buildTaskStartFailedComment(): string {
return 'I saw the mention, but Roomote could not queue a review task for this pull request. Please try again in a moment. If it keeps failing, an administrator should check the deployment logs.';
}

function formatQuotedText(text: string): string {
return text
.trim()
.split('\n')
.map((line) => `> ${line}`)
.join('\n');
}

function buildExistingTaskFollowUpMessage({
repoFullName,
pullRequestNumber,
Expand All @@ -165,8 +163,7 @@ function buildExistingTaskFollowUpMessage({
commentBody: string;
}): string {
const lines = [
`${commenter} mentioned Roomote in a comment on Bitbucket pull request #${pullRequestNumber} (${pullRequestTitle}) in ${repoFullName}:`,
formatQuotedText(commentBody),
`${commenter} mentioned Roomote in a comment on Bitbucket pull request #${pullRequestNumber} (${escapeTaskContextText(pullRequestTitle)}) in ${repoFullName}.`,
'',
'Please act on this comment as a follow-up to your existing work on this pull request.',
];
Expand All @@ -175,6 +172,14 @@ function buildExistingTaskFollowUpMessage({
lines.push(`The pull request source branch is \`${headRef}\`.`);
}

lines.push(
'',
'Mention comment (the request to act on):',
buildMentionRequestBlock(commentBody),
'',
buildUntrustedContentPolicy(),
);

return lines.join('\n');
}

Expand Down
16 changes: 15 additions & 1 deletion apps/api/src/handlers/gitea/__tests__/handleComment.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 16 additions & 11 deletions apps/api/src/handlers/gitea/handleComment.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { enqueueTask, getTaskUrl } from '@roomote/cloud-agents/server';
import {
buildMentionRequestBlock,
buildUntrustedContentPolicy,
enqueueTask,
escapeTaskContextText,
getTaskUrl,
} from '@roomote/cloud-agents/server';
import {
findActiveGitHubPrReviewTask,
findReusableGitHubPrFollowUpOwner,
Expand Down Expand Up @@ -184,14 +190,6 @@ function buildTaskStartFailedComment(): string {
return 'I saw the mention, but I could not start a task for this pull request right now. Please try again in a moment.';
}

function formatQuotedText(text: string): string {
return text
.trim()
.split('\n')
.map((line) => `> ${line}`)
.join('\n');
}

function buildExistingTaskFollowUpMessage({
repoFullName,
pullRequest,
Expand All @@ -204,8 +202,7 @@ function buildExistingTaskFollowUpMessage({
commentBody: string;
}): string {
const lines = [
`${commenter} mentioned Roomote in a comment on Gitea pull request #${pullRequest.number} (${pullRequest.title}) in ${repoFullName}:`,
formatQuotedText(commentBody),
`${commenter} mentioned Roomote in a comment on Gitea pull request #${pullRequest.number} (${escapeTaskContextText(pullRequest.title)}) in ${repoFullName}.`,
'',
'Please act on this comment as a follow-up to your existing work on this pull request.',
];
Expand All @@ -216,6 +213,14 @@ function buildExistingTaskFollowUpMessage({
);
}

lines.push(
'',
'Mention comment (the request to act on):',
buildMentionRequestBlock(commentBody),
'',
buildUntrustedContentPolicy(),
);

return lines.join('\n');
}

Expand Down
11 changes: 11 additions & 0 deletions apps/api/src/handlers/gitlab/__tests__/handleNote.test.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading