Skip to content

feat: prefer Announcements category by default for create-discussion#15513

Merged
pelikhan merged 5 commits intomainfrom
copilot/update-documentation-create-discussion-again
Feb 13, 2026
Merged

feat: prefer Announcements category by default for create-discussion#15513
pelikhan merged 5 commits intomainfrom
copilot/update-documentation-create-discussion-again

Conversation

Copy link
Contributor

Copilot AI commented Feb 13, 2026

GitHub Discussion categories have different capabilities. Announcement-capable categories (like "Announcements") provide enhanced visibility and notification features that are beneficial for AI-generated content.

Changes

Documentation

  • Added note callout in safe-outputs.md explaining announcement-capable categories and recommending their use
  • Updated example from category: "general" to category: "announcements" with inline guidance
  • Added best practice comment in frontmatter-full.md category field documentation

Implementation

  • Modified resolveCategoryId function in create_discussion.cjs to intelligently fall back to "Announcements" category when no category is specified or a non-existent category is requested
  • Added new match type "fallback-announcement" to distinguish intentional announcement fallback from generic fallback
  • Enhanced fallback message to include a helpful tip about using announcement-capable categories when discussion creation fails and an issue is created as fallback
  • Added comprehensive tests to verify the new fallback behavior and message content

Fallback Message

When discussion creation fails and falls back to issue creation, the issue body now includes:

> **Tip:** Discussion creation may fail if the specified category is not announcement-capable. Consider using the "Announcements" category or another announcement-capable category in your workflow configuration.

Example

safe-outputs:
  create-discussion:
    category: "announcements"    # category slug, name, or ID (use lowercase, prefer announcement-capable)
    expires: 3
    max: 3

Behavior

When creating discussions:

  1. If a category is explicitly specified and matches (by ID, name, or slug), it will be used
  2. If no match is found or no category is specified, the handler will look for an "Announcements" category (case-insensitive)
  3. If "Announcements" exists, it will be used automatically
  4. Otherwise, it falls back to the first available category

When fallback to issue creation occurs due to permissions errors, users receive guidance about using announcement-capable categories to prevent future failures.

This ensures that workflow-generated discussions automatically benefit from enhanced visibility and notification features without requiring explicit configuration, and provides helpful troubleshooting guidance when issues occur.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot stopped work on behalf of pelikhan due to an error February 13, 2026 21:03
Copilot stopped work on behalf of pelikhan due to an error February 13, 2026 21:03
Copilot stopped work on behalf of pelikhan due to an error February 13, 2026 21:04
…cussion

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update documentation for create discussion categories docs: recommend announcement-capable categories for create-discussion Feb 13, 2026
Copilot AI requested a review from pelikhan February 13, 2026 21:16
@pelikhan
Copy link
Contributor

@copilot update create_discussion.cjs to choose announcements by default instead of general

When no category is specified or a non-existent category is requested,
create_discussion now intelligently falls back to an "Announcements"
category (if available) instead of simply using the first category.

This change ensures AI-generated discussions are created in
announcement-capable categories by default, providing enhanced
visibility and notification features.

Added tests to verify:
- Fallback to Announcements when no category specified
- Fallback to Announcements when non-existent category specified
- Existing behavior preserved when Announcements not available

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot update create_discussion.cjs to choose announcements by default instead of general

Updated in commit da99dba. The resolveCategoryId function now prefers "Announcements" category when falling back:

  • When no category is specified or a non-existent category is requested, it first looks for an "Announcements" category (case-insensitive match on name or slug)
  • If "Announcements" is not available, it falls back to the first category (existing behavior)
  • Added new match type "fallback-announcement" to distinguish the smart fallback
  • Added comprehensive tests to verify the behavior

The change ensures AI-generated discussions automatically use announcement-capable categories for better visibility.

Copilot AI changed the title docs: recommend announcement-capable categories for create-discussion feat: prefer Announcements category by default for create-discussion Feb 13, 2026
Copy link
Contributor

@pelikhan pelikhan left a comment

Choose a reason for hiding this comment

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

@copilot update message inserted in footer when create-discussion failed and an issue is created. Hint that the category needs to be an announcement type.

When create-discussion fails and falls back to creating an issue,
the fallback message now includes a tip suggesting to use
announcement-capable categories like "Announcements".

This helps users understand that discussion creation may fail if
the specified category is not announcement-capable, guiding them
toward the correct configuration.

Updated test to verify the new message content.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 13, 2026

@copilot update message inserted in footer when create-discussion failed and an issue is created. Hint that the category needs to be an announcement type.

Updated in commit ec45bbe. The fallback message now includes a tip about announcement-capable categories:

> **Tip:** Discussion creation may fail if the specified category is not announcement-capable. Consider using the "Announcements" category or another announcement-capable category in your workflow configuration.

This message appears in the issue body when discussion creation fails and falls back to issue creation, helping users understand the category requirement and how to fix it.

