diff --git a/CHANGELOG.md b/CHANGELOG.md index 2864ca1dec75..77343f06adb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,14 @@ We published the first iteration of a [journey landing page](https://docs.github
+**15 May 2026** + +We've published a new [GitHub Secret Protection adoption journey landing page](https://docs.github.com/en/code-security/tutorials/secret-protection-adoption-path) for AppSec administrators. Our content audit found that while individual GHSP articles existed, there was no clear end-to-end path from evaluation to organization-wide rollout. + +The new page organizes existing content into a 5-phase adoption journey: assess secret risk, evaluate fit and cost, pilot with selected repositories, monitor metrics, and scale protection across your organization 🎉 + +
+ **12 May 2026** We have now published the GitHub Enterprise Server (GHES) 3.21 release candidate notes. You can read the full notes here: diff --git a/content/account-and-profile/how-tos/account-management/moving-your-work-to-an-organization.md b/content/account-and-profile/how-tos/account-management/moving-your-work-to-an-organization.md index ea6a0595d0f7..3222fef4ced8 100644 --- a/content/account-and-profile/how-tos/account-management/moving-your-work-to-an-organization.md +++ b/content/account-and-profile/how-tos/account-management/moving-your-work-to-an-organization.md @@ -28,5 +28,9 @@ If you want your new organization to use your current personal account username, ## Further reading +{% ifversion fpt or ghec %} - [AUTOTITLE](/organizations/managing-membership-in-your-organization/inviting-users-to-join-your-organization) +{% else %} +- [AUTOTITLE](/organizations/managing-membership-in-your-organization/adding-people-to-your-organization) +{% endif %} - [AUTOTITLE](/organizations/managing-peoples-access-to-your-organization-with-roles/maintaining-ownership-continuity-for-your-organization) diff --git a/content/actions/how-tos/troubleshoot-workflows.md b/content/actions/how-tos/troubleshoot-workflows.md index 1af848f1b923..26186b8e5217 100644 --- a/content/actions/how-tos/troubleshoot-workflows.md +++ b/content/actions/how-tos/troubleshoot-workflows.md @@ -142,6 +142,14 @@ If you use self-hosted runners, you can view their activity and diagnose common For more information, see [AUTOTITLE](/actions/how-tos/manage-runners/self-hosted-runners/monitor-and-troubleshoot). +{% ifversion fpt or ghec %} + +### Runner IP addresses flagged by security scanners + +{% data reusables.actions.runner-ip-reputation %} + +{% endif %} + ## Networking troubleshooting suggestions Our support is limited for network issues that involve: diff --git a/content/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses.md b/content/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses.md index 1d33e33de74f..d7afb65fb6d8 100644 --- a/content/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses.md +++ b/content/authentication/keeping-your-account-and-data-secure/about-githubs-ip-addresses.md @@ -31,6 +31,12 @@ We make changes to our IP addresses from time to time. We do not recommend allow For applications to function, you must allow TCP ports 22, 80, and 443 via our IP ranges for `github.com` and `{% data variables.enterprise.data_residency_domain %}`. +## {% data variables.product.prodname_actions %} runner IP addresses and third-party IP reputation services + +{% data reusables.actions.runner-ip-reputation %} + +For more information about {% data variables.product.prodname_actions %} runner IP ranges, see [AUTOTITLE](/actions/how-tos/troubleshoot-workflows#runner-ip-addresses-flagged-by-security-scanners). + ## Further reading * [AUTOTITLE](/get-started/using-github/troubleshooting-connectivity-problems) diff --git a/content/code-security/concepts/supply-chain-security/immutable-releases.md b/content/code-security/concepts/supply-chain-security/immutable-releases.md index 12cbdaa97cab..08757f152b7f 100644 --- a/content/code-security/concepts/supply-chain-security/immutable-releases.md +++ b/content/code-security/concepts/supply-chain-security/immutable-releases.md @@ -26,7 +26,7 @@ Additionally, creating an immutable release automatically generates a **release > [!NOTE] > Immutable releases include protection against repository resurrection attacks. Even if you delete a repository and create a new one with the same name, you cannot reuse tags that were associated with immutable releases in the original repository. -If a release is immutable, you will see "{% octicon "lock" aria-hidden="true" %} Immutable" below the title on the release page. +If a release is immutable, you will see {% octicon "lock" aria-hidden="true" %} **Immutable**" below the title on the release page. ## Best practices for publishing immutable releases diff --git a/content/code-security/reference/security-incident-response/investigation-areas.md b/content/code-security/reference/security-incident-response/investigation-areas.md index 026121d19c63..311503c2a219 100644 --- a/content/code-security/reference/security-incident-response/investigation-areas.md +++ b/content/code-security/reference/security-incident-response/investigation-areas.md @@ -128,6 +128,12 @@ You found suspicious code in your repository, a security researcher reported an * [Containment actions](/code-security/tutorials/secure-your-organization/responding-to-security-incidents#step-2-contain-the-threat) +{% ifversion fpt or ghec %} + +{% data reusables.actions.runner-ip-reputation-note %} + +{% endif %} + ## Malware and supply chain attacks This section may apply when: diff --git a/content/code-security/tutorials/secure-your-organization/responding-to-security-incidents.md b/content/code-security/tutorials/secure-your-organization/responding-to-security-incidents.md index 2e177f5971f5..524380d13996 100644 --- a/content/code-security/tutorials/secure-your-organization/responding-to-security-incidents.md +++ b/content/code-security/tutorials/secure-your-organization/responding-to-security-incidents.md @@ -47,6 +47,12 @@ Try to identify the nature of the signal you're seeing. For example, does the si For help identifying these threat signals across your organization or enterprise, consult [AUTOTITLE](/code-security/reference/security-incident-response/investigation-areas). +{% ifversion fpt or ghec %} + +{% data reusables.actions.runner-ip-reputation-note %} + +{% endif %} + We suggest you don't spend too much time on deep inspection in the earlier stages of your investigation, since the initial goal is to **identify** the threat signal in order to **validate** it and strategize your response. ### 2. Validate diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md b/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md deleted file mode 100644 index eb85aef24285..000000000000 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information.md +++ /dev/null @@ -1,73 +0,0 @@ ---- -title: Extracting information -shortTitle: Extract information -intro: Copilot Chat in GitHub can help you extract key information from issues and discussions. -versions: - feature: copilot -complexity: - - Simple -octicon: copilot -category: - - Communicate effectively - - Author and optimize with Copilot - - Scale institutional knowledge -contentType: tutorials ---- - -{% data variables.copilot.copilot_chat %} can help you extract key information from issues and discussions, making it easier to summarize and understand the content. You can ask {% data variables.copilot.copilot_chat_short %} to identify important details, such as action items, deadlines, or specific requests. - -## Example scenario 1 - -You are reviewing a long discussion thread about a feature request. You want to quickly identify the main points and any action items that need to be addressed. - -## Example prompt - -```copilot copy -Can you summarize the key points and action items from this discussion? -``` - -## Example response - -{% data reusables.copilot.example-prompts.response-is-an-example %} - -````text -Key Points: -- The feature request aims to improve the user interface for better accessibility. -- There are concerns about the impact on existing users and workflows. -- Action items include gathering feedback from users and conducting usability testing. -Action Items: -- [ ] Gather feedback from users by the end of the week. -- [ ] Conduct usability testing with a focus group next month. -```` - -## Example scenario 2 - -You have a number of open issues assigned to you, and you want to extract the deadlines and priorities for each issue to help you prioritize your work. - -## Example prompt - -```copilot copy prompt -Can you list the open issues assigned to me, along with their deadlines and priorities? -``` - -## Example response - -{% data reusables.copilot.example-prompts.response-is-an-example %} - -````text -Issue 1: -- Deadline: Next Friday -- Priority: High - -Issue 2: -- Deadline: End of the month -- Priority: Medium - -Issue 3: -- Deadline: No specific deadline -- Priority: Low -```` - -## Further reading - -{% data reusables.copilot.example-prompts.further-reading-items %} diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/index.md b/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/index.md deleted file mode 100644 index 4b57a9b46ca1..000000000000 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/index.md +++ /dev/null @@ -1,13 +0,0 @@ ---- -title: Communicate effectively -intro: 'Discover ways that you can use {% data variables.product.prodname_copilot %} to communicate effectively with your team and stakeholders.' -versions: - feature: copilot -children: - - /creating-templates - - /extracting-information - - /synthesizing-research - - /creating-diagrams - - /generating-tables -contentType: tutorials ---- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/diagnose-test-failures.md b/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/diagnose-test-failures.md deleted file mode 100644 index e1ad0dd947bc..000000000000 --- a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/diagnose-test-failures.md +++ /dev/null @@ -1,102 +0,0 @@ ---- -title: Diagnosing test failures -shortTitle: Diagnose test failures -intro: '{% data variables.copilot.copilot_chat_short %} can help you understand why a test is failing and suggest how to fix it.' -versions: - feature: copilot -category: - - Debugging code - - Author and optimize with Copilot - - Improve quality and maintainability -complexity: - - Intermediate -octicon: bug -contentType: tutorials ---- - -{% data variables.copilot.copilot_chat_short %} can analyze test failures and help identify potential causes. - -## Example scenario: Tests passing locally but failing in CI - -Consider a scenario where you have a test that passes on your local machine but sometimes fails in CI. {% data variables.copilot.copilot_chat_short %} can help identify the reason for the failure. - -In this example, the code being tested defines a simple order service (`order.py`), and there's a corresponding test that checks if an order was created today (`test_order_service.py`). - -## Example prompt - -The prompt below provides {% data variables.product.prodname_copilot_short %} with the relevant code and test files (using `#file:`) and includes a copy/paste of the relevant excerpt from the CI failure. - -```copilot copy -Please take a look at this CI failure message. The test passes locally, but intermittently fails in CI. Can you help me figure out if this looks like a code bug, environment issue, or a flaky test? - -Failure: - -___ TestOrderService.test_order_created_today ___ -> assert order["created_date"] == date.today() -E AssertionError: assert datetime.date(2024, 1, 15) == datetime.date(2024, 1, 16) - -test_order_service.py:45: AssertionError - -#file:order.py -#file:test_order_service.py - -``` - -## Example response - -{% data reusables.copilot.example-prompts.response-is-an-example %} - -{% data variables.copilot.copilot_chat_short %} notices that the dates are exactly one day apart and identifies that this could be a **timezone** or **time-boundary** issue. - -The local machine and CI runner may be using different timezone settings or deriving `today` from different clocks (UTC vs. local time), so when the test runs near midnight, `date.today()` can return different dates in each environment. - -{% data variables.copilot.copilot_chat_short %} suggests treating the failure as test flakiness caused by environment/time assumptions (and not a logic bug), and fixing it by standardizing how `today` is computed across environments. - -## Example scenario 2: Intermittent test failures - -Consider a scenario where a test sometimes passes and sometimes fails on the same machine. {% data variables.copilot.copilot_chat_short %} can compare logs from passing and failing runs to help identify the cause. - -In this example, the code under test uses a background job in `order_service.py` to update an order's status asynchronously, and a test in `test_order_service.py` asserts that the final status is `"processed"`. - -## Example prompt - -The prompt below provides {% data variables.product.prodname_copilot_short %} with the failure message, the log excerpts from both a passing and failing run, and the relevant code files (using `#file:`). - -```copilot copy -This test passes sometimes and fails sometimes. Can you compare the logs and help me figure out why? - -Failure message: - -> assert order.status == "processed" -E AssertionError: assert "pending" == "processed" - -test_order_service.py:62: AssertionError - -Logs from a passing run: -[DEBUG] Created order #1234 -[DEBUG] Background job started for order #1234 -[DEBUG] Background job completed (52ms) -[DEBUG] Checking order status -[DEBUG] Order #1234 status: processed - -Logs from the failing run: -[DEBUG] Created order #1234 -[DEBUG] Background job started for order #1234 -[DEBUG] Checking order status -[DEBUG] Order #1234 status: pending - -#file:order_service.py -#file:test_order_service.py -``` - -## Example response - -{% data reusables.copilot.example-prompts.response-is-an-example %} - -{% data variables.copilot.copilot_chat_short %} compares the two logs and notices that in the passing run, the background job completed *before* the status check, while in the failing run, the status was checked while the job was still running. {% data variables.copilot.copilot_chat_short %} notes that this is a **race condition**, as the test doesn't wait for the background job to finish. - -{% data variables.copilot.copilot_chat_short %} suggests adding a mechanism to ensure the job completes before asserting, such as running the job synchronously, awaiting completion (for example, via a callback), or polling. - -## Further reading - -{% data reusables.copilot.example-prompts.further-reading-items %} diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/creating-issues.md b/content/copilot/tutorials/copilot-chat-cookbook/document-code/creating-issues.md deleted file mode 100644 index 91e987a0f5e0..000000000000 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/creating-issues.md +++ /dev/null @@ -1,80 +0,0 @@ ---- -title: Creating issues -shortTitle: Create issues -intro: '{% data variables.copilot.copilot_chat_short %} can help you quickly create issues without filling out every field manually.' -versions: - feature: copilot -complexity: - - Simple -octicon: copilot -category: - - Documenting code - - Author and optimize with Copilot - - Scale institutional knowledge -contentType: tutorials ---- - -Creating issues manually can be time-consuming. {% data variables.copilot.copilot_chat_short %} lets you create issues from natural language, and automatically fills in the title, body, labels, and other metadata based on your prompt. - -## Example scenario - -You're working on an API service and need to add server-side validation to the `createUser` endpoint. Instead of drafting the issue manually, you use {% data variables.copilot.copilot_chat_short %} to generate a detailed issue description that includes an example implementation of the validation middleware. - -The following snippet shows the current implementation of the `createUser` route, before validation is added: - -```javascript -// Route -app.post('/users', validateCreateUser, (req, res) => { - const { username, email } = req.body; - // Simulate user creation - res.status(201).json({ message: 'User created', user: { username, email } }); -}); -``` - -## Example prompt - -`In octo-org/octo-repo, create an issue to add server-side validation for the createUser API endpoint. Include an example of how to validate the request body using an existing middleware pattern. Label it with "backend" and "enhancement".` - -## Example response - -{% data reusables.copilot.example-prompts.response-is-an-example %} - -When you submit the prompt, {% data variables.copilot.copilot_chat_short %} generates a draft issue based on your description and includes a code snippet. You can review and edit the draft before creating the issue. - -```markdown -## Problem -The `createUser` API endpoint currently lacks robust server-side validation for incoming requests. To ensure data integrity and security, we should validate the request body before proceeding with user creation. - -**Current API endpoint:** -// Route -app.post('/users', validateCreateUser, (req, res) => { - const { username, email } = req.body; - // Simulate user creation - res.status(201).json({ message: 'User created', user: { username, email } }); -}); - -## Proposal -- Add server-side validation for the request body using the existing middleware pattern. -- Ensure required fields (`username`, `email`) are present and valid. -- Return a 400 Bad Request response if validation fails. - -**Example (middleware pattern):** -function validateCreateUser(req, res, next) { - const { username, email } = req.body; - if (!username || !email) { - return res.status(400).json({ error: 'Username and email are required.' }); - } - // Additional validation logic here - next(); -} - -app.post('/users', validateCreateUser, (req, res) => { - // ... -}); - - -## Acceptance Criteria -- Server-side validation middleware is added to the `createUser` endpoint. -- Request body is properly validated. -- Appropriate error responses are returned for invalid requests. -``` diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md b/content/copilot/tutorials/copilot-cookbook/analyze-functionality/analyze-feedback.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md rename to content/copilot/tutorials/copilot-cookbook/analyze-functionality/analyze-feedback.md index 62023e3c7e3a..df8b0c17102b 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-functionality/analyze-feedback.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions/analyzing-and-incorporating-user-feedback - /copilot/tutorials/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions/analyzing-and-incorporating-user-feedback - /copilot/tutorials/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions/analyze-feedback + - /copilot/tutorials/copilot-chat-cookbook/analyze-functionality/analyze-feedback versions: feature: copilot category: - Functionality analysis - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Intermediate +surface: + - Chat octicon: lightbulb contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md b/content/copilot/tutorials/copilot-cookbook/analyze-functionality/explore-implementations.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md rename to content/copilot/tutorials/copilot-cookbook/analyze-functionality/explore-implementations.md index 61ad24b0d845..64546ac1bf8d 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-functionality/explore-implementations.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions/exploring-potential-feature-implementations - /copilot/tutorials/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions/exploring-potential-feature-implementations - /copilot/tutorials/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions/explore-implementations + - /copilot/tutorials/copilot-chat-cookbook/analyze-functionality/explore-implementations versions: feature: copilot category: - Functionality analysis - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Intermediate +surface: + - Chat octicon: lightbulb contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/index.md b/content/copilot/tutorials/copilot-cookbook/analyze-functionality/index.md similarity index 69% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/index.md rename to content/copilot/tutorials/copilot-cookbook/analyze-functionality/index.md index 10077e227a4d..04bd0c963147 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-functionality/index.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-functionality/index.md @@ -1,10 +1,11 @@ --- title: Analyze functionality -intro: 'Discover ways that you can use {% data variables.product.prodname_copilot %} to improve the functionality of your project.' +intro: Discover ways that you can use {% data variables.product.prodname_copilot %} to improve the functionality of your project. redirect_from: - /copilot/example-prompts-for-github-copilot-chat/functionality-analysis-and-feature-suggestions - /copilot/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions - /copilot/tutorials/copilot-chat-cookbook/functionality-analysis-and-feature-suggestions + - /copilot/tutorials/copilot-chat-cookbook/analyze-functionality versions: feature: copilot children: diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md b/content/copilot/tutorials/copilot-cookbook/analyze-security/find-vulnerabilities.md similarity index 96% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md rename to content/copilot/tutorials/copilot-cookbook/analyze-security/find-vulnerabilities.md index e20c3fbf7d95..4722ee948ed1 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-security/find-vulnerabilities.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/security-analysis/finding-existing-vulnerabilities-in-code - /copilot/tutorials/copilot-chat-cookbook/security-analysis/finding-existing-vulnerabilities-in-code - /copilot/tutorials/copilot-chat-cookbook/security-analysis/find-vulnerabilities + - /copilot/tutorials/copilot-chat-cookbook/analyze-security/find-vulnerabilities versions: feature: copilot category: - Security analysis - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: code contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/index.md b/content/copilot/tutorials/copilot-cookbook/analyze-security/index.md similarity index 67% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-security/index.md rename to content/copilot/tutorials/copilot-cookbook/analyze-security/index.md index 599425b4f8b3..2ed673a2e750 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/index.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-security/index.md @@ -1,10 +1,11 @@ --- title: Analyze security -intro: 'Discover ways that you can use {% data variables.product.prodname_copilot %} to improve the security of your code.' +intro: Discover ways that you can use {% data variables.product.prodname_copilot %} to improve the security of your code. redirect_from: - /copilot/example-prompts-for-github-copilot-chat/security-analysis - /copilot/copilot-chat-cookbook/security-analysis - /copilot/tutorials/copilot-chat-cookbook/security-analysis + - /copilot/tutorials/copilot-chat-cookbook/analyze-security versions: feature: copilot children: diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md b/content/copilot/tutorials/copilot-cookbook/analyze-security/manage-dependency-updates.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md rename to content/copilot/tutorials/copilot-cookbook/analyze-security/manage-dependency-updates.md index 3428957a5011..0f241248470c 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-security/manage-dependency-updates.md @@ -8,12 +8,13 @@ category: - Security analysis - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Simple +surface: + - Chat octicon: code redirect_from: - /copilot/tutorials/copilot-chat-cookbook/security-analysis/managing-dependency-updates - /copilot/tutorials/copilot-chat-cookbook/security-analysis/manage-dependency-updates + - /copilot/tutorials/copilot-chat-cookbook/analyze-security/manage-dependency-updates contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md b/content/copilot/tutorials/copilot-cookbook/analyze-security/secure-your-repository.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md rename to content/copilot/tutorials/copilot-cookbook/analyze-security/secure-your-repository.md index 46000138080a..a959ba3632ab 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository.md +++ b/content/copilot/tutorials/copilot-cookbook/analyze-security/secure-your-repository.md @@ -8,12 +8,13 @@ category: - Security analysis - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Simple +surface: + - Chat octicon: code redirect_from: - /copilot/tutorials/copilot-chat-cookbook/security-analysis/securing-your-repository - /copilot/tutorials/copilot-chat-cookbook/security-analysis/secure-your-repository + - /copilot/tutorials/copilot-chat-cookbook/analyze-security/secure-your-repository contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/creating-diagrams.md similarity index 95% rename from content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md rename to content/copilot/tutorials/copilot-cookbook/communicate-effectively/creating-diagrams.md index e23d3ce97667..7e600a646932 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams.md +++ b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/creating-diagrams.md @@ -4,8 +4,8 @@ shortTitle: Create diagrams intro: GitHub Copilot Chat can help you create diagrams to better understand your data and communicate insights. versions: feature: copilot -complexity: - - Simple +surface: + - Chat octicon: copilot category: - Communicate effectively @@ -13,6 +13,8 @@ category: - Scale institutional knowledge - Author and optimize with Copilot contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-diagrams --- {% data variables.copilot.copilot_chat %} on {% data variables.product.prodname_dotcom_the_website %} can help you create Mermaid diagrams to visualize data, making it easier to understand and communicate insights. You can ask {% data variables.copilot.copilot_chat_short %} to generate diagrams based on your data or code, and it will provide you with the necessary code to create those diagrams. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-templates.md b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/creating-templates.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-templates.md rename to content/copilot/tutorials/copilot-cookbook/communicate-effectively/creating-templates.md index 2a65e57e1f54..19697c309f3c 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-templates.md +++ b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/creating-templates.md @@ -8,10 +8,12 @@ category: - Communicate effectively - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Simple +surface: + - Chat octicon: copilot contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively/creating-templates --- {% data variables.copilot.copilot_chat %} can help you create templates for various purposes, such as project documentation, code snippets, or issue tracking. By using templates, you can streamline your workflow and ensure consistency across your projects. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/generating-tables.md b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/generating-tables.md similarity index 96% rename from content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/generating-tables.md rename to content/copilot/tutorials/copilot-cookbook/communicate-effectively/generating-tables.md index ba3157a9a43b..69e4add696dd 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/generating-tables.md +++ b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/generating-tables.md @@ -4,14 +4,16 @@ shortTitle: Generate tables intro: '{% data variables.copilot.copilot_chat_short %} can help you create tables to organize information and present it clearly.' versions: feature: copilot -complexity: - - Simple +surface: + - Chat octicon: copilot category: - Communicate effectively - Author and optimize with Copilot - Scale institutional knowledge contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively/generating-tables --- {% data variables.copilot.copilot_chat %} can help you create tables for various purposes, such as organizing data, comparing options, or summarizing information. By using tables, you can present information in a clear and structured way that is easy to read and understand. You can ask {% data variables.copilot.copilot_chat_short %} to generate tables based on existing data or to create empty tables based on your specific requirements. diff --git a/content/copilot/tutorials/copilot-cookbook/communicate-effectively/index.md b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/index.md new file mode 100644 index 000000000000..a100c2b65dde --- /dev/null +++ b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/index.md @@ -0,0 +1,16 @@ +--- +title: Communicate effectively +intro: Discover ways that you can use {% data variables.product.prodname_copilot %} to communicate effectively with your team and stakeholders. +versions: + feature: copilot +children: + - /creating-templates + - /summarize-repository-activity + - /synthesizing-research + - /creating-diagrams + - /generating-tables +contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively +--- + diff --git a/content/copilot/tutorials/copilot-cookbook/communicate-effectively/summarize-repository-activity.md b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/summarize-repository-activity.md new file mode 100644 index 000000000000..e3bed7038676 --- /dev/null +++ b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/summarize-repository-activity.md @@ -0,0 +1,59 @@ +--- +title: Triage and summarize repository activity +shortTitle: Summarize repository activity +intro: Copilot can extract key information from repositories you follow to keep you up-to-date on recent activity. +versions: + feature: copilot +surface: + - CLI +octicon: copilot +category: + - Communicate effectively + - Author and optimize with Copilot + - Scale institutional knowledge +contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively/extracting-information + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively/summarize-repository-activity +--- + +{% data variables.copilot.copilot_cli %} can help you summarize all recent activity in a repository. {% data variables.copilot.copilot_cli_short %} will find information about issues, pull requests, commits, CI health, and security notifications, and you can ask it to summarize this information in a report for you. + +## Example scenario + +You are returning to a repository after a week away and need to catch up. You want a single report that covers recent activity and the current health of the project so you can prioritize your work. + +## Example prompt + +```text copy +Summarize activity in this repository over the past week. Highlight anything that looks blocked or urgent, and suggest what I should prioritize. +``` + +## Example response + +{% data reusables.copilot.example-prompts.response-is-an-example %} + +````text +Repository activity summary (past 7 days) + +P1 — Urgent +- CI failing on `main`: the `build-and-test` workflow has been red since commit a1b2c3d ("Refactor auth middleware"). Three subsequent PRs are blocked from merging. +- Security alert: a high-severity Dependabot alert for `lodash` (CVE-2025-12345) is open and unassigned. + +P2 — Needs attention soon +- PR #482 ("Add OAuth device flow support") has 2 approvals and passing checks, but has been waiting 4 days for a final sign-off from a code owner. +- Issue #475 ("Crash on startup with empty config file") was reopened after a regression; 5 new comments and a reproduction case were added yesterday. + +P3 — Routine +- 4 new issues opened, mostly minor UI bugs and documentation requests. None are labeled `bug:critical`. +- 12 commits merged to `main` across 6 PRs, primarily dependency bumps and test cleanup. + +Suggested next steps: +1. Investigate and fix the failing `build-and-test` workflow to unblock merges. +2. Triage the Dependabot alert and assign an owner. +3. Review PR #482 so it can ship. +```` + +## Further reading + +* [AUTOTITLE](/copilot/how-tos/copilot-cli) diff --git a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/synthesizing-research.md b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/synthesizing-research.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/synthesizing-research.md rename to content/copilot/tutorials/copilot-cookbook/communicate-effectively/synthesizing-research.md index 9ecb12be99df..3c2ce0e86637 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/communicate-effectively/synthesizing-research.md +++ b/content/copilot/tutorials/copilot-cookbook/communicate-effectively/synthesizing-research.md @@ -4,14 +4,16 @@ shortTitle: Synthesize research intro: Copilot Chat can help you synthesize research findings and insights from multiple sources into a cohesive summary. versions: feature: copilot -complexity: - - Simple +surface: + - Chat octicon: copilot category: - Communicate effectively - Author and optimize with Copilot - Scale institutional knowledge contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/communicate-effectively/synthesizing-research --- When working with research data, {% data variables.copilot.copilot_chat_short %} can assist you in synthesizing findings and insights from multiple sources into a cohesive summary. This can be particularly useful for preparing reports, presentations, or discussions with stakeholders. You can ask {% data variables.copilot.copilot_chat_short %} to identify key trends, insights, and recommendations based on the research data you provide. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md b/content/copilot/tutorials/copilot-cookbook/debug-errors/debug-invalid-json.md similarity index 96% rename from content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md rename to content/copilot/tutorials/copilot-cookbook/debug-errors/debug-invalid-json.md index 40e73ccefdee..032304d897cb 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json.md +++ b/content/copilot/tutorials/copilot-cookbook/debug-errors/debug-invalid-json.md @@ -8,14 +8,15 @@ redirect_from: - /copilot/tutorials/copilot-chat-cookbook/debugging-errors/debugging-invalid-json - /copilot/tutorials/copilot-chat-cookbook/debugging-errors/debug-invalid-json - /copilot/copilot-chat-cookbook/debugging-errors/debugging-invalid-json + - /copilot/tutorials/copilot-chat-cookbook/debug-errors/debug-invalid-json versions: feature: copilot category: - Debugging code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: bug contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-cookbook/debug-errors/diagnose-ci-test-failures.md b/content/copilot/tutorials/copilot-cookbook/debug-errors/diagnose-ci-test-failures.md new file mode 100644 index 000000000000..84881418cd0d --- /dev/null +++ b/content/copilot/tutorials/copilot-cookbook/debug-errors/diagnose-ci-test-failures.md @@ -0,0 +1,131 @@ +--- +title: Diagnosing CI test failures +shortTitle: Diagnose CI test failures +intro: Use {% data variables.copilot.copilot_cli_short %} to pull CI logs, correlate failures to local code, and fix issues without leaving the terminal. +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/debug-errors/diagnose-test-failures + - /copilot/tutorials/copilot-chat-cookbook/debug-errors/diagnose-ci-test-failures +versions: + feature: copilot +category: + - Debugging code + - Author and optimize with Copilot + - Improve quality and maintainability +surface: + - CLI +octicon: bug +contentType: tutorials +--- + +{% data variables.copilot.copilot_cli_short %} ships with the GitHub MCP server, which gives it direct access to your GitHub Actions workflow runs, job logs, and check statuses. Combined with access to your local files, it can fetch CI failure details, correlate them to your code, and propose fixes from your terminal. + +## Example scenario 1: Tests pass locally but fail in CI + +You have a test that passes on your local machine but fails in CI. You can ask {% data variables.copilot.copilot_cli_short %} to investigate this test failure directly. + +In this example, the code being tested defines a simple order service (`order.py`), and there is a corresponding test that checks if an order was created today (`test_order_service.py`). + +### Example prompt + +```copilot copy +My CI is failing on this branch. Can you pull the latest workflow run +logs, figure out what is failing, and help me fix it? The relevant files +are @order.py and @test_order_service.py +``` + +### Example response + +{% data reusables.copilot.example-prompts.response-is-an-example %} + +{% data variables.copilot.copilot_cli_short %} uses the GitHub MCP server to fetch your latest workflow runs on the current branch, identifies the failed job, and retrieves its logs. It finds the following failure: + +```text +___ TestOrderService.test_order_created_today ___ +> assert order["created_date"] == date.today() +E AssertionError: assert datetime.date(2024, 1, 15) == datetime.date(2024, 1, 16) + +test_order_service.py:45: AssertionError +``` + +After reading both local files, {% data variables.copilot.copilot_cli_short %} notices that the dates are exactly one day apart and identifies this as a **timezone boundary issue**. The CI runner uses UTC while your local machine uses a different timezone. When the test runs near midnight, `date.today()` returns different dates in each environment. + +{% data variables.copilot.copilot_cli_short %} suggests standardizing how `today` is computed by injecting a clock dependency or pinning the timezone: + +```python +from datetime import timezone, datetime + +def get_today(): + return datetime.now(timezone.utc).date() +``` + +It applies the fix to both `order.py` and `test_order_service.py`, updating all references to use the new `get_today()` helper. + +After the fix, you can verify the changes and run the tests locally: + +1. Run `/diff` to review exactly what {% data variables.copilot.copilot_cli_short %} changed. +1. Run `!pytest test_order_service.py` to confirm tests pass locally. +1. Push the fix and let CI re-run. + +## Example scenario 2: Intermittent test failures with race conditions + +A test sometimes passes and sometimes fails on the same machine. You want {% data variables.copilot.copilot_cli_short %} to compare logs from passing and failing runs to identify the cause. + +In this example, the code under test uses a background job in `order_service.py` to update an order's status asynchronously, and a test in `test_order_service.py` asserts that the final status is `"processed"`. + +### Example prompt for race conditions + +```copilot copy +This test passes sometimes and fails sometimes. Can you pull the logs +from the last passing and failing CI runs for test_order_processed +on this branch, compare them, and figure out what is going wrong? +Relevant files: @order_service.py @test_order_service.py +``` + +### Example response for race conditions + +{% data reusables.copilot.example-prompts.response-is-an-example %} + +{% data variables.copilot.copilot_cli_short %} uses the GitHub MCP server to list recent workflow runs on the current branch, identifies one passing and one failing run, and retrieves the logs for both. It compares them: + +**Passing run:** + +```text +[DEBUG] Created order #1234 +[DEBUG] Background job started for order #1234 +[DEBUG] Background job completed (52ms) +[DEBUG] Checking order status +[DEBUG] Order #1234 status: processed +``` + +**Failing run:** + +```text +[DEBUG] Created order #1234 +[DEBUG] Background job started for order #1234 +[DEBUG] Checking order status +[DEBUG] Order #1234 status: pending +``` + +{% data variables.copilot.copilot_cli_short %} spots that in the passing run, the background job completed before the status check, while in the failing run, the status was checked while the job was still running. It identifies this as a **race condition** because the test does not wait for the background job to finish. + +{% data variables.copilot.copilot_cli_short %} suggests adding an explicit wait mechanism before asserting and proposes a fix using a polling helper: + +```python +import time + +def wait_for_status(order_id, expected, timeout=5): + start = time.time() + while time.time() - start < timeout: + order = get_order(order_id) + if order.status == expected: + return order + time.sleep(0.1) + raise TimeoutError( + f"Order {order_id} did not reach '{expected}' within {timeout}s" + ) +``` + + +## Further reading + +* - [AUTOTITLE](/copilot/how-tos/copilot-cli) diff --git a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md b/content/copilot/tutorials/copilot-cookbook/debug-errors/handle-api-rate-limits.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md rename to content/copilot/tutorials/copilot-cookbook/debug-errors/handle-api-rate-limits.md index b1a4681386e3..e6edff472870 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits.md +++ b/content/copilot/tutorials/copilot-cookbook/debug-errors/handle-api-rate-limits.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/debugging-errors/handling-api-rate-limits - /copilot/tutorials/copilot-chat-cookbook/debugging-errors/handling-api-rate-limits - /copilot/tutorials/copilot-chat-cookbook/debugging-errors/handle-api-rate-limits + - /copilot/tutorials/copilot-chat-cookbook/debug-errors/handle-api-rate-limits versions: feature: copilot category: - Debugging code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: bug contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/index.md b/content/copilot/tutorials/copilot-cookbook/debug-errors/index.md similarity index 61% rename from content/copilot/tutorials/copilot-chat-cookbook/debug-errors/index.md rename to content/copilot/tutorials/copilot-cookbook/debug-errors/index.md index 108e190f9229..2b9086a546d7 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/debug-errors/index.md +++ b/content/copilot/tutorials/copilot-cookbook/debug-errors/index.md @@ -1,15 +1,17 @@ --- title: Debug errors -intro: 'Discover ways that you can use {% data variables.product.prodname_copilot %} to debug errors during development.' +intro: Discover ways that you can use {% data variables.product.prodname_copilot %} to debug errors during development. redirect_from: - /copilot/example-prompts-for-github-copilot-chat/debugging-errors - /copilot/copilot-chat-cookbook/debugging-errors - /copilot/tutorials/copilot-chat-cookbook/debugging-errors + - /copilot/tutorials/copilot-chat-cookbook/debug-errors versions: feature: copilot children: - /debug-invalid-json - /handle-api-rate-limits - - /diagnose-test-failures + - /diagnose-ci-test-failures contentType: tutorials --- + diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md b/content/copilot/tutorials/copilot-cookbook/document-code/document-legacy-code.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md rename to content/copilot/tutorials/copilot-cookbook/document-code/document-legacy-code.md index d65232f0f999..84c1ce4fb606 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code.md +++ b/content/copilot/tutorials/copilot-cookbook/document-code/document-legacy-code.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/documenting-code/documenting-legacy-code - /copilot/tutorials/copilot-chat-cookbook/documenting-code/documenting-legacy-code - /copilot/tutorials/copilot-chat-cookbook/documenting-code/document-legacy-code + - /copilot/tutorials/copilot-chat-cookbook/document-code/document-legacy-code versions: feature: copilot category: - Documenting code - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Simple +surface: + - Chat octicon: book contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md b/content/copilot/tutorials/copilot-cookbook/document-code/explain-complex-logic.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md rename to content/copilot/tutorials/copilot-cookbook/document-code/explain-complex-logic.md index 81f8796995b8..5eb0744b042d 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic.md +++ b/content/copilot/tutorials/copilot-cookbook/document-code/explain-complex-logic.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/documenting-code/explaining-complex-algorithms-or-logic - /copilot/tutorials/copilot-chat-cookbook/documenting-code/explaining-complex-algorithms-or-logic - /copilot/tutorials/copilot-chat-cookbook/documenting-code/explain-complex-logic + - /copilot/tutorials/copilot-chat-cookbook/document-code/explain-complex-logic versions: feature: copilot category: - Documenting code - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Intermediate +surface: + - Chat octicon: book contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md b/content/copilot/tutorials/copilot-cookbook/document-code/explain-legacy-code.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md rename to content/copilot/tutorials/copilot-cookbook/document-code/explain-legacy-code.md index b44355c91d0a..89c07c2349e5 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code.md +++ b/content/copilot/tutorials/copilot-cookbook/document-code/explain-legacy-code.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/documenting-code/explaining-legacy-code - /copilot/tutorials/copilot-chat-cookbook/documenting-code/explaining-legacy-code - /copilot/tutorials/copilot-chat-cookbook/documenting-code/explain-legacy-code + - /copilot/tutorials/copilot-chat-cookbook/document-code/explain-legacy-code versions: feature: copilot category: - Documenting code - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Simple +surface: + - Chat octicon: book contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-cookbook/document-code/filing-issues-without-breaking-your-flow.md b/content/copilot/tutorials/copilot-cookbook/document-code/filing-issues-without-breaking-your-flow.md new file mode 100644 index 000000000000..cc7a73f964de --- /dev/null +++ b/content/copilot/tutorials/copilot-cookbook/document-code/filing-issues-without-breaking-your-flow.md @@ -0,0 +1,107 @@ +--- +title: Filing issues without breaking your flow +shortTitle: File issues without breaking flow +intro: When something catches your attention mid-task, use {% data variables.copilot.copilot_cli_short %} to file a GitHub issue with code context, linked PRs, and labels, then get back to what you were doing. +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/document-code/creating-issues + - /copilot/tutorials/copilot-chat-cookbook/document-code/filing-issues-without-breaking-your-flow +versions: + feature: copilot +category: + - Documenting code + - Author and optimize with Copilot +surface: + - CLI +octicon: issue-opened +contentType: tutorials +--- + +{% data variables.copilot.copilot_cli_short %} can open GitHub issues for you from the terminal. Instead of switching to a browser and filling out an issue by hand, you describe what you want and Copilot gathers context from your repository and GitHub, then creates the issue so you can keep working. + +## Example scenario 1: Filing an issue from a CI failure + +Your CI is failing or you've spotted errors in production logs. Rather than manually tracing the stack trace back to a commit, you ask {% data variables.copilot.copilot_cli_short %} to investigate and file the issue for you. + +### Example prompt + +```text copy +The CI workflow on main has been failing since yesterday. Look at the failing +run, figure out what's breaking and which commit likely introduced it, then +create an issue with the stack trace, a link to the failing run, and the +suspected PR that caused it. Label it "bug" and "regression". +``` + +### Example response + +{% data reusables.copilot.example-prompts.response-is-an-example %} + +{% data variables.copilot.copilot_cli_short %} uses its GitHub MCP tools to: + + +1. **Fetch the failing workflow run** and extract the stack trace from the logs. +1. **Identify the responsible code** — for example, `src/services/payment.ts:94`. +1. **Search recent commits** touching that file and find the PR that introduced the change. +1. **Create an issue** with all the context assembled: + + ```text + Created issue #421: Regression: PaymentService throws TypeError after #398 + + What's failing: + The `build` job on main has failed since commit `a3f7c21`. Stack trace: + + TypeError: Cannot read properties of undefined (reading 'amount') at processRefund (src/services/payment.ts:94:22) + + Introduced by: PR #398 (merged 2 days ago) refactored the payment types but missed updating `processRefund` to handle the new nullable `transaction` field. + + Failing run: Actions run #2847 + + Suggested fix: Add a null check for `transaction` before accessing `transaction.amount` on line 94. + + Labels: `bug`, `regression` + ``` + +## Example scenario 2: Turning TODOs into tracked work + +Over time, TODO and FIXME comments accumulate in a codebase with no visibility. You can ask {% data variables.copilot.copilot_cli_short %} to scan for these comments, assess priority, and create issues so the work is tracked. + +### Example prompt + +```text copy +Scan this repo for TODO and FIXME comments. Group them by area, pick the 5 +most important ones based on the surrounding code context, and create an issue +for each. Include the code snippet, file location, and suggest a label. +``` + +### Example response + +{% data reusables.copilot.example-prompts.response-is-an-example %} + +{% data variables.copilot.copilot_cli_short %} searches the codebase, reads the context around each comment, and prioritizes based on severity: + +```text +Found 23 TODO/FIXME comments across the repo. Here are the 5 I'd prioritize: + +Created issue #422: FIXME: SQL injection risk in search query builder +- src/db/search.ts:34 — user input concatenated directly into query string +- Label: security, priority:high + +Created issue #423: TODO: Rate limiter bypassed for internal routes +- src/middleware/rate_limit.ts:12 — comment says "temporary bypass, remove before launch" +- Label: security, technical-debt + +Created issue #424: FIXME: Memory leak in WebSocket handler +- src/ws/handler.ts:87 — listeners are added on each connection but never cleaned up +- Label: bug, performance + +Created issue #425: TODO: Retry logic missing for payment webhook +- src/webhooks/payment.ts:56 — failures silently dropped, no retry queue +- Label: reliability, priority:medium + +Created issue #426: TODO: Migrate to new auth token format +- src/auth/token.ts:3 — comment references a closing down API version +- Label: technical-debt +``` + +## Further reading + +* [AUTOTITLE](/copilot/how-tos/copilot-cli) diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/index.md b/content/copilot/tutorials/copilot-cookbook/document-code/index.md similarity index 67% rename from content/copilot/tutorials/copilot-chat-cookbook/document-code/index.md rename to content/copilot/tutorials/copilot-cookbook/document-code/index.md index 038794594898..6bb0d4037ed9 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/index.md +++ b/content/copilot/tutorials/copilot-cookbook/document-code/index.md @@ -1,14 +1,15 @@ --- title: Document code -intro: 'Discover ways that you can use {% data variables.copilot.copilot_chat %} to document your code.' +intro: Discover ways that you can use {% data variables.copilot.copilot_chat %} to document your code. redirect_from: - /copilot/example-prompts-for-github-copilot-chat/documenting-code - /copilot/copilot-chat-cookbook/documenting-code - /copilot/tutorials/copilot-chat-cookbook/documenting-code + - /copilot/tutorials/copilot-chat-cookbook/document-code versions: feature: copilot children: - - /creating-issues + - /filing-issues-without-breaking-your-flow - /document-legacy-code - /explain-legacy-code - /explain-complex-logic diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md b/content/copilot/tutorials/copilot-cookbook/document-code/sync-documentation.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md rename to content/copilot/tutorials/copilot-cookbook/document-code/sync-documentation.md index 145a54eaae7a..b5f884f2f5e3 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation.md +++ b/content/copilot/tutorials/copilot-cookbook/document-code/sync-documentation.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/documenting-code/syncing-documentation-with-code-changes - /copilot/tutorials/copilot-chat-cookbook/documenting-code/syncing-documentation-with-code-changes - /copilot/tutorials/copilot-chat-cookbook/documenting-code/sync-documentation + - /copilot/tutorials/copilot-chat-cookbook/document-code/sync-documentation versions: feature: copilot category: - Documenting code - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Intermediate +surface: + - Chat octicon: book contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/document-code/write-discussions-or-blog-posts.md b/content/copilot/tutorials/copilot-cookbook/document-code/write-discussions-or-blog-posts.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/document-code/write-discussions-or-blog-posts.md rename to content/copilot/tutorials/copilot-cookbook/document-code/write-discussions-or-blog-posts.md index c182ff0b2385..4bd58f2d02c4 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/document-code/write-discussions-or-blog-posts.md +++ b/content/copilot/tutorials/copilot-cookbook/document-code/write-discussions-or-blog-posts.md @@ -8,13 +8,14 @@ category: - Documenting code - Author and optimize with Copilot - Scale institutional knowledge -complexity: - - Simple +surface: + - Chat octicon: book redirect_from: - /copilot/copilot-chat-cookbook/documenting-code/writing-discussions-or-blog-posts - /copilot/tutorials/copilot-chat-cookbook/documenting-code/writing-discussions-or-blog-posts - /copilot/tutorials/copilot-chat-cookbook/documenting-code/write-discussions-or-blog-posts + - /copilot/tutorials/copilot-chat-cookbook/document-code/write-discussions-or-blog-posts contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-cookbook/generate-code/implement-a-feature.md b/content/copilot/tutorials/copilot-cookbook/generate-code/implement-a-feature.md new file mode 100644 index 000000000000..84512b96e91c --- /dev/null +++ b/content/copilot/tutorials/copilot-cookbook/generate-code/implement-a-feature.md @@ -0,0 +1,114 @@ +--- +title: Implementing a feature from a GitHub Issue +shortTitle: Implement a feature +intro: Give a {% data variables.product.github %} issue to {% data variables.copilot.copilot_cli %}, then steer the conversation to implement the feature. +versions: + feature: copilot +category: + - Author and optimize with Copilot +surface: + - CLI +octicon: rocket +contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/generate-code/implement-a-feature +--- + +{% data variables.copilot.copilot_cli %} can read a {% data variables.product.github %} issue, propose an implementation plan, and draft code changes that satisfy the requirements. Because the workflow is conversational, you can correct assumptions, point to relevant files, and refine the approach as {% data variables.copilot.copilot_cli %} works. + +## Example scenario + +Imagine you work on a platform team that maintains an internal Node.js billing API that powers customer subscriptions. A product manager opens an issue requesting a new `GET /subscriptions/{id}/plan` endpoint that returns the plan attached to a given subscription, along with unit tests and an update to the OpenAPI specification. The issue includes the desired response shape, error cases for missing or cancelled subscriptions, and a link to the existing `/subscriptions/{id}` endpoint to follow as a pattern. You can hand the issue to {% data variables.copilot.copilot_cli %} and have it scaffold the route, controller, and tests, then open a pull request. + +## Example workflow + +{% data variables.copilot.copilot_cli %} can read the issue directly from {% data variables.product.github %}, plan the work, write the code, run your tests, and open a pull request. + +### Pull the issue into context + +Start in the root of the repository and reference the issue by URL or `owner/repo#number`. {% data variables.copilot.copilot_cli %} uses the {% data variables.product.github %} MCP server to fetch the issue body, comments, and linked items, then keeps that context available for the rest of the session. + +```text copy +Read octo-org/billing-api#482 and any issues or PRs it links to. +Summarize what needs to be implemented before we plan the work. +``` + +### Draft an implementation plan with `/plan` + +Switch to plan mode so {% data variables.copilot.copilot_cli %} thinks through the change before touching any files. + +```text copy +/plan Implement the subscription lookup endpoint described in the issue. +Follow the same conventions as the existing GET /subscriptions/{id} endpoint. +``` + +{% data reusables.copilot.example-prompts.response-is-an-example %} + +{% data variables.copilot.copilot_cli %} returns a plan similar to: + +```text +1. Add a `getPlanForSubscription` method in `src/services/subscriptionService.ts` that reuses the existing billing client, throws `NotFoundError` when the subscription or plan does not exist, and throws `CancelledSubscriptionError` when the subscription has been cancelled. +1. Add a `GET /subscriptions/:id/plan` route in `src/routes/subscriptions.ts`, mirroring the error handling in the sibling `GET /subscriptions/:id` route and mapping `CancelledSubscriptionError` to a `410` response. +1. Update `openapi/subscriptions.yaml` with the new path, response schema, and `404` and `410` responses. +1. Add unit tests in `test/services/subscriptionService.test.ts` and `test/routes/subscriptions.test.ts` covering the success case, missing subscription, cancelled subscription, and missing plan. +1. Run the test suite and update the changelog entry. +``` + +Review the plan, push back on anything that looks off, and ask {% data variables.copilot.copilot_cli %} to revise it before you approve. For example, you might reply with `Use the existing error classes in src/errors—NotFoundError for missing subscriptions or plans and CancelledSubscriptionError for cancelled subscriptions rather than introducing new ones` and have it update the affected steps. + +### Kick off the implementation and steer as needed + +Approve the plan to start coding. {% data variables.copilot.copilot_cli %} works through the steps one at a time, showing each edit before applying it. If it heads in the wrong direction, interrupt and redirect. + +For example, suppose {% data variables.copilot.copilot_cli %} adds a new database query in your `getPlanForSubscription` method instead of reusing the billing client your team standardized on. You can stop and steer it: + +```text copy +Don't add a new query here. The billing client in +src/clients/billingClient.ts already exposes a getPlan method. +Use that and update the service to handle its NotFound response. +``` + +{% data variables.copilot.copilot_cli %} revises the code and continues with the remaining plan steps. + +### Generate and run unit tests + +When {% data variables.copilot.copilot_cli %} reaches the testing step, it scaffolds tests that match the patterns in your existing test files. For the plan endpoint, it might add cases like: + +* Returns the plan record for an active subscription. +* Returns `404` when the subscription does not exist. +* Returns `410` when the subscription has been cancelled. +* Returns `404` when the subscription has no plan attached. + +After writing the tests, {% data variables.copilot.copilot_cli %} runs them in the terminal so you can see the results immediately. + +```text copy +Run the test suite for the new endpoint and fix any failures. +``` + +If a test fails, {% data variables.copilot.copilot_cli %} reads the failure output, updates the implementation, and re-runs until the test suite is green. Review each fix to make sure it's addressing the root cause rather than masking it. + +### Review the changes with `/diff` + +Use `/diff` to see a consolidated view of changes made across the session. + +```text copy +/diff +``` + +If something looks wrong, ask {% data variables.copilot.copilot_cli %} to revise it before you commit. For example, you might reply with `Revert the formatting changes in src/routes/subscriptions.ts to only keep the new route handler` to scope the diff back to the intended changes. + +### Open a pull request + +Once the feature is implemented, tested, and reviewed, ask {% data variables.copilot.copilot_cli %} to open a pull request. It uses the {% data variables.product.github %} MCP server to push the branch and create the pull request + +```text copy +Commit the changes on a new branch, push it, and open a pull request +against main. Link it to octo-org/billing-api#482 and summarize the +implementation, the tests added, and any follow-up work. +``` + +{% data variables.copilot.copilot_cli %} reports back with the pull request's URL so you can move it forward from there. + +## Further reading + +* [AUTOTITLE](/copilot/how-tos/copilot-cli) diff --git a/content/copilot/tutorials/copilot-cookbook/generate-code/index.md b/content/copilot/tutorials/copilot-cookbook/generate-code/index.md new file mode 100644 index 000000000000..b8072f820467 --- /dev/null +++ b/content/copilot/tutorials/copilot-cookbook/generate-code/index.md @@ -0,0 +1,12 @@ +--- +title: Generate code +intro: Use {% data variables.product.prodname_copilot %} to turn requirements into working code. +versions: + feature: copilot +children: + - /implement-a-feature +contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/generate-code +--- + diff --git a/content/copilot/tutorials/copilot-chat-cookbook/index.md b/content/copilot/tutorials/copilot-cookbook/index.md similarity index 67% rename from content/copilot/tutorials/copilot-chat-cookbook/index.md rename to content/copilot/tutorials/copilot-cookbook/index.md index e55140c45d9d..75e1fedb14b1 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/index.md +++ b/content/copilot/tutorials/copilot-cookbook/index.md @@ -1,30 +1,33 @@ --- -title: GitHub Copilot Chat Cookbook -intro: 'Find examples of prompts to use with {% data variables.copilot.copilot_chat %}.' +title: GitHub Copilot Cookbook +intro: Learn how to use {% data variables.product.prodname_copilot %} to accomplish specific tasks. allowTitleToDifferFromFilename: true redirect_from: - /copilot/example-prompts-for-github-copilot-chat - /copilot/copilot-chat-cookbook + - /copilot/tutorials/copilot-chat-cookbook versions: feature: copilot layout: category-landing sidebarLink: text: All prompts - href: /copilot/tutorials/copilot-chat-cookbook + href: /copilot/tutorials/copilot-cookbook spotlight: - - article: /testing-code/generate-unit-tests + - article: /generate-code/implement-a-feature + image: /assets/images/copilot-landing/improving_code_readability.png + - article: /debug-errors/diagnose-ci-test-failures image: /assets/images/copilot-landing/generating_unit_tests.png - article: /refactor-code/improve-code-readability - image: /assets/images/copilot-landing/improving_code_readability.png - - article: /debug-errors/debug-invalid-json image: /assets/images/copilot-landing/debugging_invalid_json.png children: - /communicate-effectively - /debug-errors - /analyze-functionality + - /generate-code - /refactor-code - /document-code - /testing-code - /analyze-security contentType: tutorials --- + diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/decouple-business-logic.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/decouple-business-logic.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/decouple-business-logic.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/decouple-business-logic.md index 1062d87c2c83..51841f583ab7 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/decouple-business-logic.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/decouple-business-logic.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/decoupling-business-logic-from-ui-components - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/decoupling-business-logic-from-ui-components - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/decouple-business-logic + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/decouple-business-logic versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Advanced +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/fix-database-deadlocks.md similarity index 99% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/fix-database-deadlocks.md index 4f3bf6515a73..ca9e591d9c0b 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/fix-database-deadlocks.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/fixing-database-deadlocks-or-data-integrity-issues - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/fixing-database-deadlocks-or-data-integrity-issues - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/fix-database-deadlocks + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-database-deadlocks versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Advanced +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/fix-lint-errors.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/fix-lint-errors.md index 217fbac0bac5..68dfe4943c08 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/fix-lint-errors.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/fixing-lint-errors - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/fixing-lint-errors - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/fix-lint-errors + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/fix-lint-errors versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/handle-cross-cutting.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/handle-cross-cutting.md index b31a6a833f70..389c56ca8557 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/handle-cross-cutting.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/handling-cross-cutting-concerns - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/handling-cross-cutting-concerns - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/handle-cross-cutting + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/handle-cross-cutting versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/improve-code-readability.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/improve-code-readability.md index 513c0c4a2804..31e09aa1c9d7 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/improve-code-readability.md @@ -8,14 +8,15 @@ redirect_from: - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/improving-code-readability-and-maintainability - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/improve-code-readability - /copilot/copilot-chat-cookbook/refactoring-code/improving-code-readability-and-maintainability + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/improve-code-readability versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Simple +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/index.md similarity index 78% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/index.md index 6b488e710623..51024a58008b 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/index.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/index.md @@ -1,10 +1,11 @@ --- title: Refactor code -intro: 'Discover ways that you can use {% data variables.product.prodname_copilot %} to refactor your code.' +intro: Discover ways that you can use {% data variables.product.prodname_copilot %} to refactor your code. redirect_from: - /copilot/example-prompts-for-github-copilot-chat/refactoring-code - /copilot/copilot-chat-cookbook/refactoring-code - /copilot/tutorials/copilot-chat-cookbook/refactoring-code + - /copilot/tutorials/copilot-chat-cookbook/refactor-code versions: feature: copilot children: diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-data-access-layers.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-data-access-layers.md index 6698e239db99..9ec7a76c741f 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-data-access-layers.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/refactoring-data-access-layers - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/refactoring-data-access-layers - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/refactor-data-access-layers + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-data-access-layers versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Advanced +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-design-patterns.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-design-patterns.md index 253d5b84cd31..77fc180549ce 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-design-patterns.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/refactoring-to-implement-a-design-pattern - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/refactoring-to-implement-a-design-pattern - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/refactor-design-patterns + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-design-patterns versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-for-optimization.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-for-optimization.md index 257bc7b98c31..0b52d65054cf 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-for-optimization.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/refactoring-for-performance-optimization - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/refactoring-for-performance-optimization - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/refactor-for-optimization + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-optimization versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Simple +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-for-sustainability.md similarity index 95% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-for-sustainability.md index 0318578ce7f3..02a9677b78fa 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/refactor-for-sustainability.md @@ -8,10 +8,12 @@ category: - Refactoring code - Improve quality and maintainability - Author and optimize with Copilot -complexity: - - Simple +surface: + - Chat octicon: rocket contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/refactor-for-sustainability --- Code that is inefficient in its use of computational resources can lead to higher energy consumption, which has a negative impact on the environment. Examples of such code include algorithms with high time complexity, excessive memory usage, and unnecessary processing. diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/simplify-inheritance-hierarchies.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/simplify-inheritance-hierarchies.md index 7929a5436e3d..0fec97156ad0 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/simplify-inheritance-hierarchies.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/simplifying-complex-inheritance-hierarchies - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/simplifying-complex-inheritance-hierarchies - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/simplify-inheritance-hierarchies + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/simplify-inheritance-hierarchies versions: feature: copilot category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: rocket contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md b/content/copilot/tutorials/copilot-cookbook/refactor-code/translate-code.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md rename to content/copilot/tutorials/copilot-cookbook/refactor-code/translate-code.md index 3fe54cd94fa2..e5da7a7a0ee6 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code.md +++ b/content/copilot/tutorials/copilot-cookbook/refactor-code/translate-code.md @@ -8,13 +8,14 @@ category: - Refactoring code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Simple +surface: + - Chat octicon: rocket redirect_from: - /copilot/copilot-chat-cookbook/refactoring-code/translating-code-to-a-different-programming-language - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/translating-code-to-a-different-programming-language - /copilot/tutorials/copilot-chat-cookbook/refactoring-code/translate-code + - /copilot/tutorials/copilot-chat-cookbook/refactor-code/translate-code contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md b/content/copilot/tutorials/copilot-cookbook/testing-code/create-end-to-end-tests.md similarity index 98% rename from content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md rename to content/copilot/tutorials/copilot-cookbook/testing-code/create-end-to-end-tests.md index 5931c19cbce3..1a0c6a1bc042 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests.md +++ b/content/copilot/tutorials/copilot-cookbook/testing-code/create-end-to-end-tests.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/testing-code/create-end-to-end-tests-for-a-webpage - /copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests-for-a-webpage - /copilot/tutorials/copilot-chat-cookbook/testing-code/creating-end-to-end-tests-for-a-webpage + - /copilot/tutorials/copilot-chat-cookbook/testing-code/create-end-to-end-tests versions: feature: copilot category: - Testing code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Advanced +surface: + - Chat octicon: beaker contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md b/content/copilot/tutorials/copilot-cookbook/testing-code/create-mock-objects.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md rename to content/copilot/tutorials/copilot-cookbook/testing-code/create-mock-objects.md index 6bacc74229da..24fd45641766 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects.md +++ b/content/copilot/tutorials/copilot-cookbook/testing-code/create-mock-objects.md @@ -7,14 +7,15 @@ redirect_from: - /copilot/copilot-chat-cookbook/testing-code/create-mock-objects-to-abstract-layers - /copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects-to-abstract-layers - /copilot/tutorials/copilot-chat-cookbook/testing-code/creating-mock-objects-to-abstract-layers + - /copilot/tutorials/copilot-chat-cookbook/testing-code/create-mock-objects versions: feature: copilot category: - Testing code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: beaker contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md b/content/copilot/tutorials/copilot-cookbook/testing-code/generate-unit-tests.md similarity index 96% rename from content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md rename to content/copilot/tutorials/copilot-cookbook/testing-code/generate-unit-tests.md index fbd47acd8e30..8cf3cd633378 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests.md +++ b/content/copilot/tutorials/copilot-cookbook/testing-code/generate-unit-tests.md @@ -5,14 +5,15 @@ intro: '{% data variables.copilot.copilot_chat_short %} can help with generating redirect_from: - /copilot/example-prompts-for-github-copilot-chat/testing-code/generate-unit-tests - /copilot/copilot-chat-cookbook/testing-code/generate-unit-tests + - /copilot/tutorials/copilot-chat-cookbook/testing-code/generate-unit-tests versions: feature: copilot category: - Testing code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: beaker contentType: tutorials --- diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/index.md b/content/copilot/tutorials/copilot-cookbook/testing-code/index.md similarity index 66% rename from content/copilot/tutorials/copilot-chat-cookbook/testing-code/index.md rename to content/copilot/tutorials/copilot-cookbook/testing-code/index.md index 9a380c69e628..ea48cf460929 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/index.md +++ b/content/copilot/tutorials/copilot-cookbook/testing-code/index.md @@ -1,9 +1,10 @@ --- title: Testing code -intro: 'Discover ways that you can use {% data variables.product.prodname_copilot %} to test your code.' +intro: Discover ways that you can use {% data variables.product.prodname_copilot %} to test your code. redirect_from: - /copilot/example-prompts-for-github-copilot-chat/testing-code - /copilot/copilot-chat-cookbook/testing-code + - /copilot/tutorials/copilot-chat-cookbook/testing-code versions: feature: copilot children: diff --git a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/update-unit-tests.md b/content/copilot/tutorials/copilot-cookbook/testing-code/update-unit-tests.md similarity index 97% rename from content/copilot/tutorials/copilot-chat-cookbook/testing-code/update-unit-tests.md rename to content/copilot/tutorials/copilot-cookbook/testing-code/update-unit-tests.md index 39373e14ddea..3a523a883914 100644 --- a/content/copilot/tutorials/copilot-chat-cookbook/testing-code/update-unit-tests.md +++ b/content/copilot/tutorials/copilot-cookbook/testing-code/update-unit-tests.md @@ -8,10 +8,12 @@ category: - Testing code - Author and optimize with Copilot - Improve quality and maintainability -complexity: - - Intermediate +surface: + - Chat octicon: beaker contentType: tutorials +redirect_from: + - /copilot/tutorials/copilot-chat-cookbook/testing-code/update-unit-tests --- When you make changes to your code, it's important to update any tests to verify the new behavior and catch any bugs that the new code has introduced. {% data variables.copilot.copilot_chat_short %} can help you quickly update tests to match your code changes, ensuring your test suite stays in sync with your implementation. @@ -118,4 +120,4 @@ if __name__ == '__main__': ## Further reading -{% data reusables.copilot.example-prompts.further-reading-items %} \ No newline at end of file +{% data reusables.copilot.example-prompts.further-reading-items %} diff --git a/content/copilot/tutorials/customization-library/index.md b/content/copilot/tutorials/customization-library/index.md index 585e8041e92a..a9eb2a2b77db 100644 --- a/content/copilot/tutorials/customization-library/index.md +++ b/content/copilot/tutorials/customization-library/index.md @@ -15,6 +15,9 @@ spotlight: image: /assets/images/copilot-landing/improving_code_readability.png - article: /custom-instructions/your-first-custom-agent image: /assets/images/copilot-landing/generating_unit_tests.png +filters: + - category + - complexity children: - /custom-instructions - /prompt-files diff --git a/content/copilot/tutorials/index.md b/content/copilot/tutorials/index.md index bd3cd20375b6..aadda46a0cc1 100644 --- a/content/copilot/tutorials/index.md +++ b/content/copilot/tutorials/index.md @@ -5,7 +5,7 @@ intro: Build skills and knowledge about {% data variables.product.prodname_copil versions: feature: copilot children: - - /copilot-chat-cookbook + - /copilot-cookbook - /customization-library - /cloud-agent - /spark @@ -41,7 +41,7 @@ sidebarLink: href: /copilot/tutorials carousels: recommended: - - /copilot/tutorials/copilot-chat-cookbook + - /copilot/tutorials/copilot-cookbook - /copilot/tutorials/customization-library - /copilot/tutorials/roll-out-at-scale includedCategories: diff --git a/content/index.md b/content/index.md index 4b8577bb525b..6fa6f3010d9c 100644 --- a/content/index.md +++ b/content/index.md @@ -114,7 +114,7 @@ childGroups: - copilot/get-started/plans - copilot/how-tos/use-copilot-agents/cloud-agent - copilot/tutorials - - copilot/tutorials/copilot-chat-cookbook + - copilot/tutorials/copilot-cookbook - copilot/tutorials/customization-library - copilot/how-tos/copilot-cli - name: CI/CD and DevOps diff --git a/data/features/accessible-charts.yml b/data/features/accessible-charts.yml deleted file mode 100644 index 5afa7162f0d7..000000000000 --- a/data/features/accessible-charts.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Issue 14969 -# Accessibility updates to the repo insights and the code frequency pages -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.15' diff --git a/data/features/code-scanning-default-setup-customize-labels.yml b/data/features/code-scanning-default-setup-customize-labels.yml deleted file mode 100644 index 89bf644ce5b5..000000000000 --- a/data/features/code-scanning-default-setup-customize-labels.yml +++ /dev/null @@ -1,5 +0,0 @@ -# Reference: #15251 -versions: - fpt: '*' - ghec: '*' - ghes: '>3.15' diff --git a/data/features/org-pre-defined-roles.yml b/data/features/org-pre-defined-roles.yml deleted file mode 100644 index 9c81774e4e46..000000000000 --- a/data/features/org-pre-defined-roles.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Issue #13617 -# Documentation for Built-in organization roles -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.15' diff --git a/data/features/org-sec-manager-update.yml b/data/features/org-sec-manager-update.yml deleted file mode 100644 index 096698351e42..000000000000 --- a/data/features/org-sec-manager-update.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Issue #1115697 -# Documentation for updates to the organization-level security manager role -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.16' diff --git a/data/features/push-protection-bypass-fine-grained-permissions.yml b/data/features/push-protection-bypass-fine-grained-permissions.yml deleted file mode 100644 index 8a5bba586ec0..000000000000 --- a/data/features/push-protection-bypass-fine-grained-permissions.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Issue 13329 -# Push protection bypass fine-grained permissions -# Ref 17108 Advanced Security available to Team plans -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.16' diff --git a/data/features/push-protection-delegated-bypass-configurations.yml b/data/features/push-protection-delegated-bypass-configurations.yml deleted file mode 100644 index 5867791617b4..000000000000 --- a/data/features/push-protection-delegated-bypass-configurations.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Issue 15892 - Secret scanning push protection bypass moves from "Global Settings" to "Security configurations" -# Ref 17108 Advanced Security available to Team plans -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.16' diff --git a/data/features/push-protection-delegated-bypass-enhancements.yml b/data/features/push-protection-delegated-bypass-enhancements.yml deleted file mode 100644 index 9f22567974c9..000000000000 --- a/data/features/push-protection-delegated-bypass-enhancements.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Issue 15735 - Secret scanning push protection bypasses show branch and file path information [GA] -# Ref 17108 Advanced Security available to Team plans -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.16' diff --git a/data/features/push-protection-delegated-bypass-file-upload-support.yml b/data/features/push-protection-delegated-bypass-file-upload-support.yml deleted file mode 100644 index ec53ee0e1c1b..000000000000 --- a/data/features/push-protection-delegated-bypass-file-upload-support.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Issue 16148 - Push protection delegated bypass for file uploads [GA] -# Ref 17108 Advanced Security available to Team plans -versions: - fpt: '*' - ghec: '*' - ghes: '>3.15' diff --git a/data/features/secret-scanning-alert-experimental-list.yml b/data/features/secret-scanning-alert-experimental-list.yml deleted file mode 100644 index b28515bd4939..000000000000 --- a/data/features/secret-scanning-alert-experimental-list.yml +++ /dev/null @@ -1,7 +0,0 @@ -# Reference: #15737. -# Documentation for secret scanning experimental alert list (replacing the "Other" alert list) -# Ref 17108 Advanced Security available to Team plans -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.16' diff --git a/data/features/secret-scanning-push-protection-content-endpoints.yml b/data/features/secret-scanning-push-protection-content-endpoints.yml deleted file mode 100644 index 45e7c6a5d00e..000000000000 --- a/data/features/secret-scanning-push-protection-content-endpoints.yml +++ /dev/null @@ -1,6 +0,0 @@ -# Reference: #15626 -# Secret scanning push protection for content endpoints in the GitHub REST API. -versions: - fpt: '*' - ghec: '*' - ghes: '>=3.15' diff --git a/data/reusables/actions/runner-ip-reputation-note.md b/data/reusables/actions/runner-ip-reputation-note.md new file mode 100644 index 000000000000..4774e97c1d48 --- /dev/null +++ b/data/reusables/actions/runner-ip-reputation-note.md @@ -0,0 +1,2 @@ +> [!NOTE] +> [!NOTE] Runner IP addresses are dynamically assigned from shared infrastructure and may be flagged due to unrelated activity. For more information, see [AUTOTITLE](/actions/how-tos/troubleshoot-workflows#runner-ip-addresses-flagged-by-security-scanners). diff --git a/data/reusables/actions/runner-ip-reputation.md b/data/reusables/actions/runner-ip-reputation.md new file mode 100644 index 000000000000..d8d7b3b33acd --- /dev/null +++ b/data/reusables/actions/runner-ip-reputation.md @@ -0,0 +1,7 @@ +{% data variables.product.github %}-hosted runners use dynamically assigned IP addresses from shared infrastructure. These IP addresses are published via the Meta API (for example, the `actions` and `actions_macos` keys). For more information, see [AUTOTITLE](/rest/meta/meta#get-github-meta-information). + +Third-party threat intelligence services, IP reputation scanners, or firewall vendors may flag these IP addresses as "malicious" or "suspicious." Because the underlying infrastructure is shared, activity from other users of the same infrastructure can influence the reputation scores assigned to these addresses. + +{% data variables.product.github %} does not control third-party IP reputation lists and cannot comment on their accuracy or update frequency. To verify whether an IP address belongs to {% data variables.product.github %}-hosted runners, check the IP ranges returned by the Meta API. + +If you have a security concern about a Microsoft-owned IP address, report it to the [Microsoft Security Response Center (MSRC)](https://msrc.microsoft.com/report/). diff --git a/data/reusables/webhooks/issue_event_api_properties.md b/data/reusables/webhooks/issue_event_api_properties.md index 219bcd3c9a9d..7d4c4715ef79 100644 --- a/data/reusables/webhooks/issue_event_api_properties.md +++ b/data/reusables/webhooks/issue_event_api_properties.md @@ -1,7 +1,7 @@ Key | Type | Description ----|------|------------- | {% ifversion fpt or ghec %} | -`action`|`string` | The action that was performed. Can be one of `opened`, `closed`, `reopened`. +`action`|`string` | The action that was performed. Can be one of `opened`, `closed`, `reopened`, `assigned`, `unassigned`, `labeled`, or `unlabeled`. | {% else %} | `action`|`string` | The action that was performed. Can be one of `opened`, `closed`, `reopened`, `assigned`, `unassigned`, `labeled`, or `unlabeled`. | {% endif %} | diff --git a/data/reusables/webhooks/issue_properties.md b/data/reusables/webhooks/issue_properties.md index 4c814fad561a..ffc10ad7f1db 100644 --- a/data/reusables/webhooks/issue_properties.md +++ b/data/reusables/webhooks/issue_properties.md @@ -2,6 +2,6 @@ | {% ifversion fpt or ghec %} | `assignee`|`object` | The optional user who was assigned or unassigned from the issue. `assignees`|`array` | The optional array of assignee objects detailing the assignees on the issue. -`label`|`object` | The optional label that was added or removed from the issue. -`labels`|`array` | The optional array of label objects describing the labels on the issue. +`label`|`object` | The optional label that was added to or removed from the issue if the action was `labeled` or `unlabeled`. +`labels`|`array` | The optional array of label objects describing the labels on the issue if the action was `labeled` or `unlabeled`. | {% endif %} | diff --git a/data/ui.yml b/data/ui.yml index 18c2094a4b7e..dbb12deae55a 100644 --- a/data/ui.yml +++ b/data/ui.yml @@ -381,6 +381,7 @@ cookbook_landing: search_articles: Search examples category: Category complexity: Complexity + surface: Surface carousels: recommended: Recommended diff --git a/package-lock.json b/package-lock.json index dcab0838f66e..d2c5ebe213af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5009,6 +5009,7 @@ "version": "2.5.1", "resolved": "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz", "integrity": "sha512-dfUnCxiN9H4ap84DvD2ubjw+3vUNpstxa0TneY/Paat8a3R4uQZDLSvWjmznAY/DoahqTHl9V46HF/Zs3F29pg==", + "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -5048,6 +5049,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5068,6 +5070,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5088,6 +5091,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5108,6 +5112,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5128,6 +5133,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5148,6 +5154,7 @@ "cpu": [ "arm" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5168,6 +5175,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5188,6 +5196,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5208,6 +5217,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5228,6 +5238,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5248,6 +5259,7 @@ "cpu": [ "arm64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5268,6 +5280,7 @@ "cpu": [ "ia32" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5288,6 +5301,7 @@ "cpu": [ "x64" ], + "dev": true, "license": "MIT", "optional": true, "os": [ @@ -5305,6 +5319,7 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz", "integrity": "sha512-pGjwhsmsp4kL2RTz08wcOlGN83otlqHeD/Z5T8GXZB+/YcpQ/dgo+lbU8ZsGxV0HIvqqxo9l7mqYwyYMD9bKDg==", + "dev": true, "license": "Apache-2.0", "optional": true, "bin": { @@ -10638,6 +10653,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "optional": true, "os": [ @@ -14551,6 +14567,7 @@ "version": "7.1.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", "integrity": "sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==", + "dev": true, "license": "MIT", "optional": true }, @@ -15444,24 +15461,13 @@ } }, "node_modules/protobufjs": { - "version": "8.0.1", - "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-8.0.1.tgz", - "integrity": "sha512-NWWCCscLjs+cOKF/s/XVNFRW7Yih0fdH+9brffR5NZCy8k42yRdl5KlWKMVXuI1vfCoy4o1z80XR/W/QUb3V3w==", + "version": "8.4.0", + "resolved": "https://registry.npmjs.org/protobufjs/-/protobufjs-8.4.0.tgz", + "integrity": "sha512-iriNhQ57SYA5Jbdi+41AyPdx6jPPkFO7DODzkOBmqFhgYn/JzX2HxgxYPY18eQAs3CP/AWqtPvkWn8rclRAxdQ==", "hasInstallScript": true, "license": "BSD-3-Clause", "dependencies": { - "@protobufjs/aspromise": "^1.1.2", - "@protobufjs/base64": "^1.1.2", - "@protobufjs/codegen": "^2.0.4", - "@protobufjs/eventemitter": "^1.1.0", - "@protobufjs/fetch": "^1.1.0", - "@protobufjs/float": "^1.0.2", - "@protobufjs/inquire": "^1.1.0", - "@protobufjs/path": "^1.1.2", - "@protobufjs/pool": "^1.1.0", - "@protobufjs/utf8": "^1.1.0", - "@types/node": ">=13.7.0", - "long": "^5.0.0" + "long": "^5.3.2" }, "engines": { "node": ">=12.0.0" diff --git a/src/content-linter/tests/unit/frontmatter-schema.ts b/src/content-linter/tests/unit/frontmatter-schema.ts index c6a18114a86b..a4ca19a5c20b 100644 --- a/src/content-linter/tests/unit/frontmatter-schema.ts +++ b/src/content-linter/tests/unit/frontmatter-schema.ts @@ -57,7 +57,7 @@ describe(frontmatterSchema.names.join(' - '), () => { " fpt: '*'", 'sidebarLink:', ' text: "All prompts"', - ' href: "/copilot/copilot-chat-cookbook"', + ' href: "/copilot/copilot-cookbook"', '---', ].join('\n') const result = await runRule(frontmatterSchema, { strings: { markdown }, ...fmOptions }) @@ -72,7 +72,7 @@ describe(frontmatterSchema.names.join(' - '), () => { 'versions:', " fpt: '*'", 'sidebarLink:', - ' href: "/copilot/copilot-chat-cookbook"', + ' href: "/copilot/copilot-cookbook"', '---', ].join('\n') const result = await runRule(frontmatterSchema, { strings: { markdown }, ...fmOptions }) diff --git a/src/fixtures/fixtures/data/ui.yml b/src/fixtures/fixtures/data/ui.yml index 18c2094a4b7e..dbb12deae55a 100644 --- a/src/fixtures/fixtures/data/ui.yml +++ b/src/fixtures/fixtures/data/ui.yml @@ -381,6 +381,7 @@ cookbook_landing: search_articles: Search examples category: Category complexity: Complexity + surface: Surface carousels: recommended: Recommended diff --git a/src/frame/components/context/CategoryLandingContext.tsx b/src/frame/components/context/CategoryLandingContext.tsx index a56c14843f2b..41da55f48f96 100644 --- a/src/frame/components/context/CategoryLandingContext.tsx +++ b/src/frame/components/context/CategoryLandingContext.tsx @@ -15,6 +15,7 @@ export type CategoryLandingContextT = { renderedPage: string currentLayout: string spotlight?: SpotlightItem[] + filters?: Array<'category' | 'surface' | 'complexity'> } export const CategoryLandingContext = createContext(null) @@ -49,6 +50,11 @@ interface ContextRequest { export const getCategoryLandingContextFromRequest = ( req: ContextRequest, ): CategoryLandingContextT => { + const spotlight = req.context.page.spotlight as SpotlightItem[] | undefined + const filters = req.context.page.filters as + | Array<'category' | 'surface' | 'complexity'> + | undefined + return { title: req.context.page.title, productCallout: (req.context.page.product as string) || '', @@ -61,6 +67,9 @@ export const getCategoryLandingContextFromRequest = ( featuredLinks: getFeaturedLinksFromReq(req), renderedPage: (req.context.renderedPage as string) || '', currentLayout: req.context.currentLayoutName || '', - spotlight: req.context.page.spotlight as SpotlightItem[] | undefined, + // `getServerSideProps` cannot serialize `undefined`, so only include these + // when they are actually defined on the page frontmatter. + ...(spotlight !== undefined && { spotlight }), + ...(filters !== undefined && { filters }), } } diff --git a/src/frame/lib/frontmatter.ts b/src/frame/lib/frontmatter.ts index 77e83ae7e70e..3f5eb65a938f 100644 --- a/src/frame/lib/frontmatter.ts +++ b/src/frame/lib/frontmatter.ts @@ -363,6 +363,9 @@ category: complexity: { type: 'array', }, + surface: { + type: 'array', + }, industry: { type: 'array', }, @@ -404,6 +407,17 @@ category: }, description: 'Array of articles to feature in the spotlight section', }, + // Filters to display on cookbook-style category landing pages. + // Allowed values: 'category' (always shown), 'surface', 'complexity'. + filters: { + type: 'array', + items: { + type: 'string', + enum: ['category', 'surface', 'complexity'], + }, + description: + 'Which filter menus to display on the category landing page. The category filter is always shown.', + }, // Carousels configuration for category landing pages (supports multiple carousels) carousels: { type: 'object', diff --git a/src/frame/middleware/context/generic-toc.ts b/src/frame/middleware/context/generic-toc.ts index 7a22c9053944..580e6159ba91 100644 --- a/src/frame/middleware/context/generic-toc.ts +++ b/src/frame/middleware/context/generic-toc.ts @@ -137,6 +137,7 @@ async function getTocItems(node: Tree, context: Context, opts: Options): Promise const octicon = page.octicon ?? null const category = page.category ? page.category : null const complexity = page.complexity ? page.complexity : null + const surface = page.surface ? page.surface : null const industry = page.industry ? page.industry : null let intro = null if (opts.renderIntros) { @@ -168,6 +169,7 @@ async function getTocItems(node: Tree, context: Context, opts: Options): Promise octicon, category, complexity, + surface, industry, childTocItems, } as ToC diff --git a/src/graphql/data/fpt/schema.docs.graphql b/src/graphql/data/fpt/schema.docs.graphql index 7fc8536379b1..ea5789cb043d 100644 --- a/src/graphql/data/fpt/schema.docs.graphql +++ b/src/graphql/data/fpt/schema.docs.graphql @@ -23430,7 +23430,7 @@ type MarkedAsDuplicateEvent implements Node { """ A public description of a Marketplace category. """ -type MarketplaceCategory implements Node { +type MarketplaceCategory implements Node @docsCategory(name: "apps") { """ The category's description. """ @@ -23480,7 +23480,7 @@ type MarketplaceCategory implements Node { """ A listing in the GitHub integration marketplace. """ -type MarketplaceListing implements Node { +type MarketplaceListing implements Node @docsCategory(name: "apps") { """ The GitHub App this listing represents. """ @@ -28212,7 +28212,7 @@ type Mutation { Parameters for UpdateNotificationRestrictionSetting """ input: UpdateNotificationRestrictionSettingInput! - ): UpdateNotificationRestrictionSettingPayload + ): UpdateNotificationRestrictionSettingPayload @docsCategory(name: "activity") """ Sets whether private repository forks are enabled for an organization. @@ -28495,7 +28495,7 @@ type Mutation { Parameters for UpdateSubscription """ input: UpdateSubscriptionInput! - ): UpdateSubscriptionPayload + ): UpdateSubscriptionPayload @docsCategory(name: "activity") """ Updates team review assignment. @@ -28571,7 +28571,7 @@ interface Node { """ The possible values for the notification restriction setting. """ -enum NotificationRestrictionSettingValue { +enum NotificationRestrictionSettingValue @docsCategory(name: "activity") { """ The setting is disabled for the owner. """ @@ -43585,7 +43585,7 @@ enum PullRequestMergeMethod { """ Ways in which lists of issues can be ordered upon return. """ -input PullRequestOrder { +input PullRequestOrder @docsCategory(name: "pulls") { """ The direction in which to order pull requests by the specified field. """ @@ -43600,7 +43600,7 @@ input PullRequestOrder { """ Properties by which pull_requests connections can be ordered. """ -enum PullRequestOrderField { +enum PullRequestOrderField @docsCategory(name: "pulls") { """ Order pull_requests by creation time """ @@ -62470,7 +62470,7 @@ type SubmoduleEdge { """ Entities that can be subscribed to for web and email notifications. """ -interface Subscribable { +interface Subscribable @docsCategory(name: "activity") { """ The Node ID of the Subscribable object """ @@ -62490,7 +62490,7 @@ interface Subscribable { """ Entities that can be subscribed to for web and email notifications. """ -interface SubscribableThread { +interface SubscribableThread @docsCategory(name: "activity") { """ The Node ID of the SubscribableThread object """ @@ -62535,7 +62535,7 @@ type SubscribedEvent implements Node { """ The possible states of a subscription. """ -enum SubscriptionState { +enum SubscriptionState @docsCategory(name: "activity") { """ The User is never notified. """ @@ -64567,7 +64567,7 @@ type TextMatchHighlight { """ The possible states of a thread subscription form action """ -enum ThreadSubscriptionFormAction { +enum ThreadSubscriptionFormAction @docsCategory(name: "activity") { """ The User cannot subscribe or unsubscribe to the thread """ @@ -64587,7 +64587,7 @@ enum ThreadSubscriptionFormAction { """ The possible states of a subscription. """ -enum ThreadSubscriptionState { +enum ThreadSubscriptionState @docsCategory(name: "activity") { """ The subscription status is currently disabled. """ diff --git a/src/graphql/data/fpt/schema.json b/src/graphql/data/fpt/schema.json index 1c1943b3099e..0c4959e9efaf 100644 --- a/src/graphql/data/fpt/schema.json +++ b/src/graphql/data/fpt/schema.json @@ -8446,6 +8446,7 @@ "id": "updatenotificationrestrictionsetting", "href": "/graphql/reference/mutations#updatenotificationrestrictionsetting", "description": "

Update the setting to restrict notifications to only verified or approved domains available to an owner.

", + "isDeprecated": false, "inputFields": [ { "name": "input", @@ -9236,6 +9237,7 @@ "id": "updatesubscription", "href": "/graphql/reference/mutations#updatesubscription", "description": "

Updates the state for subscribable subjects.

", + "isDeprecated": false, "inputFields": [ { "name": "input", @@ -31410,6 +31412,7 @@ "id": "marketplacecategory", "href": "/graphql/reference/objects#marketplacecategory", "description": "

A public description of a Marketplace category.

", + "isDeprecated": false, "implements": [ { "name": "Node", @@ -31488,6 +31491,7 @@ "id": "marketplacelisting", "href": "/graphql/reference/objects#marketplacelisting", "description": "

A listing in the GitHub integration marketplace.

", + "isDeprecated": false, "implements": [ { "name": "Node", @@ -80689,6 +80693,7 @@ "id": "subscribable", "href": "/graphql/reference/interfaces#subscribable", "description": "

Entities that can be subscribed to for web and email notifications.

", + "isDeprecated": false, "fields": [ { "name": "id", @@ -80718,6 +80723,7 @@ "id": "subscribablethread", "href": "/graphql/reference/interfaces#subscribablethread", "description": "

Entities that can be subscribed to for web and email notifications.

", + "isDeprecated": false, "fields": [ { "name": "id", @@ -83259,6 +83265,7 @@ "id": "notificationrestrictionsettingvalue", "href": "/graphql/reference/enums#notificationrestrictionsettingvalue", "description": "

The possible values for the notification restriction setting.

", + "isDeprecated": false, "values": [ { "name": "DISABLED", @@ -84628,6 +84635,7 @@ "id": "pullrequestorderfield", "href": "/graphql/reference/enums#pullrequestorderfield", "description": "

Properties by which pull_requests connections can be ordered.

", + "isDeprecated": false, "values": [ { "name": "CREATED_AT", @@ -87642,6 +87650,7 @@ "id": "subscriptionstate", "href": "/graphql/reference/enums#subscriptionstate", "description": "

The possible states of a subscription.

", + "isDeprecated": false, "values": [ { "name": "IGNORED", @@ -87822,6 +87831,7 @@ "id": "threadsubscriptionformaction", "href": "/graphql/reference/enums#threadsubscriptionformaction", "description": "

The possible states of a thread subscription form action.

", + "isDeprecated": false, "values": [ { "name": "NONE", @@ -87842,6 +87852,7 @@ "id": "threadsubscriptionstate", "href": "/graphql/reference/enums#threadsubscriptionstate", "description": "

The possible states of a subscription.

", + "isDeprecated": false, "values": [ { "name": "DISABLED", @@ -98041,6 +98052,7 @@ "id": "pullrequestorder", "href": "/graphql/reference/input-objects#pullrequestorder", "description": "

Ways in which lists of issues can be ordered upon return.

", + "isDeprecated": false, "inputFields": [ { "name": "direction", diff --git a/src/graphql/data/ghec/schema.docs.graphql b/src/graphql/data/ghec/schema.docs.graphql index 7fc8536379b1..ea5789cb043d 100644 --- a/src/graphql/data/ghec/schema.docs.graphql +++ b/src/graphql/data/ghec/schema.docs.graphql @@ -23430,7 +23430,7 @@ type MarkedAsDuplicateEvent implements Node { """ A public description of a Marketplace category. """ -type MarketplaceCategory implements Node { +type MarketplaceCategory implements Node @docsCategory(name: "apps") { """ The category's description. """ @@ -23480,7 +23480,7 @@ type MarketplaceCategory implements Node { """ A listing in the GitHub integration marketplace. """ -type MarketplaceListing implements Node { +type MarketplaceListing implements Node @docsCategory(name: "apps") { """ The GitHub App this listing represents. """ @@ -28212,7 +28212,7 @@ type Mutation { Parameters for UpdateNotificationRestrictionSetting """ input: UpdateNotificationRestrictionSettingInput! - ): UpdateNotificationRestrictionSettingPayload + ): UpdateNotificationRestrictionSettingPayload @docsCategory(name: "activity") """ Sets whether private repository forks are enabled for an organization. @@ -28495,7 +28495,7 @@ type Mutation { Parameters for UpdateSubscription """ input: UpdateSubscriptionInput! - ): UpdateSubscriptionPayload + ): UpdateSubscriptionPayload @docsCategory(name: "activity") """ Updates team review assignment. @@ -28571,7 +28571,7 @@ interface Node { """ The possible values for the notification restriction setting. """ -enum NotificationRestrictionSettingValue { +enum NotificationRestrictionSettingValue @docsCategory(name: "activity") { """ The setting is disabled for the owner. """ @@ -43585,7 +43585,7 @@ enum PullRequestMergeMethod { """ Ways in which lists of issues can be ordered upon return. """ -input PullRequestOrder { +input PullRequestOrder @docsCategory(name: "pulls") { """ The direction in which to order pull requests by the specified field. """ @@ -43600,7 +43600,7 @@ input PullRequestOrder { """ Properties by which pull_requests connections can be ordered. """ -enum PullRequestOrderField { +enum PullRequestOrderField @docsCategory(name: "pulls") { """ Order pull_requests by creation time """ @@ -62470,7 +62470,7 @@ type SubmoduleEdge { """ Entities that can be subscribed to for web and email notifications. """ -interface Subscribable { +interface Subscribable @docsCategory(name: "activity") { """ The Node ID of the Subscribable object """ @@ -62490,7 +62490,7 @@ interface Subscribable { """ Entities that can be subscribed to for web and email notifications. """ -interface SubscribableThread { +interface SubscribableThread @docsCategory(name: "activity") { """ The Node ID of the SubscribableThread object """ @@ -62535,7 +62535,7 @@ type SubscribedEvent implements Node { """ The possible states of a subscription. """ -enum SubscriptionState { +enum SubscriptionState @docsCategory(name: "activity") { """ The User is never notified. """ @@ -64567,7 +64567,7 @@ type TextMatchHighlight { """ The possible states of a thread subscription form action """ -enum ThreadSubscriptionFormAction { +enum ThreadSubscriptionFormAction @docsCategory(name: "activity") { """ The User cannot subscribe or unsubscribe to the thread """ @@ -64587,7 +64587,7 @@ enum ThreadSubscriptionFormAction { """ The possible states of a subscription. """ -enum ThreadSubscriptionState { +enum ThreadSubscriptionState @docsCategory(name: "activity") { """ The subscription status is currently disabled. """ diff --git a/src/graphql/data/ghec/schema.json b/src/graphql/data/ghec/schema.json index 1c1943b3099e..0c4959e9efaf 100644 --- a/src/graphql/data/ghec/schema.json +++ b/src/graphql/data/ghec/schema.json @@ -8446,6 +8446,7 @@ "id": "updatenotificationrestrictionsetting", "href": "/graphql/reference/mutations#updatenotificationrestrictionsetting", "description": "

Update the setting to restrict notifications to only verified or approved domains available to an owner.

", + "isDeprecated": false, "inputFields": [ { "name": "input", @@ -9236,6 +9237,7 @@ "id": "updatesubscription", "href": "/graphql/reference/mutations#updatesubscription", "description": "

Updates the state for subscribable subjects.

", + "isDeprecated": false, "inputFields": [ { "name": "input", @@ -31410,6 +31412,7 @@ "id": "marketplacecategory", "href": "/graphql/reference/objects#marketplacecategory", "description": "

A public description of a Marketplace category.

", + "isDeprecated": false, "implements": [ { "name": "Node", @@ -31488,6 +31491,7 @@ "id": "marketplacelisting", "href": "/graphql/reference/objects#marketplacelisting", "description": "

A listing in the GitHub integration marketplace.

", + "isDeprecated": false, "implements": [ { "name": "Node", @@ -80689,6 +80693,7 @@ "id": "subscribable", "href": "/graphql/reference/interfaces#subscribable", "description": "

Entities that can be subscribed to for web and email notifications.

", + "isDeprecated": false, "fields": [ { "name": "id", @@ -80718,6 +80723,7 @@ "id": "subscribablethread", "href": "/graphql/reference/interfaces#subscribablethread", "description": "

Entities that can be subscribed to for web and email notifications.

", + "isDeprecated": false, "fields": [ { "name": "id", @@ -83259,6 +83265,7 @@ "id": "notificationrestrictionsettingvalue", "href": "/graphql/reference/enums#notificationrestrictionsettingvalue", "description": "

The possible values for the notification restriction setting.

", + "isDeprecated": false, "values": [ { "name": "DISABLED", @@ -84628,6 +84635,7 @@ "id": "pullrequestorderfield", "href": "/graphql/reference/enums#pullrequestorderfield", "description": "

Properties by which pull_requests connections can be ordered.

", + "isDeprecated": false, "values": [ { "name": "CREATED_AT", @@ -87642,6 +87650,7 @@ "id": "subscriptionstate", "href": "/graphql/reference/enums#subscriptionstate", "description": "

The possible states of a subscription.

", + "isDeprecated": false, "values": [ { "name": "IGNORED", @@ -87822,6 +87831,7 @@ "id": "threadsubscriptionformaction", "href": "/graphql/reference/enums#threadsubscriptionformaction", "description": "

The possible states of a thread subscription form action.

", + "isDeprecated": false, "values": [ { "name": "NONE", @@ -87842,6 +87852,7 @@ "id": "threadsubscriptionstate", "href": "/graphql/reference/enums#threadsubscriptionstate", "description": "

The possible states of a subscription.

", + "isDeprecated": false, "values": [ { "name": "DISABLED", @@ -98041,6 +98052,7 @@ "id": "pullrequestorder", "href": "/graphql/reference/input-objects#pullrequestorder", "description": "

Ways in which lists of issues can be ordered upon return.

", + "isDeprecated": false, "inputFields": [ { "name": "direction", diff --git a/src/landings/components/CategoryLanding.tsx b/src/landings/components/CategoryLanding.tsx index e2d12bafeba8..ff5081490f00 100644 --- a/src/landings/components/CategoryLanding.tsx +++ b/src/landings/components/CategoryLanding.tsx @@ -17,7 +17,12 @@ import { UtmPreserver } from '@/frame/components/UtmPreserver' export const CategoryLanding = () => { const { t } = useTranslation('cookbook_landing') const router = useRouter() - const { title, intro, tocItems, spotlight } = useCategoryLandingContext() + const { title, intro, tocItems, spotlight, filters } = useCategoryLandingContext() + + // The category filter is always shown. Surface and complexity are opt-in via + // the `filters` frontmatter array on the landing page. + const showSurface = filters ? filters.includes('surface') : true + const showComplexity = filters ? filters.includes('complexity') : false // tocItems contains directories and its children, we only want the child articles const onlyFlatItems: ArticleCardItems = tocItems.flatMap((item) => item.childTocItems || []) @@ -25,6 +30,7 @@ export const CategoryLanding = () => { const [searchQuery, setSearchQuery] = useState('') const [selectedCategory, setSelectedCategory] = useState('All') const [selectedComplexity, setSelectedComplexity] = useState('All') + const [selectedSurface, setSelectedSurface] = useState('All') const applyFilters = () => { let results = onlyFlatItems @@ -53,6 +59,10 @@ export const CategoryLanding = () => { results = results.filter((item) => item.complexity?.includes(selectedComplexity)) } + if (selectedSurface !== 'All') { + results = results.filter((item) => item.surface?.includes(selectedSurface)) + } + return results } @@ -62,9 +72,11 @@ export const CategoryLanding = () => { setSearchQuery(query) } - const handleFilter = (option: string, type: 'category' | 'complexity') => { + const handleFilter = (option: string, type: 'category' | 'complexity' | 'surface') => { if (type === 'category') { setSelectedCategory(option) + } else if (type === 'surface') { + setSelectedSurface(option) } else if (type === 'complexity') { setSelectedComplexity(option) } @@ -73,6 +85,7 @@ export const CategoryLanding = () => { const handleResetFilter = () => { setSearchQuery('') setSelectedCategory('All') + setSelectedSurface('All') setSelectedComplexity('All') } @@ -156,6 +169,8 @@ export const CategoryLanding = () => { onSearch={handleSearch} handleFilter={handleFilter} handleResetFilter={handleResetFilter} + showSurface={showSurface} + showComplexity={showComplexity} /> @@ -170,6 +185,7 @@ export const CategoryLanding = () => { ...(item.industry || []), ...(item.category || []), ...(item.complexity || []), + ...(item.surface || []), ]} url={item.fullPath} /> diff --git a/src/landings/components/CookBookArticleCard.tsx b/src/landings/components/CookBookArticleCard.tsx index d11352af963a..6aec08b2acb9 100644 --- a/src/landings/components/CookBookArticleCard.tsx +++ b/src/landings/components/CookBookArticleCard.tsx @@ -14,6 +14,7 @@ type Props = { spotlight?: boolean image?: string complexity?: string + surface?: string } function setImage(image: string, alt: string) { diff --git a/src/landings/components/CookBookFilter.module.scss b/src/landings/components/CookBookFilter.module.scss index d12bcd8755e6..f320804bb0d5 100644 --- a/src/landings/components/CookBookFilter.module.scss +++ b/src/landings/components/CookBookFilter.module.scss @@ -11,3 +11,8 @@ color: var(--fgColor-muted, var(--color-fg-muted, #656d76)); display: inline-block; } + +.surfaceLabel { + color: var(--fgColor-muted, var(--color-fg-muted, #656d76)); + display: inline-block; +} diff --git a/src/landings/components/CookBookFilter.tsx b/src/landings/components/CookBookFilter.tsx index d6ab5cd51d3d..b68b6db1c279 100644 --- a/src/landings/components/CookBookFilter.tsx +++ b/src/landings/components/CookBookFilter.tsx @@ -10,8 +10,10 @@ type Props = { tokens: ArticleCardItems onSearch: (query: string) => void isSearchOpen?: boolean - handleFilter: (option: string, type: 'category' | 'complexity') => void + handleFilter: (option: string, type: 'category' | 'surface' | 'complexity') => void handleResetFilter: () => void + showSurface?: boolean + showComplexity?: boolean } export const CookBookFilter = ({ @@ -20,8 +22,11 @@ export const CookBookFilter = ({ tokens, handleFilter, handleResetFilter, + showSurface = true, + showComplexity = false, }: Props) => { const categories: string[] = ['All', ...new Set(tokens.flatMap((item) => item.category || []))] + const surfaces: string[] = ['All', ...new Set(tokens.flatMap((item) => item.surface || []))] const complexities: string[] = [ 'All', ...new Set(tokens.flatMap((item) => item.complexity || [])), @@ -29,13 +34,16 @@ export const CookBookFilter = ({ const { t } = useTranslation('cookbook_landing') const [selectedCategory, setSelectedCategory] = useState(0) + const [selectedSurface, setSelectedSurface] = useState(0) const [selectedComplexity, setSelectedComplexity] = useState(0) const inputRef = useRef(null) - const onFilter = (option: string, type: 'category' | 'complexity', index: number) => { + const onFilter = (option: string, type: 'category' | 'surface' | 'complexity', index: number) => { if (type === 'category') { setSelectedCategory(index) + } else if (type === 'surface') { + setSelectedSurface(index) } else if (type === 'complexity') { setSelectedComplexity(index) } @@ -44,6 +52,7 @@ export const CookBookFilter = ({ const onResetFilter = () => { setSelectedCategory(0) + setSelectedSurface(0) setSelectedComplexity(0) handleResetFilter() if (inputRef.current) { @@ -96,25 +105,49 @@ export const CookBookFilter = ({ - - - {t('complexity')}:{' '} - {complexities[selectedComplexity]} - - - - {complexities.map((complexity, index) => ( - onFilter(complexity, 'complexity', index)} - > - {complexity} - - ))} - - - + {showSurface && ( + + + {t('surface')}:{' '} + {surfaces[selectedSurface]} + + + + {surfaces.map((surface, index) => ( + onFilter(surface, 'surface', index)} + > + {surface} + + ))} + + + + )} + + {showComplexity && ( + + + {t('complexity')}:{' '} + {complexities[selectedComplexity]} + + + + {complexities.map((complexity, index) => ( + onFilter(complexity, 'complexity', index)} + > + {complexity} + + ))} + + + + )}