Add tools to resolve/unresolve discussion threads on Issues

Problem Statement

Currently, the plugin lacks tools to resolve or unresolve discussion threads on GitLab Issues. While we have gitlab_resolve_mr_discussion and gitlab_unresolve_mr_discussion for Merge Requests, there are no equivalent tools for Issues.

This creates an inconsistent user experience where users can manage discussion resolution on MRs but not on Issues, even though the GitLab API supports this functionality for both resource types.

Current Behavior

When a user tries to resolve a discussion thread on an issue:

User: "resolve this thread"
Assistant: *attempts to use gitlab_resolve_mr_discussion*
Result: 404 Discussion Not Found (because it's an issue, not an MR)

Available tools for Issues:

  • gitlab_create_issue_note - Create comments (with thread support via discussion_id)
  • gitlab_list_issue_discussions - List discussion threads
  • gitlab_get_issue_discussion - Get specific discussion thread
  • gitlab_resolve_issue_discussion - MISSING
  • gitlab_unresolve_issue_discussion - MISSING

Available tools for Merge Requests (for comparison):

  • gitlab_create_mr_note - Create comments
  • gitlab_list_mr_discussions - List discussion threads
  • gitlab_get_mr_discussion - Get specific discussion thread
  • gitlab_resolve_mr_discussion - Resolve discussions
  • gitlab_unresolve_mr_discussion - Unresolve discussions

Expected Behavior

Users should be able to resolve and unresolve discussion threads on Issues just like they can on Merge Requests:

User: "resolve the discussion thread on issue #3"
Assistant: *uses gitlab_resolve_issue_discussion*
Result: Discussion marked as resolved ✓

Use Cases

  1. Mark feedback as addressed: After responding to a comment thread, mark it as resolved to indicate the discussion is complete
  2. Reopen discussions: Unresolve a thread if additional discussion is needed
  3. Discussion management: Keep track of which feedback has been addressed in issue discussions
  4. Consistent workflow: Use the same resolution workflow across Issues and MRs

Proposed Solution

Add two new tools following the existing pattern for MR discussions:

1. gitlab_resolve_issue_discussion

Marks an issue discussion thread as resolved.

Parameters:

  • project_id (string, required) - The ID or URL-encoded path of the project
  • issue_iid (number, required) - The internal ID of the issue
  • discussion_id (string, required) - The ID of the discussion thread to resolve

GitLab API Endpoint:

PUT /projects/:id/issues/:issue_iid/discussions/:discussion_id
Body: { "resolved": true }

Example usage:

gitlab_resolve_issue_discussion({
  project_id: "vglafirov/opencode-gitlab-plugin",
  issue_iid: 3,
  discussion_id: "85ae6243ddb359877af4e19d8f2e35ecd73b0ed6"
})

2. gitlab_unresolve_issue_discussion

Reopens a resolved issue discussion thread.

Parameters:

  • project_id (string, required) - The ID or URL-encoded path of the project
  • issue_iid (number, required) - The internal ID of the issue
  • discussion_id (string, required) - The ID of the discussion thread to unresolve

GitLab API Endpoint:

PUT /projects/:id/issues/:issue_iid/discussions/:discussion_id
Body: { "resolved": false }

Example usage:

gitlab_unresolve_issue_discussion({
  project_id: "vglafirov/opencode-gitlab-plugin",
  issue_iid: 3,
  discussion_id: "85ae6243ddb359877af4e19d8f2e35ecd73b0ed6"
})

Implementation Details

File Structure

Following the existing pattern:

  1. Client method in src/client/discussions.ts:
async resolveIssueDiscussion(
  projectId: string,
  issueIid: number,
  discussionId: string
): Promise<Discussion>

async unresolveIssueDiscussion(
  projectId: string,
  issueIid: number,
  discussionId: string
): Promise<Discussion>
  1. Tool definition in src/tools/discussions.ts:
export const resolveIssueDiscussionTool = {
  name: "gitlab_resolve_issue_discussion",
  description: "Mark an issue discussion thread as resolved...",
  // ... tool schema
}

export const unresolveIssueDiscussionTool = {
  name: "gitlab_unresolve_issue_discussion",
  description: "Reopen a resolved issue discussion thread...",
  // ... tool schema
}

API Reference

GitLab REST API Documentation:

  • Discussions API
  • Endpoint: PUT /projects/:id/issues/:issue_iid/discussions/:discussion_id
  • Requires: Maintainer role or higher on the project

Error Handling

Handle common error cases:

  • 404 Not Found: Discussion ID doesn't exist or user lacks permissions
  • 400 Bad Request: Invalid discussion ID format
  • 403 Forbidden: User doesn't have permission to resolve discussions
  • Individual notes: Some discussions are individual notes and cannot be resolved (check resolvable field)

Acceptance Criteria

  • gitlab_resolve_issue_discussion tool successfully marks issue discussion threads as resolved
  • gitlab_unresolve_issue_discussion tool successfully reopens resolved issue discussions
  • Tools follow the same pattern and naming convention as MR discussion tools
  • Error messages clearly indicate when a discussion cannot be resolved (e.g., individual notes)
  • Tool descriptions include examples and parameter documentation
  • Changes are reflected correctly in the GitLab UI
  • Unit tests cover both success and error cases
  • Documentation updated with new tool descriptions

Technical Notes

Discussion Types

Not all discussions can be resolved:

  • Resolvable discussions: Multi-note threads (check resolvable: true)
  • Non-resolvable: Individual notes, system notes (check resolvable: false)

The tools should check the resolvable field before attempting to resolve.

Permissions

Users need at least Reporter role to view discussions and Developer role to resolve them.

API Response

The API returns the updated discussion object with resolved: true/false and includes:

  • resolved_by: User who resolved the discussion
  • resolved_at: Timestamp when resolved
  • All notes in the thread
  • #3 - Parent issue: Add comprehensive support for comment threads across all GitLab resources
  • This issue addresses Phase 2, item 4-5 of the proposed solution in #3

Priority

High Priority - This is a commonly used workflow feature that users expect to work consistently across Issues and MRs. The gap was discovered during real usage when attempting to resolve a discussion thread on issue #3.

Additional Context

This functionality gap was discovered when attempting to resolve a discussion thread on issue #3. The user expected the same resolution workflow available for MRs to work for Issues, but the tools don't exist yet.

The GitLab API already supports this functionality - we just need to expose it through the plugin's tool interface.