Add Token Pac-Man canvas extension#2175
Open
jamesmontemagno wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new Token Pac-Man canvas extension under extensions/token-pacman/ that renders a local HTML/canvas “Pac-Man board” and syncs it with live session AI-credit usage and quota/entitlement data.
Changes:
- Introduces the Token Pac-Man canvas runtime (
extension.mjs) with SSE-based UI updates and agent actions (sync_usage,set_limit,reset_run). - Adds extension metadata (
canvas.json,copilot-extension.json,package.json) and end-user documentation (README.md). - Includes gallery assets referenced by the extension metadata (added under
assets/).
Show a summary per file
| File | Description |
|---|---|
| extensions/token-pacman/README.md | Documents what the extension does and how to install/use agent actions. |
| extensions/token-pacman/package.json | Declares extension metadata used by the site/catalog (and should declare runtime deps). |
| extensions/token-pacman/extension.mjs | Implements the canvas, loopback HTTP server, SSE updates, usage/quota syncing, and actions. |
| extensions/token-pacman/copilot-extension.json | Provides gist-install metadata (name/version). |
| extensions/token-pacman/canvas.json | Provides Awesome Copilot gallery metadata (name/author/keywords/screenshots). |
Review details
Comments suppressed due to low confidence (1)
extensions/token-pacman/extension.mjs:365
setInterval(() => syncQuota(), 60_000)is never cleared. After all canvases are closed (onClosecloses the HTTP server), the interval will keep the extension process alive and continue polling quota indefinitely.
Consider starting the interval when the first canvas instance opens and clearing it when servers.size === 0, or otherwise wiring cleanup into the extension lifecycle.
session.on("assistant.usage", (event) => {
eventNanoAiu += Number(event.data?.copilotUsage?.totalNanoAiu) || 0;
void syncUsage();
void syncQuota();
});
setInterval(() => { void syncQuota(); }, 60_000);
- Files reviewed: 5/7 changed files
- Comments generated: 3
- Review effort level: Low
Comment on lines
+4
to
+17
| const state = { | ||
| credits: 0, | ||
| limit: 100, | ||
| character: "mr", | ||
| dead: false, | ||
| achievements: [], | ||
| fruit: null, | ||
| fruitVersion: 0, | ||
| entitlement: null, | ||
| runVersion: 0, | ||
| }; | ||
| const clients = new Set(); | ||
| const servers = new Map(); | ||
| let eventNanoAiu = 0; |
Comment on lines
+315
to
+318
| let body = ""; | ||
| for await (const chunk of req) body += chunk; | ||
| const input = body ? JSON.parse(body) : {}; | ||
| if (req.url === "/choose" && characters[input.character]) state.character = input.character; |
Comment on lines
+1
to
+15
| { | ||
| "name": "token-pacman", | ||
| "version": "1.0.0", | ||
| "type": "module", | ||
| "main": "extension.mjs", | ||
| "description": "Visualizes live session AI-credit usage as a Pac-Man board with pellets, ghosts, fruit milestones, and game-over limits.", | ||
| "keywords": [ | ||
| "ai-credits", | ||
| "copilot-canvas", | ||
| "interactive-canvas", | ||
| "pac-man", | ||
| "quota-tracking", | ||
| "session-usage" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Checklist
npm startand verified thatREADME.mdis up to date.mainbranch for this pull request.Description
Type of Contribution
Additional Notes
By submitting this pull request, I confirm that my contribution abides by the Code of Conduct and will be licensed under the MIT License.