Refactor issue assistant workflow for clarity and fixes#153
Merged
Conversation
Signed-off-by: Dima Birenbaum <[email protected]>
There was a problem hiding this comment.
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.
chrisnielsen-MS
approved these changes
Feb 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.