From cb6f004ab0e9de4571fcc0e3632e76e2e7100343 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 12:37:19 +0000 Subject: [PATCH 1/5] Initial plan From d243ca885a69639668bb033a70e33cc63228cbd7 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 12:40:04 +0000 Subject: [PATCH 2/5] Fix codespace boot failure by using updateContentCommand instead of postCreateCommand Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 76faa336..1b89ab98 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -23,6 +23,6 @@ } } }, - "postCreateCommand": "npm ci", + "updateContentCommand": "npm ci", "remoteUser": "node" } From dab2dfa90cf8f9a3cc90ecb1f71c35b107d4b446 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Feb 2026 12:41:10 +0000 Subject: [PATCH 3/5] Document devcontainer fix in CONTRIBUTING.md Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- CONTRIBUTING.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0ccfb51c..fb7e6d3b 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -7,6 +7,7 @@ Thank you for your interest in contributing to the Copilot Token Tracker extensi - [Development Environment Setup](#development-environment-setup) - [Using the DevContainer (Recommended)](#using-the-devcontainer-recommended) - [Why Use a DevContainer for AI-Assisted Development?](#why-use-a-devcontainer-for-ai-assisted-development) +- [DevContainer Configuration Notes](#devcontainer-configuration-notes) - [Manual Local Setup](#manual-local-setup) - [Development Workflow](#development-workflow) - [Available Scripts](#available-scripts) @@ -114,7 +115,7 @@ The devcontainer allows you to confidently let AI assistants: - **Zero Configuration:** AI can start working immediately without environment setup - **Pre-installed Tools:** All required dependencies are ready to go - **Known State:** AI agents can make more accurate suggestions knowing the exact environment -- **Automatic Setup:** The `postCreateCommand` ensures dependencies are always up-to-date +- **Automatic Setup:** The `updateContentCommand` ensures dependencies are installed after content updates ### 💡 Real-World Scenario @@ -133,6 +134,16 @@ Without a devcontainer, you'd need to: - Risk system-level changes - Potentially need to uninstall packages or revert changes +### DevContainer Configuration Notes + +The `.devcontainer/devcontainer.json` uses `updateContentCommand` instead of `postCreateCommand` for dependency installation: + +- **Why `updateContentCommand`?** This lifecycle hook runs after workspace content is updated (including initial clone), making it more reliable for dependency installation in GitHub Codespaces and similar environments. +- **Benefits:** More reliable timing, better suited for `npm ci` operations, and follows devcontainer best practices. +- **Lifecycle Order:** The devcontainer executes hooks in this order: `onCreateCommand` → `updateContentCommand` → `postCreateCommand` → `postStartCommand`. + +Using `updateContentCommand` prevents timeout issues that can occur with `postCreateCommand` during initial codespace creation, especially for projects with many dependencies. + ## Manual Local Setup If you prefer not to use the devcontainer, you can set up the extension locally: From e12b26e58945e49d3e4ce4467ef4611f63a69593 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 5 Apr 2026 08:37:27 +0000 Subject: [PATCH 4/5] Fix devcontainer build issues and add CI test workflow - Remove PowerShell feature from default devcontainer (not needed, may cause timeouts) - Fix updateContentCommand path to 'cd vscode-extension && npm ci' (repo structure changed) - Add test-devcontainer.yml workflow to validate devcontainer builds in CI - Update devcontainer-local.json with correct npm ci path Agent-Logs-Url: https://github.com/rajbos/github-copilot-token-usage/sessions/a38744a9-240d-4e23-b4d8-b0344072c15c Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- .devcontainer/devcontainer-local.json | 2 +- .devcontainer/devcontainer.json | 5 +-- .github/workflows/test-devcontainer.yml | 52 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/test-devcontainer.yml diff --git a/.devcontainer/devcontainer-local.json b/.devcontainer/devcontainer-local.json index f1b58df8..dc746247 100644 --- a/.devcontainer/devcontainer-local.json +++ b/.devcontainer/devcontainer-local.json @@ -33,6 +33,6 @@ "containerEnv": { "NODE_OPTIONS": "--max-old-space-size=4096" }, - "updateContentCommand": "npm ci", + "updateContentCommand": "cd vscode-extension && npm ci", "remoteUser": "node" } diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 5bbb1ef6..e1c4de5b 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -2,8 +2,7 @@ "name": "Copilot Token Tracker Extension", "image": "mcr.microsoft.com/devcontainers/typescript-node:1-22-bookworm", "features": { - "ghcr.io/devcontainers/features/git:1": {}, - "ghcr.io/devcontainers/features/powershell:1": {} + "ghcr.io/devcontainers/features/git:1": {} }, "customizations": { "vscode": { @@ -27,6 +26,6 @@ "containerEnv": { "NODE_OPTIONS": "--max-old-space-size=4096" }, - "updateContentCommand": "npm ci", + "updateContentCommand": "cd vscode-extension && npm ci", "remoteUser": "node" } diff --git a/.github/workflows/test-devcontainer.yml b/.github/workflows/test-devcontainer.yml new file mode 100644 index 00000000..1a13daad --- /dev/null +++ b/.github/workflows/test-devcontainer.yml @@ -0,0 +1,52 @@ +name: Test DevContainer + +on: + push: + branches: [ main, develop, copilot/fix-codespace-boot-issue ] + paths: + - '.devcontainer/**' + - '.github/workflows/test-devcontainer.yml' + pull_request: + branches: [ main, develop ] + paths: + - '.devcontainer/**' + - '.github/workflows/test-devcontainer.yml' + workflow_dispatch: + +permissions: + contents: read + +jobs: + test-devcontainer: + runs-on: ubuntu-latest + + steps: + - name: Harden the runner (Audit all outbound calls) + uses: step-security/harden-runner@fa2e9d605c4eeb9fcad4c99c224cee0c6c7f3594 # v2.16.0 + with: + egress-policy: audit + + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Build and test devcontainer + uses: devcontainers/ci@a56d055efecd725e8cfe370543b6071b79989cc8 # v0.3 + with: + imageName: ghcr.io/${{ github.repository }}/devcontainer + cacheFrom: ghcr.io/${{ github.repository }}/devcontainer + push: never + runCmd: | + echo "=== DevContainer Environment Test ===" + echo "Node version: $(node --version)" + echo "NPM version: $(npm --version)" + echo "Working directory: $(pwd)" + echo "User: $(whoami)" + echo "" + echo "=== Installing dependencies ===" + cd /workspaces/github-copilot-token-usage/vscode-extension + npm ci + echo "" + echo "=== Running build ===" + npm run compile + echo "" + echo "=== DevContainer test successful ===" From 29d12eaabed27191508cab1a1db570dc00d438b0 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 5 Apr 2026 08:38:06 +0000 Subject: [PATCH 5/5] Update CONTRIBUTING.md with devcontainer improvements Agent-Logs-Url: https://github.com/rajbos/github-copilot-token-usage/sessions/a38744a9-240d-4e23-b4d8-b0344072c15c Co-authored-by: rajbos <6085745+rajbos@users.noreply.github.com> --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 29c4e6fd..2b064a27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -147,16 +147,21 @@ The repository provides two devcontainer configurations: The default `devcontainer.json` is designed to work reliably in GitHub Codespaces and other cloud environments: - Uses `updateContentCommand` instead of `postCreateCommand` for dependency installation (more reliable timing) +- Minimal features (Git only) for fast container creation - No host mounts (not available in cloud environments) - Includes memory optimization (`NODE_OPTIONS: --max-old-space-size=4096`) +- Working directory aware: runs `cd vscode-extension && npm ci` (repo uses monorepo structure) **Why `updateContentCommand`?** This lifecycle hook runs after workspace content is updated (including initial clone), making it more reliable than `postCreateCommand` which runs once during container creation and can timeout with large dependency trees. +**Why minimal features?** PowerShell feature installation can timeout in Codespaces. The default config only includes Git, which is essential for development. + #### Local Configuration (Windows with Mounts) The `devcontainer-local.json` configuration adds features for local development: - **Host Mounts:** Binds your VS Code session data (including Copilot logs) into the container so the extension can track your actual usage +- **PowerShell Feature:** Includes PowerShell for running build scripts like `build.ps1` - **PowerShell Init:** Runs `.devcontainer/init-mounts.ps1` to ensure mount directories exist on Windows - **Volume for node_modules:** Uses a Docker volume for faster dependency installation