Skip to content

Refactor issue assistant workflow for clarity and fixes#153

Merged
DimaBir merged 1 commit intomainfrom
dimabir/yet_another_syntax_fix
Feb 11, 2026
Merged

Refactor issue assistant workflow for clarity and fixes#153
DimaBir merged 1 commit intomainfrom
dimabir/yet_another_syntax_fix

Conversation

@DimaBir
Copy link
Contributor

@DimaBir DimaBir commented Feb 11, 2026

No description provided.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request refactors the issue assistant workflow by removing comments, simplifying code, converting ES6+ syntax to ES5, and externalizing configuration to GitHub Secrets. While the changes aim to improve clarity, several modifications introduce maintenance and configuration challenges.

Changes:

  • Removed explanatory comments and detailed logging throughout the workflow
  • Converted ES6+ syntax (const/let, arrow functions, template literals) to ES5 (var, function expressions, string concatenation) in refactored sections
  • Externalized AI prompts, footer templates, and fallback messages to GitHub Secrets (STATE_PROMPTS, FOOTER_TEMPLATES, FALLBACK_TEMPLATE)
  • Removed one secret detection pattern and simplified error messages
  • Changed conversation marker from "⬅ RESPOND TO THIS" to "[LATEST]"
Comments suppressed due to low confidence (1)

.github/workflows/issue-assistant.yml:191

  • The refactored code uses ES5 syntax (var, function expressions, string concatenation) while other parts of the same workflow file use ES6+ syntax (const, let, arrow functions, template literals). For example, lines 49-52, 246-247, and 329-332 use const. Node.js 20 (line 236) fully supports ES6+ features. This inconsistency reduces code readability and maintainability. Consider either: (1) keeping ES6+ syntax throughout for consistency and readability, or (2) if ES5 is required for a specific reason, converting all JavaScript code blocks in the workflow to ES5 for consistency.
            var sanitizeContent = function(content, maxLength) {
              maxLength = maxLength || 10000;
              if (content == null || content === '') return '';
              var str = String(content);
              var sanitized = str
                .replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g, '')
                .replace(/\r\n/g, '\n')
                .replace(/\r/g, '\n')
                .replace(/[^\S\r\n]+/g, ' ')
                .replace(/\n{3,}/g, '\n\n')
                .trim();
              if (sanitized.length > maxLength) {
                sanitized = sanitized.substring(0, maxLength) + '... [truncated]';
              }
              return sanitized;
            };
            
            var history = [];
            var issueContent = '[Issue opened] ' + issue.title + '\n\n' + (issue.body || '(no description)');
            history.push({
              role: 'user',
              author: issueAuthor,
              content: sanitizeContent(issueContent),
              timestamp: issue.created_at
            });

            for (var i = 0; i < comments.length; i++) {
              var comment = comments[i];
              var isBot = comment.body.includes('<!-- msdo-issue-assistant');
              var isIssueAuthor = comment.user.login === issueAuthor;
              
              if (!isBot && !isIssueAuthor) continue;
              
              var content = comment.body;
              if (isBot) {
                content = content
                  .replace(/<!-- msdo-issue-assistant[^>]*-->/g, '')
                  .replace(/<details>[\s\S]*?<\/details>/g, '')
                  .trim();
              } else {
                content = sanitizeContent(content);
              }

              history.push({
                role: isBot ? 'assistant' : 'user',
                author: comment.user.login,
                content: content,
                timestamp: comment.created_at
              });
            }

            var nextState = 'gathering';
            if (botComments.length === 0) {
              nextState = 'initial';
            } else if (botComments.length >= maxResponses - 1) {
              nextState = 'final_attempt';
            }

            console.log('Next state: ' + nextState);

            var MAX_HISTORY_TURNS = 10;
            var trimmedHistory = history.slice(-MAX_HISTORY_TURNS);

            core.setOutput('should_respond', 'true');
            core.setOutput('state', nextState);
            core.setOutput('history', JSON.stringify(trimmedHistory));

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@DimaBir DimaBir merged commit cd1df84 into main Feb 11, 2026
17 of 18 checks passed
@DimaBir DimaBir deleted the dimabir/yet_another_syntax_fix branch February 11, 2026 18:19
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