Skip to content

Restrict YouTrack "started working" comment to jetbrains-team - #177

Open
Sergey Pak (paksv) wants to merge 1 commit into
mainfrom
paksv/fix/junie-3685-youtrack-comment-visibility
Open

Restrict YouTrack "started working" comment to jetbrains-team#177
Sergey Pak (paksv) wants to merge 1 commit into
mainfrom
paksv/fix/junie-3685-youtrack-comment-visibility

Conversation

@paksv

Copy link
Copy Markdown
Contributor

Summary

The automated "Hey, it's Junie by JetBrains! I started working..." comment posted to YouTrack issues was publicly visible to everyone, leaking internal status updates (see JUNIE-3685). It is now restricted to the jetbrains-team group only.

Changes

  • src/github/youtrack/client.ts: YouTrackClient.addComment now accepts an optional restrictToJetBrainsTeam flag. When set, it attaches YouTrack's LimitedVisibility payload restricting the comment to the jetbrains-team group (permittedGroups: [{id: "10-3"}]). The group id is hardcoded because, per the referenced upstream fix in junie-agent, the dynamic name→id lookup via /api/groups never resolves this group and silently falls back to public visibility.
  • src/github/junie/prepare-junie.ts: the "started working" comment posted for YouTrack-triggered workflows now passes true for this flag. The final success/failure feedback comment remains visible to the reporter as before.

Verification

  • bun run typecheck passes with no errors.
  • Full non-integration unit test suite (bun test test/*.test.ts): 251/251 tests pass.
  • The live test/integration/youtrack_integration.test.ts suite requires real YouTrack/GitHub credentials and was not run locally; it should be validated in CI to confirm the token belongs to jetbrains-team so it can still locate the restricted comment.

The automated 'Hey, it's Junie by JetBrains! I started working...'
comment posted to YouTrack issues was publicly visible to everyone,
leaking internal status updates. It is now restricted to the
jetbrains-team group only, using YouTrack's LimitedVisibility with a
hardcoded group id (dynamic name->id lookup never resolves this
group, per JetBrains/junie-agent#7105).

Co-authored-by: Junie <junie@jetbrains.com>
@junie-jetbrains

junie-jetbrains Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Junie successfully finished!

Restrict YouTrack Comments Visibility to JetBrains Team

Summary of Changes

This change introduces the ability to restrict YouTrack comment visibility to specific groups. It applies this restriction to the initial execution comment in the Junie workflow, limiting its visibility to the "jetbrains-team" group.

Key Areas

YouTrack Client Visibility Support
Updated the YouTrack client to support restricted visibility for comments using a hardcoded group ID for internal team access.

  • src/github/youtrack/client.ts

Junie Execution Initialization
Updated the initialization logic to mark status comments as internal-only.

  • src/github/junie/prepare-junie.ts

Comments

📝 Suggestions are shown in the inline comments below.

The changes successfully introduce YouTrack comment visibility restrictions to prevent internal status leaks. I've suggested a critical improvement to updateComment in src/github/youtrack/client.ts to ensure that when Junie updates the initial restricted comment with final results, the visibility is explicitly reset to public (as intended per the PR description).


Help us improve Junie code review (EAP): Share feedback

Comment on lines +45 to +56
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 }],
};
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants