Skip to content
Open
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
3 changes: 2 additions & 1 deletion src/github/junie/prepare-junie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ export async function initializeJunieExecution({
try {
console.log('Youtrack Payload: ', JSON.stringify(context.payload, null, 2));
const client = getYouTrackClient(context.payload.youtrackBaseUrl);
const commentId = await client.addComment(context.payload.issueId, INIT_COMMENT_BODY);
// Restricted to jetbrains-team only: this is an internal status update, not meant for external reporters
const commentId = await client.addComment(context.payload.issueId, INIT_COMMENT_BODY, true);
if (commentId) {
core.setOutput(OUTPUT_VARS.YOUTRACK_INIT_COMMENT_ID, commentId);
}
Expand Down
18 changes: 16 additions & 2 deletions src/github/youtrack/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
/**
* YouTrack API client wrapper
*/

// Id of the "jetbrains-team" YouTrack group. Hardcoded because the dynamic name->id
// lookup via /api/groups never resolves this group, regardless of the token's
// permissions - it is simply never returned by that listing endpoint.
const JETBRAINS_TEAM_GROUP_ID = "10-3";

class YouTrackClient {

private readonly token: string;
Expand Down Expand Up @@ -33,17 +39,25 @@ class YouTrackClient {
*
* @param issueId - YouTrack issue ID (e.g., PROJ-123)
* @param text - Comment text in Markdown
* @param restrictToJetBrainsTeam - If true, the comment is only visible to the jetbrains-team group
* @returns comment ID if successful, null otherwise
*/
async addComment(issueId: string, text: string): Promise<string | null> {
async addComment(issueId: string, text: string, restrictToJetBrainsTeam = false): Promise<string | null> {
try {
console.log(`Adding comment to YouTrack issue ${issueId}`);

const url = `${this.baseUrl}/api/issues/${issueId}/comments?fields=id`;
const body: Record<string, unknown> = { text };
if (restrictToJetBrainsTeam) {
body.visibility = {
'$type': 'LimitedVisibility',
permittedGroups: [{ id: JETBRAINS_TEAM_GROUP_ID }],
};
}
Comment on lines +45 to +56

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider also updating updateComment to handle restrictToJetBrainsTeam. Since Junie updates the initial "working" comment with final results, and that initial comment is now restricted, the update must explicitly clear the visibility (e.g., by setting visibility: null) to remain visible to the reporter.

const response = await fetch(url, {
method: 'POST',
headers: this.authHeaders,
body: JSON.stringify({ text }),
body: JSON.stringify(body),
});

if (!response.ok) {
Expand Down
Loading