@pelikhan pelikhan marked this pull request as ready for review February 13, 2026 21:46
Copilot AI review requested due to automatic review settings February 13, 2026 21:46
@pelikhan pelikhan merged commit ca5369d into main Feb 13, 2026
57 checks passed
@pelikhan pelikhan deleted the copilot/update-documentation-create-discussion-again branch February 13, 2026 21:47
Copy link
Contributor

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 PR updates create-discussion to prefer the repository’s “Announcements” discussion category by default (when present), and aligns surrounding documentation/tests to encourage announcement-capable categories for workflow-generated content.

Changes:

  • Update category resolution to fall back to “Announcements” before the first available category, with a distinct match type.
  • Enhance fallback-to-issue messaging with guidance about announcement-capable categories.
  • Update docs/examples and add/extend tests covering the new behavior and messaging.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
docs/src/content/docs/reference/safe-outputs.md Updates create-discussion example to use announcements and adds guidance about announcement-capable categories.
docs/src/content/docs/reference/frontmatter-full.md Adds best-practice guidance for using announcement-capable categories in create-discussion config docs.
actions/setup/js/create_discussion.cjs Changes category fallback logic to prefer “Announcements” and expands fallback-to-issue note with troubleshooting tip.
actions/setup/js/create_discussion_category_normalization.test.cjs Adds tests verifying Announcements is preferred when category is missing or non-existent.
actions/setup/js/create_discussion_fallback.test.cjs Extends fallback test to assert the new tip text is included in the created issue body.
Comments suppressed due to low confidence (1)

actions/setup/js/create_discussion.cjs:109

  • resolveCategoryId() now prefers the “Announcements” category when no match is found, but the create_discussion tool schema/description still states “If omitted, uses the first available category.” Please update the tool description (and any other user-facing docs) to reflect the new Announcements-preferred default so agents/users don’t make incorrect assumptions.
  // Fall back to announcement-capable category if available, otherwise first category
  if (categories.length > 0) {
    // Try to find an "Announcements" category (case-insensitive)
    const announcementCategory = categories.find(cat => cat.name.toLowerCase() === "announcements" || cat.slug.toLowerCase() === "announcements");

    if (announcementCategory) {
      return {
        id: announcementCategory.id,
        matchType: "fallback-announcement",
        name: announcementCategory.name,
        requestedCategory: categoryToMatch,
      };
    }

    // Otherwise use first category
    return {
      id: categories[0].id,
      matchType: "fallback",
      name: categories[0].name,
      requestedCategory: categoryToMatch,
    };
  }

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

# available category. Matched first against category IDs, then against category
# names, then against category slugs. Numeric values are automatically converted
# to strings at runtime.
#
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

Line # introduces trailing whitespace in the YAML comment block. Please change it to # (no trailing space) or remove the blank comment line to avoid whitespace/lint issues.

Suggested change
#
#

Copilot uses AI. Check for mistakes.
Comment on lines +2195 to +2196
# Best Practice: Use announcement-capable categories (such as "announcements")
# for AI-generated content to ensure proper visibility and notification features.
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

This section still says “If not specified, uses the first available category.” With the new behavior preferring the “Announcements” category when present, update the description above to match (e.g., prefer Announcements, else first available) so the frontmatter reference stays accurate.

See below for a potential fix:

    # category name, or category slug/route. If not specified, prefers an
    # announcement-capable category (such as "Announcements") when available;
    # otherwise uses the first available category. Matched first against category
    # IDs, then against category names, then against category slugs. Numeric values
    # are automatically converted to strings at runtime.
    # 
    # Best Practice: Use announcement-capable categories (such as "Announcements")

Copilot uses AI. Check for mistakes.
Comment on lines +88 to +92
// Fall back to announcement-capable category if available, otherwise first category
if (categories.length > 0) {
// Try to find an "Announcements" category (case-insensitive)
const announcementCategory = categories.find(cat => cat.name.toLowerCase() === "announcements" || cat.slug.toLowerCase() === "announcements");

Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

In this fallback path, requestedCategory comes from categoryToMatch, but categoryToMatch is never trim()’d before ID/name/slug comparisons. If an agent outputs category: "announcements " (trailing space), the match will fail and you’ll unexpectedly fall into this fallback logic. Consider normalizing category inputs with String(...).trim() before matching/fallback.

Copilot uses AI. Check for mistakes.
Comment on lines +856 to +858
title-prefix: "[ai] " # prefix for titles
category: "announcements" # category slug, name, or ID (use lowercase, prefer announcement-capable)
expires: 3 # auto-close after 3 days (or false to disable)
Copy link

Copilot AI Feb 13, 2026

Choose a reason for hiding this comment

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

The create-discussion docs still describe the category as “defaults to first available”, but the implementation now prefers the “Announcements” category when present. Please update the surrounding description to reflect the new fallback order so the example/comment doesn’t contradict actual behavior.

Copilot uses AI. Check for mistakes.
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