Skip to content

Implement label state and issue-label routes in the GitHub simulator#38

Merged
pmcelhaney merged 3 commits into
mainfrom
copilot/implement-next-task
May 31, 2026
Merged

Implement label state and issue-label routes in the GitHub simulator#38
pmcelhaney merged 3 commits into
mainfrom
copilot/implement-next-task

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 30, 2026

The GitHub simulator was still returning random responses for repository and issue label endpoints, leaving the Issues surface incomplete for tooling that depends on label lifecycle behavior. This change adds stateful label support in the repo domain and wires the affected routes to that state.

  • Repo label state

    • adds per-repository label storage in routes/repos/_.context.ts
    • introduces label CRUD helpers plus issue-label operations (add, remove, replace, list)
    • resolves issue labels to canonical repo label objects so issue state stays aligned with repo state
  • Route implementation

    • implements stateful handlers for:
      • GET/POST /repos/{owner}/{repo}/labels
      • GET/PATCH/DELETE /repos/{owner}/{repo}/labels/{name}
      • GET/POST/PUT/DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels
      • DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/{name}
    • returns 404s for missing repos/issues instead of random payloads
    • keeps label route calls compatible via root-context forwarding methods
  • Seed data

    • seeds standard labels (bug, enhancement, documentation, question) for counterfact/platform-api
    • attaches enhancement to the existing open issue so seeded issue data exercises the new paths
  • Coverage

    • adds repo-context tests for label creation, rename, deletion, and issue-label mutation
    • adds route-level tests covering repo label CRUD, issue label add/replace/remove flows, and missing-resource behavior
    • removes the completed todo entry for this task
$.context.saveLabel("counterfact", "platform-api", {
  name: "enhancement",
  color: "84b6eb",
  description: "New feature or request",
});

$.context.addLabelToIssue("counterfact", "platform-api", 1, [
  "enhancement",
  "bug",
]);

Copilot AI requested review from Copilot and removed request for Copilot May 30, 2026 20:47
Copilot AI changed the title Implement GitHub labels domain support Implement label state and issue-label routes in the GitHub simulator May 30, 2026
Copilot AI requested a review from pmcelhaney May 30, 2026 20:48
@pmcelhaney pmcelhaney requested a review from Copilot May 31, 2026 01:39
@pmcelhaney pmcelhaney marked this pull request as ready for review May 31, 2026 01:39
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements stateful repository and issue label behavior in the GitHub API simulator, replacing random label route responses with context-backed state and seeded data.

Changes:

  • Adds repository label storage and issue-label helpers in the repos context, with root-context forwarding.
  • Implements label CRUD and issue-label route handlers with missing-resource handling.
  • Seeds default labels and adds context, route, and scenario coverage for label behavior.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
github/routes/repos/_.context.ts Adds label state, CRUD helpers, issue-label mutation, and label resolution.
github/routes/_.context.ts Forwards label methods from root context to repos context.
github/routes/repos/{owner}/{repo}/labels.ts Implements list/create repository label routes.
github/routes/repos/{owner}/{repo}/labels/{name}.ts Implements get/update/delete repository label routes.
github/routes/repos/{owner}/{repo}/issues/{issue_number}/labels.ts Implements list/add/replace/remove-all issue label routes.
github/routes/repos/{owner}/{repo}/issues/{issue_number}/labels/{name}.ts Implements remove-one-label-from-issue route.
github/scenarios/index.ts Seeds default labels before issues.
github/test/repos.context.test.ts Adds repos-context label behavior tests.
github/test/routes.test.ts Adds route-level label lifecycle and 404 tests.
github/test/scenarios.test.ts Verifies seeded labels in scenario tests.
.github/todo/labels-v2.md Removes completed labels task description.

Comment on lines +1168 to +1175
const nextLabel: label = {
...existing,
...patch,
name: nextName,
url: `${API_URL}/repos/${owner}/${repo}/labels/${encodeURIComponent(nextName)}`,
description: patch.description ?? existing.description ?? "",
default: existing.default,
};
Copy link
Copy Markdown
Contributor

@pmcelhaney pmcelhaney left a comment

Choose a reason for hiding this comment

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

@copilot address the comments

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 31, 2026

@copilot address the comments

Addressed in fa09416. Partial label updates now preserve the existing color when a rename omits it, and the repo-context test covers that regression.

Copilot AI requested a review from pmcelhaney May 31, 2026 23:40
@pmcelhaney pmcelhaney added this pull request to the merge queue May 31, 2026
Merged via the queue into main with commit 6d8444e May 31, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants