Skip to content

Add Token Pac-Man canvas extension#2175

Open
jamesmontemagno wants to merge 1 commit into
github:mainfrom
jamesmontemagno:jamesmontemagno-add-token-pac-man-canvas
Open

Add Token Pac-Man canvas extension#2175
jamesmontemagno wants to merge 1 commit into
github:mainfrom
jamesmontemagno:jamesmontemagno-add-token-pac-man-canvas

Conversation

@jamesmontemagno

@jamesmontemagno jamesmontemagno commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Pull Request Checklist

  • I have read and followed the CONTRIBUTING.md guidelines.
  • I have read and followed the Guidance for submissions involving paid services.
  • My contribution adds a new instruction, prompt, agent, skill, workflow, or canvas extension file in the correct directory.
  • The file follows the required naming convention.
  • The content is clearly structured and follows the example format.
  • I have tested my instructions, prompt, agent, skill, workflow, or canvas extension with GitHub Copilot.
  • I have run npm start and verified that README.md is up to date.
  • I am targeting the main branch for this pull request.

Description


Type of Contribution

  • New instruction file.
  • New prompt file.
  • New agent file.
  • New plugin.
  • New skill file.
  • New agentic workflow.
  • New canvas extension.
  • Update to existing instruction, prompt, agent, plugin, skill, workflow, or canvas extension.
  • Other (please specify):

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.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 1, 2026 04:24
@github-actions github-actions Bot added canvas-extension PR touches canvas extensions new-submission PR adds at least one new contribution labels Jul 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 (onClose closes 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"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

canvas-extension PR touches canvas extensions new-submission PR adds at least one new contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants